From c30ae8ac18a54ae33cb7e708ca558c5091bd55b3 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Wed, 27 Oct 2021 16:11:21 +0200 Subject: [PATCH] Add test config files Add configuration for textgrid host tests Remove not needed .info logs --- .../info/textgrid/middleware/OAIPMHImpl.java | 14 +- .../RecordListDelivererDATACITE.java | 3 +- .../middleware/RecordListDelivererDC.java | 6 +- .../middleware/OaiPmhDariahdeOnlineTests.java | 3 +- .../middleware/OaiPmhTestUtilities.java | 60 ++ .../middleware/OaiPmhTextgridOnlineTests.java | 551 +++++++++--------- oaipmh-core/src/test/resources/.gitignore | 1 + ...oaipmh.test.dev-textgridlab-org.properties | 24 + ...mh.test.repository-de-dariah-eu.properties | 2 + .../oaipmh.test.textgridlab-org.properties | 25 + 10 files changed, 397 insertions(+), 292 deletions(-) create mode 100644 oaipmh-core/src/test/resources/.gitignore create mode 100644 oaipmh-core/src/test/resources/oaipmh.test.dev-textgridlab-org.properties create mode 100644 oaipmh-core/src/test/resources/oaipmh.test.repository-de-dariah-eu.properties create mode 100644 oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java index 97470f1b..f0abb804 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -32,7 +32,7 @@ import info.textgrid.middleware.oaipmh.VerbType; * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 2021-10-26 + * @version 2021-10-27 * @since 2014-01-29 */ public class OAIPMHImpl implements OAIPMHProducer { @@ -369,7 +369,7 @@ public class OAIPMHImpl implements OAIPMHProducer { .containsKey(request.getResumptionToken())) { idListDeliv = this.identifierListDC; - this.log.info("DC collector: " + IdentifierListDelivererDC.cursorCollector); + this.log.debug("DC collector: " + IdentifierListDelivererDC.cursorCollector); } // Token is from IDIOM request. else if (IdentifierListDelivererIDIOM.cursorCollector != null @@ -377,7 +377,7 @@ public class OAIPMHImpl implements OAIPMHProducer { .containsKey(request.getResumptionToken())) { idListDeliv = this.identifierListIDIOM; - this.log.info("IDIOM collector: " + IdentifierListDelivererIDIOM.cursorCollector); + this.log.debug("IDIOM collector: " + IdentifierListDelivererIDIOM.cursorCollector); } // Token is from DATACITE request. else if (IdentifierListDelivererDATACITE.cursorCollector != null @@ -385,7 +385,7 @@ public class OAIPMHImpl implements OAIPMHProducer { .containsKey(request.getResumptionToken())) { idListDeliv = this.identifierListDATACITE; - this.log.info("DATACITE collector: " + IdentifierListDelivererDATACITE.cursorCollector); + this.log.debug("DATACITE collector: " + IdentifierListDelivererDATACITE.cursorCollector); } // We have got an invalid resumptionToken here! else { @@ -566,14 +566,14 @@ public class OAIPMHImpl implements OAIPMHProducer { && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken())) { recListDeliv = this.recordListDC; - this.log.info("DC collector: " + RecordListDelivererDC.cursorCollector); + this.log.debug("DC collector: " + RecordListDelivererDC.cursorCollector); } // Token is from IDIOM request. else if (RecordListDelivererIDIOM.cursorCollector != null && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken())) { recListDeliv = this.recordListIDIOM; - this.log.info("IDIOM collector: " + RecordListDelivererIDIOM.cursorCollector); + this.log.debug("IDIOM collector: " + RecordListDelivererIDIOM.cursorCollector); } // Token is from IDIOM request. else if (RecordListDelivererDATACITE.cursorCollector != null @@ -581,7 +581,7 @@ public class OAIPMHImpl implements OAIPMHProducer { .containsKey(request.getResumptionToken())) { recListDeliv = this.recordListDATACITE; - this.log.info("DATACITE collector: " + RecordListDelivererDATACITE.cursorCollector); + this.log.debug("DATACITE collector: " + RecordListDelivererDATACITE.cursorCollector); } // We have got an invalid resumptionToken here! else { diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java index b9978d43..8f42c131 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java @@ -251,7 +251,7 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { try { cursorCollector.remove(resumptionToken); } catch (NullPointerException couldNotRemove) { - log.info("Could not remove hash value: " + resumptionToken + " from hash map"); + log.debug("Could not remove hash value: " + resumptionToken + " from hash map"); } this.resTokenForResponse.setValue(""); } else { @@ -262,7 +262,6 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { log.debug("cursorCollector: " + cursorCollector); } else { - log.info("HALLO"); setFoundItems(false); } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java index 9a808fa5..e56bbde9 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java @@ -178,8 +178,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { } } - log.info("Queried fields: " + this.fields.toString()); - log.info("Lifetime for resumption token is set to: " + LIFETIME_RES_TOKEN); + log.debug("Queried fields: " + this.fields.toString()); + log.debug("Lifetime for resumption token is set to: " + LIFETIME_RES_TOKEN); scrollID = scrollResp.getScrollId(); @@ -296,7 +296,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { public ListRecordsType getRecords(String from, String to, String set, String resumptionToken) throws ParseException, IOException { - log.info("Started List Records with booleans for DARIAH: " + this.dariah + " and TextGrid: " + log.debug("Started List Records with booleans for DARIAH: " + this.dariah + " and TextGrid: " + this.textgrid); ListRecordsType recordList = new ListRecordsType(); diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java index eb2c0871..5814597e 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java @@ -29,7 +29,8 @@ import org.junit.Test; @Ignore public class OaiPmhDariahdeOnlineTests { - // TODO Configure config files for all the different OAI-PMH service instances! + // FIXME Configure config files for all the different OAI-PMH service instances (see TG + // implementation)! // ** // The OAIPMH host to be tested. diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestUtilities.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestUtilities.java index d53d1349..02f272b4 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestUtilities.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestUtilities.java @@ -1,7 +1,12 @@ package info.textgrid.middleware; import static org.junit.Assert.assertTrue; +import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.Client; import org.apache.cxf.jaxrs.client.WebClient; @@ -23,6 +28,11 @@ public class OaiPmhTestUtilities { protected static final String OAI_DC_PREFIX = "oai_dc"; protected static final String OAI_DATACITE_PREFIX = "oai_datacite"; protected static final String OAI_IDIOMMETS_PREFIX = "oai_idiom_mets"; + + protected static final String EXPECTED_OAIDC_FORMAT_CONTENT = "<oai_dc:dc>"; + protected static final String EXPECTED_IDIOMMETS_FORMAT_CONTENT = "<mets "; + protected static final String EXPECTED_DATACITE_FORMAT_CONTENT = "<datacite:resource>"; + protected static final String NO_SET = null; protected static final String ERROR = " >>> ERROR"; protected static final String OK = " >>> OKIDOKI"; @@ -106,4 +116,54 @@ public class OaiPmhTestUtilities { return theMillis / secs + " second" + ((theMillis / secs) != 1 ? "s" : ""); } + /** + * <p> + * Loads a resource. + * </p> + * + * TODO Put together with the method in TGCrudServiceUtilities! Maybe create a first build maven + * module for utility things. + * + * @param {@link String} The resource to search for. + * @return {@link File} The resource. + * @throws IOException + */ + protected static File getResource(String resPart) throws IOException { + + File res; + + // If we have an absolute resPart, just return the file. + if (resPart.startsWith(File.separator)) { + return new File(resPart); + } + + URL url = ClassLoader.getSystemClassLoader().getResource(resPart); + if (url == null) { + throw new IOException("Resource '" + resPart + "' not found"); + } + try { + res = new File(url.toURI()); + } catch (URISyntaxException ue) { + res = new File(url.getPath()); + } + + return res; + } + + /** + * @param theProperty + * @return + */ + protected static List<String> getListFromProperties(String theProperty) { + + List<String> result = new ArrayList<String>(); + + String parts[] = theProperty.split(","); + for (String part : parts) { + result.add(part.trim()); + } + + return result; + } + } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java index cda55fd3..3eede9f6 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java @@ -1,8 +1,12 @@ package info.textgrid.middleware; import static org.junit.Assert.assertTrue; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -33,43 +37,43 @@ import org.junit.Test; @Ignore public class OaiPmhTextgridOnlineTests { - // TODO Configure config files for all the different OAI-PMH service instances! - - // ** - // The OAIPMH host to be tested. - // ** - - // private static String host = "https://textgridlab.org/1.0/tgoaipmh/oai"; - // private static String oaipmhEndpoint = "https://test.textgridlab.org/1.0/tgoaipmh/oai"; - // private static String oaipmhEndpoint = "https://dev.textgridlab.org/1.0/tgoaipmh/oai"; - - // NOTE Test with "mvn jetty:run" in oaipmh-webapp module folder and SSH tunneling "ssh -L - // 9202:localhost:9202 -l [username] dev.textgridlab.org", please use original OAIPMH config file - // from /etc/dhrep/oaipmh/oaipmh.textgrid.properties and copy it to - // /etc/dhrep/oaipmh/oaipmh.config on your local machine! - private static String oaipmhEndpoint = "http://localhost:8095/oaipmh/oai"; - // NOTE Use "mvn tomcat:run" here! - // private static String oaipmhEndpoint = "http://localhost:8080/oaipmh-webapp/oai"; - // ** // FINALS // ** - private static final String OAIDC_SCHEMA_FORMAT = "oai_dc"; - private static final String IDIOMMETS_SCHEMA_FORMAT = "oai_idiom_mets"; - private static final String DATACITE_SCHEMA_FORMAT = "oai_datacite"; - private static final String EXPECTED_OAIDC_FORMAT_CONTENT = "<oai_dc:dc>"; - private static final String EXPECTED_IDIOMMETS_FORMAT_CONTENT = "<mets "; - private static final String EXPECTED_DATACITE_FORMAT_CONTENT = "<datacite:resource>"; + // private static final String PROPERTIES_FILE = "oaipmh.test.textgridlab-org.properties"; + private static final String PROPERTIES_FILE = "oaipmh.test.dev-textgridlab-org.properties"; // ** // STATICS // ** // Some JAXRS things. + private static String oaipmhEndpoint; private static OAIPMHProducer JAXRSClient; private static Client oaipmhWebClient; + // ListSets + private static String expectedListSets; + // GetRecord + private static String checkGetRecordDC; + private static String expectedGetRecordDC; + private static String checkGetRecordIDIOM; + private static String expectedGetRecordIDIOM; + private static String checkGetRecordDATACITE; + private static String expectedGetRecordDATACITE; + private static String checkListRecordsDC; + private static String checkListRecordsDCFrom; + private static String checkListRecordsDCUntil; + private static String checkListRecordsIDIOMFrom; + private static String checkListRecordsIDIOMUntil; + private static String checkListRecordsDATACITEFrom; + private static String checkListRecordsDATACITEUntil; + private static String checkListIdentifiersSet; + private static int checkListIdentifiersPagesToTestIDIOM; + private static int checkListIdentifiersRecordsPerPageIDIOM; + private static List<String> checkGetRecordIDList = new ArrayList<String>(); + // ** // PREPARATIONS // ** @@ -80,6 +84,36 @@ public class OaiPmhTextgridOnlineTests { @BeforeClass public static void setUpBeforeClass() throws Exception { + // Load properties file. + Properties p = new Properties(); + p.load(new FileInputStream(OaiPmhTestUtilities.getResource(PROPERTIES_FILE))); + + System.out.println("Properties file: " + PROPERTIES_FILE); + p.list(System.out); + + // Get other needed properties. + oaipmhEndpoint = p.getProperty("oaipmhEndpoint"); + checkGetRecordDC = p.getProperty("checkGetRecordDC"); + expectedGetRecordDC = p.getProperty("expectedGetRecordDC"); + checkGetRecordIDIOM = p.getProperty("checkGetRecordIDIOM"); + expectedGetRecordIDIOM = p.getProperty("expectedGetRecordIDIOM"); + checkGetRecordDATACITE = p.getProperty("checkGetRecordDATACITE"); + expectedGetRecordDATACITE = p.getProperty("expectedGetRecordDATACITE"); + checkListRecordsDC = p.getProperty("checkListRecordsDC"); + checkListRecordsDCFrom = p.getProperty("checkListRecordsDCFrom"); + checkListRecordsDCUntil = p.getProperty("checkListRecordsDCUntil"); + checkListRecordsIDIOMFrom = p.getProperty("checkListRecordsIDIOMFrom"); + checkListRecordsIDIOMUntil = p.getProperty("checkListRecordsIDIOMUntil"); + checkListRecordsDATACITEFrom = p.getProperty("checkListRecordsDATACITEFrom"); + checkListRecordsDATACITEUntil = p.getProperty("checkListRecordsDATACITEUntil"); + checkListIdentifiersSet = p.getProperty("checkListIdentifiersSet"); + checkListIdentifiersPagesToTestIDIOM = + Integer.parseInt(p.getProperty("checkListIdentifiersPagesToTestIDIOM")); + checkListIdentifiersRecordsPerPageIDIOM = + Integer.parseInt(p.getProperty("checkListIdentifiersRecordsPerPageIDIOM")); + checkGetRecordIDList = + OaiPmhTestUtilities.getListFromProperties((String) p.get("checkGetRecordIDList")); + // Get OAI-PMH REST endpoint and HTTP client. System.out.println("Getting OAI-PMH HTTP client --> " + oaipmhEndpoint + " <--"); @@ -146,6 +180,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testRootUrl()"); + // Still hard coded in OAIPMH service! String shouldContain = "textgridrep.org"; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, "oai", @@ -173,6 +208,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testIdentify()"); + // Still hard coded in OAIPMH service! String shouldContain = "textgridrep.org"; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, @@ -200,8 +236,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListMetadataFormats()"); - String shouldContainOaidc = "oai_dc"; - String shouldContainOaiidiommets = "oai_idiom_mets"; + String shouldContainDC = OaiPmhTestUtilities.OAI_DC_PREFIX; + String shouldContainIDIOM = OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX; + String shouldContainDATACITE = OaiPmhTestUtilities.OAI_DATACITE_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, "verb=" + OaiPmhTestUtilities.VERB_LIST_METADATA_FORMATS, @@ -210,12 +247,11 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContainOaidc) - || !response.contains(shouldContainOaiidiommets)) { + if (status != HttpStatus.SC_OK || !response.contains(shouldContainDC) + || !response.contains(shouldContainIDIOM) || !response.contains(shouldContainDATACITE)) { System.err.println("\tstatus: " + status); - System.err.println( - OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContainOaidc + "' and '" - + shouldContainOaiidiommets + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContainDC + + "' and '" + shouldContainIDIOM + "' and '" + shouldContainDATACITE + "'"); assertTrue(false); } @@ -231,22 +267,17 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListSets()"); - // Testing for set: TextGrid Digitale Bibliothek. - String shouldContainTEXTGRIDLABORG = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - String shouldContainDEFTEXTGRIDLABORG = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, "verb=" + OaiPmhTestUtilities.VERB_LIST_SETS, OaiPmhTestUtilities.NO_THREAD_NAME); int status = httpResponse.getStatus(); String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContainTEXTGRIDLABORG) - && !response.contains(shouldContainDEFTEXTGRIDLABORG)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedListSets)) { System.err.println("\tstatus: " + status); - System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain (textgridlab.org) '" - + shouldContainTEXTGRIDLABORG + "' or (dev.textgridlab.org) '" - + shouldContainDEFTEXTGRIDLABORG + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedListSets + "'"); System.err.println(response); assertTrue(false); } @@ -263,11 +294,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordOAIDC()"); - String identifier = "textgrid:vqn0.0"; - String shouldContain = "Heidi"; - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" - + identifier + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_DC_PREFIX; + + OaiPmhTextgridOnlineTests.checkGetRecordDC + "&metadataPrefix=" + + OaiPmhTestUtilities.OAI_DC_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); @@ -275,10 +304,11 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordDC)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedGetRecordDC + "'"); System.err.println(response); assertTrue(false); } @@ -295,11 +325,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordOAIDCNoPrefix()"); - String identifier = "mq05.0"; - String shouldContain = "tvitt@textgrid.de"; - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" - + identifier + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_DC_PREFIX; + + OaiPmhTextgridOnlineTests.checkGetRecordDC + "&metadataPrefix=" + + OaiPmhTestUtilities.OAI_DC_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); @@ -307,10 +335,12 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordDC)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println( + OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.checkGetRecordDC + "'"); System.err.println(response); assertTrue(false); } @@ -327,11 +357,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordIDIOMMETS()"); - String identifier = "textgrid:2sg18.0"; - String shouldContain = "Aguateca"; - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" - + identifier + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX; + + OaiPmhTextgridOnlineTests.checkGetRecordIDIOM + "&metadataPrefix=" + + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); @@ -339,10 +367,11 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordIDIOM)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedGetRecordIDIOM + "'"); System.err.println(response); assertTrue(false); } @@ -359,11 +388,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordIDIOMMETSNoPrefix()"); - String identifier = "2sg18.0"; - String shouldContain = "Aguateca"; - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" - + identifier + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX; + + OaiPmhTextgridOnlineTests.checkGetRecordIDIOM + "&metadataPrefix=" + + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); @@ -371,10 +398,11 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordIDIOM)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedGetRecordIDIOM + "'"); System.err.println(response); assertTrue(false); } @@ -391,11 +419,9 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordDATACITE()"); - String identifier = "textgrid:mq05.0"; - String shouldContain = "Spraach-en Höfflichkeit"; - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" - + identifier + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_DATACITE_PREFIX; + + OaiPmhTextgridOnlineTests.checkGetRecordDATACITE + "&metadataPrefix=" + + OaiPmhTestUtilities.OAI_DATACITE_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); @@ -403,10 +429,11 @@ public class OaiPmhTextgridOnlineTests { String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordDATACITE)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedGetRecordDATACITE + "'"); System.err.println(response); assertTrue(false); } @@ -423,21 +450,21 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testGetRecordDATACITENoPrefix()"); - String identifier = "mq05.0"; - String shouldContain = "Spraach-en Höfflichkeit"; - - String path = "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" + identifier - + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_DATACITE_PREFIX; + String path = + "verb=" + OaiPmhTestUtilities.VERB_GET_RECORD + "&identifier=" + + OaiPmhTextgridOnlineTests.checkGetRecordDATACITE + + "&metadataPrefix=" + OaiPmhTestUtilities.OAI_DATACITE_PREFIX; Response httpResponse = OaiPmhTestUtilities.getHttpResponse(oaipmhWebClient, path, OaiPmhTestUtilities.NO_THREAD_NAME); int status = httpResponse.getStatus(); String response = IOUtils.readStringFromStream((InputStream) httpResponse.getEntity()); - if (status != HttpStatus.SC_OK || !response.contains(shouldContain)) { + if (status != HttpStatus.SC_OK + || !response.contains(OaiPmhTextgridOnlineTests.expectedGetRecordDATACITE)) { System.err.println("\tstatus: " + status); - System.err - .println(OaiPmhTestUtilities.ERROR + ": response should contain '" + shouldContain + "'"); + System.err.println(OaiPmhTestUtilities.ERROR + ": response should contain '" + + OaiPmhTextgridOnlineTests.expectedGetRecordDATACITE + "'"); System.err.println(response); assertTrue(false); } @@ -454,12 +481,8 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsOAIDCSinglePage()"); - // IIIF - // String set = "project:TGPR-2e532567-c3e3-36f5-3ecc-520cea7904cc"; - // ELTEX Test - String set = "project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, set, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, + OaiPmhTextgridOnlineTests.checkListRecordsDC, OaiPmhTestUtilities.OAI_DC_PREFIX, 0, 100, OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); @@ -475,10 +498,8 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsOAIDCMorePages()"); - // Testing set: Digitale Bibliothek (on prod and dev available only...) - String set = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, set, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, + OaiPmhTextgridOnlineTests.checkListRecordsDC, OaiPmhTestUtilities.OAI_DC_PREFIX, 20, 100, OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); @@ -494,13 +515,11 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsOAIDCMorePagesFromUntil()"); - // Testing set: Digitale Bibliothek (on prod and dev available only...) - String set = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - String from = "2012-01-04T01:00:00"; - String until = "2012-01-04T12:00:00"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, set, - OaiPmhTestUtilities.OAI_DC_PREFIX, 0, 100, OaiPmhTestUtilities.NO_THREAD_NAME, from, until, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, + OaiPmhTextgridOnlineTests.checkListRecordsDC, + OaiPmhTestUtilities.OAI_DC_PREFIX, 0, 100, OaiPmhTestUtilities.NO_THREAD_NAME, + OaiPmhTextgridOnlineTests.checkListRecordsDCFrom, + OaiPmhTextgridOnlineTests.checkListRecordsDCUntil, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); System.out.println(OaiPmhTestUtilities.OK); @@ -543,25 +562,23 @@ public class OaiPmhTextgridOnlineTests { } /** + * NOTE The amount of records will change due to changes on the data! Please check from and until + * values before! + * * @throws IOException */ @Test @Ignore public void testListRecordsIDIOMMETSMorePagesFromUntil() throws IOException { - // FIXME Amount of records will change due to changes on the data! Please check from and until - // values before! - System.out .println(OaiPmhTestUtilities.TESTING + "testListRecordsIDIOMMETSMorePagesFromUntil()"); - String from = "2015-11-12T01:00:00"; - String until = "2016-03-02T12:00:00"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, - OaiPmhTestUtilities.NO_SET, - OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, 6, 30, OaiPmhTestUtilities.NO_THREAD_NAME, from, - until, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, OaiPmhTestUtilities.NO_SET, + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, 6, 30, OaiPmhTestUtilities.NO_THREAD_NAME, + OaiPmhTextgridOnlineTests.checkListRecordsIDIOMFrom, + OaiPmhTextgridOnlineTests.checkListRecordsIDIOMUntil, + OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); System.out.println(OaiPmhTestUtilities.OK); } @@ -591,8 +608,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsDATACITEMorePages()"); - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, - OaiPmhTestUtilities.NO_SET, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_DATACITE_PREFIX, 15, 100, OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); @@ -609,8 +625,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsDATACITEAllPages()"); - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, - OaiPmhTestUtilities.NO_SET, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_DATACITE_PREFIX, 0, 100, OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); @@ -626,33 +641,10 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListRecordsDATACITEMorePagesFromUntil()"); - String from = "2012-01-04T01:00:00"; - String until = "2012-01-04T12:00:00"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, - OaiPmhTestUtilities.NO_SET, - OaiPmhTestUtilities.OAI_DATACITE_PREFIX, 15, 100, OaiPmhTestUtilities.NO_THREAD_NAME, from, - until, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); - - System.out.println(OaiPmhTestUtilities.OK); - } - - /** - * @throws IOException - */ - @Test - public void testListIdentifierOAIDCSinglePage() throws IOException { - - System.out.println(OaiPmhTestUtilities.TESTING + "testListIdentifierOAIDCSinglePage()"); - - // IIIF - // String set = "project:TGPR-2e532567-c3e3-36f5-3ecc-520cea7904cc"; - // ELTEX Test - String set = "project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, set, - OaiPmhTestUtilities.OAI_DC_PREFIX, 0, 100, OaiPmhTestUtilities.NO_THREAD_NAME, - OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_RECORDS, OaiPmhTestUtilities.NO_SET, + OaiPmhTestUtilities.OAI_DATACITE_PREFIX, 15, 100, OaiPmhTestUtilities.NO_THREAD_NAME, + OaiPmhTextgridOnlineTests.checkListRecordsDATACITEFrom, + OaiPmhTextgridOnlineTests.checkListRecordsDATACITEUntil, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); System.out.println(OaiPmhTestUtilities.OK); @@ -666,13 +658,11 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListIdentifiersOAIDCMorePages()"); - // Testing set: Digitale Bibliothek (on prod and dev available only...) - String set = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, set, - OaiPmhTestUtilities.OAI_DC_PREFIX, 30, 100, OaiPmhTestUtilities.NO_THREAD_NAME, - OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, - OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, + OaiPmhTextgridOnlineTests.checkListIdentifiersSet, OaiPmhTestUtilities.OAI_DC_PREFIX, 30, + 100, + OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, + OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.NO_METADATA_FORMAT_WITH_RESTOK); System.out.println(OaiPmhTestUtilities.OK); } @@ -686,13 +676,11 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testListIdentifiersOAIDCMorePagesAndMetadataFormatWithRestok()"); - // Testing set: Digitale Bibliothek (on prod and dev available only...) - String set = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; - - testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, set, - OaiPmhTestUtilities.OAI_DC_PREFIX, 30, 100, OaiPmhTestUtilities.NO_THREAD_NAME, - OaiPmhTestUtilities.NO_FROM, OaiPmhTestUtilities.NO_UNTIL, - OaiPmhTestUtilities.METADATA_FORMAT_WITH_RESTOK); + testList(oaipmhWebClient, OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, + OaiPmhTextgridOnlineTests.checkListIdentifiersSet, OaiPmhTestUtilities.OAI_DC_PREFIX, 30, + 100, + OaiPmhTestUtilities.NO_THREAD_NAME, OaiPmhTestUtilities.NO_FROM, + OaiPmhTestUtilities.NO_UNTIL, OaiPmhTestUtilities.METADATA_FORMAT_WITH_RESTOK); System.out.println(OaiPmhTestUtilities.OK); } @@ -924,13 +912,6 @@ public class OaiPmhTextgridOnlineTests { System.out.println( OaiPmhTestUtilities.TESTING + "testRestokConcurrentlyListIdentifiersDCAndIDIOMMets()"); - int idiomPagesToTest = 10; - int idiomRecordsPerPage = 30; - if (!oaipmhEndpoint.contains("dev.textgridlab.org")) { - idiomPagesToTest = 1; - idiomRecordsPerPage = 1; - } - ExecutorService executor = Executors.newFixedThreadPool(3); Future<Boolean> f1 = executor @@ -941,8 +922,10 @@ public class OaiPmhTextgridOnlineTests { OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_DC_PREFIX, 28, 100, "DC2")); Future<Boolean> f3 = executor .submit(new OaiPmhResumptionTokenTestThread(OaiPmhTestUtilities.VERB_LIST_IDENTIFIERS, - OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, idiomPagesToTest, - idiomRecordsPerPage, "IDIOM")); + OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, + OaiPmhTextgridOnlineTests.checkListIdentifiersPagesToTestIDIOM, + OaiPmhTextgridOnlineTests.checkListIdentifiersRecordsPerPageIDIOM, + "IDIOM")); executor.shutdown(); @@ -1025,13 +1008,6 @@ public class OaiPmhTextgridOnlineTests { System.out .println(OaiPmhTestUtilities.TESTING + "testListRecordsRestokConcurrentlyDCAndIDIOMMets()"); - int idiomPagesToTest = 9; - int idiomRecordsPerPage = 30; - if (!oaipmhEndpoint.contains("dev.textgridlab.org")) { - idiomPagesToTest = 1; - idiomRecordsPerPage = 1; - } - ExecutorService executor = Executors.newFixedThreadPool(3); Future<Boolean> f1 = @@ -1042,8 +1018,10 @@ public class OaiPmhTextgridOnlineTests { OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_DC_PREFIX, 27, 100, "DC2")); Future<Boolean> f3 = executor.submit(new OaiPmhResumptionTokenTestThread(OaiPmhTestUtilities.VERB_LIST_RECORDS, - OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, idiomPagesToTest, - idiomRecordsPerPage, "IDIOM")); + OaiPmhTestUtilities.NO_SET, OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX, + OaiPmhTextgridOnlineTests.checkListIdentifiersPagesToTestIDIOM, + OaiPmhTextgridOnlineTests.checkListIdentifiersRecordsPerPageIDIOM, + "IDIOM")); executor.shutdown(); @@ -1061,95 +1039,107 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OaiPmhTestUtilities.TESTING + "testConcurrentlyOAIDCGetRecord()"); - String id1 = "textgrid:mq05.0"; - String id2 = "textgrid:jgv6.0"; - String id3 = "textgrid:w7rz.0"; - String id4 = "textgrid:w36b.0"; - String id5 = "textgrid:mcdv.0"; - String id6 = "textgrid:v0qx.0"; - String id7 = "textgrid:xkck.0"; - String id8 = "textgrid:t3m1.0"; - String id9 = "textgrid:10rsq.0"; - String id10 = "textgrid:mq05.0"; - String id11 = "textgrid:jgv6.0"; - String id12 = "textgrid:w7rz.0"; - String id13 = "textgrid:w36b.0"; - String id14 = "textgrid:mcdv.0"; - String id15 = "textgrid:v0qx.0"; - String id16 = "textgrid:xkck.0"; - String id17 = "textgrid:t3m1.0"; - String id18 = "textgrid:10rsq.0"; - - if (!oaipmhEndpoint.contains("dev.textgridlab.org")) { - - ExecutorService executor = Executors.newFixedThreadPool(18); - - Future<Boolean> f1 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id1, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR1")); - Future<Boolean> f2 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id2, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR2")); - Future<Boolean> f3 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id3, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR3")); - Future<Boolean> f4 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id4, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR4")); - Future<Boolean> f5 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id5, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR5")); - Future<Boolean> f6 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id6, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR6")); - Future<Boolean> f7 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id7, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR7")); - Future<Boolean> f8 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id8, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR8")); - Future<Boolean> f9 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id9, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR9")); - Future<Boolean> f10 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id10, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR10")); - Future<Boolean> f11 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id11, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR11")); - Future<Boolean> f12 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id12, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR12")); - Future<Boolean> f13 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id13, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR13")); - Future<Boolean> f14 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id14, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR14")); - Future<Boolean> f15 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id15, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR15")); - Future<Boolean> f16 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id16, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR16")); - Future<Boolean> f17 = executor - .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id17, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR17")); - Future<Boolean> f18 = - executor.submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, id18, - OaiPmhTestUtilities.OAI_DC_PREFIX, "GR18")); - - executor.shutdown(); - - System.out.println(OaiPmhTestUtilities.OK + "[GR1]=" + f1.get() + ", [GR2]=" + f2.get() - + ", [GR3]=" + f3.get() + ", [GR4]=" + f4.get() + ", [GR5]=" + f5.get() + ", [GR6]=" - + f6.get() + ", [GR7]=" + f7.get() + ", [GR8]=" + f8.get() + ", [GR9]=" + f9.get() - + ", [GR10]=" + f10.get() + ", [GR11]=" + f11.get() + ", [GR12]=" + f12.get() - + ", [GR13]=" + f13.get() + ", [GR14]=" + f14.get() + ", [GR15]=" + f15.get() - + ", [GR16]=" + f16.get() + ", [GR17]=" + f17.get() + ", [GR18]=" + f18.get()); - } else { - System.out.println(OaiPmhTestUtilities.NOT_TESTED); - } + ExecutorService executor = Executors.newFixedThreadPool(18); + + Future<Boolean> f1 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f2 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(1), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f3 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(2), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f4 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(3), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f5 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(4), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f6 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(5), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f7 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(6), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f8 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(7), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f9 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(8), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f10 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(9), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f11 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(10), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f12 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(11), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f13 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(12), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f14 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(13), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f15 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(14), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f16 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(15), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f17 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(16), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + Future<Boolean> f18 = executor + .submit(new OaiPmhGetRecordTestThread(OaiPmhTestUtilities.VERB_GET_RECORD, + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(17), + OaiPmhTestUtilities.OAI_DC_PREFIX, + "GR[" + OaiPmhTextgridOnlineTests.checkGetRecordIDList.get(0) + "]")); + + executor.shutdown(); + + System.out.println(OaiPmhTestUtilities.OK + "[GR1]=" + f1.get() + ", [GR2]=" + f2.get() + + ", [GR3]=" + f3.get() + ", [GR4]=" + f4.get() + ", [GR5]=" + f5.get() + ", [GR6]=" + + f6.get() + ", [GR7]=" + f7.get() + ", [GR8]=" + f8.get() + ", [GR9]=" + f9.get() + + ", [GR10]=" + f10.get() + ", [GR11]=" + f11.get() + ", [GR12]=" + f12.get() + + ", [GR13]=" + f13.get() + ", [GR14]=" + f14.get() + ", [GR15]=" + f15.get() + + ", [GR16]=" + f16.get() + ", [GR17]=" + f17.get() + ", [GR18]=" + f18.get()); } /** @@ -1483,26 +1473,29 @@ public class OaiPmhTextgridOnlineTests { private static void examineContent(String theResponseString, String theMetadataFormat) { // Check for correct metadata content according to metadata prefix. - if (theMetadataFormat.equals(OAIDC_SCHEMA_FORMAT) - && !theResponseString.contains("metadataPrefix=\"" + OAIDC_SCHEMA_FORMAT + "\"") - && !theResponseString.contains(EXPECTED_OAIDC_FORMAT_CONTENT)) { + if (theMetadataFormat.equals(OaiPmhTestUtilities.OAI_DC_PREFIX) + && !theResponseString + .contains("metadataPrefix=\"" + OaiPmhTestUtilities.OAI_DC_PREFIX + "\"") + && !theResponseString.contains(OaiPmhTestUtilities.EXPECTED_OAIDC_FORMAT_CONTENT)) { System.out - .println(OAIDC_SCHEMA_FORMAT + " needs to deliver content with schema: " - + EXPECTED_OAIDC_FORMAT_CONTENT + "!"); + .println(OaiPmhTestUtilities.OAI_DC_PREFIX + " needs to deliver content with schema: " + + OaiPmhTestUtilities.EXPECTED_OAIDC_FORMAT_CONTENT + "!"); assertTrue(false); - } else if (theMetadataFormat.equals(IDIOMMETS_SCHEMA_FORMAT) - && !theResponseString.contains("metadataPrefix=\"" + IDIOMMETS_SCHEMA_FORMAT + "\"") - && !theResponseString.contains(EXPECTED_IDIOMMETS_FORMAT_CONTENT)) { - System.out - .println(IDIOMMETS_SCHEMA_FORMAT + " needs to deliver content with schema: " - + EXPECTED_IDIOMMETS_FORMAT_CONTENT + "!"); + } else if (theMetadataFormat.equals(OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX) + && !theResponseString.contains( + "metadataPrefix=\"" + OaiPmhTestUtilities.EXPECTED_IDIOMMETS_FORMAT_CONTENT + "\"") + && !theResponseString.contains(OaiPmhTestUtilities.EXPECTED_IDIOMMETS_FORMAT_CONTENT)) { + System.out.println( + OaiPmhTestUtilities.OAI_IDIOMMETS_PREFIX + " needs to deliver content with schema: " + + OaiPmhTestUtilities.EXPECTED_IDIOMMETS_FORMAT_CONTENT + "!"); assertTrue(false); - } else if (theMetadataFormat.equals(DATACITE_SCHEMA_FORMAT) - && !theResponseString.contains("metadataPrefix=\"" + DATACITE_SCHEMA_FORMAT + "\"") - && !theResponseString.contains(EXPECTED_DATACITE_FORMAT_CONTENT)) { - System.out - .println(DATACITE_SCHEMA_FORMAT + " needs to deliver content with schema: " - + EXPECTED_DATACITE_FORMAT_CONTENT + "!"); + } else if (theMetadataFormat.equals(OaiPmhTestUtilities.OAI_DATACITE_PREFIX) + && !theResponseString + .contains("metadataPrefix=\"" + OaiPmhTestUtilities.OAI_DATACITE_PREFIX + "\"") + && !theResponseString.contains(OaiPmhTestUtilities.EXPECTED_DATACITE_FORMAT_CONTENT)) { + System.out.println( + OaiPmhTestUtilities.OAI_DATACITE_PREFIX + " needs to deliver content with schema: " + + OaiPmhTestUtilities.EXPECTED_DATACITE_FORMAT_CONTENT + "!"); assertTrue(false); } } diff --git a/oaipmh-core/src/test/resources/.gitignore b/oaipmh-core/src/test/resources/.gitignore new file mode 100644 index 00000000..c03706e3 --- /dev/null +++ b/oaipmh-core/src/test/resources/.gitignore @@ -0,0 +1 @@ +/oaipmh.test.local.properties diff --git a/oaipmh-core/src/test/resources/oaipmh.test.dev-textgridlab-org.properties b/oaipmh-core/src/test/resources/oaipmh.test.dev-textgridlab-org.properties new file mode 100644 index 00000000..ab192657 --- /dev/null +++ b/oaipmh-core/src/test/resources/oaipmh.test.dev-textgridlab-org.properties @@ -0,0 +1,24 @@ +# OAI-PMH host +oaipmhEndpoint = https://dev.textgridlab.org/1.0/tgoaipmh/oai +# ListSets +expectedListSets = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c +# GetRecord +checkGetRecordDC = textgrid:vqn0.0 +expectedGetRecordDC = Heidi +checkGetRecordIDIOM = textgrid:2sg18.0 +expectedGetRecordIDIOM = Aguateca +checkGetRecordDATACITE = textgrid:mq05.0 +expectedGetRecordDATACITE = Spraach-en Höfflichkeit +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 +checkListRecordsDC = project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab +checkListRecordsDCFrom = 2012-01-04T01:00:00 +checkListRecordsDCUntil = 2012-01-04T12:00:00 +checkListRecordsIDIOMFrom = 2012-01-04T01:00:00 +checkListRecordsIDIOMUntil = 2012-01-04T12:00:00 +checkListRecordsDATACITEFrom = 2012-01-04T01:00:00 +checkListRecordsDATACITEUntil = "2012-01-04T12:00:00 +# ListIdentifiers +checkListIdentifiersSet = project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab +checkListIdentifiersPagesToTestIDIOM = 10 +checkListIdentifiersRecordsPerPageIDIOM = 30 diff --git a/oaipmh-core/src/test/resources/oaipmh.test.repository-de-dariah-eu.properties b/oaipmh-core/src/test/resources/oaipmh.test.repository-de-dariah-eu.properties new file mode 100644 index 00000000..92dfdc4a --- /dev/null +++ b/oaipmh-core/src/test/resources/oaipmh.test.repository-de-dariah-eu.properties @@ -0,0 +1,2 @@ +# OAI-PMH host +oaipmhEndpoint = https://repository.de.dariah.eu/1.0/tgoaipmh/oai diff --git a/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties b/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties new file mode 100644 index 00000000..23200f32 --- /dev/null +++ b/oaipmh-core/src/test/resources/oaipmh.test.textgridlab-org.properties @@ -0,0 +1,25 @@ +# OAI-PMH host +oaipmhEndpoint = https://textgridlab.org/1.0/tgoaipmh/oai +# ListSets +expectedListSets = project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c +# GetRecord +checkGetRecordDC = textgrid:vqn0.0 +expectedGetRecordDC = Heidi +checkGetRecordIDIOM = textgrid:2sg18.0 +expectedGetRecordIDIOM = Aguateca +checkGetRecordDATACITE = textgrid:mq05.0 +expectedGetRecordDATACITE = Spraach-en Höfflichkeit +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 +checkListRecordsDC = project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab +checkListRecordsDCFrom = 2012-01-04T01:00:00 +checkListRecordsDCUntil = 2012-01-04T12:00:00 +checkListRecordsIDIOMFrom = 2012-01-04T01:00:00 +checkListRecordsIDIOMUntil = 2012-01-04T12:00:00 +checkListRecordsDATACITEFrom = 2012-01-04T01:00:00 +checkListRecordsDATACITEUntil = "2012-01-04T12:00:00 +# ListIdentifiers +checkListIdentifiersSet = project:TGPR-59722e29-efcb-330f-b9b4-5ef2fb08edab +checkListIdentifiersPagesToTestIDIOM = 10 +checkListIdentifiersRecordsPerPageIDIOM = 30 + \ No newline at end of file -- GitLab