blob: 59b596f86f79f34302a27da48f1d5f62cf9035fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import java.lang.reflect.Method;
import java.util.*;
public class LTWTest {
public void noDoubles() throws Exception {
Method[] methods = Bottom.class.getMethods();
System.out.println("Bottom.getMethods()");
boolean broken = false;
List<String> l = new ArrayList<String>();
for (Method method : methods) {
if (!method.getDeclaringClass().equals(Object.class)) {
l.add(method.getName() + " : " + method.getDeclaringClass().getName());
}
if (method.getDeclaringClass().equals(Bottom.class)) {
if (method.getName().equals("markMethod")) {
broken=true;
}
}
}
Collections.sort(l);
for (String s: l) {
System.out.println(s);
}
if (broken) {
throw new IllegalStateException("Bottom.getMethods() should not include a markMethod() declared by Bottom");
}
}
public void grandChildInherits() throws Exception {
Method[] methods = Bottom.class.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals("markMethod"))
throw new RuntimeException();
// assertThat(method.getName(), not(equalTo("doSomething")));
}
/*
methods = Bottom.class.getMethods();
for (Method method : methods) {
if (method.getName().equals("doSomething")) {
System.out.println(method.getDeclaringClass().getName());
}
}
*/
}
public static void main(String[] args) throws Exception {
LTWTest t = new LTWTest();
t.noDoubles();
t.grandChildInherits();
}
}
|