2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

View Javadoc

1   /* 
2    * ========================================================================
3    * 
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   * 
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * 
19   * ========================================================================
20   */
21  package org.apache.cactus.internal.configuration;
22  
23  import org.apache.cactus.util.ChainedRuntimeException;
24  
25  /**
26   * Provides access to the Cactus configuration parameters that are independent
27   * of any redirector. All Cactus configuration are defined as Java System
28   * Properties.
29   *
30   * @version $Id: BaseConfiguration.java 238991 2004-05-22 11:34:50Z vmassol $
31   */
32  public class BaseConfiguration implements Configuration
33  {
34      /**
35       * Name of Cactus property that specify the URL up to the webapp context.
36       * This is the base URL to call for the redirectors. It is made up of :
37       * "http://" + serverName + port + "/" + contextName.
38       */
39      public static final String CACTUS_CONTEXT_URL_PROPERTY = 
40          "cactus.contextURL";
41  
42      /**
43       * Name of the Cactus property for defining an initializer (i.e. a class
44       * that is executed before the Cactus tests start on the client side).
45       */
46      private static final String CACTUS_INITIALIZER_PROPERTY = 
47          "cactus.initializer";
48  
49      /**
50       * @return the context URL under which our application to test runs.
51       */
52      public String getContextURL()
53      {
54          // Try to read it from a System property first and then if it fails
55          // from the Cactus configuration file.
56          String contextURL = System.getProperty(CACTUS_CONTEXT_URL_PROPERTY);
57  
58          if (contextURL == null)
59          {
60              throw new ChainedRuntimeException("Missing Cactus property ["
61                  + CACTUS_CONTEXT_URL_PROPERTY + "]");
62          }
63  
64          return contextURL;
65      }
66  
67      /**
68       * @return the initializer class (i.e. a class that is executed before the
69       *         Cactus tests start on the client side) or null if none has been
70       *         defined
71       */
72      public String getInitializer()
73      {
74          return System.getProperty(CACTUS_INITIALIZER_PROPERTY);
75      }
76  }