1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.core.util;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue;
21 import static org.hamcrest.Matchers.nullValue;
22
23 import java.lang.reflect.Method;
24
25 import org.junit.Test;
26 import org.junit.experimental.categories.Category;
27
28 import de.smartics.properties.spi.core.util.SerializableMethod;
29 import de.smartics.testdoc.annotations.Uut;
30 import de.smartics.testdoc.categories.Technical;
31
32
33
34
35 @Uut(type = SerializableMethod.class)
36 public class SerializableMethodTest
37 {
38
39
40
41
42 private static final Class<?>[] NO_PARAMETER = new Class<?>[0];
43
44 private static final Method METHOD;
45
46 static
47 {
48 try
49 {
50 METHOD = String.class.getMethod("toString", NO_PARAMETER);
51 }
52 catch (final Exception e)
53 {
54 throw new IllegalStateException("Cannot find method for test.", e);
55 }
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69
70 @Test
71 public void allowsNullMethod()
72 {
73 final SerializableMethod uut = new SerializableMethod(null);
74 assertThat(uut.getMethod(), is(nullValue()));
75 }
76
77 @Test
78 public void allowsToAccessWrappedMethod()
79 {
80 final SerializableMethod uut = new SerializableMethod(METHOD);
81 final Method method = uut.getMethod();
82 assertThat(method, is(METHOD));
83 }
84
85 @Test
86 public void providesAStringRepresentation()
87 {
88 final SerializableMethod uut = new SerializableMethod(METHOD);
89 assertThat(uut.toString(), is(notNullValue()));
90 }
91
92 @Test
93 @Category(Technical.class)
94 public void providesAStringRepresentationForNullMethod()
95 {
96 final SerializableMethod uut = new SerializableMethod(null);
97 assertThat(uut.toString(), is(nullValue()));
98 }
99 }