01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.engine;
18:
19: import java.util.HashMap;
20:
21: import junit.framework.TestCase;
22:
23: import org.apache.jetspeed.components.ComponentManagement;
24: import org.apache.jetspeed.testhelpers.SpringEngineHelper;
25:
26: /**
27: * <p>
28: * AbstractEngineTest
29: * </p>
30: *
31: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
32: * @version $Id: AbstractEngineTest.java 516448 2007-03-09 16:25:47Z ate $
33: */
34: public abstract class AbstractEngineTest extends TestCase {
35:
36: /**
37: *
38: */
39: public AbstractEngineTest() {
40: super ();
41: }
42:
43: /**
44: * @param arg0
45: */
46: public AbstractEngineTest(String arg0) {
47: super (arg0);
48: }
49:
50: protected Engine engine;
51:
52: protected Object[] keysToCheck;
53:
54: private SpringEngineHelper engineHelper;
55:
56: public void testEngine() throws Exception {
57: assertNotNull(engine.getComponentManager());
58: assertNotNull(engine.getComponentManager().getRootContainer());
59: if (keysToCheck != null) {
60: verifyComponents(keysToCheck);
61: }
62: }
63:
64: protected void setUp() throws Exception {
65: HashMap context = new HashMap();
66: engineHelper = new SpringEngineHelper(context);
67: engineHelper.setUp();
68: engine = (Engine) context.get(SpringEngineHelper.ENGINE_ATTR);
69: }
70:
71: protected void tearDown() throws Exception {
72: engineHelper.tearDown();
73: super .tearDown();
74: }
75:
76: protected void verifyComponents(Object[] keys) {
77: ComponentManagement cm = engine.getComponentManager();
78: for (int i = 0; i < keys.length; i++) {
79: assertNotNull("Could not get component insatance "
80: + keys[i], cm.getComponent(keys[i]));
81: System.out.println("Load componenet "
82: + cm.getComponent(keys[i]).getClass() + " for key "
83: + keys[i]);
84: }
85: }
86:
87: }
|