01: // Copyright 2004, 2005 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package hivemind.test.services;
16:
17: import hivemind.test.FrameworkTestCase;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.apache.hivemind.internal.ServicePoint;
23: import org.apache.hivemind.service.impl.EagerLoader;
24:
25: /**
26: * Tests for the {@link org.apache.hivemind.service.impl.EagerLoader} service.
27: *
28: * @author Howard Lewis Ship
29: */
30: public class TestEagerLoader extends FrameworkTestCase {
31: public void testEagerLoaderImpl() {
32: EagerLoader el = new EagerLoader();
33: List l = new ArrayList();
34:
35: ServicePoint sp = (ServicePoint) newMock(ServicePoint.class);
36:
37: sp.forceServiceInstantiation();
38:
39: replayControls();
40:
41: l.add(sp);
42:
43: el.setServicePoints(l);
44:
45: el.run();
46:
47: verifyControls();
48: }
49:
50: public void testEagerLoadSingleton() throws Exception {
51: interceptLogging("hivemind.test.services.Loud");
52:
53: buildFrameworkRegistry("EagerLoadSingleton.xml");
54:
55: assertLoggedMessage("Instantiated.");
56: }
57:
58: public void testEagerLoadPrimitive() throws Exception {
59: interceptLogging("hivemind.test.services.Loud");
60:
61: buildFrameworkRegistry("EagerLoadPrimitive.xml");
62:
63: assertLoggedMessage("Instantiated.");
64: }
65:
66: public void testEagerLoadThreaded() throws Exception {
67: interceptLogging("hivemind.test.services.Loud");
68:
69: buildFrameworkRegistry("EagerLoadThreaded.xml");
70:
71: assertLoggedMessage("Instantiated.");
72: }
73:
74: public void testEagerLoadPooled() throws Exception {
75: interceptLogging("hivemind.test.services.Loud");
76:
77: buildFrameworkRegistry("EagerLoadPooled.xml");
78:
79: assertLoggedMessage("Instantiated.");
80: }
81: }
|