Skip to content
Snippets Groups Projects
Commit f4167560 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Merge branch '66-refactor-dhrep-online-tests' into 'develop'

Resolve "Refactor DHREP online tests"

Closes #66

See merge request dariah-de/dariah-de-oai-pmh-services!64
parents 85d71021 b1b12ec7
No related branches found
No related tags found
No related merge requests found
Pipeline #321797 passed
...@@ -4,8 +4,6 @@ import static org.junit.Assert.assertTrue; ...@@ -4,8 +4,6 @@ import static org.junit.Assert.assertTrue;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.helpers.IOUtils;
...@@ -45,21 +43,25 @@ public class TestDHOAIPMHOnline { ...@@ -45,21 +43,25 @@ public class TestDHOAIPMHOnline {
private static Client oaipmhWebClient; private static Client oaipmhWebClient;
// Properties // Properties
private static String expectedListSets;
private static String checkGetRecordDC; private static String checkGetRecordDC;
private static String expectedGetRecordDC; private static String expectedGetRecordDC;
private static String checkGetRecordDATACITE; private static String checkGetRecordDATACITE;
private static String expectedGetRecordDATACITE; private static String expectedGetRecordDATACITE;
private static String checkListRecordsDC;
private static String checkListRecordsDCSet;
private static Integer checkListRecordsDCSetExpectedPages;
private static String checkListRecordsDCFrom; private static String checkListRecordsDCFrom;
private static String checkListRecordsDCUntil; private static String checkListRecordsDCUntil;
private static String checkListRecordsDATACITEFrom; private static String checkListRecordsDATACITEFrom;
private static String checkListRecordsDATACITEUntil; private static String checkListRecordsDATACITEUntil;
private static String checkListRecordsSet;
private static Integer checkListRecordsSetExpectedPages;
private static String checkListIdentifiersSet; private static String checkListIdentifiersSet;
private static Integer checkListIdentifiersSetExpectedPages; private static Integer checkListIdentifiersSetExpectedPages;
private static List<String> checkGetRecordIDList = new ArrayList<String>();
private static String expectedListSets;
// ** // **
// PREPARATIONS // PREPARATIONS
...@@ -80,26 +82,28 @@ public class TestDHOAIPMHOnline { ...@@ -80,26 +82,28 @@ public class TestDHOAIPMHOnline {
// Get other needed properties. // Get other needed properties.
oaipmhEndpoint = p.getProperty("oaipmhEndpoint"); oaipmhEndpoint = p.getProperty("oaipmhEndpoint");
expectedListSets = p.getProperty("expectedListSets");
checkGetRecordDC = p.getProperty("checkGetRecordDC"); checkGetRecordDC = p.getProperty("checkGetRecordDC");
expectedGetRecordDC = p.getProperty("expectedGetRecordDC"); expectedGetRecordDC = p.getProperty("expectedGetRecordDC");
checkGetRecordDATACITE = p.getProperty("checkGetRecordDATACITE"); checkGetRecordDATACITE = p.getProperty("checkGetRecordDATACITE");
expectedGetRecordDATACITE = p.getProperty("expectedGetRecordDATACITE"); expectedGetRecordDATACITE = p.getProperty("expectedGetRecordDATACITE");
checkListRecordsDC = p.getProperty("checkListRecordsDC");
checkListRecordsDCSet = p.getProperty("checkListRecordsDCSet");
checkListRecordsDCSetExpectedPages =
Integer.parseInt(p.getProperty("checkListRecordsDCSetExpectedPages").trim());
checkListRecordsDCFrom = p.getProperty("checkListRecordsDCFrom"); checkListRecordsDCFrom = p.getProperty("checkListRecordsDCFrom");
checkListRecordsDCUntil = p.getProperty("checkListRecordsDCUntil"); checkListRecordsDCUntil = p.getProperty("checkListRecordsDCUntil");
checkListRecordsDATACITEFrom = p
.getProperty("checkListRecordsDATACITEFrom"); checkListRecordsDATACITEFrom = p.getProperty("checkListRecordsDATACITEFrom");
checkListRecordsDATACITEUntil = p checkListRecordsDATACITEUntil = p.getProperty("checkListRecordsDATACITEUntil");
.getProperty("checkListRecordsDATACITEUntil");
checkListRecordsSet = p.getProperty("checkListRecordsSet");
checkListRecordsSetExpectedPages =
Integer.parseInt(p.getProperty("checkListRecordsSetExpectedPages").trim());
checkListIdentifiersSet = p.getProperty("checkListIdentifiersSet"); checkListIdentifiersSet = p.getProperty("checkListIdentifiersSet");
checkListIdentifiersSetExpectedPages = checkListIdentifiersSetExpectedPages =
Integer.parseInt(p.getProperty("checkListIdentifiersSetExpectedPages").trim()); Integer.parseInt(p.getProperty("checkListIdentifiersSetExpectedPages").trim());
checkGetRecordIDList =
OAIPMHUtilitiesOnline.getListFromProperties((String) p.get("checkGetRecordIDList")); expectedListSets = p.getProperty("expectedListSets");
// Get web client from endpoint. // Get web client from endpoint.
oaipmhWebClient = OAIPMHUtilitiesOnline.getOAIPMHWEebClient(oaipmhEndpoint); oaipmhWebClient = OAIPMHUtilitiesOnline.getOAIPMHWEebClient(oaipmhEndpoint);
...@@ -141,8 +145,7 @@ public class TestDHOAIPMHOnline { ...@@ -141,8 +145,7 @@ public class TestDHOAIPMHOnline {
String shouldStartWith = "oaipmh-core"; String shouldStartWith = "oaipmh-core";
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETVERSION for '" System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETVERSION for '" + shouldStartWith + "'");
+ shouldStartWith + "'");
Response response = OAIPMHUtilitiesOnline.getVersionHttpResponse(oaipmhWebClient); Response response = OAIPMHUtilitiesOnline.getVersionHttpResponse(oaipmhWebClient);
int status = response.getStatus(); int status = response.getStatus();
...@@ -207,8 +210,7 @@ public class TestDHOAIPMHOnline { ...@@ -207,8 +210,7 @@ public class TestDHOAIPMHOnline {
Response response = OAIPMHUtilitiesOnline.getOAIHttpResponse(oaipmhWebClient, "verb=" + verb); Response response = OAIPMHUtilitiesOnline.getOAIHttpResponse(oaipmhWebClient, "verb=" + verb);
int status = response.getStatus(); int status = response.getStatus();
String responseString = IOUtils String responseString = IOUtils.readStringFromStream((InputStream) response.getEntity());
.readStringFromStream((InputStream) response.getEntity());
if (status != HttpStatus.SC_OK || !responseString.contains(shouldContain)) { if (status != HttpStatus.SC_OK || !responseString.contains(shouldContain)) {
String message = "[" + status + "]: response should contain '" + shouldContain + "'"; String message = "[" + status + "]: response should contain '" + shouldContain + "'";
...@@ -231,25 +233,27 @@ public class TestDHOAIPMHOnline { ...@@ -231,25 +233,27 @@ public class TestDHOAIPMHOnline {
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListRecordsDC() throws IOException { public void testListRecordsOAIDC() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS");
testList("ListRecords", "oai_dc", OAIPMHUtilitiesOnline.NO_SET); testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
OAIPMHUtilitiesOnline.NO_SET);
} }
/** /**
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListRecordsSetDC() throws IOException { public void testListRecordsSetOAIDC() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS");
int pages = testList("ListRecords", "oai_dc", checkListRecordsSet); int pages = testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, checkListRecordsDCSet);
if (pages != checkListRecordsSetExpectedPages) { if (pages != checkListRecordsDCSetExpectedPages) {
assertTrue(pages + " != " + checkListRecordsSetExpectedPages, false); assertTrue(pages + " != " + checkListRecordsDCSetExpectedPages, false);
} }
} }
...@@ -257,32 +261,35 @@ public class TestDHOAIPMHOnline { ...@@ -257,32 +261,35 @@ public class TestDHOAIPMHOnline {
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListRecordsSetDCDifferentPrefixes() throws IOException { public void testListRecordsSetOAIDCDifferentPrefixes() throws IOException {
String uri = checkListRecordsSet; String uri = checkListRecordsDCSet;
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - HDL PREFIX"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - HDL PREFIX");
if (!uri.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) { if (!uri.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) {
assertTrue("missing '" + OAIPMHUtilitiesOnline.HDL_PREFIX + "' prefix!", false); assertTrue("missing '" + OAIPMHUtilitiesOnline.HDL_PREFIX + "' prefix!", false);
} }
int pages1 = testList("ListRecords", "oai_dc", uri); int pages1 =
if (pages1 != checkListRecordsSetExpectedPages) { testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, uri);
System.out.println(pages1 + " != " + checkListRecordsSetExpectedPages); if (pages1 != checkListRecordsDCSetExpectedPages) {
System.out.println(pages1 + " != " + checkListRecordsDCSetExpectedPages);
} }
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - NO PREFIX"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - NO PREFIX");
if (checkListRecordsSet.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) { if (checkListRecordsDCSet.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) {
uri = checkListRecordsSet.substring(4); uri = checkListRecordsDCSet.substring(4);
} }
int pages2 = testList("ListRecords", "oai_dc", uri); int pages2 =
if (pages2 != checkListRecordsSetExpectedPages) { testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, uri);
System.out.println(pages2 + " != " + checkListRecordsSetExpectedPages); if (pages2 != checkListRecordsDCSetExpectedPages) {
System.out.println(pages2 + " != " + checkListRecordsDCSetExpectedPages);
} }
// Check pages count. // Check pages count.
if (pages1 != checkListRecordsSetExpectedPages || pages2 != checkListRecordsSetExpectedPages) { if (pages1 != checkListRecordsDCSetExpectedPages
|| pages2 != checkListRecordsDCSetExpectedPages) {
assertTrue("page count does not match", false); assertTrue("page count does not match", false);
} }
} }
...@@ -292,17 +299,19 @@ public class TestDHOAIPMHOnline { ...@@ -292,17 +299,19 @@ public class TestDHOAIPMHOnline {
*/ */
@Test @Test
@Ignore @Ignore
public void testListRecordsSetDCStarPrefix() throws IOException { public void testListRecordsSetOAIDCStarPrefix() throws IOException {
// TODO Un-ignore if identifier check is implemented! // TODO Un-ignore if identifier check is implemented!
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - STAR PREFIX"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS - STAR PREFIX");
if (checkListRecordsSet.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) { if (checkListRecordsDCSet.startsWith(OAIPMHUtilitiesOnline.HDL_PREFIX)) {
checkListRecordsSet = OAIPMHUtilitiesOnline.STAR_PREFIX + checkListRecordsSet.substring(4); checkListRecordsDCSet =
OAIPMHUtilitiesOnline.STAR_PREFIX + checkListRecordsDCSet.substring(4);
} }
int pages3 = testList("ListRecords", "oai_dc", checkListRecordsSet); int pages3 = testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, checkListRecordsDCSet);
if (pages3 != 1) { if (pages3 != 1) {
System.out.println(pages3 + " != " + 1); System.out.println(pages3 + " != " + 1);
} }
...@@ -312,12 +321,12 @@ public class TestDHOAIPMHOnline { ...@@ -312,12 +321,12 @@ public class TestDHOAIPMHOnline {
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListRecordsDCFromUntil() throws IOException { public void testListRecordsOAIDCFromUntil() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS");
testList("ListRecords", "oai_dc", OAIPMHUtilitiesOnline.NO_SET, testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
checkListRecordsDCFrom, checkListRecordsDCUntil); OAIPMHUtilitiesOnline.NO_SET, checkListRecordsDCFrom, checkListRecordsDCUntil);
} }
/** /**
...@@ -328,7 +337,8 @@ public class TestDHOAIPMHOnline { ...@@ -328,7 +337,8 @@ public class TestDHOAIPMHOnline {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS");
testList("ListRecords", "oai_datacite", OAIPMHUtilitiesOnline.NO_SET); testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DATACITE_PREFIX,
OAIPMHUtilitiesOnline.NO_SET);
} }
/** /**
...@@ -339,66 +349,56 @@ public class TestDHOAIPMHOnline { ...@@ -339,66 +349,56 @@ public class TestDHOAIPMHOnline {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTRECORDS");
testList("ListRecords", "oai_datacite", OAIPMHUtilitiesOnline.NO_SET, testList(OAIPMHUtilitiesOnline.VERB_LIST_RECORDS, OAIPMHUtilitiesOnline.OAI_DATACITE_PREFIX,
checkListRecordsDATACITEFrom, checkListRecordsDATACITEUntil); OAIPMHUtilitiesOnline.NO_SET, checkListRecordsDATACITEFrom, checkListRecordsDATACITEUntil);
} }
/** /**
* @throws IOException * @throws IOException
*/ */
@Test @Test
@Ignore public void testGetRecordOAIDC() throws IOException {
public void testGetRecordDC() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETRECORD"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETRECORD");
String identifier = ""; testRecord(checkGetRecordDC, OAIPMHUtilitiesOnline.VERB_GET_RECORD,
String shouldContain = ""; OAIPMHUtilitiesOnline.OAI_DC_PREFIX, expectedGetRecordDC);
String path = "verb=GetRecord&identifier=" + identifier
+ "&metadataPrefix=oai_dc";
// FIXME Complete test!
} }
/** /**
* @throws IOException * @throws IOException
*/ */
@Test @Test
@Ignore
public void testGetRecordDATASITE() throws IOException { public void testGetRecordDATASITE() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETRECORD"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#GETRECORD");
String identifier = ""; testRecord(checkGetRecordDATACITE, OAIPMHUtilitiesOnline.VERB_GET_RECORD,
String shouldContain = ""; OAIPMHUtilitiesOnline.OAI_DATACITE_PREFIX, expectedGetRecordDATACITE);
String path = "verb=GetRecord&identifier=" + identifier
+ "&metadataPrefix=oai_datacite";
// FIXME Complete test!
} }
/** /**
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListIdentifiersDC() throws IOException { public void testListIdentifiersOAIDC() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS");
testList("ListIdentifiers", "oai_dc", OAIPMHUtilitiesOnline.NO_SET); testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS, OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
OAIPMHUtilitiesOnline.NO_SET);
} }
/** /**
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListIdentifiersSetDC() throws IOException { public void testListIdentifiersSetOAIDC() throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS");
int pages = testList("ListIdentifiers", "oai_dc", checkListIdentifiersSet); int pages = testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, checkListIdentifiersSet);
if (pages != checkListIdentifiersSetExpectedPages) { if (pages != checkListIdentifiersSetExpectedPages) {
assertTrue(pages + " != " + checkListIdentifiersSetExpectedPages, false); assertTrue(pages + " != " + checkListIdentifiersSetExpectedPages, false);
...@@ -409,7 +409,7 @@ public class TestDHOAIPMHOnline { ...@@ -409,7 +409,7 @@ public class TestDHOAIPMHOnline {
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testListIdentifiersSetDCDifferentPrefixes() throws IOException { public void testListIdentifiersSetOAIDCDifferentPrefixes() throws IOException {
String uri = checkListIdentifiersSet; String uri = checkListIdentifiersSet;
...@@ -419,7 +419,8 @@ public class TestDHOAIPMHOnline { ...@@ -419,7 +419,8 @@ public class TestDHOAIPMHOnline {
assertTrue("missing '" + OAIPMHUtilitiesOnline.HDL_PREFIX + "' prefix!", false); assertTrue("missing '" + OAIPMHUtilitiesOnline.HDL_PREFIX + "' prefix!", false);
} }
System.out.println("uri: " + uri); System.out.println("uri: " + uri);
int pages1 = testList("ListIdentifiers", "oai_dc", uri); int pages1 = testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, uri);
if (pages1 != checkListIdentifiersSetExpectedPages) { if (pages1 != checkListIdentifiersSetExpectedPages) {
System.out.println(pages1 + " != " + checkListIdentifiersSetExpectedPages); System.out.println(pages1 + " != " + checkListIdentifiersSetExpectedPages);
} }
...@@ -430,13 +431,15 @@ public class TestDHOAIPMHOnline { ...@@ -430,13 +431,15 @@ public class TestDHOAIPMHOnline {
uri = checkListIdentifiersSet.substring(4); uri = checkListIdentifiersSet.substring(4);
} }
System.out.println("uri: " + uri); System.out.println("uri: " + uri);
int pages2 = testList("ListIdentifiers", "oai_dc", uri); int pages2 = testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, uri);
if (pages2 != checkListIdentifiersSetExpectedPages) { if (pages2 != checkListIdentifiersSetExpectedPages) {
System.out.println(pages2 + " != " + checkListIdentifiersSetExpectedPages); System.out.println(pages2 + " != " + checkListIdentifiersSetExpectedPages);
} }
// Check pages count. // Check pages count.
if (pages1 != checkListRecordsSetExpectedPages || pages2 != checkListRecordsSetExpectedPages) { if (pages1 != checkListRecordsDCSetExpectedPages
|| pages2 != checkListRecordsDCSetExpectedPages) {
assertTrue("pages count does not match", false); assertTrue("pages count does not match", false);
} }
} }
...@@ -458,7 +461,8 @@ public class TestDHOAIPMHOnline { ...@@ -458,7 +461,8 @@ public class TestDHOAIPMHOnline {
OAIPMHUtilitiesOnline.STAR_PREFIX + checkListIdentifiersSet.substring(4); OAIPMHUtilitiesOnline.STAR_PREFIX + checkListIdentifiersSet.substring(4);
} }
System.out.println("uri: " + checkListIdentifiersSet); System.out.println("uri: " + checkListIdentifiersSet);
int pages3 = testList("ListIdentifiers", "oai_dc", checkListIdentifiersSet); int pages3 = testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX, checkListIdentifiersSet);
if (pages3 != checkListIdentifiersSetExpectedPages) { if (pages3 != checkListIdentifiersSetExpectedPages) {
System.out.println(pages3 + " != " + checkListIdentifiersSetExpectedPages); System.out.println(pages3 + " != " + checkListIdentifiersSetExpectedPages);
} }
...@@ -472,7 +476,8 @@ public class TestDHOAIPMHOnline { ...@@ -472,7 +476,8 @@ public class TestDHOAIPMHOnline {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTIDENTIFIERS");
testList("ListIdentifiers", "oai_datacite", OAIPMHUtilitiesOnline.NO_SET); testList(OAIPMHUtilitiesOnline.VERB_LIST_IDENTIFIERS, OAIPMHUtilitiesOnline.OAI_DATACITE_PREFIX,
OAIPMHUtilitiesOnline.NO_SET);
} }
// ** // **
...@@ -518,8 +523,7 @@ public class TestDHOAIPMHOnline { ...@@ -518,8 +523,7 @@ public class TestDHOAIPMHOnline {
String restokTmp = theResponseString.substring(tokStart, tokEnd); String restokTmp = theResponseString.substring(tokStart, tokEnd);
// Get token tag. // Get token tag.
String toktag = restokTmp.substring(0, restokTmp.indexOf(">") + 1) String toktag = restokTmp.substring(0, restokTmp.indexOf(">") + 1).trim();
.trim();
System.out.println("\ttokentag: " + toktag); System.out.println("\ttokentag: " + toktag);
// Get token. // Get token.
...@@ -531,13 +535,10 @@ public class TestDHOAIPMHOnline { ...@@ -531,13 +535,10 @@ public class TestDHOAIPMHOnline {
System.out.println("\ttokchngd: " + tokchanged); System.out.println("\ttokchngd: " + tokchanged);
// Get completeListSize and cursor. // Get completeListSize and cursor.
String sizeStr = toktag String sizeStr = toktag.substring(toktag.indexOf("completeListSize=\"") + 18);
.substring(toktag.indexOf("completeListSize=\"") + 18); int size = Integer.parseInt(sizeStr.substring(0, sizeStr.indexOf("\"")));
int size = Integer
.parseInt(sizeStr.substring(0, sizeStr.indexOf("\"")));
String cursorStr = toktag.substring(toktag.indexOf("cursor=\"") + 8); String cursorStr = toktag.substring(toktag.indexOf("cursor=\"") + 8);
int cursor = Integer int cursor = Integer.parseInt(cursorStr.substring(0, cursorStr.indexOf("\"")));
.parseInt(cursorStr.substring(0, cursorStr.indexOf("\"")));
System.out.println("\tsize: " + size + " / " + cursor); System.out.println("\tsize: " + size + " / " + cursor);
// If token is provided, and we have less than 100 elements: mekkern! // If token is provided, and we have less than 100 elements: mekkern!
...@@ -581,14 +582,14 @@ public class TestDHOAIPMHOnline { ...@@ -581,14 +582,14 @@ public class TestDHOAIPMHOnline {
* @return * @return
* @throws IOException * @throws IOException
*/ */
private static int testList(String theVerb, String theMetadataPrefix, private static int testList(String theVerb, String theMetadataPrefix, String theSet)
String theSet) throws IOException { throws IOException {
return testList(theVerb, theMetadataPrefix, theSet, return testList(theVerb, theMetadataPrefix, theSet, OAIPMHUtilitiesOnline.NO_FROM,
OAIPMHUtilitiesOnline.NO_FROM, OAIPMHUtilitiesOnline.NO_UNTIL); OAIPMHUtilitiesOnline.NO_UNTIL);
} }
/** /**
* TODO Generalise in OaiPmhTestUtilities! * TODO Generalise in OAIPMHUtilitiesOnline??
* *
* @param theVerb * @param theVerb
* @param theMetadataPrefix * @param theMetadataPrefix
...@@ -598,8 +599,8 @@ public class TestDHOAIPMHOnline { ...@@ -598,8 +599,8 @@ public class TestDHOAIPMHOnline {
* @return How many pages were delivered * @return How many pages were delivered
* @throws IOException * @throws IOException
*/ */
private static int testList(String theVerb, String theMetadataPrefix, private static int testList(String theVerb, String theMetadataPrefix, String theSet, String from,
String theSet, String from, String until) throws IOException { String until) throws IOException {
int result; int result;
...@@ -610,8 +611,7 @@ public class TestDHOAIPMHOnline { ...@@ -610,8 +611,7 @@ public class TestDHOAIPMHOnline {
testOccurance = "record"; testOccurance = "record";
} }
String query = "verb=" + theVerb + "&metadataPrefix=" String query = "verb=" + theVerb + "&metadataPrefix=" + theMetadataPrefix;
+ theMetadataPrefix;
if (theSet != null && !theSet.isEmpty()) { if (theSet != null && !theSet.isEmpty()) {
query += "&set=" + theSet; query += "&set=" + theSet;
...@@ -622,6 +622,7 @@ public class TestDHOAIPMHOnline { ...@@ -622,6 +622,7 @@ public class TestDHOAIPMHOnline {
} }
Response response = OAIPMHUtilitiesOnline.getOAIHttpResponse(oaipmhWebClient, query); Response response = OAIPMHUtilitiesOnline.getOAIHttpResponse(oaipmhWebClient, query);
String responseString = IOUtils.readStringFromStream((InputStream) response.getEntity()); String responseString = IOUtils.readStringFromStream((InputStream) response.getEntity());
int status = response.getStatus(); int status = response.getStatus();
...@@ -649,12 +650,49 @@ public class TestDHOAIPMHOnline { ...@@ -649,12 +650,49 @@ public class TestDHOAIPMHOnline {
return result; return result;
} }
/**
* TODO Generalise in OAIPMHUtilitiesOnline??
*
* @param theIdentifier
* @param theVerb
* @param theMetadataPrefix
* @param theExpected
* @throws IOException
*/
private static void testRecord(String theIdentifier, String theVerb, String theMetadataPrefix,
String theExpected) throws IOException {
long startTime = System.currentTimeMillis();
String query =
"verb=" + theVerb + "&identifier=" + theIdentifier + "&metadataPrefix=" + theMetadataPrefix;
Response response = OAIPMHUtilitiesOnline.getOAIHttpResponse(oaipmhWebClient, query);
String responseString = IOUtils.readStringFromStream((InputStream) response.getEntity());
int status = response.getStatus();
System.out.println(status);
System.out.println(responseString);
long timeRunning = System.currentTimeMillis() - startTime;
System.out.println("\ttime: " + OAIPMHUtilitiesOnline.getDurationInSecs(timeRunning));
examineIdentifiers(responseString);
if (!responseString.contains(theExpected)) {
System.out.println("NOT CONTAINED: " + theExpected);
assertTrue(false);
} else {
System.out.println(OAIPMHUtilitiesOnline.OK);
}
}
/** /**
* @param theSet * @param theSet
* @throws IOException * @throws IOException
*/ */
private static void testListSet(String theSet, String theExpectedResponse) private static void testListSet(String theSet, String theExpectedResponse) throws IOException {
throws IOException {
System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTSETS"); System.out.println(OAIPMHUtilitiesOnline.TESTING + "#LISTSETS");
...@@ -662,8 +700,7 @@ public class TestDHOAIPMHOnline { ...@@ -662,8 +700,7 @@ public class TestDHOAIPMHOnline {
"verb=" + OAIPMHUtilitiesOnline.VERB_LIST_SETS); "verb=" + OAIPMHUtilitiesOnline.VERB_LIST_SETS);
int status = response.getStatus(); int status = response.getStatus();
String responseString = IOUtils String responseString = IOUtils.readStringFromStream((InputStream) response.getEntity());
.readStringFromStream((InputStream) response.getEntity());
if (status != HttpStatus.SC_OK || !responseString.contains(theExpectedResponse)) { if (status != HttpStatus.SC_OK || !responseString.contains(theExpectedResponse)) {
String message = "[" + status + "] response should contain '" + theExpectedResponse + "'"; String message = "[" + status + "] response should contain '" + theExpectedResponse + "'";
......
# OAI-PMH host # OAI-PMH host
oaipmhEndpoint = https://dev.textgridlab.org/1.0/tgoaipmh oaipmhEndpoint = https://dev.textgridlab.org/1.0/tgoaipmh
# GetRecord --> TestGetRecordONLINE.class # GetRecord
checkGetRecordDC = textgrid:vqn0.0 checkGetRecordDC = textgrid:vqn0.0
expectedGetRecordDC = Heidi expectedGetRecordDC = Heidi
......
# OAI-PMH host # OAI-PMH host
oaipmhEndpoint = https://repository.de.dariah.eu/1.0/oaipmh/oai oaipmhEndpoint = https://repository.de.dariah.eu/1.0/oaipmh
# ListSets
expectedListSets = hdl:21.11113/0000-000B-CADD-9
# GetRecord # GetRecord
checkGetRecordDC = checkGetRecordDC = hdl:21.T11991/0000-001A-7532-8
expectedGetRecordDC = expectedGetRecordDC = <dc:identifier>doi:10.20375/0000-001A-7532-8</dc:identifier>
checkGetRecordDATACITE =
expectedGetRecordDATACITE = checkGetRecordDATACITE = hdl:21.T11991/0000-001A-7532-8
checkGetRecordIDList = expectedGetRecordDATACITE = <datacite:alternateIdentifier alternateIdentifierType="DOI">10.20375/0000-001A-7532-8</datacite:alternateIdentifier>
# ListRecords # ListRecords
checkListRecordsDC = checkListRecordsDCSet = hdl:21.11113/0000-000B-C8F2-2
checkListRecordsDCFrom = checkListRecordsDCSetExpectedPages = 4
checkListRecordsDCUntil =
checkListRecordsDATACITEFrom = checkListRecordsDCFrom = 2018-07-02T16:00
checkListRecordsDATACITEUntil = checkListRecordsDCUntil = 2018-07-02T23:00
checkListRecordsSet = hdl:21.11113/0000-000B-C8F2-2
checkListRecordsSetExpectedPages = 4 checkListRecordsDATACITEFrom = 2018-07-02T16:00
checkListRecordsDATACITEUntil = 2018-07-02T23:00
# ListIdentifiers # ListIdentifiers
checkListIdentifiersSet = hdl:21.11113/0000-000B-C8F2-2 checkListIdentifiersSet = hdl:21.11113/0000-000B-C8F2-2
checkListIdentifiersSetExpectedPages = 4 checkListIdentifiersSetExpectedPages = 4
\ No newline at end of file # ListSets
expectedListSets = hdl:21.11113/0000-000B-CADD-9
# OAI-PMH host # OAI-PMH host
oaipmhEndpoint = https://textgridlab.org/1.0/tgoaipmh/oai oaipmhEndpoint = https://textgridlab.org/1.0/tgoaipmh/oai
# ListSets
expectedListSets = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c
!! Please CHECK config !!
# GetRecord # GetRecord
checkGetRecordDC = textgrid:vqn0.0 checkGetRecordDC = textgrid:vqn0.0
expectedGetRecordDC = Heidi expectedGetRecordDC = Heidi
checkGetRecordIDIOM = textgrid:2sg18.0
expectedGetRecordIDIOM = Aguateca
checkGetRecordIDIOM_Images = textgrid:3x641.0
expectedGetRecordIDIOM_Images = Aguateca
checkGetRecordDATACITE = textgrid:mq05.0 checkGetRecordDATACITE = textgrid:mq05.0
expectedGetRecordDATACITE = Weise Klugredenn expectedGetRecordDATACITE = Weise Klugredenn
checkGetRecordIDIOM = textgrid:2sg18.0
expectedGetRecordIDIOM = Aguateca
checkGetRecordIDIOMImage = textgrid:3x641.0
expectedGetRecordIDIOMImage = Aguateca
checkGetRecordIDList = textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0, textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0 checkGetRecordIDList = textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0, textgrid:mq05.0, textgrid:jgv6.0, textgrid:w7rz.0, textgrid:w36b.0, textgrid:mcdv.0, textgrid:v0qx.0, textgrid:xkck.0, textgrid:t3m1.0, textgrid:10rsq.0
# ListRecords # ListRecords
checkListRecordsDC = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c checkListRecordsDC = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c
checkListRecordsDCFrom = 2012-01-04T01:00:00 checkListRecordsDCFrom = 2012-01-04T01:00:00
checkListRecordsDCUntil = 2012-01-04T12:00:00 checkListRecordsDCUntil = 2012-01-04T12:00:00
checkListRecordsIDIOMFrom = 2012-01-04T01:00:00 checkListRecordsIDIOMFrom = 2012-01-04T01:00:00
checkListRecordsIDIOMUntil = 2012-01-04T12:00:00 checkListRecordsIDIOMUntil = 2012-01-04T12:00:00
checkListRecordsDATACITEFrom = 2012-01-04T01:00:00 checkListRecordsDATACITEFrom = 2012-01-04T01:00:00
checkListRecordsDATACITEUntil = 2012-01-04T12:00:00 checkListRecordsDATACITEUntil = 2012-01-04T12:00:00
# ListIdentifiers # ListIdentifiers
checkListIdentifiersSet = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c checkListIdentifiersSet = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c
c
\ No newline at end of file # ListSets
expectedListSets = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c
# OAI-PMH host # OAI-PMH host
oaipmhEndpoint = https://trep.de.dariah.eu/1.0/oaipmh/oai oaipmhEndpoint = https://trep.de.dariah.eu/1.0/oaipmh
# ListSets
expectedListSets = hdl:21.T11991/0000-0005-E1A9-E
# GetRecord # GetRecord
checkGetRecordDC = checkGetRecordDC = hdl:21.T11991/0000-000D-2845-9
expectedGetRecordDC = expectedGetRecordDC = <dc:identifier>doi:10.5072/0000-000D-2845-9</dc:identifier>
checkGetRecordDATACITE =
expectedGetRecordDATACITE = checkGetRecordDATACITE = hdl:21.T11991/0000-000D-2845-9
checkGetRecordIDList = expectedGetRecordDATACITE = <datacite:alternateIdentifier alternateIdentifierType="DOI">10.5072/0000-000D-2845-9</datacite:alternateIdentifier>
# ListRecords # ListRecords
checkListRecordsDC = checkListRecordsDCSet = hdl:21.T11991/0000-001C-2AA6-8
checkListRecordsDCFrom = checkListRecordsDCSetExpectedPages = 4
checkListRecordsDCUntil =
checkListRecordsDATACITEFrom = checkListRecordsDCFrom = 2018-07-02T16:00
checkListRecordsDATACITEUntil = checkListRecordsDCUntil = 2018-07-02T23:00
checkListRecordsSet = hdl:21.T11991/0000-001C-2AA6-8
checkListRecordsSetExpectedPages = 4 checkListRecordsDATACITEFrom = 2018-07-02T16:00
checkListRecordsDATACITEUntil = 2018-07-02T23:00
# ListIdentifiers # ListIdentifiers
checkListIdentifiersSet = hdl:21.T11991/0000-001C-2AA6-8 checkListIdentifiersSet = hdl:21.T11991/0000-001C-2AA6-8
checkListIdentifiersSetExpectedPages = 4 checkListIdentifiersSetExpectedPages = 4
\ No newline at end of file # ListSets
expectedListSets = hdl:21.T11991/0000-0005-E1A9-E
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