Author: painter
Date: Wed Sep 18 01:25:12 2019
New Revision: 1867084

URL: http://svn.apache.org/viewvc?rev=1867084&view=rev
Log:
Update junit and jupiter dependencies, source cleanup for Turbine compliance

Modified:
    turbine/fulcrum/trunk/testcontainer/pom.xml
    turbine/fulcrum/trunk/testcontainer/src/changes/changes.xml
    
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
    
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit5Test.java
    
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java

Modified: turbine/fulcrum/trunk/testcontainer/pom.xml
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/pom.xml?rev=1867084&r1=1867083&r2=1867084&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/pom.xml (original)
+++ turbine/fulcrum/trunk/testcontainer/pom.xml Wed Sep 18 01:25:12 2019
@@ -1,189 +1,182 @@
 <?xml version="1.0"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-  <parent>
-    <artifactId>turbine-parent</artifactId>
-       <groupId>org.apache.turbine</groupId>
-       <version>6</version>
-  </parent>
-
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.apache.fulcrum</groupId>
-  <artifactId>fulcrum-testcontainer</artifactId>
-  <version>1.0.9-SNAPSHOT</version>
-  <name>Fulcrum Test Container</name>
-  <inceptionYear>2004</inceptionYear>
-  <description>A test framework for Avalon components</description>
-  <url>https://turbine.apache.org/fulcrum/fulcrum-testcontainer</url>
-        
-  <scm>
-    
<connection>scm:svn:http://svn.apache.org/repos/asf/turbine/fulcrum/trunk/testcontainer</connection>
-    
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/testcontainer</developerConnection>
-    <url>http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer</url>
-  </scm>
-
-  <distributionManagement>
-    <site>
-      <id>apache.website</id>
-      <name>Fulcrum Website</name>
-      <url>http://turbine.apache.org/fulcrum/fulcrum-testcontainer/</url>
-    </site>    
-  </distributionManagement>
-    
-  <developers>
-    <developer>
-      <name>Siegfried Goeschl</name>
-      <id>sgoeschl</id>
-      <email>[email protected]</email>
-      <organization />
-      <roles>
-        <role>Java Developer</role>
-      </roles>
-    </developer>
-  </developers>
-
-  <dependencies>
-     <!-- we still need this dependency to  compile -->
-     <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.12</version>
-        </dependency>
-    <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-api</artifactId>
-            <version>${junit.jupiter.version}</version>
-            <!--scope>test</scope-->
-        </dependency>
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-params</artifactId>
-            <version>${junit.jupiter.version}</version>
-            <!--scope>test</scope-->
-        </dependency>
-        <dependency>
-            <groupId>org.junit.jupiter</groupId>
-            <artifactId>junit-jupiter-engine</artifactId>
-            <version>${junit.jupiter.version}</version>
-        </dependency>
-    <!-- use Junit 4 within Junit 5 -->
-    <dependency>
-        <groupId>org.junit.vintage</groupId>
-        <artifactId>junit-vintage-engine</artifactId>
-        <version>${junit.jupiter.version}</version>
-    </dependency>
-    <dependency>
-        <groupId>org.junit.platform</groupId>
-        <artifactId>junit-platform-runner</artifactId>
-        <version>${junit.platform}</version>
-    </dependency>
-    <dependency>
-       <groupId>org.junit.platform</groupId>
-       <artifactId>junit-platform-launcher</artifactId>
-       <version>${junit.platform}</version>
-    </dependency>
-
-    <!-- Needed if testing with YAAFI -->
-    <dependency>
-      <groupId>org.apache.fulcrum</groupId>
-      <artifactId>fulcrum-yaafi</artifactId>
-      <version>1.0.8</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-        <groupId>javax.servlet</groupId>
-        <artifactId>javax.servlet-api</artifactId>
-        <version>3.1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <version>2.28.2</version>
-    </dependency>
-    <!-- Needed if testing with ECM -->
-    <dependency>
-      <groupId>org.apache.excalibur.component</groupId>
-      <artifactId>excalibur-component</artifactId>
-      <version>2.2.1</version>
-      <type>jar</type>
-      <optional>true</optional>
-    </dependency>
-    <!-- Log4j2 may be better used by default   -->
-    <dependency>
-      <groupId>org.apache.logging.log4j</groupId>
-      <artifactId>log4j-api</artifactId>
-      <version>${turbine.log4j2.version}</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-       <groupId>org.apache.logging.log4j</groupId>
-       <artifactId>log4j-core</artifactId>
-       <version>${turbine.log4j2.version}</version>
-       <optional>true</optional>
-    </dependency>
-    <!-- log4j1.2 bridge instead of log4j -->
-    <dependency>
-        <groupId>org.apache.logging.log4j</groupId>
-        <artifactId>log4j-1.2-api</artifactId>
-        <version>${turbine.log4j2.version}</version>
-        <optional>true</optional>
-    </dependency>
-    
-  </dependencies>
-
-  <build>
-    <sourceDirectory>${basedir}/src/java</sourceDirectory>
-    <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
-    <testResources>
-      <testResource>
-        <directory>${basedir}/src/test</directory>
-        <includes>
-          <include>*.xml</include>
-        </includes>
-      </testResource>
-    </testResources>
-    <plugins>
-      <plugin>
-        <!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <!-- setting the default: forkCount=1/reuseForks=true -->
-          <forkCount>1</forkCount>
-          <!-- setting this to false (highest isolation: each test class has 
its own jvm process) let maven test ignore all tests? -->
-          <reuseForks>true</reuseForks>
-        </configuration>
-        <dependencies>
-            <!-- need no junit-platform-surefire-provider dependency-->
-          </dependencies>
-      </plugin>
-    </plugins>
-  </build>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor 
+       license agreements. See the NOTICE file distributed with this work for 
additional 
+       information regarding copyright ownership. The ASF licenses this file 
to 
+       You under the Apache License, Version 2.0 (the "License"); you may not 
use 
+       this file except in compliance with the License. You may obtain a copy 
of 
+       the License at http://www.apache.org/licenses/LICENSE-2.0 Unless 
required 
+       by applicable law or agreed to in writing, software distributed under 
the 
+       License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS 
+       OF ANY KIND, either express or implied. See the License for the 
specific 
+       language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+       <parent>
+               <artifactId>turbine-parent</artifactId>
+               <groupId>org.apache.turbine</groupId>
+               <version>6</version>
+       </parent>
+
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.apache.fulcrum</groupId>
+       <artifactId>fulcrum-testcontainer</artifactId>
+       <version>1.0.9-SNAPSHOT</version>
+       <name>Fulcrum Test Container</name>
+       <inceptionYear>2004</inceptionYear>
+       <description>A test framework for Avalon components</description>
+       <url>https://turbine.apache.org/fulcrum/fulcrum-testcontainer</url>
+
+       <scm>
+               
<connection>scm:svn:http://svn.apache.org/repos/asf/turbine/fulcrum/trunk/testcontainer</connection>
+               
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/testcontainer</developerConnection>
+               
<url>http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer</url>
+       </scm>
+
+       <distributionManagement>
+               <site>
+                       <id>apache.website</id>
+                       <name>Fulcrum Website</name>
+                       
<url>http://turbine.apache.org/fulcrum/fulcrum-testcontainer/</url>
+               </site>
+       </distributionManagement>
+
+       <developers>
+               <developer>
+                       <name>Siegfried Goeschl</name>
+                       <id>sgoeschl</id>
+                       <email>[email protected]</email>
+                       <organization />
+                       <roles>
+                               <role>Java Developer</role>
+                       </roles>
+               </developer>
+       </developers>
+
+       <dependencies>
+               <!-- we still need this dependency to compile -->
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.12</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.jupiter</groupId>
+                       <artifactId>junit-jupiter-api</artifactId>
+                       <version>${junit.jupiter.version}</version>
+                       <!--scope>test</scope -->
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.jupiter</groupId>
+                       <artifactId>junit-jupiter-params</artifactId>
+                       <version>${junit.jupiter.version}</version>
+                       <!--scope>test</scope -->
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.jupiter</groupId>
+                       <artifactId>junit-jupiter-engine</artifactId>
+                       <version>${junit.jupiter.version}</version>
+               </dependency>
+               <!-- use Junit 4 within Junit 5 -->
+               <dependency>
+                       <groupId>org.junit.vintage</groupId>
+                       <artifactId>junit-vintage-engine</artifactId>
+                       <version>${junit.jupiter.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.platform</groupId>
+                       <artifactId>junit-platform-runner</artifactId>
+                       <version>${junit.platform}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.junit.platform</groupId>
+                       <artifactId>junit-platform-launcher</artifactId>
+                       <version>${junit.platform}</version>
+               </dependency>
+
+               <!-- Needed if testing with YAAFI -->
+               <dependency>
+                       <groupId>org.apache.fulcrum</groupId>
+                       <artifactId>fulcrum-yaafi</artifactId>
+                       <version>1.0.8</version>
+                       <optional>true</optional>
+               </dependency>
+               <dependency>
+                       <groupId>javax.servlet</groupId>
+                       <artifactId>javax.servlet-api</artifactId>
+                       <version>3.1.0</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <version>2.28.2</version>
+               </dependency>
+               <!-- Needed if testing with ECM -->
+               <dependency>
+                       <groupId>org.apache.excalibur.component</groupId>
+                       <artifactId>excalibur-component</artifactId>
+                       <version>2.2.1</version>
+                       <type>jar</type>
+                       <optional>true</optional>
+               </dependency>
+               <!-- Log4j2 may be better used by default -->
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-api</artifactId>
+                       <version>${turbine.log4j2.version}</version>
+                       <optional>true</optional>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-core</artifactId>
+                       <version>${turbine.log4j2.version}</version>
+                       <optional>true</optional>
+               </dependency>
+               <!-- log4j1.2 bridge instead of log4j -->
+               <dependency>
+                       <groupId>org.apache.logging.log4j</groupId>
+                       <artifactId>log4j-1.2-api</artifactId>
+                       <version>${turbine.log4j2.version}</version>
+                       <optional>true</optional>
+               </dependency>
+
+       </dependencies>
+
+       <build>
+               <sourceDirectory>${basedir}/src/java</sourceDirectory>
+               <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
+               <testResources>
+                       <testResource>
+                               <directory>${basedir}/src/test</directory>
+                               <includes>
+                                       <include>*.xml</include>
+                               </includes>
+                       </testResource>
+               </testResources>
+               <plugins>
+                       <plugin>
+                               <!-- JUnit 5 requires Surefire version 2.22.0 
or higher -->
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <configuration>
+                                       <!-- setting the default: 
forkCount=1/reuseForks=true -->
+                                       <forkCount>1</forkCount>
+                                       <!-- setting this to false (highest 
isolation: each test class has its 
+                                               own jvm process) let maven test 
ignore all tests? -->
+                                       <reuseForks>true</reuseForks>
+                               </configuration>
+                               <dependencies>
+                                       <!-- need no 
junit-platform-surefire-provider dependency -->
+                               </dependencies>
+                       </plugin>
+               </plugins>
+       </build>
 
-  <properties>
-
-    <turbine.site.path>fulcrum/fulcrum-testcontainer</turbine.site.path>
-    
<turbine.scmPubCheckoutDirectory>${turbine.site.cache}/fulcrum/testcontainer</turbine.scmPubCheckoutDirectory>
-
-    <junit.jupiter.version>5.5.1</junit.jupiter.version>
-    <junit.platform>1.5.1</junit.platform>
-    <!--junit.platform>1.3.2</junit.platform-->
-    
<!--turbine.site.cache>${project.build.directory}/turbine-sites</turbine.site.cache-->
-  </properties>
+       <properties>
+               
<turbine.site.path>fulcrum/fulcrum-testcontainer</turbine.site.path>
+               
<turbine.scmPubCheckoutDirectory>${turbine.site.cache}/fulcrum/testcontainer</turbine.scmPubCheckoutDirectory>
+               <junit.jupiter.version>5.5.2</junit.jupiter.version>
+               <junit.platform>1.5.2</junit.platform>
+       </properties>
 
 </project>

Modified: turbine/fulcrum/trunk/testcontainer/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/changes/changes.xml?rev=1867084&r1=1867083&r2=1867084&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/changes/changes.xml (original)
+++ turbine/fulcrum/trunk/testcontainer/src/changes/changes.xml Wed Sep 18 
01:25:12 2019
@@ -25,6 +25,9 @@
   </properties>
   <body>
     <release version="1.0.9" date="in SVN">
+       <action type="update" dev="painter">
+        Update junit and jupiter dependencies, source cleanup for Turbine 
compliance
+      </action>  
     </release>
     <release version="1.0.8" date="2019-01-06">
        <action type="update" dev="painter">

Modified: 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java?rev=1867084&r1=1867083&r2=1867084&view=diff
==============================================================================
--- 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
 (original)
+++ 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
 Wed Sep 18 01:25:12 2019
@@ -1,20 +1,5 @@
 package org.apache.fulcrum.testcontainer;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -33,6 +18,22 @@ import javax.servlet.http.HttpSession;
  * specific language governing permissions and limitations
  * under the License.
  */
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
 import org.apache.avalon.framework.component.ComponentException;
 import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.junit.After;
@@ -40,260 +41,258 @@ import org.mockito.invocation.Invocation
 import org.mockito.stubbing.Answer;
 
 /**
- * Alternative Base class to {@link BaseUnitTest} for component tests. 
+ * Alternative Base class to {@link BaseUnitTest} for component tests.
  * 
- * This version doesn't load the container until the
- * first request for a component. This allows the tester to populate the 
configurationFileName and
+ * This version doesn't load the container until the first request for a
+ * component. This allows the tester to populate the configurationFileName and
  * roleFileName, possible one per test.
  * 
  * JUnit 4 Version of BaseUnitTest class.
  * 
- * @see BaseUnitTest 
+ * @see BaseUnitTest
  *
  * @author <a href="mailto:[email protected]";>Eric Pugh</a>
  * @author <a href="mailto:[email protected]";>Quinton McCombs</a>
  * @version $Id$
  */
 
-public class BaseUnit4Test
-{
-    public static final String CONTAINER_ECM = "CONTAINER_ECM";
-    public static final String CONTAINER_YAAFI = "CONTAINER_YAAFI";
-
-    /** Key used in the context for defining the application root */
-    public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
-
-    /** Pick the default container to be YAAFI **/
-    private String containerType = CONTAINER_YAAFI;
-
-    /** Use INFO for ConsoleLogger */
-    public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
-
-    /** Container for the components */
-    private Container container;
-
-    /** Setup our default configurationFileName */
-    private String configurationFileName = "src/test/TestComponentConfig.xml";
-
-    /** Setup our default roleFileName */
-    private String roleFileName = "src/test/TestRoleConfig.xml";
-
-    /** Setup our default parameterFileName */
-    private String parameterFileName = null;
-
-    /** Set the log level (only works for YAAFI container) */
-    private int logLevel = defaultLogLevel;
-
-    /** Hash map to store attributes for the test **/
-    public Map<String,Object> attributes = new HashMap<String,Object>();
-    
-    /** set the Max inactive interval **/
-    public int maxInactiveInterval = 0;
-    
-    /**
-     * Gets the configuration file name for the container should use for this 
test. By default it
-     * is src/test/TestComponentConfig.
-     * 
-     * @param configurationFileName the location of the config file
-     */
-    protected void setConfigurationFileName(String configurationFileName)
-    {
-        this.configurationFileName = configurationFileName;
-    }
-
-    /**
-     * Override the role file name for the container should use for this test. 
By default it is
-     * src/test/TestRoleConfig.
-     * 
-     * @param roleFileName location of the role file
-     */
-    protected void setRoleFileName(String roleFileName)
-    {
-        this.roleFileName = roleFileName;
-    }
-
-    /**
-     * Set the console logger level
-     * 
-     * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
-     * @param logLevel set valid logging level
-     */
-    protected void setLogLevel(int logLevel) {
-        this.logLevel = logLevel;
-    }
-
-    /**
-     * Constructor for test.
-     */
-    public BaseUnit4Test()
-    {
-    }
-
-    /**
-     * Clean up after each test is run.
-     */
-    @After
-    public void tearDown()
-    {
-        if (container != null)
-        {
-            container.dispose();
-        }
-        container = null;
-    }
-
-    /**
-     * Gets the configuration file name for the container should use for this 
test.
-     *
-     * @return The filename of the configuration file
-     */
-    protected String getConfigurationFileName()
-    {
-        return configurationFileName;
-    }
-
-    /**
-     * Gets the role file name for the container should use for this test.
-     *
-     * @return The filename of the role configuration file
-     */
-    protected String getRoleFileName()
-    {
-        return roleFileName;
-    }
-
-    /**
-     * Gets the parameter file name for the container should use for this test.
-     *
-     * @return The filename of the role configuration file
-     */
-    protected String getParameterFileName()
-    {
-        return parameterFileName;
-    }
-
-    /**
-     * Returns an instance of the named component. 
-     * This method will also start the container if it
-     * has not been started already
-     *
-     * @param roleName Name of the role the component fills.
-     * @return instance of the component
-     * @throws ComponentException generic exception
-     */
-    protected Object lookup(String roleName) throws ComponentException
-    {
-        if (container == null)
-        {
-            if(containerType.equals(CONTAINER_ECM)){
-                container = new ECMContainer();
-            }
-            else {
-                container = new YAAFIContainer(logLevel);
-            }
-            container.startup(getConfigurationFileName(), 
getRoleFileName(),getParameterFileName());
-        }
-        return container.lookup(roleName);
-    }
-
-    /**
-     * Releases the component.
-     *
-     * @param component component to be released
-     */
-    protected void release(Object component)
-    {
-        if (container != null)
-        {
-            container.release(component);
-        }
-    }
-    
-
-    /**
-     * Get a mock requestion 
-     *
-     * @return HttpServletRequest a mock servlet request
-     */
-    protected HttpServletRequest getMockRequest()
-    {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        HttpSession session = mock(HttpSession.class);
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                String key = (String) invocation.getArguments()[0];
-                return attributes.get(key);
-            }
-        }).when(session).getAttribute(anyString());
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                String key = (String) invocation.getArguments()[0];
-                Object value = invocation.getArguments()[1];
-                attributes.put(key, value);
-                return null;
-            }
-        }).when(session).setAttribute(anyString(), any());
-
-        when(session.getMaxInactiveInterval()).thenReturn(maxInactiveInterval);
-
-        doAnswer(new Answer<Integer>()
-        {
-            @Override
-            public Integer answer(InvocationOnMock invocation) throws Throwable
-            {
-                return Integer.valueOf(maxInactiveInterval);
-            }
-        }).when(session).getMaxInactiveInterval();
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                Integer value = (Integer) invocation.getArguments()[0];
-                maxInactiveInterval = value.intValue();
-                return null;
-            }
-        }).when(session).setMaxInactiveInterval(anyInt());
-
-        when(session.isNew()).thenReturn(true);
-        when(request.getSession()).thenReturn(session);
-
-        when(request.getServerName()).thenReturn("bob");
-        when(request.getProtocol()).thenReturn("http");
-        when(request.getScheme()).thenReturn("scheme");
-        when(request.getPathInfo()).thenReturn("damn");
-        when(request.getServletPath()).thenReturn("damn2");
-        when(request.getContextPath()).thenReturn("wow");
-        when(request.getContentType()).thenReturn("text/html");
-
-        when(request.getCharacterEncoding()).thenReturn("US-ASCII");
-        when(request.getServerPort()).thenReturn(8080);
-        when(request.getLocale()).thenReturn(Locale.US);
-
-        when(request.getHeader("Content-type")).thenReturn("text/html");
-        when(request.getHeader("Accept-Language")).thenReturn("en-US");
-
-        Vector<String> v = new Vector<String>();
-        when(request.getParameterNames()).thenReturn(v.elements());
-        return request;
-    }
-
-    public String getContainerType()
-    {
-        return containerType;
-    }
-
-    public void setContainerType( String containerType )
-    {
-        this.containerType = containerType;
-    }
+public class BaseUnit4Test {
+       public static final String CONTAINER_ECM = "CONTAINER_ECM";
+       public static final String CONTAINER_YAAFI = "CONTAINER_YAAFI";
+
+       /** Key used in the context for defining the application root */
+       public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
+
+       /** Pick the default container to be YAAFI **/
+       private String containerType = CONTAINER_YAAFI;
+
+       /** Use INFO for ConsoleLogger */
+       public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
+
+       /** Container for the components */
+       private Container container;
+
+       /** Setup our default configurationFileName */
+       private String configurationFileName = 
"src/test/TestComponentConfig.xml";
+
+       /** Setup our default roleFileName */
+       private String roleFileName = "src/test/TestRoleConfig.xml";
+
+       /** Setup our default parameterFileName */
+       private String parameterFileName = null;
+
+       /** Set the log level (only works for YAAFI container) */
+       private int logLevel = defaultLogLevel;
+
+       /** Hash map to store attributes for the test **/
+       public Map<String, Object> attributes = new HashMap<String, Object>();
+
+       /** set the Max inactive interval **/
+       public int maxInactiveInterval = 0;
+
+       /**
+        * Gets the configuration file name for the container should use for 
this test.
+        * By default it is src/test/TestComponentConfig.
+        * 
+        * @param configurationFileName the location of the config file
+        */
+       protected void setConfigurationFileName(String configurationFileName) 
+       {
+               this.configurationFileName = configurationFileName;
+       }
+
+       /**
+        * Override the role file name for the container should use for this 
test. By
+        * default it is src/test/TestRoleConfig.
+        * 
+        * @param roleFileName location of the role file
+        */
+       protected void setRoleFileName(String roleFileName) 
+       {
+               this.roleFileName = roleFileName;
+       }
+
+       /**
+        * Set the console logger level
+        * 
+        * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
+        * @param logLevel set valid logging level
+        */
+       protected void setLogLevel(int logLevel) 
+       {
+               this.logLevel = logLevel;
+       }
+
+       /**
+        * Constructor for test.
+        */
+       public BaseUnit4Test() 
+       {
+       }
+
+       /**
+        * Clean up after each test is run.
+        */
+       @After
+       public void tearDown() 
+       {
+               if (container != null) {
+                       container.dispose();
+               }
+               container = null;
+       }
+
+       /**
+        * Gets the configuration file name for the container should use for 
this test.
+        *
+        * @return The filename of the configuration file
+        */
+       protected String getConfigurationFileName() 
+       {
+               return configurationFileName;
+       }
+
+       /**
+        * Gets the role file name for the container should use for this test.
+        *
+        * @return The filename of the role configuration file
+        */
+       protected String getRoleFileName() 
+       {
+               return roleFileName;
+       }
+
+       /**
+        * Gets the parameter file name for the container should use for this 
test.
+        *
+        * @return The filename of the role configuration file
+        */
+       protected String getParameterFileName() 
+       {
+               return parameterFileName;
+       }
+
+       /**
+        * Returns an instance of the named component. This method will also 
start the
+        * container if it has not been started already
+        *
+        * @param roleName Name of the role the component fills.
+        * @return instance of the component
+        * @throws ComponentException generic exception
+        */
+       protected Object lookup(String roleName) throws ComponentException 
+       {
+               if (container == null) 
+               {
+                       if (containerType.equals(CONTAINER_ECM)) 
+                       {
+                               container = new ECMContainer();
+                       } 
+                       else 
+                       {
+                               container = new YAAFIContainer(logLevel);
+                       }
+                       container.startup(getConfigurationFileName(), 
getRoleFileName(), getParameterFileName());
+               }
+               return container.lookup(roleName);
+       }
+
+       /**
+        * Releases the component.
+        *
+        * @param component component to be released
+        */
+       protected void release(Object component) 
+       {
+               if (container != null) 
+               {
+                       container.release(component);
+               }
+       }
+
+       /**
+        * Get a mock requestion
+        *
+        * @return HttpServletRequest a mock servlet request
+        */
+       protected HttpServletRequest getMockRequest() 
+       {
+               HttpServletRequest request = mock(HttpServletRequest.class);
+               HttpSession session = mock(HttpSession.class);
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable 
+                       {
+                               String key = (String) 
invocation.getArguments()[0];
+                               return attributes.get(key);
+                       }
+               }).when(session).getAttribute(anyString());
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable 
+                       {
+                               String key = (String) 
invocation.getArguments()[0];
+                               Object value = invocation.getArguments()[1];
+                               attributes.put(key, value);
+                               return null;
+                       }
+               }).when(session).setAttribute(anyString(), any());
+
+               
when(session.getMaxInactiveInterval()).thenReturn(maxInactiveInterval);
+
+               doAnswer(new Answer<Integer>() 
+               {
+                       @Override
+                       public Integer answer(InvocationOnMock invocation) 
throws Throwable {
+                               return Integer.valueOf(maxInactiveInterval);
+                       }
+               }).when(session).getMaxInactiveInterval();
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable 
+                       {
+                               Integer value = (Integer) 
invocation.getArguments()[0];
+                               maxInactiveInterval = value.intValue();
+                               return null;
+                       }
+               }).when(session).setMaxInactiveInterval(anyInt());
+
+               when(session.isNew()).thenReturn(true);
+               when(request.getSession()).thenReturn(session);
+
+               when(request.getServerName()).thenReturn("bob");
+               when(request.getProtocol()).thenReturn("http");
+               when(request.getScheme()).thenReturn("scheme");
+               when(request.getPathInfo()).thenReturn("damn");
+               when(request.getServletPath()).thenReturn("damn2");
+               when(request.getContextPath()).thenReturn("wow");
+               when(request.getContentType()).thenReturn("text/html");
+
+               when(request.getCharacterEncoding()).thenReturn("US-ASCII");
+               when(request.getServerPort()).thenReturn(8080);
+               when(request.getLocale()).thenReturn(Locale.US);
+
+               when(request.getHeader("Content-type")).thenReturn("text/html");
+               when(request.getHeader("Accept-Language")).thenReturn("en-US");
+
+               Vector<String> v = new Vector<String>();
+               when(request.getParameterNames()).thenReturn(v.elements());
+               return request;
+       }
+
+       public String getContainerType() 
+       {
+               return containerType;
+       }
+
+       public void setContainerType(String containerType) 
+       {
+               this.containerType = containerType;
+       }
 }

Modified: 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit5Test.java
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit5Test.java?rev=1867084&r1=1867083&r2=1867084&view=diff
==============================================================================
--- 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit5Test.java
 (original)
+++ 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit5Test.java
 Wed Sep 18 01:25:12 2019
@@ -1,5 +1,24 @@
 package org.apache.fulcrum.testcontainer;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -17,286 +36,266 @@ import javax.servlet.http.HttpSession;
 
 import org.apache.avalon.framework.component.ComponentException;
 import org.apache.avalon.framework.logger.ConsoleLogger;
-// import static org.junit.jupiter.api.Assertions.*;
 import org.junit.jupiter.api.AfterEach;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
 /**
- * Alternative Base class to {@link BaseUnit4Test} for component tests. 
+ * Alternative Base class to {@link BaseUnit4Test} for component tests.
  * 
- * This version doesn't load the container until the
- * first request for a component. This allows the tester to populate the 
configurationFileName and
+ * This version doesn't load the container until the first request for a
+ * component. This allows the tester to populate the configurationFileName and
  * roleFileName, possible one per test.
  * 
  * JUnit 5 Version of BaseUnitTest class.
  * 
- * @see BaseUnit4Test 
+ * @see BaseUnit4Test
  *
  * @author <a href="mailto:[email protected]";>Eric Pugh</a>
  * @author <a href="mailto:[email protected]";>Quinton McCombs</a>
  * @version $Id$
  */
-public class BaseUnit5Test
-{
-    public static final String CONTAINER_ECM = "CONTAINER_ECM";
-    public static final String CONTAINER_YAAFI = "CONTAINER_YAAFI";
-
-    /** Key used in the context for defining the application root */
-    public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
-
-    /** Pick the default container to be YAAFI, running in **/
-    private String containerType = CONTAINER_YAAFI;
-
-    /** Use INFO for ConsoleLogger */
-    public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
-
-    /** Container for the components */
-    private Container container;
-
-    /** Setup our default configurationFileName */
-    private String configurationFileName = "src/test/TestComponentConfig.xml";
-
-    /** Setup our default roleFileName */
-    private String roleFileName = "src/test/TestRoleConfig.xml";
-
-    /** Setup our default parameterFileName */
-    private String parameterFileName = null;
-
-    /** Set the log level (only works for YAAFI container) */
-    private int logLevel = defaultLogLevel;
-
-    /** Hash map to store attributes for the test **/
-    public Map<String,Object> attributes = new HashMap<String,Object>();
-    
-    /** set the Max inactive interval **/
-    public int maxInactiveInterval = 0;
-    
-    /**
-     * Gets the configuration file name for the container should use for this 
test. By default it
-     * is src/test/TestComponentConfig.
-     * 
-     * @param configurationFileName the location of the config file
-     */
-    protected void setConfigurationFileName(String configurationFileName)
-    {
-        this.configurationFileName = configurationFileName;
-    }
-
-    /**
-     * Override the role file name for the container should use for this test. 
By default it is
-     * src/test/TestRoleConfig.
-     * 
-     * @param roleFileName location of the role file
-     */
-    protected void setRoleFileName(String roleFileName)
-    {
-        this.roleFileName = roleFileName;
-    }
-
-    /**
-     * Set the console logger level
-     * 
-     * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
-     * @param logLevel set valid logging level
-     */
-    protected void setLogLevel(int logLevel) {
-        this.logLevel = logLevel;
-    }
-
-    /**
-     * Constructor for test.
-     */
-    public BaseUnit5Test()
-    {
-    }
-
-    /**
-     * Clean up after each test is run.
-     */
-    @AfterEach
-    public void tearDown()
-    {
-        if (container != null)
-        {
-            container.dispose();
-        }
-        container = null;
-    }
-
-    /**
-     * Gets the configuration file name for the container should use for this 
test.
-     *
-     * @return The filename of the configuration file
-     */
-    protected String getConfigurationFileName()
-    {
-        return configurationFileName;
-    }
-
-    /**
-     * Gets the role file name for the container should use for this test.
-     *
-     * @return The filename of the role configuration file
-     */
-    protected String getRoleFileName()
-    {
-        return roleFileName;
-    }
-
-    /**
-     * Gets the parameter file name for the container should use for this test.
-     *
-     * @return The filename of the role configuration file
-     */
-    protected String getParameterFileName()
-    {
-        return parameterFileName;
-    }
-
-    /**
-     * Returns an instance of the named component. 
-     * This method will also start the container if it
-     * has not been started already
-     *
-     * @param roleName Name of the role the component fills.
-     * @return instance of the component
-     * @throws ComponentException generic exception
-     */
-    protected Object lookup(String roleName) throws ComponentException
-    {
-        if (container == null)
-        {
-            if(containerType.equals(CONTAINER_ECM)){
-                container = new ECMContainer();
-            }
-            else {
-                container = new YAAFIContainer(logLevel);
-                //((LogEnabled)container).enableLogging(new 
Log4JLogger(LogManager.getLogger("avalon")));
-            }
-            container.startup(getConfigurationFileName(), 
getRoleFileName(),getParameterFileName());
-        }
-        return container.lookup(roleName);
-    }
-
-    /**
-     * Releases the component.
-     *
-     * @param component component to be released
-     */
-    protected void release(Object component)
-    {
-        if (container != null)
-        {
-            container.release(component);
-        }
-    }
-    
-
-    /**
-     * Get a mock requestion 
-     *
-     * @return HttpServletRequest a mock servlet request
-     */
-    protected HttpServletRequest getMockRequest()
-    {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        HttpSession session = mock(HttpSession.class);
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                String key = (String) invocation.getArguments()[0];
-                return attributes.get(key);
-            }
-        }).when(session).getAttribute(anyString());
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                String key = (String) invocation.getArguments()[0];
-                Object value = invocation.getArguments()[1];
-                attributes.put(key, value);
-                return null;
-            }
-        }).when(session).setAttribute(anyString(), any());
-
-        when(session.getMaxInactiveInterval()).thenReturn(maxInactiveInterval);
-
-        doAnswer(new Answer<Integer>()
-        {
-            @Override
-            public Integer answer(InvocationOnMock invocation) throws Throwable
-            {
-                return Integer.valueOf(maxInactiveInterval);
-            }
-        }).when(session).getMaxInactiveInterval();
-
-        doAnswer(new Answer<Object>()
-        {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                Integer value = (Integer) invocation.getArguments()[0];
-                maxInactiveInterval = value.intValue();
-                return null;
-            }
-        }).when(session).setMaxInactiveInterval(anyInt());
-
-        when(session.isNew()).thenReturn(true);
-        when(request.getSession()).thenReturn(session);
-
-        when(request.getServerName()).thenReturn("bob");
-        when(request.getProtocol()).thenReturn("http");
-        when(request.getScheme()).thenReturn("scheme");
-        when(request.getPathInfo()).thenReturn("damn");
-        when(request.getServletPath()).thenReturn("damn2");
-        when(request.getContextPath()).thenReturn("wow");
-        when(request.getContentType()).thenReturn("text/html");
-
-        when(request.getCharacterEncoding()).thenReturn("US-ASCII");
-        when(request.getServerPort()).thenReturn(8080);
-        when(request.getLocale()).thenReturn(Locale.US);
-
-        when(request.getHeader("Content-type")).thenReturn("text/html");
-        when(request.getHeader("Accept-Language")).thenReturn("en-US");
-
-        Vector<String> v = new Vector<String>();
-        when(request.getParameterNames()).thenReturn(v.elements());
-        return request;
-    }
-
-    public String getContainerType()
-    {
-        return containerType;
-    }
-
-    public void setContainerType( String containerType )
-    {
-        this.containerType = containerType;
-    }
+public class BaseUnit5Test {
+       public static final String CONTAINER_ECM = "CONTAINER_ECM";
+       public static final String CONTAINER_YAAFI = "CONTAINER_YAAFI";
+
+       /** Key used in the context for defining the application root */
+       public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
+
+       /** Pick the default container to be YAAFI, running in **/
+       private String containerType = CONTAINER_YAAFI;
+
+       /** Use INFO for ConsoleLogger */
+       public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
+
+       /** Container for the components */
+       private Container container;
+
+       /** Setup our default configurationFileName */
+       private String configurationFileName = 
"src/test/TestComponentConfig.xml";
+
+       /** Setup our default roleFileName */
+       private String roleFileName = "src/test/TestRoleConfig.xml";
+
+       /** Setup our default parameterFileName */
+       private String parameterFileName = null;
+
+       /** Set the log level (only works for YAAFI container) */
+       private int logLevel = defaultLogLevel;
+
+       /** Hash map to store attributes for the test **/
+       public Map<String, Object> attributes = new HashMap<String, Object>();
+
+       /** set the Max inactive interval **/
+       public int maxInactiveInterval = 0;
+
+       /**
+        * Gets the configuration file name for the container should use for 
this test.
+        * By default it is src/test/TestComponentConfig.
+        * 
+        * @param configurationFileName the location of the config file
+        */
+       protected void setConfigurationFileName(String configurationFileName) 
+       {
+               this.configurationFileName = configurationFileName;
+       }
+
+       /**
+        * Override the role file name for the container should use for this 
test. By
+        * default it is src/test/TestRoleConfig.
+        * 
+        * @param roleFileName location of the role file
+        */
+       protected void setRoleFileName(String roleFileName) 
+       {
+               this.roleFileName = roleFileName;
+       }
+
+       /**
+        * Set the console logger level
+        * 
+        * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
+        * @param logLevel set valid logging level
+        */
+       protected void setLogLevel(int logLevel) 
+       {
+               this.logLevel = logLevel;
+       }
+
+       /**
+        * Constructor for test.
+        */
+       public BaseUnit5Test() 
+       {
+       }
+
+       /**
+        * Clean up after each test is run.
+        */
+       @AfterEach
+       public void tearDown() 
+       {
+               if (container != null) 
+               {
+                       container.dispose();
+               }
+               container = null;
+       }
+
+       /**
+        * Gets the configuration file name for the container should use for 
this test.
+        *
+        * @return The filename of the configuration file
+        */
+       protected String getConfigurationFileName() 
+       {
+               return configurationFileName;
+       }
+
+       /**
+        * Gets the role file name for the container should use for this test.
+        *
+        * @return The filename of the role configuration file
+        */
+       protected String getRoleFileName() 
+       {
+               return roleFileName;
+       }
+
+       /**
+        * Gets the parameter file name for the container should use for this 
test.
+        *
+        * @return The filename of the role configuration file
+        */
+       protected String getParameterFileName() 
+       {
+               return parameterFileName;
+       }
+
+       /**
+        * Returns an instance of the named component. This method will also 
start the
+        * container if it has not been started already
+        *
+        * @param roleName Name of the role the component fills.
+        * @return instance of the component
+        * @throws ComponentException generic exception
+        */
+       protected Object lookup(String roleName) throws ComponentException 
+       {
+               if (container == null) 
+               {
+                       if (containerType.equals(CONTAINER_ECM)) 
+                       {
+                               container = new ECMContainer();
+                       } 
+                       else 
+                       {
+                               container = new YAAFIContainer(logLevel);
+                       }
+                       container.startup(getConfigurationFileName(), 
getRoleFileName(), getParameterFileName());
+               }
+               return container.lookup(roleName);
+       }
+
+       /**
+        * Releases the component.
+        *
+        * @param component component to be released
+        */
+       protected void release(Object component) 
+       {
+               if (container != null) 
+               {
+                       container.release(component);
+               }
+       }
+
+       /**
+        * Get a mock requestion
+        *
+        * @return HttpServletRequest a mock servlet request
+        */
+       protected HttpServletRequest getMockRequest() 
+       {
+               HttpServletRequest request = mock(HttpServletRequest.class);
+               HttpSession session = mock(HttpSession.class);
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable {
+                               String key = (String) 
invocation.getArguments()[0];
+                               return attributes.get(key);
+                       }
+               }).when(session).getAttribute(anyString());
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable {
+                               String key = (String) 
invocation.getArguments()[0];
+                               Object value = invocation.getArguments()[1];
+                               attributes.put(key, value);
+                               return null;
+                       }
+               }).when(session).setAttribute(anyString(), any());
+
+               
when(session.getMaxInactiveInterval()).thenReturn(maxInactiveInterval);
+
+               doAnswer(new Answer<Integer>() 
+               {
+                       @Override
+                       public Integer answer(InvocationOnMock invocation) 
throws Throwable {
+                               return Integer.valueOf(maxInactiveInterval);
+                       }
+               }).when(session).getMaxInactiveInterval();
+
+               doAnswer(new Answer<Object>() 
+               {
+                       @Override
+                       public Object answer(InvocationOnMock invocation) 
throws Throwable {
+                               Integer value = (Integer) 
invocation.getArguments()[0];
+                               maxInactiveInterval = value.intValue();
+                               return null;
+                       }
+               }).when(session).setMaxInactiveInterval(anyInt());
+
+               when(session.isNew()).thenReturn(true);
+               when(request.getSession()).thenReturn(session);
+
+               when(request.getServerName()).thenReturn("bob");
+               when(request.getProtocol()).thenReturn("http");
+               when(request.getScheme()).thenReturn("scheme");
+               when(request.getPathInfo()).thenReturn("damn");
+               when(request.getServletPath()).thenReturn("damn2");
+               when(request.getContextPath()).thenReturn("wow");
+               when(request.getContentType()).thenReturn("text/html");
+
+               when(request.getCharacterEncoding()).thenReturn("US-ASCII");
+               when(request.getServerPort()).thenReturn(8080);
+               when(request.getLocale()).thenReturn(Locale.US);
+
+               when(request.getHeader("Content-type")).thenReturn("text/html");
+               when(request.getHeader("Accept-Language")).thenReturn("en-US");
+
+               Vector<String> v = new Vector<String>();
+               when(request.getParameterNames()).thenReturn(v.elements());
+               return request;
+       }
+
+       /**
+        * @return the container type
+        */
+       public String getContainerType() 
+       {
+               return containerType;
+       }
+
+       /**
+        * @param containerType container type to set
+        */
+       public void setContainerType(String containerType) 
+       {
+               this.containerType = containerType;
+       }
 }

Modified: 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
URL: 
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java?rev=1867084&r1=1867083&r2=1867084&view=diff
==============================================================================
--- 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
 (original)
+++ 
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
 Wed Sep 18 01:25:12 2019
@@ -1,4 +1,5 @@
 package org.apache.fulcrum.testcontainer;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,15 +18,16 @@ package org.apache.fulcrum.testcontainer
  * specific language governing permissions and limitations
  * under the License.
  */
-import junit.framework.TestCase;
 
 import org.apache.avalon.framework.component.ComponentException;
 import org.apache.avalon.framework.logger.ConsoleLogger;
 
+import junit.framework.TestCase;
+
 /**
- * Base class for unit tests for components. This version doesn't load the 
container until the
- * first request for a component. This allows the tester to populate the 
configurationFileName and
- * roleFileName, possible one per test.
+ * Base class for unit tests for components. This version doesn't load the
+ * container until the first request for a component. This allows the tester to
+ * populate the configurationFileName and roleFileName, possible one per test.
  * 
  * This class uses JUnit 3.
  * 
@@ -35,164 +37,165 @@ import org.apache.avalon.framework.logge
  * @author <a href="mailto:[email protected]";>Quinton McCombs</a>
  * @version $Id$
  */
-public class BaseUnitTest extends TestCase
-{
-    public static final String CONTAINER_ECM="CONTAINER_ECM";
-    public static final String CONTAINER_YAAFI="CONTAINER_YAAFI";
-
-    /** Key used in the context for defining the application root */
-    public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
-
-    /** Pick the default container to be Yaafi **/
-    public static final String containerType = CONTAINER_YAAFI;
-
-    /** Use INFO for ConsoleLogger */
-    public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
-
-    /** Container for the components */
-    private Container container;
-    
-    /** Setup our default configurationFileName */
-    private String configurationFileName = "src/test/TestComponentConfig.xml";
-    
-    /** Setup our default roleFileName */
-    private String roleFileName = "src/test/TestRoleConfig.xml";
-    
-    /** Setup our default parameterFileName */
-    private String parameterFileName = null;
-    
-    /** Set the log level (only works for YAAFI container) */
-    private int logLevel = defaultLogLevel;
-
-    /**
-        * Gets the configuration file name for the container should use for 
this test. By default it
-        * is src/test/TestComponentConfig.
+public class BaseUnitTest extends TestCase {
+       public static final String CONTAINER_ECM = "CONTAINER_ECM";
+       public static final String CONTAINER_YAAFI = "CONTAINER_YAAFI";
+
+       /** Key used in the context for defining the application root */
+       public static final String COMPONENT_APP_ROOT = 
Container.COMPONENT_APP_ROOT;
+
+       /** Pick the default container to be Yaafi **/
+       public static final String containerType = CONTAINER_YAAFI;
+
+       /** Use INFO for ConsoleLogger */
+       public static final int defaultLogLevel = ConsoleLogger.LEVEL_INFO;
+
+       /** Container for the components */
+       private Container container;
+
+       /** Setup our default configurationFileName */
+       private String configurationFileName = 
"src/test/TestComponentConfig.xml";
+
+       /** Setup our default roleFileName */
+       private String roleFileName = "src/test/TestRoleConfig.xml";
+
+       /** Setup our default parameterFileName */
+       private String parameterFileName = null;
+
+       /** Set the log level (only works for YAAFI container) */
+       private int logLevel = defaultLogLevel;
+
+       /**
+        * Gets the configuration file name for the container should use for 
this test.
+        * By default it is src/test/TestComponentConfig.
+        * 
         * @param configurationFileName the location of the config file
         */
-    protected void setConfigurationFileName(String configurationFileName)
-    {
-        this.configurationFileName = configurationFileName;
-    }
-
-    /**
-        * Override the role file name for the container should use for this 
test. By default it is
-        * src/test/TestRoleConfig.
+       protected void setConfigurationFileName(String configurationFileName) 
+       {
+               this.configurationFileName = configurationFileName;
+       }
+
+       /**
+        * Override the role file name for the container should use for this 
test. By
+        * default it is src/test/TestRoleConfig.
         * 
         * @param roleFileName location of the role file
         */
-    protected void setRoleFileName(String roleFileName)
-    {
-        this.roleFileName = roleFileName;
-    }
-
-    /**
-     * Set the console logger level
-     * 
-     * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
-     * @param logLevel set valid logging level
-     */
-    protected void setLogLevel(int logLevel) {
-        this.logLevel = logLevel;
-    }
+       protected void setRoleFileName(String roleFileName) 
+       {
+               this.roleFileName = roleFileName;
+       }
+
+       /**
+        * Set the console logger level
+        * 
+        * @see org.apache.avalon.framework.logger.ConsoleLogger for debugging 
levels
+        * @param logLevel set valid logging level
+        */
+       protected void setLogLevel(int logLevel) 
+       {
+               this.logLevel = logLevel;
+       }
 
-    /**
+       /**
         * Constructor for test.
         *
         * @param testName name of the test being executed
         */
-    public BaseUnitTest(String testName)
-    {
-        super(testName);
-    }
+       public BaseUnitTest(String testName) 
+       {
+               super(testName);
+       }
 
-    /**
+       /**
         * Clean up after each test is run.
         */
-    protected void tearDown()
-    {
-        if (container != null)
-        {
-            container.dispose();
-        }
-        container = null;
-    }
+       protected void tearDown() 
+       {
+               if (container != null) 
+               {
+                       container.dispose();
+               }
+               container = null;
+       }
 
-    /**
+       /**
         * Gets the configuration file name for the container should use for 
this test.
         *
         * @return The filename of the configuration file
         */
-    protected String getConfigurationFileName()
-    {
-        return configurationFileName;
-    }
+       protected String getConfigurationFileName() 
+       {
+               return configurationFileName;
+       }
 
-    /**
+       /**
         * Gets the role file name for the container should use for this test.
         *
         * @return The filename of the role configuration file
         */
-    protected String getRoleFileName()
-    {
-        return roleFileName;
-    }
-
-    /**
-     * Gets the parameter file name for the container should use for this test.
-     *
-     * @return The filename of the role configuration file
-     */
-    protected String getParameterFileName()
-    {
-        return parameterFileName;
-    }
-
-    /**
-     * Returns an instance of the named component. 
-     * This method will also start the container if it
-     * has not been started already
-     *
-     * @param roleName Name of the role the component fills.
-     * @return instance of the component
-     * @throws ComponentException generic exception
-        */
-    protected Object lookup(String roleName) throws ComponentException
-    {
-        if (container == null)
-        {
-            if(containerType.equals(CONTAINER_ECM)){
-                container = new ECMContainer();
-            }
-            else {
-                container = new YAAFIContainer(logLevel);
-            }
-            container.startup(getConfigurationFileName(), 
getRoleFileName(),getParameterFileName());
-        }
-        return container.lookup(roleName);
-    }
-
-    /**
-     * Helper method for converting to and from Merlin Unit TestCase.
-     * 
-     * @param roleName the role name to resolve
-     * @return the component matching the role
-     * @throws ComponentException generic exception
-     */
-    protected Object resolve(String roleName) throws ComponentException
-    {
-        return lookup(roleName);
-    }
-
-    /**
-     * Releases the component.
-     *
-     * @param component component to be released
-     */
-    protected void release(Object component)
-    {
-        if (container != null)
-        {
-            container.release(component);
-        }
-    }
+       protected String getRoleFileName() 
+       {
+               return roleFileName;
+       }
+
+       /**
+        * Gets the parameter file name for the container should use for this 
test.
+        *
+        * @return The filename of the role configuration file
+        */
+       protected String getParameterFileName() 
+       {
+               return parameterFileName;
+       }
+
+       /**
+        * Returns an instance of the named component. This method will also 
start the
+        * container if it has not been started already
+        *
+        * @param roleName Name of the role the component fills.
+        * @return instance of the component
+        * @throws ComponentException generic exception
+        */
+       protected Object lookup(String roleName) throws ComponentException 
+       {
+               if (container == null) {
+                       if (containerType.equals(CONTAINER_ECM)) 
+                       {
+                               container = new ECMContainer();
+                       } 
+                       else 
+                       {
+                               container = new YAAFIContainer(logLevel);
+                       }
+                       container.startup(getConfigurationFileName(), 
getRoleFileName(), getParameterFileName());
+               }
+               return container.lookup(roleName);
+       }
+
+       /**
+        * Helper method for converting to and from Merlin Unit TestCase.
+        * 
+        * @param roleName the role name to resolve
+        * @return the component matching the role
+        * @throws ComponentException generic exception
+        */
+       protected Object resolve(String roleName) throws ComponentException 
+       {
+               return lookup(roleName);
+       }
+
+       /**
+        * Releases the component.
+        *
+        * @param component component to be released
+        */
+       protected void release(Object component) 
+       {
+               if (container != null) 
+               {
+                       container.release(component);
+               }
+       }
 }


Reply via email to