Skip to content
Snippets Groups Projects
Commit 5502abdb authored by mbrodhu's avatar mbrodhu
Browse files

testitest

parents 590c311e 46dfa53f
No related branches found
No related tags found
No related merge requests found
......@@ -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 getDurationInSecs(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: " + getDurationInSecs(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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment