1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.yaml.snakeyaml.extensions.compactnotation;
17
18 import junit.framework.TestCase;
19
20 public class PackageCompactConstructorTest extends TestCase {
21
22 public void testGetClassForName() throws ClassNotFoundException {
23 assertEquals(Table.class, check("Table"));
24 assertEquals(Table.class, check("org.yaml.snakeyaml.extensions.compactnotation.Table"));
25 assertEquals(String.class, check("java.lang.String"));
26 }
27
28 public void testException1() throws ClassNotFoundException {
29 try {
30 check("foo.Bar");
31 fail();
32 } catch (ClassNotFoundException e) {
33 assertEquals("foo.Bar", e.getMessage());
34 }
35 }
36
37 public void testException2() throws ClassNotFoundException {
38 try {
39 check("FooBar");
40 fail();
41 } catch (ClassNotFoundException e) {
42 assertEquals("FooBar", e.getMessage());
43 }
44 }
45
46 private Class<?> check(String name) throws ClassNotFoundException {
47 return new PackageCompactConstructor("org.yaml.snakeyaml.extensions.compactnotation")
48 .getClassForName(name);
49 }
50 }