private UUID taxonomicallyIncludedInUuid;\r
\r
@Before\r
- public void setUp() {\r
- taxonomicallyIncludedInUuid = UUID.fromString("d13fecdf-eb44-4dd7-9244-26679c05df1c");\r
+ public void setUp() {\r
+ taxonomicallyIncludedInUuid = UUID.fromString("d13fecdf-eb44-4dd7-9244-26679c05df1c");\r
}\r
\r
// @Test uncomment for creating datasets\r
- public void testPrintDataSet() {\r
- try {\r
- ExcludeTableFilter filter = new ExcludeTableFilter();\r
- filter.excludeTable("Rights"); //throws exception wiht H2\r
- printDataSetWithNull(new FileOutputStream("NewDataSet.xml"), filter);\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
+ public void testPrintDataSet() {\r
+ try {\r
+ ExcludeTableFilter filter = new ExcludeTableFilter();\r
+ filter.excludeTable("Rights"); //throws exception wiht H2\r
+ printDataSetWithNull(new FileOutputStream("NewDataSet.xml"), null, filter);\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
\r
- @Test\r
- public void testInit() {\r
- assertNotNull("TermInitializer should have initialized Language.DEFAULT",Language.DEFAULT());\r
- assertEquals("Language.DEFAULT should equal Language.ENGLISH",Language.DEFAULT(),Language.ENGLISH());\r
- }\r
+ @Test\r
+ public void testInit() {\r
+ assertNotNull("TermInitializer should have initialized Language.DEFAULT",Language.DEFAULT());\r
+ assertEquals("Language.DEFAULT should equal Language.ENGLISH",Language.DEFAULT(),Language.ENGLISH());\r
+ }\r
\r
- @Test\r
- public void testMarkerTypeIds() {\r
- assertEquals("We expect MarkerType.TO_BE_CHECKED to have an id of 893",893,MarkerType.TO_BE_CHECKED().getId());\r
- }\r
+ @Test\r
+ public void testMarkerTypeIds() {\r
+ assertEquals("We expect MarkerType.TO_BE_CHECKED to have an id of 893",893,MarkerType.TO_BE_CHECKED().getId());\r
+ }\r
\r
- @Test\r
- public void testFeatureIds() {\r
- assertEquals("We expect Feature.ECOLOGY to have an id of 922",922,Feature.ECOLOGY().getId());\r
- }\r
+ @Test\r
+ public void testFeatureIds() {\r
+ assertEquals("We expect Feature.ECOLOGY to have an id of 922",922,Feature.ECOLOGY().getId());\r
+ }\r
\r
- /**\r
- * Test method for {@link eu.etaxonomy.cdm.model.taxon.ConceptRelationshipType#TAXONOMICALLY_INCLUDED_IN()}.\r
- */\r
- @Test\r
- public final void testTermsAreLoaded() {\r
- assertNotNull("TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN should have been initialized",TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN());\r
- assertEquals("TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN should have a uuid of " + taxonomicallyIncludedInUuid.toString(),taxonomicallyIncludedInUuid, TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN().getUuid());\r
- assertNotNull("SynonymRelationshipType.INFERREDEPITHET should be loaded" + SynonymRelationshipType.INFERRED_EPITHET_OF());\r
- }\r
+ /**\r
+ * Test method for {@link eu.etaxonomy.cdm.model.taxon.ConceptRelationshipType#TAXONOMICALLY_INCLUDED_IN()}.\r
+ */\r
+ @Test\r
+ public final void testTermsAreLoaded() {\r
+ assertNotNull("TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN should have been initialized",TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN());\r
+ assertEquals("TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN should have a uuid of " + taxonomicallyIncludedInUuid.toString(),taxonomicallyIncludedInUuid, TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN().getUuid());\r
+ assertNotNull("SynonymRelationshipType.INFERREDEPITHET should be loaded" + SynonymRelationshipType.INFERRED_EPITHET_OF());\r
+ }\r
\r
- @Test\r
- public void testUnlazyStatusTerms() {\r
- assertNotNull("NomenclaturalStatusType.SUPERFLUOUS should exist",NomenclaturalStatusType.SUPERFLUOUS());\r
- assertNotNull("NomenclaturalStatusType.NUDUM should exist",NomenclaturalStatusType.NUDUM());\r
- assertNotNull("NomenclaturalStatusType.ILLEGITIMATE should exist",NomenclaturalStatusType.ILLEGITIMATE());\r
- assertNotNull("NomenclaturalStatusType.INVALID should exist",NomenclaturalStatusType.INVALID());\r
- assertNotNull("NomenclaturalStatusType.CONSERVED should exist",NomenclaturalStatusType.CONSERVED());\r
- assertNotNull("NomenclaturalStatusType.ALTERNATIVE should exist",NomenclaturalStatusType.ALTERNATIVE());\r
- assertNotNull("NomenclaturalStatusType.REJECTED should exist",NomenclaturalStatusType.REJECTED());\r
- assertNotNull("NomenclaturalStatusType.REJECTED_PROP should exist",NomenclaturalStatusType.REJECTED_PROP());\r
- assertNotNull("NomenclaturalStatusType.PROVISIONAL should exist",NomenclaturalStatusType.PROVISIONAL());\r
- assertNotNull("NomenclaturalStatusType.SUBNUDUM should exist",NomenclaturalStatusType.SUBNUDUM());\r
- assertNotNull("NomenclaturalStatusType.OPUS_UTIQUE_OPPR should exist",NomenclaturalStatusType.OPUS_UTIQUE_OPPR());\r
- assertNotNull("NomenclaturalStatusType.VALID should exist",NomenclaturalStatusType.VALID());\r
- }\r
+ @Test\r
+ public void testUnlazyStatusTerms() {\r
+ assertNotNull("NomenclaturalStatusType.SUPERFLUOUS should exist",NomenclaturalStatusType.SUPERFLUOUS());\r
+ assertNotNull("NomenclaturalStatusType.NUDUM should exist",NomenclaturalStatusType.NUDUM());\r
+ assertNotNull("NomenclaturalStatusType.ILLEGITIMATE should exist",NomenclaturalStatusType.ILLEGITIMATE());\r
+ assertNotNull("NomenclaturalStatusType.INVALID should exist",NomenclaturalStatusType.INVALID());\r
+ assertNotNull("NomenclaturalStatusType.CONSERVED should exist",NomenclaturalStatusType.CONSERVED());\r
+ assertNotNull("NomenclaturalStatusType.ALTERNATIVE should exist",NomenclaturalStatusType.ALTERNATIVE());\r
+ assertNotNull("NomenclaturalStatusType.REJECTED should exist",NomenclaturalStatusType.REJECTED());\r
+ assertNotNull("NomenclaturalStatusType.REJECTED_PROP should exist",NomenclaturalStatusType.REJECTED_PROP());\r
+ assertNotNull("NomenclaturalStatusType.PROVISIONAL should exist",NomenclaturalStatusType.PROVISIONAL());\r
+ assertNotNull("NomenclaturalStatusType.SUBNUDUM should exist",NomenclaturalStatusType.SUBNUDUM());\r
+ assertNotNull("NomenclaturalStatusType.OPUS_UTIQUE_OPPR should exist",NomenclaturalStatusType.OPUS_UTIQUE_OPPR());\r
+ assertNotNull("NomenclaturalStatusType.VALID should exist",NomenclaturalStatusType.VALID());\r
+ }\r
}\r
import java.net.URISyntaxException;\r
import java.net.URL;\r
import java.sql.SQLException;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collections;\r
import java.util.List;\r
\r
import javax.sql.DataSource;\r
import org.unitils.spring.annotation.SpringBean;\r
import org.unitils.spring.annotation.SpringBeanByType;\r
\r
+import eu.etaxonomy.cdm.database.PersistentTermInitializer;\r
import eu.etaxonomy.cdm.model.agent.AgentBase;\r
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao;\r
import eu.etaxonomy.cdm.persistence.dao.hibernate.agent.AgentDaoImpl;\r
*/\r
@SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")\r
public abstract class CdmIntegrationTest extends UnitilsJUnit4 {\r
+\r
protected static final Logger logger = Logger.getLogger(CdmIntegrationTest.class);\r
\r
+ /**\r
+ * List of the tables which are initially being populated during term loading. {@link PersistentTermInitializer}\r
+ */\r
+ public static final String[] termLoadingTables = new String[]{\r
+ "DEFINEDTERMBASE",\r
+ "DEFINEDTERMBASE_AUD",\r
+ "DEFINEDTERMBASE_CONTINENT",\r
+ "DEFINEDTERMBASE_REPRESENTATION",\r
+ "DEFINEDTERMBASE_REPRESENTATION_AUD",\r
+ "HIBERNATE_SEQUENCES",\r
+ "RELATIONSHIPTERMBASE_INVERSEREPRESENTATION",\r
+ "RELATIONSHIPTERMBASE_INVERSEREPRESENTATION_AUD",\r
+ "REPRESENTATION",\r
+ "REPRESENTATION_AUD",\r
+ "TERMVOCABULARY",\r
+ "TERMVOCABULARY_AUD",\r
+ "TERMVOCABULARY_REPRESENTATION",\r
+ "TERMVOCABULARY_REPRESENTATION_AUD"};\r
+\r
// @SpringBeanByType\r
// private IAgentDao agentDao;\r
//\r
\r
/**\r
* Prints the data set to an output stream, using the\r
- * {@link FlatFullXmlWriter}.\r
+ * {@link FlatXmlDataSet}.\r
* <p>\r
* <h2>NOTE: for compatibility with unitils 3.x you may\r
* want to use the {@link #printDataSetWithNull(OutputStream)}\r
* @see FlatFullXmlWriter\r
*/\r
public void printDataSetWithNull(OutputStream out) {\r
- printDataSetWithNull(out, null);\r
+ printDataSetWithNull(out, null, null);\r
}\r
- \r
- public void printDataSetWithNull(OutputStream out, ITableFilterSimple filter) {\r
+\r
+ public void printDataSetWithNull(OutputStream out, Boolean excludeTermLoadingTables, ITableFilterSimple filter) {\r
+\r
+ if(excludeTermLoadingTables != null && excludeTermLoadingTables.equals(true)){\r
+ ExcludeTableFilter excludeTableFilter = new ExcludeTableFilter();\r
+\r
+ for(String tname : termLoadingTables){\r
+ excludeTableFilter.excludeTable(tname);\r
+ }\r
+ filter = excludeTableFilter;\r
+ }\r
+\r
if (filter == null){\r
- filter = new ExcludeTableFilter();\r
+ filter = new ExcludeTableFilter();\r
}\r
- IDatabaseConnection connection = null;\r
- \r
- \r
+\r
+ IDatabaseConnection connection = null;\r
try {\r
connection = getConnection();\r
-\r
-// IDataSet dataSet = connection.createDataSet();\r
DatabaseDataSet dataSet = new DatabaseDataSet(connection, false, filter);\r
\r
FlatFullXmlWriter writer = new FlatFullXmlWriter(out);\r
IDataSet actualDataSet = connection.createDataSet(tableNames);\r
FlatXmlDataSet.write(actualDataSet, out);\r
\r
- \r
+\r
} catch (Exception e) {\r
logger.error(e);\r
} finally {\r
*/\r
public void printDataSet(OutputStream out, ITableFilterSimple filter) {\r
if (filter == null){\r
- filter = new ExcludeTableFilter();\r
+ filter = new ExcludeTableFilter();\r
}\r
- \r
- IDatabaseConnection connection = null;\r
+\r
+ IDatabaseConnection connection = null;\r
\r
try {\r
connection = getConnection();\r
\r
FlatXmlWriter writer = new FlatXmlWriter(out);\r
writer.write(dataSet);\r
- \r
+\r
} catch (Exception e) {\r
logger.error(e);\r
} finally {\r
}\r
}\r
\r
- \r
+\r
/**\r
* Prints a dtd to an output stream, using dbunit's\r
* {@link org.dbunit.dataset.xml.FlatDtdDataSet}.\r
* @param classPathResourceName
* @param fileSystemDirectoryName
* @return
+ * @throws IOException
*/
- public File copyClassPathResource(URL resourceURL, String fileSystemDirectoryName) {
+ public File copyClassPathResource(URL resourceURL, String fileSystemDirectoryName) throws IOException {
InputStream resourceInputStream = null;
OutputStream fileOutputStream = null;
fileOutputStream = new FileOutputStream(filePath);
IOUtils.copy(resourceInputStream, fileOutputStream);
file = new File(filePath);
+ if(!file.canRead()){
+ throw new IOException("tmp file " + file.toString() + " not readable.");
+ }
} catch (IOException e) {
- throw new UnitilsException(e);
+ throw e;
} finally {
closeQuietly(resourceInputStream);
closeQuietly(fileOutputStream);
<RELATIONSHIPTERMBASE_INVERSEREPRESENTATION />\r
<RELATIONSHIPTERMBASE_INVERSEREPRESENTATION_AUD />\r
<REPRESENTATION />\r
+<REPRESENTATION_AUD />\r
<REPRESENTATION_ANNOTATION />\r
<REPRESENTATION_ANNOTATION_AUD />\r
-<REPRESENTATION_AUD />\r
<REPRESENTATION_MARKER />\r
<REPRESENTATION_MARKER_AUD />\r
<RIGHTS/>\r
public void testDeleteTaxonNameBaseWithNameRelations() {\r
final String[] tableNames = new String[]{"TaxonNameBase","NameRelationship","HybridRelationship","DescriptionBase","NomenclaturalStatus","TaxonBase","SpecimenOrObservationBase","OriginalSourceBase","DescriptionElementBase"};\r
\r
+ printDataSet(System.err, new String[]{"TaxonNameBase","NameRelationship","HybridRelationship","DescriptionBase","NomenclaturalStatus","TaxonBase","SpecimenOrObservationBase","OriginalSourceBase","DescriptionElementBase","USERACCOUNT","USERACCOUNT_PERMISSIONGROUP", "USERACCOUNT_GRANTEDAUTHORITYIMPL", "GRANTEDAUTHORITYIMPL"});\r
+\r
NonViralName<?> name1 = BotanicalName.NewInstance(getSpeciesRank());\r
name1.setTitleCache("Name1", true);\r
TaxonNameBase<?,?> nameWithBasionym = BotanicalName.NewInstance(getSpeciesRank());\r
public void testDeleteTaxonNameBaseConfiguratorWithNameRelations() {\r
final String[] tableNames = new String[]{"TaxonNameBase","NameRelationship","HybridRelationship"};\r
\r
+// printDataSet(System.err, new String[]{"TaxonNameBase","NameRelationship","HybridRelationship","DescriptionBase","NomenclaturalStatus","TaxonBase","SpecimenOrObservationBase","OriginalSourceBase",\r
+// "DescriptionElementBase",\r
+// "AGENTBASE", "USERACCOUNT", "PERMISSIONGROUP", "USERACCOUNT_PERMISSIONGROUP", "USERACCOUNT_GRANTEDAUTHORITYIMPL", "GRANTEDAUTHORITYIMPL"});\r
+\r
+ printDataSetWithNull(System.err, true, null);\r
+\r
NonViralName<?> name1 = BotanicalName.NewInstance(getSpeciesRank());\r
name1.setTitleCache("Name1", true);\r
TaxonNameBase<?,?> nameWithBasionym = BotanicalName.NewInstance(getSpeciesRank());\r
\r
<TYPEDESIGNATIONBASE DTYPE="SpecimenTypeDesignation" ID="10" CREATED="2011-10-06 12:10:14.0" UUID="9bbda70b-7272-4e65-a807-852a3f2eba63" NOTDESIGNATED="false" TYPESPECIMEN_ID="10" CONSERVEDTYPE="[null]" REJECTEDTYPE="[null]" TYPENAME_ID="[null]"/>\r
<TYPEDESIGNATIONBASE DTYPE="SpecimenTypeDesignation" ID="11" CREATED="2011-10-06 12:10:14.0" UUID="1357c307-00c3-499c-8e20-0849d4706125" NOTDESIGNATED="false" TYPESPECIMEN_ID="11" CONSERVEDTYPE="[null]" REJECTEDTYPE="[null]" TYPENAME_ID="[null]"/>\r
- <TYPEDESIGNATIONBASE DTYPE="NameTypeDesignation" ID="12" CREATED="2011-10-06 12:10:14.0" UUID="0b67b4e1-3183-4272-ace8-7b533f2cc2e5" NOTDESIGNATED="false" TYPESPECIMEN_ID="[null]" CONSERVEDTYPE="false" REJECTEDTYPE="false" TYPENAME_ID="10"/>\r
+ <TYPEDESIGNATIONBASE DTYPE="NameTypeDesignation" ID="12" CREATED="2011-10-06 12:10:14.0" UUID="0b67b4e1-3183-4272-ace8-7b533f2cc2e5" NOTDESIGNATED="false" TYPESPECIMEN_ID="[null]" CONSERVEDTYPE="false" REJECTEDTYPE="false" TYPENAME_ID="10"/>\r
\r
<TAXONNAMEBASE_TYPEDESIGNATIONBASE TYPEDESIGNATIONS_ID="10" TAXONNAMEBASE_ID="10"/>\r
<TAXONNAMEBASE_TYPEDESIGNATIONBASE TYPEDESIGNATIONS_ID="11" TAXONNAMEBASE_ID="10"/>\r
<TAXONNAMEBASE_TYPEDESIGNATIONBASE TYPEDESIGNATIONS_ID="11" TAXONNAMEBASE_ID="11"/>\r
<TAXONNAMEBASE_TYPEDESIGNATIONBASE TYPEDESIGNATIONS_ID="12" TAXONNAMEBASE_ID="12"/>\r
+\r
<SPECIMENOROBSERVATIONBASE DTYPE="Fossil" ID="10" CREATED="2011-10-06 12:10:14.0" UUID="4c48b7c8-4c8d-4e48-b083-0837fe51a0a9" PROTECTEDTITLECACHE="false" TITLECACHE="-title cache generation not implemented-"/>\r
<SPECIMENOROBSERVATIONBASE DTYPE="Specimen" ID="11" CREATED="2011-10-06 12:10:14.0" UUID="0d19a9ca-21a7-4adb-8640-8d6719e15eea" PROTECTEDTITLECACHE="false" TITLECACHE="-title cache generation not implemented-"/>\r
+\r
<HOMOTYPICALGROUP ID="1" CREATED="2011-10-12 19:57:31.0" UUID="d8652fa0-eff9-460d-8990-aed0ebf1322e"/>\r
<HOMOTYPICALGROUP ID="2" CREATED="2011-10-12 19:57:31.0" UUID="2a1b0776-b4b5-462a-9be7-f88378ebd732"/>\r
<HOMOTYPICALGROUP ID="3" CREATED="2011-10-12 19:57:31.0" UUID="3ac4e376-31cd-47fd-9dd6-eaff415ff0e7"/>\r