01: package org.andromda.core.common;
02:
03: import java.net.URL;
04:
05: import java.util.List;
06:
07: import junit.framework.TestCase;
08:
09: /**
10: * JUnit test for {@link org.andromda.core.common.ResourceUtils}
11: *
12: * @author Chad Brandon
13: */
14: public class ResourceUtilsTest extends TestCase {
15: public void testGetDirectoryContentsZeroLevels() throws Exception {
16: URL resource = ResourceUtilsTest.class
17: .getResource("ResourceUtilsTestDir");
18: assertNotNull(resource);
19: List resources = ResourceUtils
20: .getDirectoryContents(resource, 0);
21: assertNotNull(resources);
22: assertFalse(resources.isEmpty());
23: assertEquals(5, resources.size());
24: }
25:
26: public void testGetDirectoryContentsTwoLevels() throws Exception {
27: URL resource = ResourceUtilsTest.class
28: .getResource("ResourceUtilsTestDir/one/two");
29: assertNotNull(resource);
30: List resources = ResourceUtils
31: .getDirectoryContents(resource, 2);
32: assertNotNull(resources);
33: assertFalse(resources.isEmpty());
34: assertEquals(5, resources.size());
35: }
36:
37: public void testResolveClasspathResource() throws Exception {
38: URL resource = ResourceUtils
39: .resolveClasspathResource("classpath:"
40: + ResourceUtilsTest.class.getPackage()
41: .getName().replace('.', '/')
42: + '/'
43: + "ResourceUtilsTestDir/one.zip!/two.zip!/three.zip!/file.txt");
44: assertNotNull(resource);
45: }
46: }
|