Project

General

Profile

Revision 20eb0d2c

ID20eb0d2ccc4b2a6046d8a713792af51b1ae4098c
Parent e5737323
Child de7b09aa

Added by Andreas Müller about 13 years ago

View differences:

.gitattributes
331 331
cdmlib-persistence/src/site/site.xml -text
332 332
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/database/CdmDataSourceTest.java -text
333 333
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/database/DatabaseEnumTest.java -text
334
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/CdmEntityDaoBaseTest.java -text
335
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/CdmEntityDaoBaseTestClass.java -text
336
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/DaoBaseTest.java -text
337
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/DefinedTermDaoImplTest.java -text
338
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/IdentifiableDaoBaseTest.java -text
339
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/taxon/TaxonDaoHibernateImplTest.java -text
334
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBaseTest.java -text
335
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBaseTestClass.java -text
336
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DaoBaseTest.java -text
337
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.java -text
338
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBaseTest.java -text
339
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java -text
340 340
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java -text
341 341
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/TestDatabase.java -text
342 342
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/TestPersistence.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/CdmEntityDaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import java.util.List;
9
import java.util.UUID;
10

  
11
import org.apache.log4j.Logger;
12
import org.junit.After;
13
import org.junit.AfterClass;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Ignore;
17
import org.junit.Test;
18
import org.junit.runner.RunWith;
19
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.stereotype.Repository;
21

  
22
import eu.etaxonomy.cdm.model.common.CdmBase;
23
import eu.etaxonomy.cdm.model.name.BotanicalName;
24
import eu.etaxonomy.cdm.model.name.Rank;
25
import eu.etaxonomy.cdm.model.reference.Journal;
26
import eu.etaxonomy.cdm.model.taxon.Taxon;
27
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
28
import eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl;
29
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
30

  
31
/**
32
 * @author a.mueller
33
 *
34
 */
35
public class CdmEntityDaoBaseTest extends CdmUnitTestBase{
36
	private static final Logger logger = Logger.getLogger(CdmEntityDaoBaseTest.class);
37
	
38

  
39
	
40
	private static UUID taxonUUID;
41
	private static boolean isInitialized;
42
	
43
	@Autowired
44
	private CdmEntityDaoBaseTestClass cdmEntityDaoBase;
45

  
46
	/**
47
	 * @throws java.lang.Exception
48
	 */
49
	@BeforeClass
50
	public static void setUpBeforeClass() throws Exception {
51
		logger.info("setUpBeforeClass");
52
	}
53
	
54

  
55
	/**
56
	 * @throws java.lang.Exception
57
	 */
58
	@AfterClass
59
	public static void tearDownAfterClass() throws Exception {
60
	}
61

  
62
	/**
63
	 * @throws java.lang.Exception
64
	 */
65
	@Before
66
	public void setUp() throws Exception {
67
		logger.debug("setUp");
68
		Rank genus = Rank.GENUS();
69
		BotanicalName botanicalName = BotanicalName.NewInstance(genus);
70
		botanicalName.setGenusOrUninomial("GenusName");
71
		Journal journal = new Journal();
72
		journal.setTitle("JournalTitel");
73
		
74
		Taxon taxon = Taxon.NewInstance(botanicalName, journal);
75
		UUID uuid = cdmEntityDaoBase.saveOrUpdate(taxon);
76
		taxonUUID = UUID.fromString(uuid.toString());
77
		logger.debug("setUpEnd");
78
	}
79

  
80
	/**
81
	 * @throws java.lang.Exception
82
	 */
83
	@After
84
	public void tearDown() throws Exception {
85
	}
86
	
87
/************ TESTS ********************************/
88

  
89

  
90
	/**
91
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#CdmEntityDaoBase(java.lang.Class)}.
92
	 */
93
	//@Test
94
	public void testCdmEntityDaoBase() {
95
		logger.debug("testCdmEntityDaoBase");
96
		assertNotNull(cdmEntityDaoBase);
97
	}
98

  
99
	/**
100
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#saveCdmObj(eu.etaxonomy.cdm.model.common.CdmBase)}.
101
	 */
102
	@Test
103
	public void testSaveCdmObj() {
104
		logger.debug("testSaveCdmObj");
105
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
106
		assertNotNull(cdmBase);
107
	}
108

  
109
	/**
110
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#saveOrUpdate(eu.etaxonomy.cdm.model.common.CdmBase)}.
111
	 */
112
	@Test
113
	public void testSaveOrUpdate() {
114
		logger.debug("testSaveOrUpdate");
115
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
116
		cdmBase.setUuid(UUID.randomUUID());
117
		UUID newUuid = cdmEntityDaoBase.saveOrUpdate(cdmBase);
118
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(newUuid);
119
		assertEquals(cdmBase.getId(), cdmBase2.getId());
120
	}
121

  
122
	/**
123
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#save(eu.etaxonomy.cdm.model.common.CdmBase)}.
124
	 */
125
	@Test
126
	public void testSave() {
127
		logger.debug("testSave");
128
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
129
		UUID newUuid = UUID.randomUUID();
130
		cdmBase.setUuid(newUuid);
131
		cdmEntityDaoBase.save(cdmBase);
132
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(newUuid);
133
		logger.warn("semantic unclear");
134
		//assertFalse(cdmBase.getId() == cdmBase2.getId());
135
	}
136

  
137
	/**
138
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#update(eu.etaxonomy.cdm.model.common.CdmBase)}.
139
	 */
140
	@Test
141
	public void testUpdate() {
142
		logger.debug("testUpdate");
143
		logger.warn("testUpdate - Not yet implemented"); // TODO
144
	}
145

  
146

  
147
	/**
148
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#findById(int)}.
149
	 */
150
	@Test
151
	public void testFindById() {
152
		logger.debug("testFindById");
153
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
154
		CdmBase cdmBase2 = cdmEntityDaoBase.findById(cdmBase.getId());
155
		assertSame(cdmBase, cdmBase2);
156
	}
157

  
158
	/**
159
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#findByUuid(java.util.UUID)}.
160
	 */
161
	@Test
162
	public void testFindByUuid() {
163
		logger.debug("testFindByUuid");
164
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
165
		assertNotNull(cdmBase);
166
	}
167

  
168
	/**
169
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#exists(java.util.UUID)}.
170
	 */
171
	@Test
172
	public void testExists() {
173
		logger.debug("testExists");
174
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
175
		boolean exists = cdmEntityDaoBase.exists(cdmBase.getUuid());
176
		assertTrue(exists);
177
		boolean existsRandom = cdmEntityDaoBase.exists(UUID.randomUUID());
178
		assertFalse(existsRandom);
179
	}
180

  
181
	/**
182
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#list(int, int)}.
183
	 */
184
	@Test
185
	public void testList() {
186
		logger.debug("testList");
187
		List<TaxonBase> list = cdmEntityDaoBase.list(1000, 0);
188
		assertNotNull(list);
189
		assertTrue(list.size()>0);
190
	}
191
	
192
	/**
193
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
194
	 */
195
	@Test
196
	public void testDelete() {
197
		logger.debug("testDelete");
198
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
199
		assertNotNull(cdmBase);
200
		cdmEntityDaoBase.delete(cdmBase);
201
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(taxonUUID);
202
		assertNull(cdmBase2);
203
	}
204

  
205
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/CdmEntityDaoBaseTestClass.java
1
package eu.etaxonomy.cdm.persistence.dao.common;
2

  
3
import org.springframework.stereotype.Repository;
4

  
5
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
6

  
7
@Repository
8
public class  CdmEntityDaoBaseTestClass extends CdmEntityDaoBase {
9
	
10
	public  CdmEntityDaoBaseTestClass() {
11
		super(TaxonBase.class);
12
	}
13

  
14
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/DaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15

  
16
import eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl;
17
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
18

  
19
/**
20
 * @author a.mueller
21
 *
22
 */
23
public class DaoBaseTest  extends CdmUnitTestBase{
24
	private static final Logger logger = Logger.getLogger(DaoBaseTest.class);
25
	
26
	@Autowired
27
	private  TaxonDaoHibernateImpl daoBaseTester;
28
	
29
	/**
30
	 * @throws java.lang.Exception
31
	 */
32
	@BeforeClass
33
	public static void setUpBeforeClass() throws Exception {
34
	}
35

  
36
	/**
37
	 * @throws java.lang.Exception
38
	 */
39
	@AfterClass
40
	public static void tearDownAfterClass() throws Exception {
41
	}
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@Before
47
	public void setUp() throws Exception {
48
	}
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@After
54
	public void tearDown() throws Exception {
55
	}
56
	
57
	
58
/************ TESTS ********************************/
59

  
60
	/**
61
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.DaoBase#getSession()}.
62
	 */
63
	@Test
64
	public void testGetSession() {
65
		assertNotNull(daoBaseTester.getSession());
66
	}
67

  
68
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/DefinedTermDaoImplTest.java
1
package eu.etaxonomy.cdm.persistence.dao.common;
2

  
3

  
4
import static org.junit.Assert.*;
5

  
6
import java.util.List;
7
import java.util.UUID;
8

  
9
import org.apache.log4j.Logger;
10
import org.junit.Test;
11
import org.springframework.beans.factory.annotation.Autowired;
12

  
13
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
14
import eu.etaxonomy.cdm.model.common.Keyword;
15
import eu.etaxonomy.cdm.model.common.TermVocabulary;
16
import eu.etaxonomy.cdm.model.common.WrongTermTypeException;
17
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
18

  
19
public class DefinedTermDaoImplTest extends CdmUnitTestBase{
20
	static Logger logger = Logger.getLogger(DefinedTermDaoImplTest.class);
21

  
22
	@Autowired
23
	private IDefinedTermDao dao;
24

  
25
	@Test
26
	public void save() throws WrongTermTypeException {
27
		TermVocabulary<DefinedTermBase> vocabulary	= new TermVocabulary<DefinedTermBase>("Biological subdomains","biodomain","http://myterms.org/biodomain");
28
		String [] repres = {"genetics","physiology","systematics","taxonomy","nomenclature"};
29
		for (String r : repres){
30
			Keyword term = Keyword.NewInstance(r,r);
31
			vocabulary.addTerm(term);			
32
		}
33
		for (DefinedTermBase dt : vocabulary){
34
			dao.save(dt);
35
		}
36
	}
37

  
38
	@Test
39
	public void findByTitle() {
40
		List<DefinedTermBase> terms = dao.findByTitle("En");
41
		logger.debug("Results: "+terms.size());
42
		for (DefinedTermBase dt:terms){
43
			logger.debug(dt.toString());
44
		}
45
		//fail();
46
		logger.warn("findByTitle - Not yet implemented");
47
		//assertTrue(terms.contains(this.vocabulary));
48
	}
49

  
50
	@Test
51
	public void listOneTerm() {
52
		logger.debug("TEST: List 1 defined term");
53
		List<DefinedTermBase> terms = dao.list(3, 3);
54
		for (DefinedTermBase dt:terms){
55
			logger.debug("Loaded term: "+dt.toString());
56
		}
57
	}
58
	
59
	@Test
60
	public void getTermByUUID() {
61
		String strUuid = "eeaea868-c4c1-497f-b9fe-52c9fc4aca53";
62
		logger.debug("TEST: getTermByUUID " + strUuid);
63
		DefinedTermBase dt = dao.findByUuid(UUID.fromString(strUuid));
64
		//logger.debug("Loaded term: "+dt.toString());
65
	}
66
	
67
	@Test
68
	public void listManyTerms() {
69
		logger.debug("TEST: List 10 defined terms");
70
		List<DefinedTermBase> terms = dao.list(10, 0);
71
		for (DefinedTermBase dt:terms){
72
			logger.debug("Loaded term: "+dt.toString());
73
		}
74
	}
75
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/common/IdentifiableDaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15

  
16
import eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl;
17
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
18

  
19
/**
20
 * @author a.mueller
21
 *
22
 */
23
public class IdentifiableDaoBaseTest extends CdmUnitTestBase {
24
	private static final Logger logger = Logger.getLogger(IdentifiableDaoBaseTest.class);
25
	
26
	@Autowired
27
	private  TaxonDaoHibernateImpl identifiableDaoBaseTester;
28
	
29
	/**
30
	 * @throws java.lang.Exception
31
	 */
32
	@BeforeClass
33
	public static void setUpBeforeClass() throws Exception {
34
	}
35

  
36
	/**
37
	 * @throws java.lang.Exception
38
	 */
39
	@AfterClass
40
	public static void tearDownAfterClass() throws Exception {
41
	}
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@Before
47
	public void setUp() throws Exception {
48
	}
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@After
54
	public void tearDown() throws Exception {
55
	}
56
	
57
/************ TESTS ********************************/
58

  
59

  
60
	/**
61
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.IdentifiableDaoBase#IdentifiableDaoBase(java.lang.Class)}.
62
	 */
63
	@Test
64
	public void testIdentifiableDaoBase() {
65
		logger.warn("testIdentifiableDaoBase - Not yet implemented");
66
	}
67

  
68
	/**
69
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.common.IdentifiableDaoBase#findByTitle(java.lang.String)}.
70
	 */
71
	@Test
72
	public void testFindByTitle() {
73
		logger.warn("testFindByTitle - Not yet implemented");
74
	}
75

  
76
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import java.util.List;
9
import java.util.UUID;
10

  
11
import org.apache.log4j.Logger;
12
import org.junit.After;
13
import org.junit.AfterClass;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Ignore;
17
import org.junit.Test;
18
import org.junit.runner.RunWith;
19
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.stereotype.Repository;
21

  
22
import eu.etaxonomy.cdm.model.common.CdmBase;
23
import eu.etaxonomy.cdm.model.name.BotanicalName;
24
import eu.etaxonomy.cdm.model.name.Rank;
25
import eu.etaxonomy.cdm.model.reference.Journal;
26
import eu.etaxonomy.cdm.model.taxon.Taxon;
27
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
28
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl;
29
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
30

  
31
/**
32
 * @author a.mueller
33
 *
34
 */
35
public class CdmEntityDaoBaseTest extends CdmUnitTestBase{
36
	private static final Logger logger = Logger.getLogger(CdmEntityDaoBaseTest.class);
37
	
38

  
39
	
40
	private static UUID taxonUUID;
41
	private static boolean isInitialized;
42
	
43
	@Autowired
44
	private CdmEntityDaoBaseTestClass cdmEntityDaoBase;
45

  
46
	/**
47
	 * @throws java.lang.Exception
48
	 */
49
	@BeforeClass
50
	public static void setUpBeforeClass() throws Exception {
51
		logger.info("setUpBeforeClass");
52
	}
53
	
54

  
55
	/**
56
	 * @throws java.lang.Exception
57
	 */
58
	@AfterClass
59
	public static void tearDownAfterClass() throws Exception {
60
	}
61

  
62
	/**
63
	 * @throws java.lang.Exception
64
	 */
65
	@Before
66
	public void setUp() throws Exception {
67
		logger.debug("setUp");
68
		Rank genus = Rank.GENUS();
69
		BotanicalName botanicalName = BotanicalName.NewInstance(genus);
70
		botanicalName.setGenusOrUninomial("GenusName");
71
		Journal journal = new Journal();
72
		journal.setTitle("JournalTitel");
73
		
74
		Taxon taxon = Taxon.NewInstance(botanicalName, journal);
75
		UUID uuid = cdmEntityDaoBase.saveOrUpdate(taxon);
76
		taxonUUID = UUID.fromString(uuid.toString());
77
		logger.debug("setUpEnd");
78
	}
79

  
80
	/**
81
	 * @throws java.lang.Exception
82
	 */
83
	@After
84
	public void tearDown() throws Exception {
85
	}
86
	
87
/************ TESTS ********************************/
88

  
89

  
90
	/**
91
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#CdmEntityDaoBase(java.lang.Class)}.
92
	 */
93
	//@Test
94
	public void testCdmEntityDaoBase() {
95
		logger.debug("testCdmEntityDaoBase");
96
		assertNotNull(cdmEntityDaoBase);
97
	}
98

  
99
	/**
100
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#saveCdmObj(eu.etaxonomy.cdm.model.common.CdmBase)}.
101
	 */
102
	@Test
103
	public void testSaveCdmObj() {
104
		logger.debug("testSaveCdmObj");
105
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
106
		assertNotNull(cdmBase);
107
	}
108

  
109
	/**
110
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#saveOrUpdate(eu.etaxonomy.cdm.model.common.CdmBase)}.
111
	 */
112
	@Test
113
	public void testSaveOrUpdate() {
114
		logger.debug("testSaveOrUpdate");
115
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
116
		cdmBase.setUuid(UUID.randomUUID());
117
		UUID newUuid = cdmEntityDaoBase.saveOrUpdate(cdmBase);
118
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(newUuid);
119
		assertEquals(cdmBase.getId(), cdmBase2.getId());
120
	}
121

  
122
	/**
123
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#save(eu.etaxonomy.cdm.model.common.CdmBase)}.
124
	 */
125
	@Test
126
	public void testSave() {
127
		logger.debug("testSave");
128
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
129
		UUID newUuid = UUID.randomUUID();
130
		cdmBase.setUuid(newUuid);
131
		cdmEntityDaoBase.save(cdmBase);
132
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(newUuid);
133
		logger.warn("semantic unclear");
134
		//assertFalse(cdmBase.getId() == cdmBase2.getId());
135
	}
136

  
137
	/**
138
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#update(eu.etaxonomy.cdm.model.common.CdmBase)}.
139
	 */
140
	@Test
141
	public void testUpdate() {
142
		logger.debug("testUpdate");
143
		logger.warn("testUpdate - Not yet implemented"); // TODO
144
	}
145

  
146

  
147
	/**
148
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#findById(int)}.
149
	 */
150
	@Test
151
	public void testFindById() {
152
		logger.debug("testFindById");
153
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
154
		CdmBase cdmBase2 = cdmEntityDaoBase.findById(cdmBase.getId());
155
		assertSame(cdmBase, cdmBase2);
156
	}
157

  
158
	/**
159
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#findByUuid(java.util.UUID)}.
160
	 */
161
	@Test
162
	public void testFindByUuid() {
163
		logger.debug("testFindByUuid");
164
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
165
		assertNotNull(cdmBase);
166
	}
167

  
168
	/**
169
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#exists(java.util.UUID)}.
170
	 */
171
	@Test
172
	public void testExists() {
173
		logger.debug("testExists");
174
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
175
		boolean exists = cdmEntityDaoBase.exists(cdmBase.getUuid());
176
		assertTrue(exists);
177
		boolean existsRandom = cdmEntityDaoBase.exists(UUID.randomUUID());
178
		assertFalse(existsRandom);
179
	}
180

  
181
	/**
182
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#list(int, int)}.
183
	 */
184
	@Test
185
	public void testList() {
186
		logger.debug("testList");
187
		List<TaxonBase> list = cdmEntityDaoBase.list(1000, 0);
188
		assertNotNull(list);
189
		assertTrue(list.size()>0);
190
	}
191
	
192
	/**
193
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
194
	 */
195
	@Test
196
	public void testDelete() {
197
		logger.debug("testDelete");
198
		CdmBase cdmBase = cdmEntityDaoBase.findByUuid(taxonUUID);
199
		assertNotNull(cdmBase);
200
		cdmEntityDaoBase.delete(cdmBase);
201
		CdmBase cdmBase2 = cdmEntityDaoBase.findByUuid(taxonUUID);
202
		assertNull(cdmBase2);
203
	}
204

  
205
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBaseTestClass.java
1
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
2

  
3
import org.springframework.stereotype.Repository;
4

  
5
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
6
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase;
7

  
8
@Repository
9
public class  CdmEntityDaoBaseTestClass extends CdmEntityDaoBase {
10
	
11
	public  CdmEntityDaoBaseTestClass() {
12
		super(TaxonBase.class);
13
	}
14

  
15
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15

  
16
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl;
17
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
18

  
19
/**
20
 * @author a.mueller
21
 *
22
 */
23
public class DaoBaseTest  extends CdmUnitTestBase{
24
	private static final Logger logger = Logger.getLogger(DaoBaseTest.class);
25
	
26
	@Autowired
27
	private  TaxonDaoHibernateImpl daoBaseTester;
28
	
29
	/**
30
	 * @throws java.lang.Exception
31
	 */
32
	@BeforeClass
33
	public static void setUpBeforeClass() throws Exception {
34
	}
35

  
36
	/**
37
	 * @throws java.lang.Exception
38
	 */
39
	@AfterClass
40
	public static void tearDownAfterClass() throws Exception {
41
	}
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@Before
47
	public void setUp() throws Exception {
48
	}
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@After
54
	public void tearDown() throws Exception {
55
	}
56
	
57
	
58
/************ TESTS ********************************/
59

  
60
	/**
61
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase#getSession()}.
62
	 */
63
	@Test
64
	public void testGetSession() {
65
		assertNotNull(daoBaseTester.getSession());
66
	}
67

  
68
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.java
1
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
2

  
3

  
4
import static org.junit.Assert.*;
5

  
6
import java.util.List;
7
import java.util.UUID;
8

  
9
import org.apache.log4j.Logger;
10
import org.junit.Test;
11
import org.springframework.beans.factory.annotation.Autowired;
12

  
13
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
14
import eu.etaxonomy.cdm.model.common.Keyword;
15
import eu.etaxonomy.cdm.model.common.TermVocabulary;
16
import eu.etaxonomy.cdm.model.common.WrongTermTypeException;
17
import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;
18
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
19

  
20
public class DefinedTermDaoImplTest extends CdmUnitTestBase{
21
	static Logger logger = Logger.getLogger(DefinedTermDaoImplTest.class);
22

  
23
	@Autowired
24
	private IDefinedTermDao dao;
25

  
26
	@Test
27
	public void save() throws WrongTermTypeException {
28
		TermVocabulary<DefinedTermBase> vocabulary	= new TermVocabulary<DefinedTermBase>("Biological subdomains","biodomain","http://myterms.org/biodomain");
29
		String [] repres = {"genetics","physiology","systematics","taxonomy","nomenclature"};
30
		for (String r : repres){
31
			Keyword term = Keyword.NewInstance(r,r);
32
			vocabulary.addTerm(term);			
33
		}
34
		for (DefinedTermBase dt : vocabulary){
35
			dao.save(dt);
36
		}
37
	}
38

  
39
	@Test
40
	public void findByTitle() {
41
		List<DefinedTermBase> terms = dao.findByTitle("En");
42
		logger.debug("Results: "+terms.size());
43
		for (DefinedTermBase dt:terms){
44
			logger.debug(dt.toString());
45
		}
46
		//fail();
47
		logger.warn("findByTitle - Not yet implemented");
48
		//assertTrue(terms.contains(this.vocabulary));
49
	}
50

  
51
	@Test
52
	public void listOneTerm() {
53
		logger.debug("TEST: List 1 defined term");
54
		List<DefinedTermBase> terms = dao.list(3, 3);
55
		for (DefinedTermBase dt:terms){
56
			logger.debug("Loaded term: "+dt.toString());
57
		}
58
	}
59
	
60
	@Test
61
	public void getTermByUUID() {
62
		String strUuid = "eeaea868-c4c1-497f-b9fe-52c9fc4aca53";
63
		logger.debug("TEST: getTermByUUID " + strUuid);
64
		DefinedTermBase dt = dao.findByUuid(UUID.fromString(strUuid));
65
		//logger.debug("Loaded term: "+dt.toString());
66
	}
67
	
68
	@Test
69
	public void listManyTerms() {
70
		logger.debug("TEST: List 10 defined terms");
71
		List<DefinedTermBase> terms = dao.list(10, 0);
72
		for (DefinedTermBase dt:terms){
73
			logger.debug("Loaded term: "+dt.toString());
74
		}
75
	}
76
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBaseTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15

  
16
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl;
17
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
18

  
19
/**
20
 * @author a.mueller
21
 *
22
 */
23
public class IdentifiableDaoBaseTest extends CdmUnitTestBase {
24
	private static final Logger logger = Logger.getLogger(IdentifiableDaoBaseTest.class);
25
	
26
	@Autowired
27
	private  TaxonDaoHibernateImpl identifiableDaoBaseTester;
28
	
29
	/**
30
	 * @throws java.lang.Exception
31
	 */
32
	@BeforeClass
33
	public static void setUpBeforeClass() throws Exception {
34
	}
35

  
36
	/**
37
	 * @throws java.lang.Exception
38
	 */
39
	@AfterClass
40
	public static void tearDownAfterClass() throws Exception {
41
	}
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@Before
47
	public void setUp() throws Exception {
48
	}
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@After
54
	public void tearDown() throws Exception {
55
	}
56
	
57
/************ TESTS ********************************/
58

  
59

  
60
	/**
61
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase#IdentifiableDaoBase(java.lang.Class)}.
62
	 */
63
	@Test
64
	public void testIdentifiableDaoBase() {
65
		logger.warn("testIdentifiableDaoBase - Not yet implemented");
66
	}
67

  
68
	/**
69
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase#findByTitle(java.lang.String)}.
70
	 */
71
	@Test
72
	public void testFindByTitle() {
73
		logger.warn("testFindByTitle - Not yet implemented");
74
	}
75

  
76
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.test.context.transaction.TransactionConfiguration;
16

  
17
import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBaseTest;
20
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl;
21
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
22

  
23
/**
24
 * @author a.mueller
25
 *
26
 */
27
@TransactionConfiguration(defaultRollback=false)
28
public class TaxonDaoHibernateImplTest extends CdmUnitTestBase {
29
	private static final Logger logger = Logger.getLogger(TaxonDaoHibernateImplTest.class);
30
	
31
	@Autowired
32
	private  TaxonDaoHibernateImpl taxonDao;
33
	private static TaxonGenerator taxGen;
34
	
35
	/**
36
	 * @throws java.lang.Exception
37
	 */
38
	@BeforeClass
39
	public static void setUpBeforeClass() throws Exception {
40
		taxGen = new TaxonGenerator();
41
	}
42

  
43
	/**
44
	 * @throws java.lang.Exception
45
	 */
46
	@AfterClass
47
	public static void tearDownAfterClass() throws Exception {
48
	}
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@Before
54
	public void setUp() throws Exception {
55
	}
56

  
57
	/**
58
	 * @throws java.lang.Exception
59
	 */
60
	@After
61
	public void tearDown() throws Exception {
62
	}
63
	
64
/************ TESTS ********************************/
65

  
66

  
67
	/**
68
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#TaxonDaoHibernateImpl()}.
69
	 */
70
	@Test
71
	public void testTaxonDaoHibernateImpl() {
72
		logger.warn("testTaxonDaoHibernateImpl - Not yet implemented"); // TODO
73
	}
74

  
75
	/**
76
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#getRootTaxa(eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
77
	 */
78
	@Test
79
	public void testGetRootTaxa() {
80
		//taxonDao.getRootTaxa(null);
81
	}
82

  
83
	/**
84
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#getTaxaByName(java.lang.String, eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
85
	 */
86
	@Test
87
	public void testGetTaxaByName() {
88
		//taxonDaoHibernateImplTester.getTaxaByName();
89
		logger.warn("testGetTaxaByName - Not yet implemented");//TODO
90
	}
91

  
92
	@Test
93
	public void testSaveTaxon() {
94
		Taxon t = taxGen.getTestTaxon();
95
		taxonDao.save(t);
96
	}
97
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/taxon/TaxonDaoHibernateImplTest.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.persistence.dao.taxon;
5

  
6
import static org.junit.Assert.*;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.After;
10
import org.junit.AfterClass;
11
import org.junit.Before;
12
import org.junit.BeforeClass;
13
import org.junit.Test;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.test.context.transaction.TransactionConfiguration;
16

  
17
import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.cdm.persistence.dao.common.IdentifiableDaoBaseTest;
20
import eu.etaxonomy.cdm.test.unit.CdmUnitTestBase;
21

  
22
/**
23
 * @author a.mueller
24
 *
25
 */
26
@TransactionConfiguration(defaultRollback=false)
27
public class TaxonDaoHibernateImplTest extends CdmUnitTestBase {
28
	private static final Logger logger = Logger.getLogger(TaxonDaoHibernateImplTest.class);
29
	
30
	@Autowired
31
	private  TaxonDaoHibernateImpl taxonDao;
32
	private static TaxonGenerator taxGen;
33
	
34
	/**
35
	 * @throws java.lang.Exception
36
	 */
37
	@BeforeClass
38
	public static void setUpBeforeClass() throws Exception {
39
		taxGen = new TaxonGenerator();
40
	}
41

  
42
	/**
43
	 * @throws java.lang.Exception
44
	 */
45
	@AfterClass
46
	public static void tearDownAfterClass() throws Exception {
47
	}
48

  
49
	/**
50
	 * @throws java.lang.Exception
51
	 */
52
	@Before
53
	public void setUp() throws Exception {
54
	}
55

  
56
	/**
57
	 * @throws java.lang.Exception
58
	 */
59
	@After
60
	public void tearDown() throws Exception {
61
	}
62
	
63
/************ TESTS ********************************/
64

  
65

  
66
	/**
67
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl#TaxonDaoHibernateImpl()}.
68
	 */
69
	@Test
70
	public void testTaxonDaoHibernateImpl() {
71
		logger.warn("testTaxonDaoHibernateImpl - Not yet implemented"); // TODO
72
	}
73

  
74
	/**
75
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl#getRootTaxa(eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
76
	 */
77
	@Test
78
	public void testGetRootTaxa() {
79
		//taxonDao.getRootTaxa(null);
80
	}
81

  
82
	/**
83
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImpl#getTaxaByName(java.lang.String, eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
84
	 */
85
	@Test
86
	public void testGetTaxaByName() {
87
		//taxonDaoHibernateImplTester.getTaxaByName();
88
		logger.warn("testGetTaxaByName - Not yet implemented");//TODO
89
	}
90

  
91
	@Test
92
	public void testSaveTaxon() {
93
		Taxon t = taxGen.getTestTaxon();
94
		taxonDao.save(t);
95
	}
96
}
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/suite/CdmTestSuite.java
6 6

  
7 7
import eu.etaxonomy.cdm.database.CdmDataSourceTest;
8 8
import eu.etaxonomy.cdm.database.DatabaseEnumTest;
9
import eu.etaxonomy.cdm.persistence.dao.common.CdmEntityDaoBaseTest;
10
import eu.etaxonomy.cdm.persistence.dao.common.DaoBaseTest;
11
import eu.etaxonomy.cdm.persistence.dao.common.DefinedTermDaoImplTest;
12
import eu.etaxonomy.cdm.persistence.dao.common.IdentifiableDaoBaseTest;
13
import eu.etaxonomy.cdm.persistence.dao.taxon.TaxonDaoHibernateImplTest;
9
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBaseTest;
10
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBaseTest;
11
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.DefinedTermDaoImplTest;
12
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBaseTest;
13
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImplTest;
14 14

  
15 15

  
16 16
@RunWith(Suite.class)

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)