Project

General

Profile

Download (1.7 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.common;
2

    
3
import static org.junit.Assert.*;
4

    
5
import java.io.File;
6
import java.io.IOException;
7
import java.io.InputStream;
8

    
9
import org.apache.log4j.Level;
10
import org.apache.log4j.Logger;
11
import org.junit.After;
12
import org.junit.AfterClass;
13
import org.junit.Assert;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Test;
17

    
18
public class CdmUtilsTest {
19
	private static final Logger logger = Logger.getLogger(CdmUtilsTest.class);
20
	
21
	@BeforeClass
22
	public static void setUpBeforeClass() throws Exception {
23
	}
24

    
25
	@AfterClass
26
	public static void tearDownAfterClass() throws Exception {
27
	}
28

    
29
	@Before
30
	public void setUp() throws Exception {
31
	}
32

    
33
	@After
34
	public void tearDown() throws Exception {
35
	}
36

    
37
/************************** TESTS ****************************************/
38
	
39
	@Test
40
	public void testGetReadableResourceStream() {
41
		String resourceFileName = CdmUtils.MUST_EXIST_FILE;
42
		try {
43
			InputStream inputStream = CdmUtils.getReadableResourceStream(resourceFileName);
44
			assertNotNull(inputStream);
45
		} catch (IOException e) {
46
			Assert.fail("IOException");
47
		}
48
	}
49

    
50
	@Test
51
	public void testGetFolderSeperator() {
52
		Assert.assertEquals(File.separator, CdmUtils.getFolderSeperator());
53
	}
54

    
55
	@Test
56
	public void testFindLibrary() {
57
		if (logger.isEnabledFor(Level.DEBUG)) {logger.debug(CdmUtils.findLibrary(CdmUtils.class));}
58
		
59
		String library = CdmUtils.findLibrary(CdmUtils.class);
60
		String endOfLibrary = "target/classes/eu/etaxonomy/cdm/common/CdmUtils.class";
61
		String libraryContains = "/cdmlib-commons/";
62
		
63
		Assert.assertTrue(library.endsWith(endOfLibrary)); 
64
		Assert.assertTrue(library.contains(libraryContains)); 
65
	}
66

    
67
}
(1-1/4)