1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.common;
|
12
|
|
13
|
import static org.junit.Assert.*;
|
14
|
|
15
|
import java.io.File;
|
16
|
import java.io.IOException;
|
17
|
import java.io.InputStream;
|
18
|
|
19
|
import org.apache.log4j.Level;
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.junit.After;
|
22
|
import org.junit.AfterClass;
|
23
|
import org.junit.Assert;
|
24
|
import org.junit.Before;
|
25
|
import org.junit.BeforeClass;
|
26
|
import org.junit.Test;
|
27
|
|
28
|
public class CdmUtilsTest {
|
29
|
private static final Logger logger = Logger.getLogger(CdmUtilsTest.class);
|
30
|
|
31
|
@BeforeClass
|
32
|
public static void setUpBeforeClass() throws Exception {
|
33
|
}
|
34
|
|
35
|
@AfterClass
|
36
|
public static void tearDownAfterClass() throws Exception {
|
37
|
}
|
38
|
|
39
|
@Before
|
40
|
public void setUp() throws Exception {
|
41
|
}
|
42
|
|
43
|
@After
|
44
|
public void tearDown() throws Exception {
|
45
|
}
|
46
|
|
47
|
/************************** TESTS ****************************************/
|
48
|
|
49
|
@Test
|
50
|
public void testGetReadableResourceStream() {
|
51
|
String resourceFileName = CdmUtils.MUST_EXIST_FILE;
|
52
|
try {
|
53
|
InputStream inputStream = CdmUtils.getReadableResourceStream(resourceFileName);
|
54
|
assertNotNull(inputStream);
|
55
|
} catch (IOException e) {
|
56
|
Assert.fail("IOException");
|
57
|
}
|
58
|
}
|
59
|
|
60
|
@Test
|
61
|
public void testGetFolderSeperator() {
|
62
|
Assert.assertEquals(File.separator, CdmUtils.getFolderSeperator());
|
63
|
}
|
64
|
|
65
|
@Test
|
66
|
public void testGetHomeDir() {
|
67
|
//Assert.assertEquals("", CdmUtils.getHomeDir());
|
68
|
}
|
69
|
|
70
|
@Test
|
71
|
public void testFindLibrary() {
|
72
|
if (logger.isEnabledFor(Level.DEBUG)) {logger.debug(CdmUtils.findLibrary(CdmUtils.class));}
|
73
|
|
74
|
String library = CdmUtils.findLibrary(CdmUtils.class);
|
75
|
String endOfLibrary = "target/classes/eu/etaxonomy/cdm/common/CdmUtils.class";
|
76
|
String libraryContains = "/cdmlib-commons/";
|
77
|
|
78
|
Assert.assertTrue(library.endsWith(endOfLibrary));
|
79
|
Assert.assertTrue(library.contains(libraryContains));
|
80
|
}
|
81
|
|
82
|
}
|