diff --git a/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java b/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java index 2d367249077..2af2c53e39a 100644 --- a/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java +++ b/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java @@ -22,7 +22,6 @@ import javax.persistence.Query; import org.apache.commons.lang3.tuple.Pair; -import org.dbunit.dataset.DataSetException; import org.joda.time.LocalDateTime; import org.junit.AfterClass; import org.junit.Before; @@ -119,7 +118,7 @@ public void testFindAll() { @Test @Rollback(true) @Transactional(propagation = Propagation.REQUIRES_NEW) - public void testInsert() throws DataSetException { + public void testInsert() { String newOrcid = "4444-1111-6666-4441"; ProfileEntity profile = new ProfileEntity(); profile.setId(newOrcid); @@ -144,7 +143,7 @@ public void testInsert() throws DataSetException { @Test @Rollback(true) @Transactional(propagation = Propagation.REQUIRES_NEW) - public void testInsertWithPrimaryInstitutions() throws DataSetException { + public void testInsertWithPrimaryInstitutions() { String newOrcid = "4444-1111-6666-4442"; ProfileEntity profile = new ProfileEntity(); profile.setId(newOrcid); @@ -168,7 +167,7 @@ public void testInsertWithPrimaryInstitutions() throws DataSetException { @Test @Rollback(true) @Transactional(propagation = Propagation.REQUIRES_NEW) - public void testInsertWithInstitutionDepartments() throws DataSetException { + public void testInsertWithInstitutionDepartments() { String newOrcid = "4444-1111-6666-4443"; ProfileEntity profile = new ProfileEntity(); profile.setId(newOrcid); diff --git a/orcid-test/src/main/java/org/orcid/test/CustomDataTypeFactory.java b/orcid-test/src/main/java/org/orcid/test/CustomDataTypeFactory.java index cc95e9abad4..55388a49ed5 100644 --- a/orcid-test/src/main/java/org/orcid/test/CustomDataTypeFactory.java +++ b/orcid-test/src/main/java/org/orcid/test/CustomDataTypeFactory.java @@ -12,11 +12,14 @@ public class CustomDataTypeFactory extends HsqldbDataTypeFactory { private static final JsonDatatype JSON_DATATYPE = new JsonDatatype(); + private static final TimestampWithTimezoneDataType TIMESTAMP_WITH_TIMEZONE_DATATYPE = new TimestampWithTimezoneDataType(); @Override public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException { if ("json".equals(sqlTypeName)) { return JSON_DATATYPE; + } else if ("TIMESTAMP WITH TIME ZONE".equals(sqlTypeName)) { + return TIMESTAMP_WITH_TIMEZONE_DATATYPE; } DataType dt = super.createDataType(sqlType, sqlTypeName); return dt; diff --git a/orcid-test/src/main/java/org/orcid/test/DBUnitTest.java b/orcid-test/src/main/java/org/orcid/test/DBUnitTest.java index f75946beb70..a5ad0da5ed0 100644 --- a/orcid-test/src/main/java/org/orcid/test/DBUnitTest.java +++ b/orcid-test/src/main/java/org/orcid/test/DBUnitTest.java @@ -60,6 +60,7 @@ public static void initDBUnitData(List flatXMLDataFiles) throws Exceptio cleanClientSourcedProfiles(connection); cleanAll(connection); for (String flatXMLDataFile : flatXMLDataFiles) { + System.out.println(flatXMLDataFile); DatabaseOperation.INSERT.execute(connection, getDataSet(flatXMLDataFile)); } connection.close(); @@ -144,8 +145,8 @@ private static void cleanClientSourcedProfiles(IDatabaseConnection connection) t dataSet.addTable("research_resource"); dataSet.addTable("find_my_stuff_history"); dataSet.addTable("spam"); - DatabaseOperation.DELETE.execute(connection, dataSet); - + DatabaseOperation.DELETE.execute(connection, dataSet); + QueryDataSet theRest = new QueryDataSet(connection); theRest.addTable("profile", "SELECT * FROM profile WHERE source_id IS NOT NULL AND source_id != orcid ORDER BY orcid DESC"); theRest.addTable("client_details"); diff --git a/orcid-test/src/main/java/org/orcid/test/TimestampWithTimezoneDataType.java b/orcid-test/src/main/java/org/orcid/test/TimestampWithTimezoneDataType.java new file mode 100644 index 00000000000..fe594d055b8 --- /dev/null +++ b/orcid-test/src/main/java/org/orcid/test/TimestampWithTimezoneDataType.java @@ -0,0 +1,29 @@ +package org.orcid.test; + +import java.sql.Timestamp; +import java.sql.Types; + +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.datatype.AbstractDataType; +import org.dbunit.dataset.datatype.TypeCastException; + +public class TimestampWithTimezoneDataType extends AbstractDataType { + + public TimestampWithTimezoneDataType(String name, int sqlType, Class classType, boolean isNumber) { + super(name, sqlType, classType, isNumber); + } + + public TimestampWithTimezoneDataType() { + super("TIMESTAMP WITH TIME ZONE", Types.TIMESTAMP_WITH_TIMEZONE, String.class, false); + } + + @Override + public Object typeCast(Object value) throws TypeCastException { + if (value == null || value == ITable.NO_VALUE) { + return null; + } + System.out.println((String) value); + return Timestamp.valueOf((String) value); + } + +} diff --git a/orcid-test/src/main/resources/data/ClientDetailsEntityData.xml b/orcid-test/src/main/resources/data/ClientDetailsEntityData.xml index e3de41d55ce..64fd1665541 100644 --- a/orcid-test/src/main/resources/data/ClientDetailsEntityData.xml +++ b/orcid-test/src/main/resources/data/ClientDetailsEntityData.xml @@ -1,14 +1,14 @@ - - - - - - - - + + + + + + + + @@ -104,14 +104,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/orcid-test/src/main/resources/data/PremiumInstitutionMemberData.xml b/orcid-test/src/main/resources/data/PremiumInstitutionMemberData.xml index ae94a5cf14e..f7617690b19 100644 --- a/orcid-test/src/main/resources/data/PremiumInstitutionMemberData.xml +++ b/orcid-test/src/main/resources/data/PremiumInstitutionMemberData.xml @@ -41,9 +41,9 @@ source_id="5555-5555-5555-0000" /> - - - + + + @@ -124,7 +124,7 @@ - - - + + + \ No newline at end of file diff --git a/orcid-test/src/main/resources/data/SourceClientDetailsEntityData.xml b/orcid-test/src/main/resources/data/SourceClientDetailsEntityData.xml index c81b363a5d1..98d22822cde 100644 --- a/orcid-test/src/main/resources/data/SourceClientDetailsEntityData.xml +++ b/orcid-test/src/main/resources/data/SourceClientDetailsEntityData.xml @@ -46,10 +46,10 @@ source_id="5555-5555-5555-5558" /> - - - - + + + + @@ -152,15 +152,15 @@ - - + + - - - + + + - - + + diff --git a/pom.xml b/pom.xml index c1077dac8a1..2fea181de30 100644 --- a/pom.xml +++ b/pom.xml @@ -876,7 +876,7 @@ the software. org.hsqldb hsqldb - 2.3.1 + 2.7.1 test