epugh 2004/10/30 06:18:00
Modified: testcontainer/src/java/org/apache/fulcrum/testcontainer
Container.java BaseUnitTest.java
testcontainer project.xml
testcontainer/src/test/org/apache/fulcrum/testcontainer
SimpleComponentImpl.java
AlternativeComponentImpl.java SimpleComponent.java
testcontainer/xdocs changes.xml
Added: testcontainer/src/java/org/apache/fulcrum/testcontainer
YAAFIContainer.java ECMContainer.java
testcontainer/src/test/org/apache/fulcrum/testcontainer
EcmContainerTest.java YaafiContainerTest.java
Removed: testcontainer/src/test/org/apache/fulcrum/testcontainer
ContainerTest.java
Log:
use Yaafi as container instead of ECM. Can still use ECM if desired.
Revision Changes Path
1.5 +29 -182
jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java
Index: Container.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Container.java 13 Feb 2004 14:25:57 -0000 1.4
+++ Container.java 30 Oct 2004 13:18:00 -0000 1.5
@@ -1,199 +1,46 @@
package org.apache.fulcrum.testcontainer;
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
+
+/*
+ * Copyright 2004 The Apache Software Foundation.
*
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Licensed 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 java.io.File;
-import org.apache.avalon.excalibur.component.DefaultRoleManager;
-import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
-import org.apache.avalon.excalibur.logger.Log4JLoggerManager;
-import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
/**
- * This is a simple ECM based container that can be used in unit test
- * of the fulcrum components.
+ * This is a simple interface around the ECM and Yaafi containers
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
- * @version $Id$
+ * @author <a href="mailto:epugh at opensourceconnections.com">Eric Pugh</a>
*/
-public class Container extends AbstractLogEnabled implements Initializable,
Disposable
+public interface Container extends Initializable, Disposable
{
/** Key used in the context for defining the application root */
public static String COMPONENT_APP_ROOT = "componentAppRoot";
- /** Alternate Merlin Friendly Key used in the context for
- * defining the application root */
+ /** Alternate Merlin Friendly Key used in the context for defining the
application root */
public static String URN_AVALON_HOME = "urn:avalon:home";
+
+ /** Alternate Merlin Friendly Key used in the context for defining the
application root */
+ public static String URN_AVALON_TEMP = "urn:avalon:temp";
+
+ public void startup(String configFileName, String roleFileName, String
parametersFileName);
+
+ public Object lookup(String roleName) throws ComponentException;
+
+ public void release(Object component);
+
- /** Component manager */
- private ExcaliburComponentManager manager = new ExcaliburComponentManager();
- /** Configurqation file */
- private String configFileName;
- /** Role file name */
- private String roleFileName;
- /** LogManager for logging */
- private LoggerManager lm = new Log4JLoggerManager();
- /**
- * Constructor
- */
- public Container()
- {
- org.apache.log4j.BasicConfigurator.configure();
-
this.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum.testcontainer.Container"));
- }
- /**
- * Starts up the container and initializes it.
- *
- * @param configFileName Name of the component configuration file
- * @param roleFileName Name of the role configuration file
- */
- public void startup(String configFileName, String roleFileName)
- {
- getLogger().debug("Starting container...");
- this.configFileName = configFileName;
- this.roleFileName = roleFileName;
- File configFile = new File(configFileName);
- if (!configFile.exists())
- {
- throw new RuntimeException(
- "Could not initialize the container because the config file could
not be found:" + configFile);
- }
- try
- {
- initialize();
- getLogger().info("Container ready.");
- }
- catch (Exception e)
- {
- getLogger().error("Could not initialize the container", e);
- throw new RuntimeException("Could not initialize the container");
- }
- }
- // -------------------------------------------------------------
- // Avalon lifecycle interfaces
- // -------------------------------------------------------------
- /**
- * Initializes the container
- *
- * @throws Exception generic exception
- */
- public void initialize() throws Exception
- {
- boolean useRoles = true;
- File roleFile = new File(roleFileName+"");
- if (!roleFile.exists())
- {
- useRoles = false;
- getLogger().info("Not using seperate roles file");
- }
- // process configuration files
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- Configuration sysConfig = builder.buildFromFile(configFileName);
- if (useRoles)
- {
- Configuration roleConfig = builder.buildFromFile(roleFileName);
- // Setup the RoleManager
- DefaultRoleManager roles = new DefaultRoleManager();
- roles.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum"));
- roles.configure(roleConfig);
- this.manager.setRoleManager(roles);
- }
- // Setup ECM
- this.manager.setLoggerManager(lm);
- this.manager.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum"));
- DefaultContext context = new DefaultContext();
- String absolutePath = new File("").getAbsolutePath();
- context.put(COMPONENT_APP_ROOT, absolutePath);
- context.put(URN_AVALON_HOME, absolutePath);
- this.manager.contextualize(context);
-
- this.manager.configure(sysConfig);
- // Init ECM!!!!
- this.manager.initialize();
- }
- /**
- * Disposes of the container and releases resources
- */
- public void dispose()
- {
- getLogger().debug("Disposing of container...");
- this.manager.dispose();
- getLogger().info("Container has been disposed.");
- }
- /**
- * Returns an instance of the named component
- *
- * @param roleName Name of the role the component fills.
- * @throws ComponentException generic exception
- */
- public Component lookup(String roleName) throws ComponentException
- {
- return this.manager.lookup(roleName);
- }
- /**
- * Releases the component
- *
- * @param component
- */
- public void release(Component component)
- {
- this.manager.release(component);
- }
}
1.7 +28 -46
jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
Index: BaseUnitTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseUnitTest.java 19 Oct 2004 11:18:39 -0000 1.6
+++ BaseUnitTest.java 30 Oct 2004 13:18:00 -0000 1.7
@@ -1,45 +1,22 @@
package org.apache.fulcrum.testcontainer;
/*
- * ==================================================================== The Apache
Software
- * License, Version 1.1
- *
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
are permitted
- * provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice, this
list of
- * conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
this list of
- * conditions and the following disclaimer in the documentation and/or other
materials provided
- * with the distribution.
- * 3. The end-user documentation included with the redistribution, if any, must
include the
- * following acknowledgment: "This product includes software developed by the
Apache Software
- * Foundation (http://www.apache.org/)." Alternately, this acknowledgment may
appear in the
- * software itself, if and wherever such third-party acknowledgments normally
appear.
- * 4. The names "Apache" and "Apache Software Foundation" and "Apache Turbine"
must not be used to
- * endorse or promote products derived from this software without prior written
permission. For
- * written permission, please contact [EMAIL PROTECTED]
- * 5. Products derived from this software may not be called "Apache", "Apache
Turbine", nor may
- * "Apache" appear in their name, without prior written permission of the Apache
Software
- * Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS
BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many individuals on
behalf of the
- * Apache Software Foundation. For more information on the Apache Software
Foundation, please see
- * <http://www.apache.org/> .
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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 org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
import junit.framework.TestCase;
+
+import org.apache.avalon.framework.component.ComponentException;
/**
* 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
@@ -52,16 +29,21 @@
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 String COMPONENT_APP_ROOT = Container.COMPONENT_APP_ROOT;
+ public static String COMPONENT_APP_ROOT = ECMContainer.COMPONENT_APP_ROOT;
+ /** Pick the default container to be Yaafi **/
+ public static String containerType = CONTAINER_YAAFI;
/** 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";
+
+
/**
* Gets the configuration file name for the container should use for this
test. By default it
* is src/test/TestComponentConfig.
@@ -129,12 +111,12 @@
* @param roleName Name of the role the component fills.
* @throws ComponentException generic exception
*/
- protected Component lookup(String roleName) throws ComponentException
+ protected Object lookup(String roleName) throws ComponentException
{
if (container == null)
{
- container = new Container();
- container.startup(getConfigurationFileName(), getRoleFileName());
+ container = new ECMContainer();
+ container.startup(getConfigurationFileName(), getRoleFileName(),null);
}
return container.lookup(roleName);
}
@@ -145,7 +127,7 @@
* @return
* @throws ComponentException
*/
- protected Component resolve(String roleName) throws ComponentException
+ protected Object resolve(String roleName) throws ComponentException
{
return lookup(roleName);
}
@@ -154,7 +136,7 @@
*
* @param component
*/
- protected void release(Component component)
+ protected void release(Object component)
{
if (container != null)
{
1.1
jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java
Index: YAAFIContainer.java
===================================================================
package org.apache.fulcrum.testcontainer;
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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 java.io.File;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainerImpl;
import org.apache.fulcrum.yaafi.framework.factory.ServiceManagerFactory;
import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService;
/**
* This is a simple YAAFI based container that can be used in unit test
* of the fulcrum components.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Siegfried Goeschl</a>
*/
public class YAAFIContainer extends AbstractLogEnabled implements Container
{
/** Key used in the context for defining the application root */
public static String COMPONENT_APP_ROOT = "componentAppRoot";
/** Alternate Merlin Friendly Key used in the context for defining the
application root */
public static String URN_AVALON_HOME = "urn:avalon:home";
/** Alternate Merlin Friendly Key used in the context for defining the
application root */
public static String URN_AVALON_TEMP = "urn:avalon:temp";
/** Component manager */
private ServiceContainer manager;
/** Configuration file name */
private String configFileName;
/** Role file name */
private String roleFileName;
/** Parameters file name */
private String parametersFileName;
/**
* Constructor
*/
public YAAFIContainer()
{
// org.apache.log4j.BasicConfigurator.configure();
this.manager = new ServiceContainerImpl();
this.enableLogging( new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG ) );
}
/**
* Starts up the container and initializes it.
*
* @param configFileName Name of the component configuration file
* @param roleFileName Name of the role configuration file
*/
public void startup(String configFileName, String roleFileName, String
parametersFileName )
{
getLogger().debug("Starting container...");
this.configFileName = configFileName;
this.roleFileName = roleFileName;
this.parametersFileName = parametersFileName;
File configFile = new File(configFileName);
if (!configFile.exists())
{
throw new RuntimeException(
"Could not initialize the container because the config file could
not be found:" + configFile);
}
try
{
initialize();
getLogger().info("YaffiContainer ready.");
}
catch (Exception e)
{
getLogger().error("Could not initialize the container", e);
throw new RuntimeException("Could not initialize the container");
}
}
// -------------------------------------------------------------
// Avalon lifecycle interfaces
// -------------------------------------------------------------
/**
* Initializes the container
*
* @throws Exception generic exception
*/
public void initialize() throws Exception
{
DefaultContext context = new DefaultContext();
String absolutePath = new File("").getAbsolutePath();
context.put(COMPONENT_APP_ROOT, absolutePath);
context.put(URN_AVALON_HOME, new File( new File("").getAbsolutePath() ) );
Logger logger = new ConsoleLogger( ConsoleLogger.LEVEL_DEBUG );
this.manager = ServiceManagerFactory.create(
logger,
this.roleFileName,
this.configFileName,
this.parametersFileName,
context
);
}
/**
* Disposes of the container and releases resources
*/
public void dispose()
{
getLogger().debug("Disposing of container...");
this.manager.dispose();
getLogger().info("YaffiContainer has been disposed.");
}
/**
* Returns an instance of the named component
*
* @param roleName Name of the role the component fills.
* @throws ComponentException generic exception
*/
public Object lookup(String roleName) throws ComponentException
{
try
{
return ServiceManagerService.getServiceManager().lookup(roleName);
}
catch( Exception e )
{
String msg = "Failed to lookup role " + roleName;
throw new ComponentException(roleName,msg,e);
}
}
/**
* Releases the component implementing the Component interface. This
* interface is depracted but still around in Fulcrum
*
* @param component
*/
public void release(Component component)
{
ServiceManagerService.getServiceManager().release(component);
}
/**
* Releases the component
*
* @param component
*/
public void release(Object component)
{
ServiceManagerService.getServiceManager().release(component);
}
}
1.1
jakarta-turbine-fulcrum/testcontainer/src/java/org/apache/fulcrum/testcontainer/ECMContainer.java
Index: ECMContainer.java
===================================================================
package org.apache.fulcrum.testcontainer;
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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 java.io.File;
import org.apache.avalon.excalibur.component.DefaultRoleManager;
import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
import org.apache.avalon.excalibur.logger.Log4JLoggerManager;
import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
* This is a simple ECM based container that can be used in unit test
* of the fulcrum components.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
* @version $Id: ECMContainer.java,v 1.1 2004/10/30 13:18:00 epugh Exp $
*/
public class ECMContainer extends AbstractLogEnabled implements Container
{
/** Key used in the context for defining the application root */
public static String COMPONENT_APP_ROOT = "componentAppRoot";
/** Alternate Merlin Friendly Key used in the context for
* defining the application root */
public static String URN_AVALON_HOME = "urn:avalon:home";
/** Component manager */
private ExcaliburComponentManager manager = new ExcaliburComponentManager();
/** Configurqation file */
private String configFileName;
/** Role file name */
private String roleFileName;
/** LogManager for logging */
private LoggerManager lm = new Log4JLoggerManager();
/**
* Constructor
*/
public ECMContainer()
{
org.apache.log4j.BasicConfigurator.configure();
this.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum.testcontainer.Container"));
}
/**
* Starts up the container and initializes it.
*
* @param configFileName Name of the component configuration file
* @param roleFileName Name of the role configuration file
*/
public void startup(String configFileName, String roleFileName,String
parametersFileName)
{
getLogger().debug("Starting container...");
this.configFileName = configFileName;
this.roleFileName = roleFileName;
File configFile = new File(configFileName);
if (!configFile.exists())
{
throw new RuntimeException(
"Could not initialize the container because the config file could
not be found:" + configFile);
}
try
{
initialize();
getLogger().info("Container ready.");
}
catch (Exception e)
{
getLogger().error("Could not initialize the container", e);
throw new RuntimeException("Could not initialize the container");
}
}
// -------------------------------------------------------------
// Avalon lifecycle interfaces
// -------------------------------------------------------------
/**
* Initializes the container
*
* @throws Exception generic exception
*/
public void initialize() throws Exception
{
boolean useRoles = true;
File roleFile = new File(roleFileName+"");
if (!roleFile.exists())
{
useRoles = false;
getLogger().info("Not using seperate roles file");
}
// process configuration files
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration sysConfig = builder.buildFromFile(configFileName);
if (useRoles)
{
Configuration roleConfig = builder.buildFromFile(roleFileName);
// Setup the RoleManager
DefaultRoleManager roles = new DefaultRoleManager();
roles.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum"));
roles.configure(roleConfig);
this.manager.setRoleManager(roles);
}
// Setup ECM
this.manager.setLoggerManager(lm);
this.manager.enableLogging(lm.getLoggerForCategory("org.apache.fulcrum"));
DefaultContext context = new DefaultContext();
String absolutePath = new File("").getAbsolutePath();
context.put(COMPONENT_APP_ROOT, absolutePath);
context.put(URN_AVALON_HOME, absolutePath);
this.manager.contextualize(context);
this.manager.configure(sysConfig);
// Init ECM!!!!
this.manager.initialize();
}
/**
* Disposes of the container and releases resources
*/
public void dispose()
{
getLogger().debug("Disposing of container...");
this.manager.dispose();
getLogger().info("Container has been disposed.");
}
/**
* Returns an instance of the named component
*
* @param roleName Name of the role the component fills.
* @throws ComponentException generic exception
*/
public Object lookup(String roleName) throws ComponentException
{
return this.manager.lookup(roleName);
}
/**
* Releases the component
*
* @param component
*/
public void release(Component component)
{
this.manager.release(component);
}
public void release(Object component)
{
this.manager.release((Component)component);
}
}
1.8 +55 -4 jakarta-turbine-fulcrum/testcontainer/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/testcontainer/project.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- project.xml 16 Oct 2004 17:31:30 -0000 1.7
+++ project.xml 30 Oct 2004 13:18:00 -0000 1.8
@@ -6,12 +6,63 @@
<currentVersion>1.0.4-dev</currentVersion>
<dependencies>
-
+
+ <!-- Needed if testing with YAAFI -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <groupId>fulcrum</groupId>
+ <artifactId>fulcrum-yaafi</artifactId>
+ <version>1.0.3-dev</version>
</dependency>
+
+ <!-- Needed if testing with ECM -->
+ <dependency>
+ <groupId>excalibur-component</groupId>
+ <artifactId>excalibur-component</artifactId>
+ <version>1.1</version>
+ <url>http://excalibur.apache.org/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>excalibur-instrument</groupId>
+ <artifactId>excalibur-instrument</artifactId>
+ <version>1.0</version>
+ <url>http://excalibur.apache.org/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>excalibur-logger</groupId>
+ <artifactId>excalibur-logger</artifactId>
+ <version>1.1</version>
+ <url>http://excalibur.apache.org/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ <url>http://jakarta.apache.org/commons/collections.html</url>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.8</version>
+ <url>http://jakarta.apache.org/log4j/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>excalibur-pool</groupId>
+ <artifactId>excalibur-pool-api</artifactId>
+ <version>2.0.0</version>
+ <url>http://excalibur.apache.org/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon-logkit</groupId>
+ <artifactId>avalon-logkit</artifactId>
+ <version>2.0.0</version>
+ <url>http://avalon.apache.org</url>
+ </dependency>
</dependencies>
1.4 +14 -52
jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java
Index: SimpleComponentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleComponentImpl.java 13 Feb 2004 14:25:56 -0000 1.3
+++ SimpleComponentImpl.java 30 Oct 2004 13:18:00 -0000 1.4
@@ -1,57 +1,19 @@
package org.apache.fulcrum.testcontainer;
-/* ====================================================================
- * The Apache Software License, Version 1.1
+/*
+ * Copyright 2004 The Apache Software Foundation.
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Licensed 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 org.apache.avalon.framework.logger.AbstractLogEnabled;
1.4 +14 -52
jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/AlternativeComponentImpl.java
Index: AlternativeComponentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/AlternativeComponentImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AlternativeComponentImpl.java 13 Feb 2004 14:25:56 -0000 1.3
+++ AlternativeComponentImpl.java 30 Oct 2004 13:18:00 -0000 1.4
@@ -1,57 +1,19 @@
package org.apache.fulcrum.testcontainer;
-/* ====================================================================
- * The Apache Software License, Version 1.1
+/*
+ * Copyright 2004 The Apache Software Foundation.
*
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Licensed 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 org.apache.avalon.framework.logger.AbstractLogEnabled;
1.3 +15 -55
jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java
Index: SimpleComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SimpleComponent.java 13 Feb 2004 14:25:56 -0000 1.2
+++ SimpleComponent.java 30 Oct 2004 13:18:00 -0000 1.3
@@ -1,60 +1,20 @@
package org.apache.fulcrum.testcontainer;
-
-import org.apache.avalon.framework.component.Component;
-
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
+/*
+ * Copyright 2004 The Apache Software Foundation.
*
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact [EMAIL PROTECTED]
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * Licensed 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 org.apache.avalon.framework.component.Component;
/**
1.1
jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java
Index: EcmContainerTest.java
===================================================================
package org.apache.fulcrum.testcontainer;
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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 java.io.File;
import org.apache.avalon.framework.component.ComponentException;
/**
* Basic testing of the Container
*
* @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
* @version $Id: EcmContainerTest.java,v 1.1 2004/10/30 13:18:00 epugh Exp $
*/
public class EcmContainerTest extends BaseUnitTest
{
/**
* Constructor for test.
*
* @param testName name of the test being executed
*/
public EcmContainerTest(String testName)
{
super(testName);
}
public void setUp() throws Exception{
containerType=CONTAINER_ECM;
super.setUp();
}
public void testInitialization()
{
assertTrue(true);
}
public void testComponentUsage()
{
SimpleComponent sc = null;
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertNotNull(sc);
sc.test();
assertEquals(sc.getAppRoot(),sc.getAppRoot2());
this.release(sc);
}
public void testAlternativeRoles()
{
SimpleComponent sc = null;
File f = new File("src/test/TestAlternativeRoleConfig.xml");
assertTrue(f.exists());
this.setRoleFileName("src/test/TestAlternativeRoleConfig.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertTrue(sc instanceof AlternativeComponentImpl);
assertNotNull(sc);
sc.test();
this.release(sc);
}
public void testLoadingContainerWithNoRolesfile()
{
SimpleComponent sc = null;
this.setRoleFileName(null);
this.setConfigurationFileName(
"src/test/TestComponentConfigIntegratedRoles.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertTrue(sc instanceof AlternativeComponentImpl);
assertNotNull(sc);
sc.test();
this.release(sc);
}
public void testLoadingNonExistentFile()
{
SimpleComponent sc = null;
this.setRoleFileName(null);
this.setConfigurationFileName("BogusFile.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch(RuntimeException re){
//good
}
catch (ComponentException e)
{
fail(e.getMessage());
}
}
}
1.1
jakarta-turbine-fulcrum/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java
Index: YaafiContainerTest.java
===================================================================
package org.apache.fulcrum.testcontainer;
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed 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 java.io.File;
import org.apache.avalon.framework.component.ComponentException;
/**
* Basic testing of the Container
*
* @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
* @version $Id: YaafiContainerTest.java,v 1.1 2004/10/30 13:18:00 epugh Exp $
*/
public class YaafiContainerTest extends BaseUnitTest
{
/**
* Constructor for test.
*
* @param testName name of the test being executed
*/
public YaafiContainerTest(String testName)
{
super(testName);
}
public void testInitialization()
{
assertTrue(true);
}
public void testComponentUsage()
{
SimpleComponent sc = null;
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertNotNull(sc);
sc.test();
assertEquals(sc.getAppRoot(),sc.getAppRoot2());
this.release(sc);
}
public void testAlternativeRoles()
{
SimpleComponent sc = null;
File f = new File("src/test/TestAlternativeRoleConfig.xml");
assertTrue(f.exists());
this.setRoleFileName("src/test/TestAlternativeRoleConfig.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertTrue(sc instanceof AlternativeComponentImpl);
assertNotNull(sc);
sc.test();
this.release(sc);
}
public void testLoadingContainerWithNoRolesfile()
{
SimpleComponent sc = null;
this.setRoleFileName(null);
this.setConfigurationFileName(
"src/test/TestComponentConfigIntegratedRoles.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch (ComponentException e)
{
e.printStackTrace();
fail(e.getMessage());
}
assertTrue(sc instanceof AlternativeComponentImpl);
assertNotNull(sc);
sc.test();
this.release(sc);
}
public void testLoadingNonExistentFile()
{
SimpleComponent sc = null;
this.setRoleFileName(null);
this.setConfigurationFileName("BogusFile.xml");
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
}
catch(RuntimeException re){
//good
}
catch (ComponentException e)
{
fail(e.getMessage());
}
}
}
1.7 +5 -1 jakarta-turbine-fulcrum/testcontainer/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/testcontainer/xdocs/changes.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- changes.xml 19 Oct 2004 11:18:39 -0000 1.6
+++ changes.xml 30 Oct 2004 13:18:00 -0000 1.7
@@ -7,7 +7,11 @@
</properties>
<body>
- <release version="1.0.4-dev" date="in cvs">
+ <release version="1.0.4-dev" date="in cvs">
+ <action dev="epugh" type="add">
+ By default use Yaafi as the Test container, but you can swap to ECM for
+ more "real" testing if required by doing
<code>containerType=CONTAINER_ECM;</code>.
+ </action>
<action dev="epugh" type="add">
Add helper "resolve" method that delegates to "lookup" to faciliate
using in both Merlin and ECM enviroments.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]