1 /*
2 * File: SingleCallStrategyTest.java
3 * Date: Nov 17, 2003
4 */
5 package com.rhi.architecture.parc;
6
7 import com.rhi.architecture.logging.*;
8 import com.rhi.architecture.resource.*;
9
10 import java.util.*;
11
12 import junit.framework.Test;
13 import junit.framework.TestCase;
14 import junit.framework.TestSuite;
15
16 /***
17 * SingleCallStrategyTest
18 *
19 * @author <a href="mailto:pete_mckinstry@yahoo.com">Pete McKinstry</a>
20 * @copyright 2003, All rights reserved.
21 */
22 public class SingleCallStrategyTest extends TestCase {
23
24 private static final Logger log = new DefaultLogger();
25
26 private ResourceContext ctx;
27
28 /***
29 * Constructor for SingleCallStrategyTest.
30 * @param name
31 */
32 public SingleCallStrategyTest(String name) {
33 super(name);
34 }
35
36 /* (non-Javadoc)
37 * @see junit.framework.TestCase#setUp()
38 */
39 protected void setUp() throws Exception {
40 super.setUp();
41 log.debug("START: " + this.getName());
42 try {
43 ctx = new ResourceContext();
44 Properties p = getProperties();
45 //p.list(System.err);
46 log.debug("calling ResourceContext.init()");
47 ctx.init( p );
48 }
49 catch (Exception e) {
50 log.debug(e.toString());
51 e.printStackTrace();
52 throw new java.lang.RuntimeException(
53 "ResourceContext failed to initialize. " +
54 " e = " + e.toString() );
55 }
56 }
57
58 /***
59 * @return Properties
60 */
61 public Properties getProperties() {
62 Properties p = new Properties();
63 p.setProperty("Resource.LogFactory",
64 "com.rhi.architecture.logging.TestLogFactory");
65 // for this test.
66 p.setProperty(InfiniteLoopStrategy.SLEEP_TIME, "25");
67
68 return p;
69 }
70
71 /* (non-Javadoc)
72 * @see junit.framework.TestCase#tearDown()
73 */
74 protected void tearDown() throws Exception {
75 super.tearDown();
76 ctx.cleanup();
77 log.debug("END: " + this.getName());
78 }
79
80 /***
81 * test run
82 * @throws Exception
83 */
84 public void testRun() throws Exception {
85 new TestableSingleCallStrategy().run();
86 assertTrue(TestableSingleCallStrategy.loopCount==1);
87 }
88
89 /***
90 * return suite of all tests for this class.
91 * @return TestSuite
92 */
93 public static Test suite() {
94 return new TestSuite(SingleCallStrategyTest.class);
95 }
96
97 /***
98 * main()
99 * @param args
100 */
101 public static void main(String[] args) {
102 junit.textui.TestRunner.run(suite());
103 }
104
105 }
This page was automatically generated by Maven