Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DARIAH-DE OAI-PMH Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DARIAH-DE
DARIAH-DE OAI-PMH Services
Commits
5502abdb
Commit
5502abdb
authored
8 years ago
by
mbrodhu
Browse files
Options
Downloads
Plain Diff
testitest
parents
590c311e
46dfa53f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhOnlineTests.java
+28
-42
28 additions, 42 deletions
...test/java/info/textgrid/middleware/OaiPmhOnlineTests.java
with
28 additions
and
42 deletions
oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhOnlineTests.java
+
28
−
42
View file @
5502abdb
...
...
@@ -191,7 +191,6 @@ public class OaiPmhOnlineTests {
* @throws IOException
*/
@Test
//@Ignore
public
void
testListRecords
()
throws
IOException
{
System
.
out
.
println
(
TESTING
+
"#LISTRECORDS"
);
...
...
@@ -203,7 +202,6 @@ public class OaiPmhOnlineTests {
* @throws IOException
*/
@Test
@Ignore
public
void
testListIdentifier
()
throws
IOException
{
System
.
out
.
println
(
TESTING
+
"#LISTIDENTIFIERS"
);
...
...
@@ -247,8 +245,12 @@ public class OaiPmhOnlineTests {
* @throws IOException
*/
private
static
String
examineResumptionTokenTag
(
TGHttpResponse
theResponse
,
String
recordOrHeader
)
throws
IOException
{
System
.
out
.
println
(
"BLAAAAAAAAAAAAAAAAAAAAAAAAAAA"
);
String
recordOrHeader
,
String
oldtok
)
throws
IOException
{
int
status
=
theResponse
.
getStatusCode
();
String
reason
=
theResponse
.
getReasonPhrase
();
System
.
out
.
println
(
"\tstatus: "
+
status
+
" "
+
reason
);
String
res
=
IOUtils
.
readStringFromStream
(
theResponse
.
getInputstream
());
// System.out.println(res);
...
...
@@ -261,9 +263,6 @@ public class OaiPmhOnlineTests {
return
"-1"
;
}
String
restokTmp
=
res
.
substring
(
tokStart
,
tokEnd
);
// Get token tag.
String
toktag
=
restokTmp
.
substring
(
0
,
restokTmp
.
indexOf
(
">"
)
+
1
)
...
...
@@ -274,6 +273,10 @@ public class OaiPmhOnlineTests {
String
restok
=
restokTmp
.
substring
(
restokTmp
.
indexOf
(
">"
)
+
1
).
trim
();
System
.
out
.
println
(
"\ttoken: "
+
restok
);
// Check if old and new token are equal or not.
boolean
tokchanged
=
!
oldtok
.
equals
(
restok
);
System
.
out
.
println
(
"\ttokchngd: "
+
tokchanged
);
// Get completeListSize and cursor.
String
sizeStr
=
toktag
.
substring
(
toktag
.
indexOf
(
"completeListSize=\""
)
+
18
);
...
...
@@ -318,33 +321,13 @@ public class OaiPmhOnlineTests {
* @param theMillis
* @return
*/
public
static
String
getDuration
(
long
theMillis
)
{
public
static
String
getDuration
InSecs
(
long
theMillis
)
{
int
SECS_IN_MILLIS
=
1000
;
int
MINS_IN_SECS
=
60
;
int
HORS_IN_MINS
=
60
;
int
DAYS_IN_HORS
=
24
;
int
secs
=
SECS_IN_MILLIS
;
int
mins
=
secs
*
MINS_IN_SECS
;
int
hors
=
mins
*
HORS_IN_MINS
;
int
days
=
hors
*
DAYS_IN_HORS
;
if
(
theMillis
>
days
)
{
return
theMillis
/
days
+
" day"
+
((
theMillis
/
days
)
!=
1
?
"s"
:
""
);
}
else
if
(
theMillis
>
hors
)
{
return
theMillis
/
hors
+
" hour"
+
((
theMillis
/
hors
)
!=
1
?
"s"
:
""
);
}
else
if
(
theMillis
>
mins
)
{
return
theMillis
/
mins
+
" minute"
+
((
theMillis
/
mins
)
!=
1
?
"s"
:
""
);
}
else
if
(
theMillis
>
secs
)
{
return
theMillis
/
secs
+
" second"
+
((
theMillis
/
secs
)
!=
1
?
"s"
:
""
);
}
else
{
return
theMillis
+
" millisecond"
+
(
theMillis
!=
1
?
"s"
:
""
);
}
return
theMillis
/
secs
+
" second"
+
((
theMillis
/
secs
)
!=
1
?
"s"
:
""
);
}
/**
...
...
@@ -362,7 +345,7 @@ public class OaiPmhOnlineTests {
String
prefix
=
"oai_dc"
;
// Testing set: fu's shakespeare.
//String set = "project:TGPR-962c949c-56a3-7134-9265-582f29a0992d";
//
String set = "project:TGPR-962c949c-56a3-7134-9265-582f29a0992d";
// Testing set: Digitale Bibliothek.
String
set
=
"project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"
;
...
...
@@ -372,23 +355,26 @@ public class OaiPmhOnlineTests {
TGHttpResponse
httpResponse
=
getHttpResponse
(
url
);
int
status
=
httpResponse
.
getStatusCode
();
// Check HTTP status.
if
(
status
!=
HttpStatus
.
SC_OK
)
{
System
.
err
.
println
(
"\tstatus: "
+
status
);
System
.
err
.
println
(
ERROR
);
assertTrue
(
false
);
}
long
timeRunning
=
System
.
currentTimeMillis
()
-
startTime
;
System
.
out
.
println
(
"\ttime: "
+
getDuration
(
timeRunning
));
System
.
out
.
println
(
"\ttime: "
+
getDuration
InSecs
(
timeRunning
));
String
restok
=
examineResumptionTokenTag
(
httpResponse
,
testOccurance
);
String
restok
=
examineResumptionTokenTag
(
httpResponse
,
testOccurance
,
""
);
while
(
status
==
HttpStatus
.
SC_OK
&&
!
restok
.
equals
(
"-1"
))
{
url
=
host
+
"/oai?verb="
+
theVerb
+
"&resumptionToken="
+
restok
;
httpResponse
=
getHttpResponse
(
url
);
timeRunning
=
System
.
currentTimeMillis
()
-
startTime
;
System
.
out
.
println
(
"\ttime: "
+
getDuration
(
timeRunning
));
restok
=
examineResumptionTokenTag
(
httpResponse
,
testOccurance
);
}
if
(
status
!=
HttpStatus
.
SC_OK
)
{
System
.
err
.
println
(
"\tstatus: "
+
status
);
System
.
err
.
println
(
ERROR
);
assertTrue
(
false
);
System
.
out
.
println
(
"\ttime: "
+
getDurationInSecs
(
timeRunning
));
restok
=
examineResumptionTokenTag
(
httpResponse
,
testOccurance
,
restok
);
}
System
.
out
.
println
(
OK
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment