1 package org.apache.turbine.om;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertNotSame;
25 import static org.junit.Assert.assertSame;
26 import static org.junit.Assert.assertTrue;
27
28 import org.apache.turbine.util.TurbineConfig;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.junit.Test;
33
34
35
36
37
38
39 public class OMToolTest
40 {
41 private static TurbineConfig tc = null;
42 private OMTool om;
43
44 @BeforeClass
45 public static void init() {
46 tc = new TurbineConfig(
47 ".",
48 "/conf/test/CompleteTurbineResources.properties");
49 tc.initialize();
50 }
51
52 @Before
53 public void setUpBefore() throws Exception
54 {
55 om = new OMTool();
56 }
57
58 @Test
59 public void testGetString() throws Exception
60 {
61 assertNotNull("RetrieverFactory should not be null", om.omFactory);
62 OMTool.PullHelper ph1 = om.get("test1");
63 assertNotNull("PullHelper should not be null", ph1);
64 OMTool.PullHelper ph2 = om.get("test2");
65 assertNotNull("PullHelper should not be null", ph2);
66 assertNotSame("Should not be same instance", ph1, ph2);
67 OMTool.PullHelper ph3 = om.get("test2");
68 assertNotNull("PullHelper should not be null", ph3);
69 assertSame("Should be same instance", ph3, ph2);
70 }
71
72 @Test
73 public void testGetStringString() throws Exception
74 {
75 Object testString1 = om.get("test1", "testString");
76 assertNotNull("Object should not be null", testString1);
77 assertTrue("Object should be a string", testString1 instanceof String);
78 assertEquals("Object should be a string", "testString", testString1);
79 Object testString2 = om.get("test1", "testString");
80 assertNotNull("Object should not be null", testString2);
81 assertSame("Should be same instance", testString1, testString2);
82 }
83
84 @AfterClass
85 public static void destroy()
86 {
87 tc.dispose();
88 }
89 }