Project

General

Profile

Download (4.04 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
package eu.etaxonomy.cdm.model.metadata;
10

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

    
14
import java.util.List;
15

    
16
import org.junit.Assert;
17
import org.junit.Before;
18
import org.junit.Test;
19

    
20
/**
21
 * @author e.-m.lee
22
 \* @since 09.03.2010
23
 *
24
 */
25
public class CdmMetaDataTest {
26

    
27
	/**
28
	 * @throws java.lang.Exception
29
	 */
30
	@Before
31
	public void setUp() throws Exception {
32
	}
33

    
34
	/**
35
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getSchemaVersion()}.
36
	 */
37
	@Test
38
	public void testGetSchemaVersion() {
39
		//TODO
40
	}
41

    
42
	/**
43
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#propertyList()}.
44
	 */
45
	@Test
46
	public void testDefaultMetaData() {
47
		List<CdmMetaData> propList = CdmMetaData.defaultMetaData();
48
		assertNotNull(propList);
49
	}
50

    
51
	/**
52
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#CdmMetaData(eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName, java.lang.String)}.
53
	 */
54
	@Test
55
	public void testCdmMetaData() {
56
		//TODO
57
	}
58

    
59
	/**
60
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getPropertyName()}.
61
	 */
62
	@Test
63
	public void testGetPropertyName() {
64
		//TODO
65
	}
66

    
67
	/**
68
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#setPropertyName(eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName)}.
69
	 */
70
	@Test
71
	public void testSetPropertyName() {
72
		//TODO
73
	}
74

    
75
	/**
76
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getValue()}.
77
	 */
78
	@Test
79
	public void testGetValue() {
80
		//TODO
81
	}
82

    
83
	/**
84
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#setValue(java.lang.String)}.
85
	 */
86
	@Test
87
	public void testSetValue() {
88
		//TODO
89
	}
90

    
91
	/**
92
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getCurrentSchemaVersion(int)}.
93
	 */
94
	@Test
95
	public void testGetDbSchemaVersion() {
96
		String strSchemaVersion = CdmMetaData.getDbSchemaVersion();
97
		assertNotNull(strSchemaVersion);
98
		int indexFirst = strSchemaVersion.indexOf(".");
99
		int indexLast = strSchemaVersion.lastIndexOf(".");
100
		assertTrue(indexFirst >0 );
101
		assertTrue("DB schema version is not in the correct format", indexLast == 7);
102
	}
103

    
104
	/**
105
	 * Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getDatabaseSchemaVersion(java.util.Map, int)}.
106
	 */
107
	@Test
108
	public void testGetDatabaseSchemaVersion() {
109
		//TODO
110
	}
111

    
112
	@Test
113
	public void testCompareVersion(){
114
		String version1 = "2.1.2.5.12343244234";
115
		String version2 = "2.1.3.5.11654354355";
116
		String version3 = "2.1.2";
117

    
118
		int compare = CdmMetaData.compareVersion(version1, version2, 4, null);
119
		Assert.assertEquals("Result should be -1", -1, compare);
120

    
121
		compare = CdmMetaData.compareVersion(version2, version1, 4, null);
122
		Assert.assertEquals("Result should be 1", 1, compare);
123

    
124
		compare = CdmMetaData.compareVersion(version2, version1, 2, null);
125
		Assert.assertEquals("Result should be 0", 0, compare);
126

    
127
		compare = CdmMetaData.compareVersion(version2, version1, null, null);
128
		Assert.assertEquals("Result should be 1", 1, compare);
129

    
130
		compare = CdmMetaData.compareVersion(version1, version3, 3, null);
131
		Assert.assertEquals("Result should be 0", 0, compare);
132

    
133
		boolean exception = false;
134
		try{
135
			compare = CdmMetaData.compareVersion("test", version1, null, null);
136
		}catch(RuntimeException e){
137
			exception = true;
138
		}
139

    
140
		Assert.assertTrue("Should have thrown an exception on incorrect input values", exception);
141
		exception = false;
142

    
143
		try{
144
			compare = CdmMetaData.compareVersion(version1, version2, 7, null);
145
		}catch(RuntimeException e){
146
			exception = true;
147
		}
148

    
149
		Assert.assertTrue("Should have thrown an exception on incompatible depth", exception);
150
		exception = false;
151

    
152
	}
153

    
154
}
(1-1/3)