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

test: correct test

parent a36707c4
No related branches found
No related tags found
No related merge requests found
Pipeline #324446 failed
......@@ -8,11 +8,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import javax.ws.rs.core.Response;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.Client;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
......@@ -582,20 +586,28 @@ public class OaipmhUtilitiesOnline {
* </p>
*
* @param theResponseString
* @throws DatatypeConfigurationException
* @throws ParseException
*/
public static void examineModificationDates(String theResponseString) {
public static void examineTGModificationDates(String theResponseString)
throws ParseException, DatatypeConfigurationException {
String datestampTag = "<datestamp>";
String recordChangeTag = "<recordChangeDate encoding=\"iso8601\">";
// Count the occurrence of modification date, must be in GetRecord.record.header.datestamp, and
// in mets.recordInfo.recordChangeDate!
String datestamp = theResponseString.substring(
theResponseString.indexOf(datestampTag) + datestampTag.length(),
theResponseString.indexOf("</datestamp>") - 10);
String recordChangeDate = theResponseString.substring(
theResponseString.indexOf(recordChangeTag) + recordChangeTag.length(),
theResponseString.indexOf("</recordChangeDate>") - 1);
XMLGregorianCalendar datestamp = OaipmhUtilities.convertDateFormat(
theResponseString.substring(
theResponseString.indexOf(datestampTag) + datestampTag.length(),
theResponseString.indexOf("</datestamp>")).trim());
System.out.println(datestamp);
XMLGregorianCalendar recordChangeDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(
theResponseString.substring(
theResponseString.indexOf(recordChangeTag) + recordChangeTag.length(),
theResponseString.indexOf("</recordChangeDate>")).trim());
if (!datestamp.equals(recordChangeDate)) {
assertTrue(datestamp + " != " + recordChangeDate, false);
......
......@@ -3,6 +3,7 @@ package info.textgrid.middleware.test.online.tg;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
......@@ -12,6 +13,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import javax.ws.rs.core.Response;
import javax.xml.datatype.DatatypeConfigurationException;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.client.Client;
import org.apache.http.HttpStatus;
......@@ -36,7 +38,7 @@ import info.textgrid.middleware.test.online.OaipmhUtilitiesOnline;
* @version 2022-09-23
* @since 2022-09-08
*/
@Ignore
// @Ignore
public class TestTGGetRecordOnline {
// **
......@@ -153,9 +155,12 @@ public class TestTGGetRecordOnline {
/**
* @throws IOException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
@Test
public void testGetRecordIdiomMETS() throws IOException {
public void testGetRecordIdiomMETS()
throws IOException, ParseException, DatatypeConfigurationException {
System.out.println(OaipmhUtilitiesOnline.TESTING + "testGetRecordIdiomMETS()");
......@@ -175,7 +180,7 @@ public class TestTGGetRecordOnline {
// Test OAI header.
OaipmhUtilitiesOnline.examineTGHeaderIDs(response, OaipmhUtilitiesOnline.OAI_IDIOMMETS_PREFIX);
OaipmhUtilitiesOnline.examineModificationDates(response);
OaipmhUtilitiesOnline.examineTGModificationDates(response);
System.out.println("\tresponse: " + response);
System.out.println(OaipmhUtilitiesOnline.OK);
......@@ -183,9 +188,12 @@ public class TestTGGetRecordOnline {
/**
* @throws IOException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
@Test
public void testGetRecordIDIOMMETSImage() throws IOException {
public void testGetRecordIDIOMMETSImage()
throws IOException, ParseException, DatatypeConfigurationException {
System.out.println(OaipmhUtilitiesOnline.TESTING + "testGetRecordIDIOMMETS_Image()");
......@@ -207,7 +215,7 @@ public class TestTGGetRecordOnline {
// Test OAI header.
OaipmhUtilitiesOnline.examineTGHeaderIDs(response, OaipmhUtilitiesOnline.OAI_IDIOMMETS_PREFIX);
OaipmhUtilitiesOnline.examineModificationDates(response);
OaipmhUtilitiesOnline.examineTGModificationDates(response);
System.out.println("\tresponse: " + response);
System.out.println(OaipmhUtilitiesOnline.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