Project

General

Profile

Download (3.18 KB) Statistics
| Branch: | Tag: | Revision:
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.model.common.init;
11

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

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

    
17
import org.apache.log4j.Logger;
18
import org.junit.After;
19
import org.junit.AfterClass;
20
import org.junit.Before;
21
import org.junit.BeforeClass;
22
import org.junit.Test;
23

    
24
import eu.etaxonomy.cdm.model.common.NoDefinedTermClassException;
25
import eu.etaxonomy.cdm.model.common.init.DefaultVocabularyStore;
26
import eu.etaxonomy.cdm.model.common.init.IVocabularyStore;
27
import eu.etaxonomy.cdm.model.common.init.TermLoader;
28
import eu.etaxonomy.cdm.model.name.Rank;
29

    
30
/**
31
 * @author a.mueller
32
 *
33
 */
34
public class TermLoaderTest {
35
	static Logger logger = Logger.getLogger(TermLoaderTest.class);
36

    
37
	static TermLoader termLoader;
38
	
39
	/**
40
	 * @throws java.lang.Exception
41
	 */
42
	@BeforeClass
43
	public static void setUpBeforeClass() throws Exception {
44
	}
45

    
46
	/**
47
	 * @throws java.lang.Exception
48
	 */
49
	@AfterClass
50
	public static void tearDownAfterClass() throws Exception {
51
	}
52

    
53
	/**
54
	 * @throws java.lang.Exception
55
	 */
56
	@Before
57
	public void setUp() throws Exception {
58
		IVocabularyStore vocStore = new DefaultVocabularyStore();
59
		termLoader = new TermLoader(vocStore);
60
	}
61

    
62
	/**
63
	 * @throws java.lang.Exception
64
	 */
65
	@After
66
	public void tearDown() throws Exception {
67
	}
68

    
69
	
70
/************** TESTS **********************************/
71
	
72

    
73
	@Test
74
	public void testNewMethods() {
75
		logger.warn("test for new mtehods have to be implemented");
76
	}
77

    
78
	/**
79
	 * Test method for {@link eu.etaxonomy.cdm.model.common.init.TermLoader#loadTerms(java.lang.Class, java.lang.String, boolean)}.
80
	 */
81
	@Test
82
	public void testLoadTerms() {
83
		try {
84
			String filename = "Rank.csv";
85
			boolean isEnumeration = true;
86
			Class termClass = Rank.class;
87
			termLoader.insertTerms(termClass, filename, isEnumeration, true);
88
		} catch (FileNotFoundException e) {
89
			fail();
90
		} catch (NoDefinedTermClassException e) {
91
			fail();;
92
		}
93
		assertEquals(Rank.GENUS().getUuid(), UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a"));
94
	}
95

    
96
	/**
97
	 * Test method for {@link eu.etaxonomy.cdm.model.common.init.TermLoader#loadDefaultTerms(java.lang.Class)}.
98
	 */
99
	@Test
100
	public void testLoadDefaultTerms() {
101
		try {
102
			termLoader.insertDefaultTerms(Rank.class, true);
103
		} catch (FileNotFoundException e) {
104
			fail();
105
		} catch (NoDefinedTermClassException e) {
106
			fail();;
107
		}
108
		assertEquals(Rank.GENUS().getUuid(), UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a"));
109
	}
110

    
111
	/**
112
	 * Test method for {@link eu.etaxonomy.cdm.model.common.init.TermLoader#loadAllDefaultTerms()}.
113
	 */
114
	@Test
115
	public void testMakeDefaultTermsLoaded() {
116
		try {
117
			termLoader.makeDefaultTermsInserted();
118
		} catch (FileNotFoundException e) {
119
			fail();
120
		} catch (NoDefinedTermClassException e) {
121
			fail();;
122
		}
123
		assertEquals(Rank.GENUS().getUuid(), UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a"));
124
	}
125

    
126
}
(2-2/2)