1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.apache.commons.classscan.builtin;
15
16 import static org.junit.Assert.assertEquals;
17
18 import java.net.URISyntaxException;
19 import java.util.Map;
20
21 import org.apache.commons.classscan.ClassPath;
22 import org.apache.commons.classscan.ClassPathElement;
23 import org.apache.commons.classscan.MetaRegistry;
24 import org.apache.commons.classscan.ResourceFile;
25 import org.apache.commons.classscan.test.classes.FullInterface;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 public class UrlClassPathTest {
30
31 ClassPath classPath;
32
33 @Before
34 public void loadLocation() throws URISyntaxException {
35 ClassLoader classLoader = getClass().getClassLoader();
36 classPath = MetaRegistry.DEFAULT_REGISTRY.getClassPath(classLoader);
37 }
38
39 @Test
40 public void testGetClassLocationsWithMetaFile() throws URISyntaxException {
41 String serviceFileName = "META-INF/services/"+FullInterface.class.getCanonicalName();
42
43 Map<ClassPathElement, ResourceFile> resources = classPath.getResources(serviceFileName);
44 assertEquals(1, resources.size());
45
46 for(Map.Entry<ClassPathElement, ResourceFile> entry : resources.entrySet()) {
47 ResourceFile file = entry.getValue();
48 assertEquals(serviceFileName, file.getFileName());
49 }
50 }
51 }