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.*;
|
12
|
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.junit.Assert;
|
16
|
|
17
|
import org.junit.Before;
|
18
|
import org.junit.Test;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
|
21
|
|
22
|
/**
|
23
|
* @author e.-m.lee
|
24
|
* @date 09.03.2010
|
25
|
*
|
26
|
*/
|
27
|
public class CdmMetaDataTest {
|
28
|
|
29
|
/**
|
30
|
* @throws java.lang.Exception
|
31
|
*/
|
32
|
@Before
|
33
|
public void setUp() throws Exception {
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getSchemaVersion()}.
|
38
|
*/
|
39
|
@Test
|
40
|
public void testGetSchemaVersion() {
|
41
|
//TODO
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#propertyList()}.
|
46
|
*/
|
47
|
@Test
|
48
|
public void testPropertyList() {
|
49
|
List<CdmMetaData> propList = CdmMetaData.propertyList();
|
50
|
assertNotNull(propList);
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#CdmMetaData(eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName, java.lang.String)}.
|
55
|
*/
|
56
|
@Test
|
57
|
public void testCdmMetaData() {
|
58
|
//TODO
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getPropertyName()}.
|
63
|
*/
|
64
|
@Test
|
65
|
public void testGetPropertyName() {
|
66
|
//TODO
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#setPropertyName(eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName)}.
|
71
|
*/
|
72
|
@Test
|
73
|
public void testSetPropertyName() {
|
74
|
//TODO
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getValue()}.
|
79
|
*/
|
80
|
@Test
|
81
|
public void testGetValue() {
|
82
|
//TODO
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#setValue(java.lang.String)}.
|
87
|
*/
|
88
|
@Test
|
89
|
public void testSetValue() {
|
90
|
//TODO
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getCurrentSchemaVersion(int)}.
|
95
|
*/
|
96
|
@Test
|
97
|
public void testGetDbSchemaVersion() {
|
98
|
String strSchemaVersion = CdmMetaData.getDbSchemaVersion();
|
99
|
assertNotNull(strSchemaVersion);
|
100
|
int indexFirst = strSchemaVersion.indexOf(".");
|
101
|
int indexLast = strSchemaVersion.lastIndexOf(".");
|
102
|
assertTrue(indexFirst >0 );
|
103
|
assertTrue("DB schema version is not in the correct format", indexLast == 7);
|
104
|
}
|
105
|
|
106
|
/**
|
107
|
* Test method for {@link eu.etaxonomy.cdm.model.metadata.CdmMetaData#getDatabaseSchemaVersion(java.util.Map, int)}.
|
108
|
*/
|
109
|
@Test
|
110
|
public void testGetDatabaseSchemaVersion() {
|
111
|
//TODO
|
112
|
}
|
113
|
|
114
|
@Test
|
115
|
public void testCompareVersion(){
|
116
|
String version1 = "2.1.2.5.12343244234";
|
117
|
String version2 = "2.1.3.5.11654354355";
|
118
|
String version3 = "2.1.2";
|
119
|
|
120
|
int compare = CdmMetaData.compareVersion(version1, version2, 4, null);
|
121
|
Assert.assertEquals("Result should be -1", -1, compare);
|
122
|
|
123
|
compare = CdmMetaData.compareVersion(version2, version1, 4, null);
|
124
|
Assert.assertEquals("Result should be 1", 1, compare);
|
125
|
|
126
|
compare = CdmMetaData.compareVersion(version2, version1, 2, null);
|
127
|
Assert.assertEquals("Result should be 0", 0, compare);
|
128
|
|
129
|
compare = CdmMetaData.compareVersion(version2, version1, null, null);
|
130
|
Assert.assertEquals("Result should be 1", 1, compare);
|
131
|
|
132
|
compare = CdmMetaData.compareVersion(version1, version3, 3, null);
|
133
|
Assert.assertEquals("Result should be 0", 0, compare);
|
134
|
|
135
|
boolean exception = false;
|
136
|
try{
|
137
|
compare = CdmMetaData.compareVersion("test", version1, null, null);
|
138
|
}catch(RuntimeException e){
|
139
|
exception = true;
|
140
|
}
|
141
|
|
142
|
Assert.assertTrue("Should have thrown an exception on incorrect input values", exception);
|
143
|
exception = false;
|
144
|
|
145
|
try{
|
146
|
compare = CdmMetaData.compareVersion(version1, version2, 7, null);
|
147
|
}catch(RuntimeException e){
|
148
|
exception = true;
|
149
|
}
|
150
|
|
151
|
Assert.assertTrue("Should have thrown an exception on incompatible depth", exception);
|
152
|
exception = false;
|
153
|
|
154
|
}
|
155
|
|
156
|
}
|