1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.pipeline;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import junit.framework.TestCase;
23  
24  import org.apache.jetspeed.engine.Engine;
25  import org.apache.jetspeed.pipeline.valve.Valve;
26  import org.apache.jetspeed.testhelpers.SpringEngineHelper;
27  
28  /***
29   * TestPipeline
30   *
31   * @author <a href="taylor@apache.org">David Sean Taylor</a>
32   * @version $Id: TestPipeline.java 598476 2007-11-27 00:39:21Z ate $
33   */
34  public class TestPipeline extends TestCase
35  {
36       private Engine engine;
37      private SpringEngineHelper engineHelper;
38  
39      /***
40       * Tests
41       *
42       * @throws Exception
43       */
44      public void testPipeline() throws Exception
45      {
46          assertNotNull(engine);
47          Pipeline pipeline = engine.getPipeline();
48          assertNotNull(pipeline);
49          Valve[] valves = pipeline.getValves();
50          HashMap valvesMap = new HashMap(valves.length);
51          for (int i = 0; i < valves.length; i++)
52          {
53              valvesMap.put(valves[i].toString(), valves[i]);
54          }
55          assertNotNull("CapabilityValveImpl", valvesMap.get("CapabilityValveImpl"));
56          assertNotNull("PortalURLValveImpl", valvesMap.get("PortalURLValveImpl"));
57          assertNotNull("SecurityValve", valvesMap.get("SecurityValve"));
58          assertNotNull("LocalizationValve", valvesMap.get("LocalizationValve"));
59          assertNotNull("PasswordCredentialValve", valvesMap.get("PasswordCredentialValve"));
60          assertNotNull("LoginValidationValve", valvesMap.get("LoginValidationValve"));
61          assertNotNull("ProfilerValve", valvesMap.get("ProfilerValve"));
62          assertNotNull("ContainerValve", valvesMap.get("ContainerValve"));
63          assertNotNull("ActionValveImpl", valvesMap.get("ActionValveImpl"));
64          assertNotNull("ResourceValveImpl", valvesMap.get("ResourceValveImpl"));
65          assertNotNull("DecorationValve", valvesMap.get("DecorationValve"));
66          assertNotNull("HeaderAggregatorValve", valvesMap.get("HeaderAggregatorValve"));
67          assertNotNull("AggregatorValve", valvesMap.get("AggregatorValve"));
68          assertNotNull("CleanupValveImpl", valvesMap.get("CleanupValveImpl"));
69          
70          
71          assertNotNull(engine.getPipeline("action-pipeline"));
72          assertNotNull(engine.getPipeline("portlet-pipeline"));
73      }
74  
75      protected void setUp() throws Exception
76      {
77          Map context = new HashMap();
78          engineHelper = new SpringEngineHelper(context);
79          engineHelper.setUp();
80          this.engine = (Engine)context.get(SpringEngineHelper.ENGINE_ATTR);
81      }
82  
83      protected void tearDown() throws Exception
84      {
85          engineHelper.tearDown();
86      }
87  }