9a4b93d244c40f8d98a6e1488cdc73c00f121088
[cdmlib.git] / cdmlib-persistence / src / test / java / eu / etaxonomy / cdm / persistence / hibernate / CacheStrategyGeneratorTest.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.persistence.hibernate;
11
12
13 import static org.junit.Assert.assertNotNull;
14
15 import java.util.UUID;
16
17 import org.apache.log4j.Logger;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.unitils.dbunit.annotation.DataSet;
21 import org.unitils.dbunit.annotation.ExpectedDataSet;
22 import org.unitils.spring.annotation.SpringBeanByType;
23
24 import eu.etaxonomy.cdm.model.name.BotanicalName;
25 import eu.etaxonomy.cdm.model.taxon.Taxon;
26 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
27 import eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao;
28 import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
29
30 /**
31 * @author a.mueller
32 * @created 18.03.2009
33 * @version 1.0
34 */
35 public class CacheStrategyGeneratorTest extends CdmIntegrationTest {
36 @SuppressWarnings("unused")
37 private static Logger logger = Logger.getLogger(CacheStrategyGeneratorTest.class);
38
39 private UUID uuid;
40 private TaxonBase cdmBase;
41
42 @SpringBeanByType
43 private ITaxonNameDao cdmEntityDaoBase;
44
45
46 /**
47 * @throws java.lang.Exception
48 */
49 @Before
50 public void setUp() throws Exception {
51 uuid = UUID.fromString("8d77c380-c76a-11dd-ad8b-0800200c9a66");
52 cdmBase = Taxon.NewInstance(null, null);
53 cdmBase.setUuid(UUID.fromString("e463b270-c76b-11dd-ad8b-0800200c9a66"));
54 }
55
56 /**
57 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#CdmEntityDaoBase(java.lang.Class)}.
58 * @throws Exception
59 */
60 @Test
61 public void testCdmEntityDaoBase() throws Exception {
62 assertNotNull("cdmEntityDaoBase should exist",cdmEntityDaoBase);
63 }
64
65 /**
66 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#saveOrUpdate(eu.etaxonomy.cdm.model.common.CdmBase)}.
67 */
68 @Test
69 @DataSet("CacheStrategyGeneratorTest.xml")
70 @ExpectedDataSet
71 public void testOnSaveOrUpdate() {
72 BotanicalName name = (BotanicalName)cdmEntityDaoBase.findByUuid(UUID.fromString("a49a3963-c4ea-4047-8588-2f8f15352730"));;
73 name.setTitleCache(null, false);
74 name.setNameCache(null, false);
75 name.setGenusOrUninomial("Abies");
76 name.setAuthorshipCache("Mill.", true);
77 cdmEntityDaoBase.saveOrUpdate(name);
78 }
79
80
81 }
82
83