Project

General

Profile

Download (4.8 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.dao.hibernate.taxon;
11

    
12
import static org.junit.Assert.assertNotNull;
13

    
14
import java.io.FileNotFoundException;
15
import java.util.UUID;
16

    
17
import org.junit.After;
18
import org.junit.Before;
19
import org.junit.Test;
20
import org.unitils.dbunit.annotation.DataSet;
21
import org.unitils.spring.annotation.SpringBeanByType;
22

    
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.cdm.model.view.AuditEvent;
25
import eu.etaxonomy.cdm.model.view.context.AuditEventContextHolder;
26
import eu.etaxonomy.cdm.persistence.dao.reference.IReferenceDao;
27
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
28
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
29
import eu.etaxonomy.cdm.persistence.dao.term.IDefinedTermDao;
30
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
31

    
32
/**
33
 * @author a.mueller
34
 * @author ben.clark
35
 *
36
 */
37
public class TaxonDaoHibernateImplBenchmark extends CdmTransactionalIntegrationTest {
38

    
39
//    @Rule
40
//    public MethodRule benchmarkRun = new BenchmarkRule();
41

    
42
    @SpringBeanByType
43
    private ITaxonDao taxonDao;
44

    
45
    @SpringBeanByType
46
    private IClassificationDao classificationDao;
47

    
48
    @SpringBeanByType
49
    private IReferenceDao referenceDao;
50

    
51
    @SpringBeanByType
52
    IDefinedTermDao definedTermDao;
53

    
54
    private UUID uuid;
55
    private UUID sphingidae;
56
    private UUID acherontia;
57
    private UUID mimas;
58
    private UUID rethera;
59
    private UUID retheraSecCdmtest;
60
    private UUID atroposAgassiz;
61
    private UUID atroposLeach;
62
    private UUID acherontiaLachesis;
63
    private AuditEvent previousAuditEvent;
64
    private AuditEvent mostRecentAuditEvent;
65

    
66
    private UUID northernAmericaUuid;
67
    private UUID southernAmericaUuid;
68
    private UUID antarcticaUuid;
69

    
70
    private UUID classificationUuid;
71

    
72
    private Taxon taxonAcherontia;
73

    
74

    
75
    @Before
76
    public void setUp() {
77

    
78
        uuid = UUID.fromString("496b1325-be50-4b0a-9aa2-3ecd610215f2");
79
        sphingidae = UUID.fromString("54e767ee-894e-4540-a758-f906ecb4e2d9");
80
        acherontia = UUID.fromString("c5cc8674-4242-49a4-aada-72d63194f5fa");
81
        acherontiaLachesis = UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06");
82
        atroposAgassiz = UUID.fromString("d75b2e3d-7394-4ada-b6a5-93175b8751c1");
83
        atroposLeach =  UUID.fromString("3da4ab34-6c50-4586-801e-732615899b07");
84
        rethera = UUID.fromString("a9f42927-e507-4fda-9629-62073a908aae");
85
        retheraSecCdmtest = UUID.fromString("a9f42927-e507-433a-9629-62073a908aae");
86

    
87

    
88
        mimas = UUID.fromString("900052b7-b69c-4e26-a8f0-01c215214c40");
89
        previousAuditEvent = new AuditEvent();
90
        previousAuditEvent.setRevisionNumber(1025);
91
        previousAuditEvent.setUuid(UUID.fromString("a680fab4-365e-4765-b49e-768f2ee30cda"));
92
        mostRecentAuditEvent = new AuditEvent();
93
        mostRecentAuditEvent.setRevisionNumber(1026);
94
        mostRecentAuditEvent.setUuid(UUID.fromString("afe8e761-8545-497b-9134-6a6791fc0b0d"));
95
        AuditEventContextHolder.clearContext(); // By default we're in the current view (i.e. view == null)
96

    
97
        northernAmericaUuid = UUID.fromString("2757e726-d897-4546-93bd-7951d203bf6f");
98
        southernAmericaUuid = UUID.fromString("6310b3ba-96f4-4855-bb5b-326e7af188ea");
99
        antarcticaUuid = UUID.fromString("791b3aa0-54dd-4bed-9b68-56b4680aad0c");
100

    
101
        classificationUuid = UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9");
102

    
103
        taxonAcherontia = (Taxon)taxonDao.findByUuid(acherontia);
104
    }
105

    
106
    @After
107
    public void tearDown() {
108
        AuditEventContextHolder.clearContext();
109
    }
110

    
111
    /**
112
     * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#TaxonDaoHibernateImpl()}.
113
     */
114
    @Test
115
    @DataSet(value="TaxonDaoHibernateImplTest.xml")
116
    public void testInit() {
117
        logger.warn("testInit()");
118
        assertNotNull("Instance of ITaxonDao expected",taxonDao);
119
        assertNotNull("Instance of IReferenceDao expected",referenceDao);
120

    
121
    }
122

    
123
    @Test
124
    @DataSet(value="TaxonDaoHibernateImplTest.xml")
125
    public void testDelete() {
126
        assert taxonAcherontia != null : "taxon must exist";
127
        taxonDao.delete(taxonAcherontia);
128
        setComplete();
129
        endTransaction();
130
    }
131

    
132
//    @Test
133
    @DataSet(value="TaxonDaoHibernateImplTest.xml")
134
    public void testAddTaxon() {
135
        assert taxonAcherontia != null : "taxon must exist";
136
        taxonDao.delete(taxonAcherontia);
137
        setComplete();
138
        endTransaction();
139
    }
140

    
141

    
142
    @Override
143
    public void createTestDataSet() throws FileNotFoundException {
144
        // TODO Auto-generated method stub
145

    
146
    }
147

    
148
}
(2-2/5)