1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.core.classpath;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.hasItems;
20 import static org.hamcrest.Matchers.is;
21
22 import help.de.smartics.properties.core.SimpleProperties;
23
24 import java.net.URL;
25 import java.util.Arrays;
26 import java.util.HashSet;
27 import java.util.Set;
28
29 import org.hamcrest.Matcher;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.experimental.categories.Category;
33
34 import de.smartics.properties.spi.core.classpath.PropertySetClassesLoader;
35 import de.smartics.testdoc.annotations.Uut;
36 import de.smartics.testdoc.categories.Technical;
37
38
39
40
41 public class PropertySetClassesLoaderTest
42 {
43
44
45
46
47
48
49 @Uut
50 private PropertySetClassesLoader uut;
51
52
53
54
55
56
57
58 @Before
59 public void setUp()
60 {
61 uut = new PropertySetClassesLoader();
62 }
63
64
65
66
67
68 @Test
69 @Category(Technical.class)
70 public void allowsNullAsCollectionOfClassPathRoots()
71 {
72 final Set<Class<?>> types = uut.getPropertySetTypes(null);
73 assertThat(types.isEmpty(), is(true));
74 }
75
76 @Test
77 @Category(Technical.class)
78 public void allowsAnEmptyCollectionOfClassPathRoots()
79 {
80 final Set<Class<?>> types = uut.getPropertySetTypes(new HashSet<URL>());
81 assertThat(types.isEmpty(), is(true));
82 }
83
84 @SuppressWarnings({ "unchecked", "rawtypes" })
85 @Test
86 @Category(Technical.class)
87 public void returnsOnlyTypesAnnotatedAsPropertySet()
88 {
89 final URL url = SimpleProperties.class.getClassLoader().getResource("");
90 final Set<Class<?>> types = uut.getPropertySetTypes(Arrays.asList(url));
91 assertThat(types.isEmpty(), is(false));
92 assertThat(types, (Matcher) hasItems(SimpleProperties.class));
93 }
94
95 }