From 80a86aadd3850c2eb010a1d1796918666408954d Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 11 Apr 2002 13:39:01 +0000 Subject: [PATCH] Remove some unit tests that are part of container. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272375 13f79535-47bb-0310-9956-ffa450edef68 --- .../myrmidon/DependencyMetricsTestCase.java | 293 ------ .../components/AbstractComponentTest.java | 249 ----- .../test/DefaultProjectBuilderTestCase.java | 302 ------ .../builder/test/bad-project-name.ant | 4 - .../builder/test/bad-target-name.ant | 5 - .../components/builder/test/bad-version.ant | 3 - .../components/builder/test/bad-xml.ant | 1 - .../components/builder/test/defaults.ant | 3 - .../builder/test/mismatched-version.ant | 3 - .../components/builder/test/no-version.ant | 3 - .../components/builder/test/set-base-dir.ant | 3 - .../builder/test/set-default-target.ant | 3 - .../builder/test/set-project-name.ant | 3 - .../DefaultClassLoaderManagerTestCase.java | 364 ------- .../test/libs/cycle-extension-1.mf | 10 - .../test/libs/cycle-extension-2.mf | 10 - .../classloader/test/libs/extn/ExtnClass.java | 21 - .../classloader/test/libs/extn/extn.txt | 1 - .../classloader/test/libs/one-dependency.mf | 3 - .../test/libs/shared/SharedClass.java | 18 - .../classloader/test/libs/shared/shared.txt | 1 - .../classloader/test/libs/simple-extension.mf | 7 - .../test/libs/unshared/UnsharedClass.java | 21 - .../test/libs/unshared/unshared.txt | 1 - .../test/ConfigTestConfigurable.java | 36 - .../test/DefaultConfigurerTestCase.java | 896 ------------------ .../components/configurer/test/MyRole1.java | 22 - .../configurer/test/MyRole1Adaptor.java | 34 - .../components/configurer/test/MyRole2.java | 18 - .../components/configurer/test/MyType1.java | 25 - .../components/configurer/test/MyType2.java | 25 - .../test/ObjectToMyRole1Converter.java | 34 - .../test/data/ConfigTestAttributeConvert.java | 46 - .../test/data/ConfigTestConfigAdder.java | 33 - .../test/data/ConfigTestContent.java | 42 - .../configurer/test/data/ConfigTestEmpty.java | 20 - .../test/data/ConfigTestIdResolve.java | 42 - .../data/ConfigTestIgnoreStringMethods.java | 105 -- .../test/data/ConfigTestInterfaceAdder.java | 33 - .../data/ConfigTestMismatchedRefType.java | 26 - .../data/ConfigTestMultipleTypedAdder.java | 28 - .../test/data/ConfigTestNestedErrors.java | 20 - .../data/ConfigTestNonInterfaceAdder.java | 23 - .../test/data/ConfigTestPropResolution.java | 41 - .../data/ConfigTestReferenceAttribute.java | 41 - .../data/ConfigTestReferenceConversion.java | 32 - .../test/data/ConfigTestReferenceElement.java | 37 - .../test/data/ConfigTestSetAndAdd.java | 50 - .../test/data/ConfigTestSetAttribute.java | 41 - .../test/data/ConfigTestSetElement.java | 47 - .../test/data/ConfigTestTypedAdder.java | 33 - .../data/ConfigTestTypedAdderConversion.java | 40 - .../data/ConfigTestTypedAdderReference.java | 33 - .../test/data/ConfigTestTypedAdderRole.java | 33 - .../test/data/ConfigTestTypedConfigAdder.java | 33 - .../test/data/ConfigTestUnknownReference.java | 23 - .../test/DefaultDeployerTestCase.java | 203 ---- .../deployer/test/TestConverter1.java | 29 - .../components/deployer/test/TestRole1.java | 18 - .../components/deployer/test/TestType1.java | 21 - .../deployer/test/ant-descriptor.xml | 18 - .../components/deployer/test/ant-roles.xml | 4 - .../embeddor/test/DefaultEmbeddorTest.java | 136 --- .../embeddor/test/project-builder.ant | 6 - .../AbstractPropertyResolverTestCase.java | 171 ---- .../test/ClassicPropertyResolverTestCase.java | 42 - .../test/DefaultPropertyResolverTestCase.java | 51 - .../role/test/DefaultRoleManagerTestCase.java | 182 ---- .../InstantiatingServiceManagerTestCase.java | 152 --- .../service/test/LifecycleValidator.java | 90 -- .../components/service/test/TestService.java | 19 - .../service/test/TestServiceFactory1.java | 30 - .../service/test/TestServiceFactory2.java | 34 - .../service/test/TestServiceImpl1.java | 24 - .../service/test/TestServiceImpl2.java | 27 - .../test/DefaultNameValidatorTestCase.java | 123 --- .../interfaces/type/test/MyType1.java | 22 - .../interfaces/type/test/MyType2.java | 22 - .../type/test/TypeFactoryTestCase.java | 85 -- 79 files changed, 4833 deletions(-) delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/DependencyMetricsTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-project-name.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-target-name.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-version.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-xml.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/defaults.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/mismatched-version.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/no-version.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-default-target.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/DefaultClassLoaderManagerTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-1.mf delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-2.mf delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/ExtnClass.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/extn.txt delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/one-dependency.mf delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/SharedClass.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/shared.txt delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/simple-extension.mf delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/UnsharedClass.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/unshared.txt delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ConfigTestConfigurable.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1Adaptor.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole2.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType2.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ObjectToMyRole1Converter.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestAttributeConvert.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestConfigAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestInterfaceAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMismatchedRefType.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMultipleTypedAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNestedErrors.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNonInterfaceAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestPropResolution.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceConversion.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceElement.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAndAdd.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderConversion.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderReference.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderRole.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedConfigAdder.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestConverter1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestRole1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestType1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-roles.xml delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/project-builder.ant delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/LifecycleValidator.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestService.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl2.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType1.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType2.java delete mode 100644 proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/DependencyMetricsTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/DependencyMetricsTestCase.java deleted file mode 100644 index 8321b4eb1..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/DependencyMetricsTestCase.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import jdepend.framework.JDepend; -import jdepend.framework.JavaPackage; -import junit.framework.TestCase; - -/** - * An abstract Unit test that can be used to test Dependency metrics - * fall in acceptable limits. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class DependencyMetricsTestCase - extends TestCase -{ - private JDepend m_jDepend; - - public DependencyMetricsTestCase( final String name ) - { - super( name ); - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - */ - protected void setUp() - { - m_jDepend = new JDepend(); - - try - { - - m_jDepend.addDirectory( "src/java" ); - //m_jDepend.addDirectory( "src/main" ); - } - catch( final IOException ioe ) - { - fail( ioe.getMessage() ); - } - - m_jDepend.analyze(); - } - - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - protected void tearDown() - { - m_jDepend = null; - } - - /** - * Utility method to retrieve JDpenden instance that contains statistics. - */ - protected final JDepend getJDepend() - { - return m_jDepend; - } - - /** - * Make sure that the launcher classes in org.apache.myrmidon.launcher.* - * are completely decoupled from the rest of the system. - */ - public void testLauncherDecoupled() - { - final JDepend jDepend = getJDepend(); - final String name = "org.apache.myrmidon.launcher"; - final JavaPackage javaPackage = jDepend.getPackage( name ); - - final Collection efferentSet = javaPackage.getEfferents(); - final Iterator afferents = efferentSet.iterator(); - while( afferents.hasNext() ) - { - final JavaPackage efferent = (JavaPackage)afferents.next(); - final String efferentName = efferent.getName(); - if( ! isSubPackage( name, efferentName ) ) - { - fail( "The launcher package " + name + " depends on external classes " + - "contained in " + efferentName + ". No classes besides " + - "those in the launcher hierarchy should be referenced" ); - } - } - } - - /** - * Make sure that the implementations of the myrmidon kernel components - * (ie org.apache.myrmidon.component.X.*) are not referenced by anyone - * except by other objects in the same package or child packages. - */ - public void testNoComponentImplSharing() - { - final JDepend jDepend = getJDepend(); - final Collection packageSet = jDepend.getPackages(); - - final Iterator packages = packageSet.iterator(); - while( packages.hasNext() ) - { - final JavaPackage javaPackage = (JavaPackage)packages.next(); - final String name = javaPackage.getName(); - final String componentPackage = "org.apache.myrmidon.components."; - if( !name.startsWith( componentPackage ) ) - { - continue; - } - - // Extract the component package - final int start = componentPackage.length() + 1; - final int end = name.indexOf( '.', start ); - final String component; - if( end > -1 ) - { - component = name.substring( end ); - } - else - { - component = name; - } - - // Make sure that all the afferent packages of this package (i.e. - // those that refer to this package) are sub-packages of the - // component package - final Collection afferentSet = javaPackage.getAfferents(); - final Iterator afferents = afferentSet.iterator(); - while( afferents.hasNext() ) - { - final JavaPackage efferent = (JavaPackage)afferents.next(); - final String efferentName = efferent.getName(); - if( !isSubPackage( component, efferentName ) ) - { - fail( "The package " + name + " is referred to by classes " + - "contained in " + efferentName + ". No classes besides " + - "those part of the particular implementation of kernel " + - "component should reference the implementations" ); - } - } - } - } - - /** - * Make sure that aut does not depend on any other ant classes - * and thus can be cleanly decoupled. - */ - public void testAutDecoupled() - { - final String packageName = "org.apache.aut"; - final String[] badEfferents = new String[] - { - "org.apache.myrmidon", "org.apache.antlib", "org.apache.tools.ant" - }; - doTestDecoupled( packageName, badEfferents ); - } - - /** - * Make sure that myrmidon package does not have any - * unwanted dependencies. - */ - /* - public void testMyrmidonDecoupled() - { - final String packageName = "org.apache.myrmidon"; - final String[] badEfferents = new String[] - { - "org.apache.antlib", "org.apache.tools.ant" - }; - doTestDecoupled( packageName, badEfferents ); - } - */ - - /** - * Make sure that antlib package does not have any - * unwanted dependencies. - */ - /* - public void testAntlibDecoupled() - { - final String packageName = "org.apache.antlib"; - final String[] badEfferents = new String[] - { - "org.apache.tools.ant" - }; - doTestDecoupled( packageName, badEfferents ); - } - */ - /** - * Make sure there are no circular dependencies between packages because - * circular dependencies are evil!!! - */ - public void testNoCircularity() - { - final JDepend jDepend = getJDepend(); - final Collection packageSet = jDepend.getPackages(); - final Iterator packages = packageSet.iterator(); - while( packages.hasNext() ) - { - final JavaPackage javaPackage = (JavaPackage)packages.next(); - if( javaPackage.containsCycle() ) - { - final ArrayList cycle = new ArrayList(); - javaPackage.collectCycle( cycle ); - - final ArrayList names = getPackageNames( cycle ); - fail( "The package " + javaPackage.getName() + " contains a cycle " + - "with a path " + names ); - } - } - } - - private ArrayList getPackageNames( final ArrayList cycle ) - { - final ArrayList names = new ArrayList(); - - final int size = cycle.size(); - for( int i = 0; i < size; i++ ) - { - final JavaPackage javaPackage = (JavaPackage)cycle.get( i ); - names.add( javaPackage.getName() ); - } - - return names; - } - - /** - * Make sure that the specified package does not depend on any - * of the specified package hierarchies. - */ - private void doTestDecoupled( final String packageName, - final String[] invalidEfferents ) - { - final JDepend jDepend = getJDepend(); - final Collection packageSet = jDepend.getPackages(); - - final Iterator packages = packageSet.iterator(); - while( packages.hasNext() ) - { - final JavaPackage javaPackage = (JavaPackage)packages.next(); - final String name = javaPackage.getName(); - if( !isSubPackage( packageName, name ) ) - { - continue; - } - - final Collection efferentSet = javaPackage.getEfferents(); - final Iterator efferents = efferentSet.iterator(); - while( efferents.hasNext() ) - { - final JavaPackage efferent = (JavaPackage)efferents.next(); - final String efferentName = efferent.getName(); - for( int i = 0; i < invalidEfferents.length; i++ ) - { - final String other = invalidEfferents[ i ]; - if( isSubPackage( other, efferentName ) ) - { - fail( "The package " + name + " has an unwanted dependency " + - "on classes contained in " + efferentName ); - } - } - } - } - } - - /** - * Determines if a package is a sub-package of another package. - * - * @return true if subpackage is either the same package as - * basePackage, or a sub-package of it. - */ - private boolean isSubPackage( final String basePackage, - final String subpackage ) - { - if( ! subpackage.startsWith( basePackage ) ) - { - return false; - } - return ( subpackage.length() == basePackage.length() - || subpackage.charAt( basePackage.length() ) == '.' ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java deleted file mode 100644 index 625b8481f..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/AbstractComponentTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.apache.aut.converter.Converter; -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.Contextualizable; -import org.apache.avalon.framework.context.DefaultContext; -import org.apache.avalon.framework.logger.LogEnabled; -import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.service.DefaultServiceManager; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.components.classloader.DefaultClassLoaderManager; -import org.apache.myrmidon.components.configurer.DefaultConfigurer; -import org.apache.myrmidon.components.converter.DefaultMasterConverter; -import org.apache.myrmidon.components.deployer.DefaultDeployer; -import org.apache.myrmidon.components.executor.DefaultExecutor; -import org.apache.myrmidon.components.extensions.DefaultExtensionManager; -import org.apache.myrmidon.components.property.DefaultPropertyResolver; -import org.apache.myrmidon.components.role.DefaultRoleManager; -import org.apache.myrmidon.components.type.DefaultTypeManager; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager; -import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.converter.ConverterRegistry; -import org.apache.myrmidon.interfaces.deployer.Deployer; -import org.apache.myrmidon.interfaces.executor.Executor; -import org.apache.myrmidon.interfaces.extensions.ExtensionManager; -import org.apache.myrmidon.interfaces.property.PropertyResolver; -import org.apache.myrmidon.interfaces.role.RoleInfo; -import org.apache.myrmidon.interfaces.role.RoleManager; -import org.apache.myrmidon.interfaces.service.ServiceFactory; -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; -import org.apache.myrmidon.interfaces.type.TypeManager; - -/** - * A base class for tests for the default components. - * - * @author Adam Murdoch - */ -public abstract class AbstractComponentTest - extends AbstractMyrmidonTest -{ - private DefaultServiceManager m_serviceManager; - - public static final String DATA_TYPE_ROLE = "data-type"; - public static final String CONVERTER_ROLE = "converter"; - public static final String SERVICE_FACTORY_ROLE = "service-factory"; - - public AbstractComponentTest( final String name ) - { - super( name ); - } - - /** - * Returns the component manager containing the components to test. - */ - protected final ServiceManager getServiceManager() throws Exception - { - if( m_serviceManager == null ) - { - Logger logger = getLogger(); - - // Create the components - m_serviceManager = new DefaultServiceManager(); - List components = new ArrayList(); - - Object component = createComponent( Converter.ROLE, DefaultMasterConverter.class ); - m_serviceManager.put( Converter.ROLE, component ); - m_serviceManager.put( ConverterRegistry.ROLE, component ); - components.add( component ); - - component = createComponent( TypeManager.ROLE, DefaultTypeManager.class ); - m_serviceManager.put( TypeManager.ROLE, component ); - components.add( component ); - - component = createComponent( Configurer.ROLE, DefaultConfigurer.class ); - m_serviceManager.put( Configurer.ROLE, component ); - components.add( component ); - - component = createComponent( Deployer.ROLE, DefaultDeployer.class ); - m_serviceManager.put( Deployer.ROLE, component ); - components.add( component ); - - component = createComponent( Executor.ROLE, DefaultExecutor.class ); - m_serviceManager.put( Executor.ROLE, component ); - components.add( component ); - - component = createComponent( ClassLoaderManager.ROLE, DefaultClassLoaderManager.class ); - m_serviceManager.put( ClassLoaderManager.ROLE, component ); - components.add( component ); - - component = createComponent( ExtensionManager.ROLE, DefaultExtensionManager.class ); - m_serviceManager.put( ExtensionManager.ROLE, component ); - components.add( component ); - - component = createComponent( RoleManager.ROLE, DefaultRoleManager.class ); - m_serviceManager.put( RoleManager.ROLE, component ); - components.add( component ); - - component = createComponent( PropertyResolver.ROLE, DefaultPropertyResolver.class ); - m_serviceManager.put( PropertyResolver.ROLE, component ); - components.add( component ); - - // Log enable the components - for( Iterator iterator = components.iterator(); iterator.hasNext(); ) - { - Object obj = iterator.next(); - if( obj instanceof LogEnabled ) - { - final LogEnabled logEnabled = (LogEnabled)obj; - logEnabled.enableLogging( logger ); - } - } - - // Contextualise the components - final Context context = new DefaultContext( getParameters() ); - for( Iterator iterator = components.iterator(); iterator.hasNext(); ) - { - Object obj = iterator.next(); - if( obj instanceof Contextualizable ) - { - final Contextualizable contextualizable = (Contextualizable)obj; - contextualizable.contextualize( context ); - } - } - - // Compose the components - for( Iterator iterator = components.iterator(); iterator.hasNext(); ) - { - Object obj = iterator.next(); - if( obj instanceof Serviceable ) - { - final Serviceable serviceable = (Serviceable)obj; - serviceable.service( m_serviceManager ); - } - } - - // Initialise the components - for( Iterator iterator = components.iterator(); iterator.hasNext(); ) - { - Object obj = iterator.next(); - if( obj instanceof Initializable ) - { - final Initializable initializable = (Initializable)obj; - initializable.initialize(); - } - } - - // Register some standard roles - // Add some core roles - final RoleManager roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - roleManager.addRole( new RoleInfo( DataType.ROLE, DATA_TYPE_ROLE, DataType.class ) ); - roleManager.addRole( new RoleInfo( Converter.ROLE, CONVERTER_ROLE, Converter.class ) ); - roleManager.addRole( new RoleInfo( ServiceFactory.ROLE, SERVICE_FACTORY_ROLE, ServiceFactory.class ) ); - } - - return m_serviceManager; - } - - /** - * Creates the parameters for the test. Sub-classes can override this - * method to set-up the parameters. - */ - protected Map getParameters() - { - final Map parameters = new HashMap(); - final File homeDir = getInstallDirectory(); - parameters.put( "myrmidon.home", homeDir ); - parameters.put( "myrmidon.ext.path", new File[] { new File ( homeDir, "ext" ) } ); - return parameters; - } - - /** - * Creates an instance of a test component. Sub-classes can override this - * method to add a particular implementation to the set of test components. - */ - protected Object createComponent( final String role, final Class defaultImpl ) - throws Exception - { - if( role.equals( ClassLoaderManager.ROLE ) ) - { - return new DefaultClassLoaderManager( getClass().getClassLoader() ); - } - return defaultImpl.newInstance(); - } - - /** - * Returns the type manager. - */ - protected TypeManager getTypeManager() - throws Exception - { - return (TypeManager)getServiceManager().lookup( TypeManager.ROLE ); - } - - /** - * Utility method to register a role. - */ - protected void registerRole( final RoleInfo roleInfo ) - throws Exception - { - RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - roleMgr.addRole( roleInfo ); - } - - /** - * Utility method to register a type. - */ - protected void registerType( final String roleName, - final String typeName, - final Class type ) - throws Exception - { - final ClassLoader loader = getClass().getClassLoader(); - final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); - factory.addNameClassMapping( typeName, type.getName() ); - getTypeManager().registerType( roleName, typeName, factory ); - } - - /** - * Utility method to register a Converter. - */ - protected void registerConverter( final Class converterClass, - final Class sourceClass, - final Class destClass ) - throws Exception - { - ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup( ConverterRegistry.ROLE ); - converterRegistry.registerConverter( converterClass.getName(), sourceClass.getName(), destClass.getName() ); - DefaultTypeFactory factory = new DefaultTypeFactory( getClass().getClassLoader() ); - factory.addNameClassMapping( converterClass.getName(), converterClass.getName() ); - getTypeManager().registerType( Converter.ROLE, converterClass.getName(), factory ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java deleted file mode 100644 index af901c97d..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.builder.test; - -import java.io.File; -import java.util.Arrays; -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.excalibur.io.FileUtil; -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.components.builder.DefaultProjectBuilder; -import org.apache.myrmidon.components.builder.DefaultProject; -import org.apache.myrmidon.interfaces.builder.ProjectException; -import org.apache.myrmidon.interfaces.model.Project; - -/** - * Test cases for {@link org.apache.myrmidon.components.builder.DefaultProjectBuilder}. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public class DefaultProjectBuilderTestCase - extends AbstractMyrmidonTest -{ - private final static Resources REZ = getResourcesForTested( DefaultProjectBuilderTestCase.class ); - - private DefaultProjectBuilder m_builder; - - public DefaultProjectBuilderTestCase( String name ) - { - super( name ); - } - - protected void setUp() throws Exception - { - super.setUp(); - m_builder = new DefaultProjectBuilder(); - m_builder.enableLogging( getLogger() ); - } - - /** - * Creates a project, with default values set. - */ - private DefaultProject createProject( final File projFile ) - { - final DefaultProject project = new DefaultProject(); - project.setProjectName( FileUtil.removeExtension( projFile.getName() ) ); - project.setBaseDirectory( getTestDirectory( "." ) ); - project.setDefaultTargetName( "main" ); - return project; - } - - /** - * Tests bad project file name. - */ - public void testProjectFileName() throws Exception - { - // Test with a file that does not exist - File projFile = getTestResource( "unknown.ant", false ); - - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.no-project-file.error" ) - }; - assertSameMessage( messages, e ); - } - - // Test with a directory - projFile = getTestDirectory( "some-dir" ); - - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.no-project-file.error" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Tests error reporting when the project file contains badly formed XML. - */ - public void testBadlyFormedFile() throws Exception - { - final File projFile = getTestResource( "bad-xml.ant" ); - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.project-parse.error" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Tests building a project with default values for project name, base dir - * and default target. - */ - public void testDefaults() throws Exception - { - // Build project - final File projFile = getTestResource( "defaults.ant" ); - Project project = m_builder.build( projFile.getAbsolutePath() ); - - // Compare against expected project - DefaultProject expected = createProject( projFile ); - assertSameProject( expected, project ); - } - - /** - * Tests setting the project name. - */ - public void testProjectName() throws Exception - { - // Build project - final File projFile = getTestResource( "set-project-name.ant" ); - Project project = m_builder.build( projFile.getAbsolutePath() ); - - // Compare against expected project - DefaultProject expected = createProject( projFile ); - expected.setProjectName( "some-project" ); - assertSameProject( expected, project ); - } - - /** - * Tests setting the base directory. - */ - public void testBaseDirectory() throws Exception - { - // Build project - final File projFile = getTestResource( "set-base-dir.ant" ); - Project project = m_builder.build( projFile.getAbsolutePath() ); - - // Compare against expected project - DefaultProject expected = createProject( projFile ); - final File baseDir = getTestDirectory( "other-base-dir" ); - expected.setBaseDirectory( baseDir ); - assertSameProject( expected, project ); - } - - /** - * Tests setting the default target name. - */ - public void testDefaultTarget() throws Exception - { - // Build project - final File projFile = getTestResource( "set-default-target.ant" ); - Project project = m_builder.build( projFile.getAbsolutePath() ); - - // Compare against expected project - DefaultProject expected = createProject( projFile ); - expected.setDefaultTargetName( "some-target" ); - assertSameProject( expected, project ); - } - - /** - * Tests missing, invalid and incompatible project version. - */ - public void testProjectVersion() throws Exception - { - // No version - File projFile = getTestResource( "no-version.ant" ); - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.version-missing.error" ) - }; - assertSameMessage( messages, e ); - } - - // Badly formed version - projFile = getTestResource( "bad-version.ant" ); - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.malformed.version", "ant2" ) - }; - assertSameMessage( messages, e ); - } - - // Incompatible version - projFile = getTestResource( "mismatched-version.ant" ); - try - { - m_builder.build( projFile.getAbsolutePath() ); - fail(); - } - catch( ProjectException e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", projFile.getAbsolutePath() ), - REZ.getString( "ant.bad-version.error", "2.0.0", "1.0.2" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Asserts that 2 projects are identical. - */ - protected void assertSameProject( final Project expected, - final Project project ) - { - assertEquals( expected.getProjectName(), project.getProjectName() ); - assertEquals( expected.getBaseDirectory(), project.getBaseDirectory() ); - assertEquals( expected.getDefaultTargetName(), project.getDefaultTargetName() ); - - // TODO - make sure each of the projects are the same - assertTrue( Arrays.equals( expected.getProjectNames(), project.getProjectNames() ) ); - - // TODO - make sure the implicit targets are the same - - // TODO - make sure each of the targets are the same - assertTrue( Arrays.equals( expected.getTargetNames(), project.getTargetNames() ) ); - - // TODO - implement TypeLib.equals(), or use a comparator - assertTrue( Arrays.equals( expected.getTypeLibs(), project.getTypeLibs() ) ); - } - - /** - * Tests validation of project and target names. - */ - public void testNameValidation() throws Exception - { - // Check bad project name - final File badProjectFile = getTestResource( "bad-project-name.ant" ); - try - { - m_builder.build( badProjectFile.getAbsolutePath() ); - fail(); - } - catch( Exception e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", badProjectFile.getAbsolutePath() ), - REZ.getString( "ant.project-bad-name.error" ) - }; - assertSameMessage( messages, e ); - } - - // Check bad target name - final File badTargetFile = getTestResource( "bad-target-name.ant" ); - try - { - m_builder.build( badTargetFile.getAbsolutePath() ); - fail(); - } - catch( Exception e ) - { - final String[] messages = - { - REZ.getString( "ant.project-build.error", badTargetFile.getAbsolutePath() ), - // TODO - check error message - null - }; - assertSameMessage( messages, e ); - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-project-name.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-project-name.ant deleted file mode 100644 index 7b0ed6f75..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-project-name.ant +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-target-name.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-target-name.ant deleted file mode 100644 index 8c7186956..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-target-name.ant +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-version.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-version.ant deleted file mode 100644 index 922f14aee..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-version.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-xml.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-xml.ant deleted file mode 100644 index 91717fd16..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/bad-xml.ant +++ /dev/null @@ -1 +0,0 @@ -this ain't xml. diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/defaults.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/defaults.ant deleted file mode 100644 index b36a5c7ce..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/defaults.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/mismatched-version.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/mismatched-version.ant deleted file mode 100644 index b9176c9c0..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/mismatched-version.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/no-version.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/no-version.ant deleted file mode 100644 index d1979fedf..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/no-version.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant deleted file mode 100644 index 56fe72aa4..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-base-dir.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-default-target.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-default-target.ant deleted file mode 100644 index f83f3bbeb..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-default-target.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant deleted file mode 100644 index a8ae1a941..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/builder/test/set-project-name.ant +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/DefaultClassLoaderManagerTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/DefaultClassLoaderManagerTestCase.java deleted file mode 100644 index 009e3fa9f..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/DefaultClassLoaderManagerTestCase.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.classloader.test; - -import java.io.File; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Enumeration; -import java.util.Map; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.components.AbstractComponentTest; -import org.apache.myrmidon.components.classloader.DefaultClassLoaderManager; -import org.apache.myrmidon.interfaces.classloader.ClassLoaderException; -import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager; - -/** - * Test cases for the DefaultClassLoaderManager. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class DefaultClassLoaderManagerTestCase - extends AbstractComponentTest -{ - private static final String UNSHARED_PKG_NAME = - getPackageName( DefaultClassLoaderManagerTestCase.class ) + ".libs.unshared"; - private static final String UNSHARED_RES_NAME = getResourceName( UNSHARED_PKG_NAME, "unshared.txt" ); - private static final String UNSHARED_CLASS_NAME = UNSHARED_PKG_NAME + ".UnsharedClass"; - - private static final String SHARED_PKG_NAME = - getPackageName( DefaultClassLoaderManagerTestCase.class ) + ".libs.shared"; - private static final String SHARED_RES_NAME = getResourceName( SHARED_PKG_NAME, "shared.txt" ); - private static final String SHARED_CLASS_NAME = SHARED_PKG_NAME + ".SharedClass"; - - private static final String EXTN_PKG_NAME = - getPackageName( DefaultClassLoaderManagerTestCase.class ) + ".libs.extn"; - private static final String EXTN_RES_NAME = getResourceName( EXTN_PKG_NAME, "extn.txt" ); - private static final String EXTN_CLASS_NAME = EXTN_PKG_NAME + ".ExtnClass"; - - private File m_commonJar; - private ClassLoader m_commonClassLoader; - private ClassLoaderManager m_loaderManager; - - public DefaultClassLoaderManagerTestCase( final String name ) - { - super( name ); - } - - /** - * Sets up the test. - */ - protected void setUp() throws Exception - { - m_commonJar = getTestResource( "common.jar" ); - final URL commonJarUrl = m_commonJar.toURL(); - m_commonClassLoader = new URLClassLoader( new URL[]{commonJarUrl} ); - - assertClassFound( m_commonClassLoader, SHARED_CLASS_NAME ); - assertResourcesFound( m_commonClassLoader, SHARED_RES_NAME, m_commonJar ); - - // Create the classloader mgr - m_loaderManager = (ClassLoaderManager)getServiceManager().lookup( ClassLoaderManager.ROLE ); - } - - /** - * Creates an instance of a test component. - */ - protected Object createComponent( final String role, final Class defaultImpl ) - throws Exception - { - if( role.equals( ClassLoaderManager.ROLE ) ) - { - return new DefaultClassLoaderManager( m_commonClassLoader ); - } - else - { - return super.createComponent( role, defaultImpl ); - } - } - - /** - * Creates the parameters for the test. Sub-classes can override this - * method to set-up the parameters. - */ - protected Map getParameters() - { - final Map parameters = super.getParameters(); - parameters.put( "myrmidon.ext.path", new File[] { getTestDirectory( "ext" ) } ); - return parameters; - } - - /** - * Returns the name of a resource in a package. - */ - private static String getResourceName( final String pkgName, - final String resname ) - { - return pkgName.replace( '.', '/' ) + '/' + resname; - } - - /** - * Asserts that a class is not available in a classloader. - */ - private void assertClassNotFound( final ClassLoader classLoader, - final String className ) - { - try - { - classLoader.loadClass( className ); - fail( "Class " + className + " should not be available." ); - } - catch( ClassNotFoundException e ) - { - } - } - - /** - * Asserts that a class is available in a classloader. - */ - private void assertClassFound( final ClassLoader classLoader, - final String className ) - throws Exception - { - assertClassFound( classLoader, className, classLoader ); - } - - /** - * Asserts that a class is available in a classloader. - */ - private void assertClassFound( final ClassLoader classLoader, - final String className, - final ClassLoader expectedClassLoader ) - throws Exception - { - try - { - final Class cls = classLoader.loadClass( className ); - assertSame( expectedClassLoader, cls.getClassLoader() ); - if( classLoader != expectedClassLoader ) - { - final Class expectedCls = expectedClassLoader.loadClass( className ); - assertSame( expectedCls, cls ); - } - } - catch( ClassNotFoundException e ) - { - fail( "Class " + className + " not found." ); - } - - } - - /** - * Asserts that a resouce is not available in a classloader. - */ - private void assertResourceNotFound( final ClassLoader classLoader, - final String resName ) - throws Exception - { - assertNull( classLoader.getResource( resName ) ); - assertNull( classLoader.getResourceAsStream( resName ) ); - final Enumeration enum = classLoader.getResources( resName ); - assertTrue( !enum.hasMoreElements() ); - } - - /** - * Asserts that a resource is available in a classloader. - */ - private void assertResourcesFound( final ClassLoader classLoader, - final String resName, - final File expectedJar ) - throws Exception - { - assertResourcesFound( classLoader, resName, new File[]{expectedJar} ); - } - - /** - * Asserts that a resource is available in a classloader. - */ - private void assertResourcesFound( final ClassLoader classLoader, - final String resName, - final File[] expectedJars ) - throws Exception - { - final String[] expectedLocations = new String[ expectedJars.length ]; - for( int i = 0; i < expectedJars.length; i++ ) - { - final File jar = expectedJars[ i ]; - expectedLocations[ i ] = "jar:" + jar.toURL() + "!/" + resName; - } - - assertResourcesFound( classLoader, resName, expectedLocations ); - } - - /** - * Asserts that a resource is available in a classloader. - */ - private void assertResourcesFound( final ClassLoader classLoader, - final String resName, - final String[] expectedLocations ) - throws Exception - { - // Use the first in the list of expected locations as the location - // of the resource returned by getResource() - final URL resUrl = classLoader.getResource( resName ); - assertNotNull( resUrl ); - assertEquals( expectedLocations[ 0 ], resUrl.toString() ); - - // Now check all of the resources returned by getResources() - final Enumeration resources = classLoader.getResources( resName ); - for( int i = 0; i < expectedLocations.length; i++ ) - { - final String expectedLocation = expectedLocations[ i ]; - assertTrue( resources.hasMoreElements() ); - final URL location = (URL)resources.nextElement(); - assertEquals( expectedLocation, location.toString() ); - } - assertTrue( !resources.hasMoreElements() ); - } - - /** - * Tests for a Jar with no required extensions. - */ - public void testNoDependencies() throws Exception - { - // Make some assumptions about the common classloader - assertClassNotFound( m_commonClassLoader, UNSHARED_CLASS_NAME ); - assertResourceNotFound( m_commonClassLoader, UNSHARED_RES_NAME ); - - // Build the classloader - final File jarFile = getTestResource( "no-dependencies.jar" ); - final ClassLoader classLoader = m_loaderManager.getClassLoader( jarFile ); - - // Check shared classes/resources - assertClassFound( classLoader, SHARED_CLASS_NAME, m_commonClassLoader ); - assertResourcesFound( classLoader, SHARED_RES_NAME, new File[]{m_commonJar, jarFile} ); - - // Check unshared classes/resources - assertClassFound( classLoader, UNSHARED_CLASS_NAME ); - assertResourcesFound( classLoader, UNSHARED_RES_NAME, jarFile ); - } - - /** - * Tests ClassLoader caching. - */ - public void testClassLoaderReuse() throws Exception - { - final File jarFile = getTestResource( "no-dependencies.jar" ); - final ClassLoader classLoader1 = m_loaderManager.getClassLoader( jarFile ); - final ClassLoader classLoader2 = m_loaderManager.getClassLoader( jarFile ); - assertSame( classLoader1, classLoader2 ); - } - - /** - * Tests for a Jar with a single required extension. - */ - public void testOneDependency() throws Exception - { - // Make some assumptions about the common classloader - assertClassNotFound( m_commonClassLoader, UNSHARED_CLASS_NAME ); - assertResourceNotFound( m_commonClassLoader, UNSHARED_RES_NAME ); - assertClassNotFound( m_commonClassLoader, EXTN_CLASS_NAME ); - assertResourceNotFound( m_commonClassLoader, EXTN_RES_NAME ); - - // Build the extension classloader - final File extnJarFile = getTestResource( "ext/simple-extension.jar" ); - final ClassLoader extnClassLoader = m_loaderManager.getClassLoader( extnJarFile ); - - // Build the Jar classloader - final File jarFile = getTestResource( "one-dependency.jar" ); - final ClassLoader classLoader = m_loaderManager.getClassLoader( jarFile ); - - // Check shared classes/resources - assertClassFound( classLoader, SHARED_CLASS_NAME, m_commonClassLoader ); - assertResourcesFound( classLoader, SHARED_RES_NAME, new File[]{m_commonJar, extnJarFile, jarFile} ); - - // Check extension classes/resources - assertClassFound( classLoader, EXTN_CLASS_NAME, extnClassLoader ); - assertResourcesFound( classLoader, EXTN_RES_NAME, extnJarFile ); - - // Check unshared classes/resources - assertClassFound( classLoader, UNSHARED_CLASS_NAME ); - assertResourcesFound( classLoader, UNSHARED_RES_NAME, jarFile ); - } - - /** - * Tests that classes from extensions can be shared across classloaders. - */ - public void testShareClasses() throws Exception - { - // Build the extension classloader - final File extnJarFile = getTestResource( "ext/simple-extension.jar" ); - final ClassLoader extnClassLoader = m_loaderManager.getClassLoader( extnJarFile ); - - // Build the Jar classloaders - final File jarFile1 = getTestResource( "one-dependency.jar" ); - final ClassLoader classLoader1 = m_loaderManager.getClassLoader( jarFile1 ); - final File jarFile2 = getTestResource( "one-dependency-2.jar" ); - final ClassLoader classLoader2 = m_loaderManager.getClassLoader( jarFile2 ); - - // Check extension classes/resources - assertClassFound( classLoader1, EXTN_CLASS_NAME, extnClassLoader ); - assertResourcesFound( classLoader1, EXTN_RES_NAME, extnJarFile ); - assertClassFound( classLoader2, EXTN_CLASS_NAME, extnClassLoader ); - assertResourcesFound( classLoader2, EXTN_RES_NAME, extnJarFile ); - } - - /** - * Tests detection of dependency cycles in extensions. - */ - public void testCycle() throws Exception - { - final File jarFile = getTestResource( "ext/cycle-extension-1.jar" ); - try - { - m_loaderManager.getClassLoader( jarFile ); - fail(); - } - catch( final ClassLoaderException e ) - { - final Resources rez = getResourcesForTested( DefaultClassLoaderManager.class ); - final String[] messages = { - rez.getString( "create-classloader-for-file.error", jarFile ), - rez.getString( "dependency-cycle.error", jarFile ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * add some classes to common loader only. - * - * unknown extension - * multiple versions of the same extension - * extn with requirement on itself - * - * jar with 1 and 2 extns: - * class/resources in parent - * class/resources in jar - * class/resources in extn - * class/resources in all - * - * jar with transitive extn - * class/resources in 2nd extn - * - * jar with transitive extn + explicit extn on same jar - * class/resources in 2nd extn - * - * Same classes: - * get extn explicitly and implicitly, and check classes are the same - * extn shared by 2 jars, using same extn and different extns - * classes in common classloader, shared by 2 jars - * - * multiple files: - * fetch classloader twice - * different path ordering - * - * tools.jar - */ -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-1.mf b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-1.mf deleted file mode 100644 index 5380f28ed..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-1.mf +++ /dev/null @@ -1,10 +0,0 @@ -Extension-Name: test.cycle1 -Specification-Title: Test Extension -Specification-Version: 1.0.0 -Specification-Vendor: Jakarta Apache -Implementation-Vendor-Id: org.apache.myrmidon -Implementation-Vendor: Apache Myrmidon Project -Implementation-Version: 3.0 -Extension-List: cycle2 -cycle2-Extension-Name: test.cycle2 -cycle2-Specification-Version: 1.0 diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-2.mf b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-2.mf deleted file mode 100644 index 799efc5de..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/cycle-extension-2.mf +++ /dev/null @@ -1,10 +0,0 @@ -Extension-Name: test.cycle2 -Specification-Title: Test Extension -Specification-Version: 1.0.0 -Specification-Vendor: Jakarta Apache -Implementation-Vendor-Id: org.apache.myrmidon -Implementation-Vendor: Apache Myrmidon Project -Implementation-Version: 1.709.2 -Extension-List: cycle1 -cycle1-Extension-Name: test.cycle1 -cycle1-Specification-Version: 1.0 diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/ExtnClass.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/ExtnClass.java deleted file mode 100644 index 6300e4049..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/ExtnClass.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.classloader.test.libs.extn; - -import org.apache.myrmidon.components.classloader.test.libs.shared.SharedClass; - -/** - * A test class loaded from an extension. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class ExtnClass -{ - public SharedClass m_test = new SharedClass(); -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/extn.txt b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/extn.txt deleted file mode 100644 index f7953b475..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/extn/extn.txt +++ /dev/null @@ -1 +0,0 @@ -A test resource loaded from an extension. \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/one-dependency.mf b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/one-dependency.mf deleted file mode 100644 index 5ffbb34e4..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/one-dependency.mf +++ /dev/null @@ -1,3 +0,0 @@ -Extension-List: extension1 -extension1-Extension-Name: test.simple -extension1-Specification-Version: 1.0 diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/SharedClass.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/SharedClass.java deleted file mode 100644 index dfb8fc5d0..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/SharedClass.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.classloader.test.libs.shared; - -/** - * A test class. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class SharedClass -{ -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/shared.txt b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/shared.txt deleted file mode 100644 index 31897ec6d..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/shared/shared.txt +++ /dev/null @@ -1 +0,0 @@ -A shared resource. \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/simple-extension.mf b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/simple-extension.mf deleted file mode 100644 index 54c47a9cf..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/simple-extension.mf +++ /dev/null @@ -1,7 +0,0 @@ -Extension-Name: test.simple -Specification-Title: Test Simple Extension -Specification-Version: 1.0.0 -Specification-Vendor: Jakarta Apache -Implementation-Vendor-Id: org.apache.myrmidon -Implementation-Vendor: Apache Myrmidon Project -Implementation-Version: 1.0.2 diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/UnsharedClass.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/UnsharedClass.java deleted file mode 100644 index 6f250eab9..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/UnsharedClass.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.classloader.test.libs.unshared; - -import org.apache.myrmidon.components.classloader.test.libs.shared.SharedClass; - -/** - * A test class. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class UnsharedClass -{ - public SharedClass m_test = new SharedClass(); -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/unshared.txt b/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/unshared.txt deleted file mode 100644 index 082b78cb1..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/classloader/test/libs/unshared/unshared.txt +++ /dev/null @@ -1 +0,0 @@ -An unshared resource. \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ConfigTestConfigurable.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ConfigTestConfigurable.java deleted file mode 100644 index 4a1d5d628..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ConfigTestConfigurable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.avalon.framework.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; - -/** - * Simple class to test {@link org.apache.avalon.framework.configuration.Configurable}. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestConfigurable - implements Configurable -{ - private Configuration m_configuration; - - public void configure( Configuration configuration ) - throws ConfigurationException - { - m_configuration = configuration; - } - - public boolean equals( final Object object ) - { - final ConfigTestConfigurable other = (ConfigTestConfigurable)object; - return m_configuration == other.m_configuration; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java deleted file mode 100644 index bb808392b..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java +++ /dev/null @@ -1,896 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import java.io.File; -import org.apache.aut.converter.lib.StringToIntegerConverter; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.configuration.DefaultConfiguration; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.components.AbstractComponentTest; -import org.apache.myrmidon.components.store.DefaultPropertyStore; -import org.apache.myrmidon.components.configurer.DefaultConfigurer; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestAttributeConvert; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestConfigAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestContent; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestEmpty; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestIdResolve; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestIgnoreStringMethods; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestInterfaceAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestMismatchedRefType; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestMultipleTypedAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestNestedErrors; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestNonInterfaceAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestPropResolution; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestReferenceAttribute; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestReferenceConversion; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestReferenceElement; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestSetAndAdd; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestSetAttribute; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestSetElement; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderConversion; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderReference; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedAdderRole; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestTypedConfigAdder; -import org.apache.myrmidon.components.configurer.test.data.ConfigTestUnknownReference; -import org.apache.myrmidon.components.workspace.DefaultTaskContext; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.interfaces.configurer.Configurer; -import org.apache.myrmidon.interfaces.role.RoleInfo; - -/** - * Test cases for the default configurer and related classes. - * - * @author Adam Murdoch - */ -public class DefaultConfigurerTestCase - extends AbstractComponentTest -{ - private final static Resources REZ = - getResourcesForTested( DefaultConfigurerTestCase.class ); - - private Configurer m_configurer; - private DefaultTaskContext m_context; - - public DefaultConfigurerTestCase( String name ) - { - super( name ); - } - - /** - * Setup the test case - prepares a set of components, including the - * configurer. - */ - protected void setUp() throws Exception - { - super.setUp(); - - // Find the configurer - m_configurer = (Configurer)getServiceManager().lookup( Configurer.ROLE ); - - // Setup a context - final DefaultPropertyStore store = new DefaultPropertyStore(); - m_context = - new DefaultTaskContext( getServiceManager(), getLogger(), store ); - final File baseDir = new File( "." ).getAbsoluteFile(); - m_context.setProperty( TaskContext.BASE_DIRECTORY, baseDir ); - } - - /** - * Creates an instance of a component. Sub-classes can override this - * method to add a particular implementation to the set of test components. - */ - protected Object createComponent( final String role, final Class defaultImpl ) - throws Exception - { - if( role.equals( Configurer.ROLE) ) - { - return new DefaultConfigurer(); - } - else - { - return super.createComponent( role, defaultImpl ); - } - } - - /** - * Tests setting an attribute, via a setter method. - */ - public void testSetAttribute() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final String value1 = "some value"; - config.setAttribute( "some-prop", value1 ); - - final ConfigTestSetAttribute test = new ConfigTestSetAttribute(); - - // Configure the object - configure( test, config ); - - // Check result - final ConfigTestSetAttribute expected = new ConfigTestSetAttribute(); - expected.setSomeProp( value1 ); - assertEquals( expected, test ); - } - - /** - * Tests attribute conversion. - */ - public void testAttributeConvert() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "int-prop", "90" ); - config.setAttribute( "integer-prop", "-401" ); - - // Register the converter - registerConverter( StringToIntegerConverter.class, String.class, Integer.class ); - - final ConfigTestAttributeConvert test = new ConfigTestAttributeConvert(); - - // Configure the object - configure( test, config ); - - // Check result - final ConfigTestAttributeConvert expected = new ConfigTestAttributeConvert(); - expected.setIntProp( 90 ); - expected.setIntegerProp( new Integer( -401 ) ); - assertEquals( expected, test ); - } - - /** - * Tests setting an unknown attribute. - */ - public void testSetUnknownAttribute() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "unknown", "some value" ); - - final ConfigTestEmpty test = new ConfigTestEmpty(); - - // Configure the object - try - { - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( final ConfigurationException ce ) - { - final String message = REZ.getString( "no-such-attribute.error", "test", "unknown" ); - assertSameMessage( message, ce ); - } - } - - /** - * Tests setting a nested element, via adder and setter methods. - */ - public void testSetElement() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child1 = new DefaultConfiguration( "prop", "test" ); - final String value1 = "some value"; - child1.setAttribute( "some-prop", value1 ); - config.addChild( child1 ); - final DefaultConfiguration child2 = new DefaultConfiguration( "prop", "test" ); - final String value2 = "another value"; - child2.setAttribute( "some-prop", value2 ); - config.addChild( child2 ); - - final ConfigTestSetElement test = new ConfigTestSetElement(); - - // Configure the object - configure( test, config ); - - // Check result - final ConfigTestSetElement expected = new ConfigTestSetElement(); - ConfigTestSetElement elem = new ConfigTestSetElement(); - elem.setSomeProp( value1 ); - expected.addProp( elem ); - elem = new ConfigTestSetElement(); - elem.setSomeProp( value2 ); - expected.addProp( elem ); - assertEquals( expected, test ); - } - - /** - * Tests setting an unknown element. - */ - public void testSetUnknownElement() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration elem = new DefaultConfiguration( "unknown", "test" ); - config.addChild( elem ); - - final ConfigTestEmpty test = new ConfigTestEmpty(); - - // Configure the object - try - { - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( final ConfigurationException ce ) - { - final String message = REZ.getString( "no-such-element.error", "test", "unknown" ); - assertSameMessage( message, ce ); - } - } - - /** - * Tests setting the content of an object. - */ - public void testContent() - throws Exception - { - // Create the test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final String value1 = "some value"; - config.setValue( value1 ); - - final ConfigTestContent test = new ConfigTestContent(); - - // Configure the object - configure( test, config ); - - // Check result - final ConfigTestContent expected = new ConfigTestContent(); - expected.addContent( value1 ); - assertEquals( expected, test ); - } - - /** - * Tests setting the content of an object that does not handle it. - */ - public void testUnexpectedContent() - throws Exception - { - // Create the test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setValue( "some value" ); - - final ConfigTestEmpty test = new ConfigTestEmpty(); - - // Configure the object - try - { - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( final ConfigurationException ce ) - { - final String message = REZ.getString( "no-content.error", "test" ); - assertSameMessage( message, ce ); - } - } - - /** - * Tests property resolution. - */ - public void testPropResolution() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "prop", "some ${prop-a} value" ); - - final ConfigTestPropResolution test = new ConfigTestPropResolution(); - - m_context.setProperty( "prop-a", "other" ); - - // Configure the object - configure( test, config ); - - // Check the configured object - final ConfigTestPropResolution expected = new ConfigTestPropResolution(); - expected.setProp( "some other value" ); - assertEquals( expected, test ); - } - - /** - * Tests reference resolution via an attribute. - */ - public void testReferenceAttribute() throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "some-prop-ref", "prop-a" ); - - final ConfigTestReferenceAttribute test = new ConfigTestReferenceAttribute(); - - m_context.setProperty( "prop-a", "some value" ); - - // Configure the object - try - { - configure( test, config ); - } - catch( ConfigurationException e ) - { - //Expected to fail as -ref no longer supported - //pattern for attributes - return; - } - - fail( "-ref pattern on attributes no longer supported" ); - // Check the configured object - //final ConfigTestReferenceAttribute expected = new ConfigTestReferenceAttribute(); - //expected.setSomeProp( "some value" ); - //assertEquals( expected, test ); - } - - /** - * Tests reference resolution via a nested element. - */ - public void testReferenceElement() throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration elem = new DefaultConfiguration( "some-prop-ref", "test" ); - elem.setAttribute( "id", "prop-a" ); - config.addChild( elem ); - - final ConfigTestReferenceElement test = new ConfigTestReferenceElement(); - - m_context.setProperty( "prop-a", "some value" ); - - // Configure the object - m_configurer.configureElement( test, config, m_context ); - - // Check the configured object - final ConfigTestReferenceElement expected = new ConfigTestReferenceElement(); - expected.addSomeProp( "some value" ); - assertEquals( expected, test ); - } - - /** - * Tests that extra content is not allowed in a reference element. - */ - public void testReferenceElementExtra() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration elem = new DefaultConfiguration( "some-prop-ref", "test" ); - elem.setAttribute( "id", "prop-a" ); - elem.setAttribute( "extra-attr", "some value" ); - config.addChild( elem ); - - final ConfigTestReferenceElement test = new ConfigTestReferenceElement(); - - try - { - // Configure the object - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( ConfigurationException e ) - { - final String[] messages = new String[] - { - REZ.getString( "bad-configure-element.error", "some-prop-ref" ), - REZ.getString( "extra-config-for-ref.error" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Tests reference type conversion. - */ - public void testReferenceConversion() throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "prop-a-ref", "id" ); - - final Integer refValue = new Integer( 21 ); - m_context.setProperty( "id", refValue ); - - registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); - - final ConfigTestReferenceConversion test = new ConfigTestReferenceConversion(); - - // Configure - try - { - configure( test, config ); - } - catch( ConfigurationException e ) - { - //Good should no longer work - return; - } - - fail( "-ref pattern on attributes no longer supported" ); - - // Check result - //final ConfigTestReferenceConversion expected = new ConfigTestReferenceConversion(); - //expected.setPropA( new MyRole1Adaptor( refValue ) ); - //assertEquals( expected, test ); - } - - /** - * Tests that the role's default type is used for interface typed - * elements. - */ - public void testInterfaceAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child = new DefaultConfiguration( "prop-a", "test" ); - config.addChild( child ); - - registerRole( new RoleInfo( "myrole1", null, MyRole1.class, "default-type" ) ); - registerType( "myrole1", "default-type", MyType1.class ); - - final ConfigTestInterfaceAdder test = new ConfigTestInterfaceAdder(); - - // Configure object - configure( test, config ); - - // Check result - final ConfigTestInterfaceAdder expected = new ConfigTestInterfaceAdder(); - expected.addPropA( new MyType1() ); - assertEquals( expected, test ); - } - - /** - * Tests whether an object with a non-iterface typed adder causes an - * exception. - */ - public void testNonInterfaceTypedAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - - final ConfigTestNonInterfaceAdder test = new ConfigTestNonInterfaceAdder(); - - try - { - // Configure the object - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( final ConfigurationException ce ) - { - final String[] messages = { - REZ.getString( "bad-configure-element.error", "test" ), - REZ.getString( "typed-adder-non-interface.error", - ConfigTestNonInterfaceAdder.class.getName(), - Integer.class.getName() ) - }; - assertSameMessage( messages, ce ); - } - } - - /** - * Tests whether an object with multiple typed adders causes an exception. - */ - public void testMultipleTypedAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - - final ConfigTestMultipleTypedAdder test = new ConfigTestMultipleTypedAdder(); - - try - { - // Configure the object - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( final ConfigurationException ce ) - { - final String[] messages = new String[] - { - REZ.getString( "bad-configure-element.error", "test" ), - REZ.getString( "multiple-methods-for-element.error", - ConfigTestMultipleTypedAdder.class.getName(), - "add" ) - }; - assertSameMessage( messages, ce ); - } - } - - /** - * Tests to see if typed adder works, with iterface types. - */ - public void testTypedAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child1 = new DefaultConfiguration( "my-type1", "test" ); - final DefaultConfiguration child2 = new DefaultConfiguration( "my-type2", "test" ); - config.addChild( child1 ); - config.addChild( child2 ); - - registerRole( new RoleInfo( MyRole1.ROLE, "my-role1", MyRole1.class ) ); - registerType( MyRole1.ROLE, "my-type1", MyType1.class ); - registerType( MyRole1.ROLE, "my-type2", MyType2.class ); - - final ConfigTestTypedAdder test = new ConfigTestTypedAdder(); - - // Configure the object - configure( test, config ); - - final ConfigTestTypedAdder expected = new ConfigTestTypedAdder(); - expected.add( new MyType1() ); - expected.add( new MyType2() ); - assertEquals( expected, test ); - } - - /** - * Tests to check that role is used for typed adder. - */ - public void testTypedAdderRole() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child1 = new DefaultConfiguration( "my-type1", "test" ); - config.addChild( child1 ); - - // Register incompatible types with the same name, as data-type and myrole1. - registerRole( new RoleInfo( "myrole1", "myrole1", MyRole1.class ) ); - registerType( "myrole1", "my-type1", MyType1.class ); - registerType( DataType.ROLE, "my-type1", StringBuffer.class ); - - final ConfigTestTypedAdderRole test = new ConfigTestTypedAdderRole(); - - // Configure the object - configure( test, config ); - - // Check the result - final ConfigTestTypedAdderRole expected = new ConfigTestTypedAdderRole(); - expected.add( new MyType1() ); - assertEquals( expected, test ); - } - - /** - * Tests conversion with a typed adder. - */ - public void testTypedAdderConversion() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child = new DefaultConfiguration( "some-type", "test" ); - child.setAttribute( "prop", "some value" ); - config.addChild( child ); - - registerType( DataType.ROLE, "some-type", ConfigTestTypedAdderConversion.class ); - registerConverter( ObjectToMyRole1Converter.class, Object.class, MyRole1.class ); - - final ConfigTestTypedAdderConversion test = new ConfigTestTypedAdderConversion(); - - // Configure the object - configure( test, config ); - - // Check the result - final ConfigTestTypedAdderConversion expected = new ConfigTestTypedAdderConversion(); - final ConfigTestTypedAdderConversion nested = new ConfigTestTypedAdderConversion(); - nested.setProp( "some value" ); - expected.add( new MyRole1Adaptor( nested ) ); - assertEquals( expected, test ); - } - - /** - * Tests to see if typed adder works, with Configuration type. - */ - public void testTypedConfigAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child1 = new DefaultConfiguration( "my-type1", "test" ); - final DefaultConfiguration child2 = new DefaultConfiguration( "my-type2", "test" ); - config.addChild( child1 ); - config.addChild( child2 ); - - final ConfigTestTypedConfigAdder test = new ConfigTestTypedConfigAdder(); - - // Configure the object - configure( test, config ); - - final ConfigTestTypedConfigAdder expected = new ConfigTestTypedConfigAdder(); - expected.add( child1 ); - expected.add( child2 ); - assertEquals( expected, test ); - } - - /** - * Tests to see if adder works, with Configuration objects. - */ - public void testConfigAdder() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child1 = new DefaultConfiguration( "config", "test" ); - final DefaultConfiguration child2 = new DefaultConfiguration( "config", "test" ); - config.addChild( child1 ); - config.addChild( child2 ); - - final ConfigTestConfigAdder test = new ConfigTestConfigAdder(); - - // Configure the object - configure( test, config ); - - final ConfigTestConfigAdder expected = new ConfigTestConfigAdder(); - expected.addConfig( child1 ); - expected.addConfig( child2 ); - assertEquals( expected, test ); - } - - /** - * Tests to check that Configurable is handled properly. - */ - public void testConfigurable() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - - final ConfigTestConfigurable test = new ConfigTestConfigurable(); - - // Configure the object - m_configurer.configureElement( test, config, m_context ); - - final ConfigTestConfigurable expected = new ConfigTestConfigurable(); - expected.configure( config ); - assertEquals( expected, test ); - } - - /** - * Test resolving properties in an id. - */ - public void testIdResolve() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "some-prop-ref", "${id}" ); - - final ConfigTestIdResolve test = new ConfigTestIdResolve(); - - m_context.setProperty( "id", "prop-a" ); - m_context.setProperty( "prop-a", "some indirect value" ); - - // Configure the object - try - { - configure( test, config ); - } - catch( ConfigurationException e ) - { - return; - } - - fail( "-ref pattern on attributes no longer supported" ); - // Check the configured object - //final ConfigTestIdResolve expected = new ConfigTestIdResolve(); - //expected.setSomeProp( "some indirect value" ); - //assertEquals( expected, test ); - } - - /** - * Tests an unknown reference. - */ - public void __testUnknownReference() - throws Exception - { - //Should rework - fail( "-ref pattern on attributes no longer supported" ); - - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "some-prop-ref", "unknown-prop" ); - - final ConfigTestUnknownReference test = new ConfigTestUnknownReference(); - - // Configure the object - try - { - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( ConfigurationException e ) - { - final String[] messages = new String[] - { - REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ), - REZ.getString( "unknown-reference.error", "unknown-prop" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Tests handling of mismatched reference type. - */ - public void __testMismatchedRefType() - throws Exception - { - //FIXME: rework testcase - fail( "-ref pattern on attributes no longer supported" ); - - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "some-prop-ref", "prop-a" ); - - final ConfigTestMismatchedRefType test = new ConfigTestMismatchedRefType(); - - m_context.setProperty( "prop-a", new Integer( 23 ) ); - - // Configure the object - try - { - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( ConfigurationException e ) - { - final String[] messages = new String[] - { - REZ.getString( "bad-set-attribute.error", "test", "some-prop-ref" ), - REZ.getString( "mismatch-ref-types.error", - "prop-a", - "some-prop" ) - }; - assertSameMessage( messages, e ); - } - } - - /** - * Tests using a reference with a typed adder. Tests using an attribute - * and a nested element. - */ - public void testTypedAdderReference() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration child = new DefaultConfiguration( "my-role1-ref", "test" ); - child.setAttribute( "id", "id2" ); - config.addChild( child ); - - // Add role mapping, and add to reference to context - registerRole( new RoleInfo( "my-role1", MyRole1.class ) ); - m_context.setProperty( "id2", new MyType2() ); - - final ConfigTestTypedAdderReference test = new ConfigTestTypedAdderReference(); - - // Configure the object - configure( test, config ); - - // Compare against expected value - final ConfigTestTypedAdderReference expected = new ConfigTestTypedAdderReference(); - expected.add( new MyType2() ); - assertEquals( expected, test ); - } - - /** - * Tests reporting of nested errors. - */ - public void testNestedErrors() throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - final DefaultConfiguration elem = new DefaultConfiguration( "prop", "test" ); - elem.setAttribute( "not-a-prop", "not-a-value" ); - config.addChild( elem ); - - final ConfigTestNestedErrors test = new ConfigTestNestedErrors(); - - try - { - // Configure the object - m_configurer.configureElement( test, config, m_context ); - fail(); - } - catch( ConfigurationException e ) - { - final String message = REZ.getString( "no-such-attribute.error", - "prop", - "not-a-prop" ); - assertSameMessage( message, e ); - } - } - - /** - * Tests that string setter/adder/creators are ignored when there - * are multiple. - */ - public void testIgnoreStringMethods() - throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "prop1", "some-value" ); - config.setValue( "99" ); - DefaultConfiguration elem = new DefaultConfiguration( "prop2", "test" ); - config.addChild( elem ); - elem = new DefaultConfiguration( "my-type1", "test" ); - config.addChild( elem ); - - registerConverter( ObjectToMyRole1Converter.class, String.class, MyRole1.class ); - registerConverter( StringToIntegerConverter.class, String.class, Integer.class ); - registerType( DataType.ROLE, "my-type1", MyType1.class ); - - final ConfigTestIgnoreStringMethods test = new ConfigTestIgnoreStringMethods(); - - // Configure the object - configure( test, config ); - - // Test expected value - final ConfigTestIgnoreStringMethods expected = new ConfigTestIgnoreStringMethods(); - expected.setProp1( new MyRole1Adaptor( "some-value" ) ); - expected.addProp2( new ConfigTestIgnoreStringMethods() ); - expected.add( new MyType1() ); - expected.addContent( 99 ); - assertEquals( expected, test ); - } - - /** - * Tests that a class with a setter and adder with the same property name - * is handled correctly. - */ - public void testSetAndAdd() throws Exception - { - // Setup test data - final DefaultConfiguration config = new DefaultConfiguration( "test", "test" ); - config.setAttribute( "prop", "some value" ); - DefaultConfiguration elem = new DefaultConfiguration( "prop", "test" ); - elem.setAttribute( "prop", "another value" ); - config.addChild( elem ); - - final ConfigTestSetAndAdd test = new ConfigTestSetAndAdd(); - - // Configure the object - configure( test, config ); - - // Test expected value - final ConfigTestSetAndAdd expected = new ConfigTestSetAndAdd(); - expected.setProp( "some value" ); - final ConfigTestSetAndAdd nested = new ConfigTestSetAndAdd(); - nested.setProp( "another value" ); - expected.addProp( nested ); - assertEquals( expected, test ); - } - - private void configure( final Object test, - final DefaultConfiguration config ) - throws ConfigurationException - { - try - { - m_configurer.configureElement( test, config, m_context ); - } - catch( final ConfigurationException ce ) - { - ExceptionUtil.printStackTrace( ce ); - throw ce; - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1.java deleted file mode 100644 index c7dc8ae9e..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.myrmidon.framework.DataType; - -/** - * A basic interface to test configurer. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public interface MyRole1 - extends DataType -{ - String ROLE = MyRole1.class.getName(); -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1Adaptor.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1Adaptor.java deleted file mode 100644 index 4c8f448d7..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole1Adaptor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * Adapts an Object to MyRole - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class MyRole1Adaptor - implements MyRole1 -{ - private final Object m_object; - - public MyRole1Adaptor( final Object o ) - { - m_object = o; - } - - public boolean equals( Object obj ) - { - final MyRole1Adaptor adaptor = (MyRole1Adaptor)obj; - return AbstractMyrmidonTest.equals( m_object, adaptor.m_object ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole2.java deleted file mode 100644 index e21a3ee95..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyRole2.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -/** - * A basic interface to test configurer. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public interface MyRole2 -{ -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType1.java deleted file mode 100644 index a0b6b7b70..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType1.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * A basic implementation of MyRole1 to test configurer. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class MyType1 - implements MyRole1 -{ - public boolean equals( final Object object ) - { - return object.getClass() == getClass(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType2.java deleted file mode 100644 index a605ddeed..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/MyType2.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * A basic implementation of MyRole1 to test configurer. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class MyType2 - implements MyRole1 -{ - public boolean equals( final Object object ) - { - return object.getClass() == getClass(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ObjectToMyRole1Converter.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ObjectToMyRole1Converter.java deleted file mode 100644 index 06d74ea6e..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/ObjectToMyRole1Converter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test; - -import org.apache.aut.converter.AbstractConverter; -import org.apache.aut.converter.ConverterException; -import org.apache.myrmidon.components.configurer.test.MyRole1; -import org.apache.myrmidon.components.configurer.test.MyRole1Adaptor; - -/** - * Converts from Object to MyRole1. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class ObjectToMyRole1Converter - extends AbstractConverter -{ - public ObjectToMyRole1Converter() - { - super( Object.class, MyRole1.class ); - } - - protected Object convert( Object original, Object context ) - throws ConverterException - { - return new MyRole1Adaptor( original ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestAttributeConvert.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestAttributeConvert.java deleted file mode 100644 index 840e6d43c..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestAttributeConvert.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import org.apache.myrmidon.components.AbstractComponentTest; - -/** - * A class for testing conversion. - * - * @author Adam Murdoch - */ -public class ConfigTestAttributeConvert -{ - private int m_intProp; - private Integer m_integerProp; - - public void setIntProp( final int intProp ) - { - m_intProp = intProp; - } - - public void setIntegerProp( final Integer integerProp ) - { - m_integerProp = integerProp; - } - - public boolean equals( Object obj ) - { - ConfigTestAttributeConvert test = (ConfigTestAttributeConvert)obj; - if( m_intProp != test.m_intProp ) - { - return false; - } - if( !AbstractComponentTest.equals( m_integerProp, test.m_integerProp ) ) - { - return false; - } - - return true; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestConfigAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestConfigAdder.java deleted file mode 100644 index 1568b4f28..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestConfigAdder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.avalon.framework.configuration.Configuration; - -/** - * Simple class to test adder for Configurations. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestConfigAdder -{ - private ArrayList m_configurations = new ArrayList(); - - public void addConfig( final Configuration configuration ) - { - m_configurations.add( configuration ); - } - - public boolean equals( final Object object ) - { - final ConfigTestConfigAdder other = (ConfigTestConfigAdder)object; - return m_configurations.equals( other.m_configurations ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java deleted file mode 100644 index 0ab4e74c8..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestContent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * A simple test class with string properties. - * - * @author Adam Murdoch - */ -public class ConfigTestContent - implements DataType -{ - private String m_content; - - public boolean equals( final Object obj ) - { - final ConfigTestContent test = (ConfigTestContent)obj; - if( !DefaultConfigurerTestCase.equals( m_content, test.m_content ) ) - { - return false; - } - else - { - return true; - } - } - - public void addContent( final String content ) - { - m_content = content; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java deleted file mode 100644 index 7438e1b6b..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestEmpty.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import org.apache.myrmidon.framework.DataType; - -/** - * An empty class. - * - * @author Adam Murdoch - */ -public class ConfigTestEmpty - implements DataType -{ -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java deleted file mode 100644 index 22fe5d770..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIdResolve.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * A simple test class with string properties. - * - * @author Adam Murdoch - */ -public class ConfigTestIdResolve - implements DataType -{ - private String m_someProp; - - public boolean equals( final Object obj ) - { - final ConfigTestIdResolve test = (ConfigTestIdResolve)obj; - if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) ) - { - return false; - } - else - { - return true; - } - } - - public void setSomeProp( final String value ) - { - m_someProp = value; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java deleted file mode 100644 index 9ecd3d688..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestIgnoreStringMethods.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import junit.framework.AssertionFailedError; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * A test class with multiple setters/adders/creators for a property. - * - * @author Adam Murdoch - */ -public class ConfigTestIgnoreStringMethods -{ - private MyRole1 m_prop1; - private ArrayList m_prop2 = new ArrayList(); - private int m_content; - private ArrayList m_typed = new ArrayList(); - - public boolean equals( Object obj ) - { - ConfigTestIgnoreStringMethods test = (ConfigTestIgnoreStringMethods)obj; - if( !DefaultConfigurerTestCase.equals( m_prop1, test.m_prop1 ) ) - { - return false; - } - if( !m_prop2.equals( test.m_prop2 ) ) - { - return false; - } - if( m_content != test.m_content ) - { - return false; - } - if( !m_typed.equals( test.m_typed ) ) - { - return false; - } - return true; - } - - // - // Multiple Setters - // - - public void setProp1( final String value ) - { - throw new AssertionFailedError(); - } - - public void setProp1( final MyRole1 value ) - { - m_prop1 = value; - } - - // - // Multiple Adders - // - - public void addProp2( final String value ) - { - throw new AssertionFailedError(); - } - - public void addProp2( final ConfigTestIgnoreStringMethods value ) - { - m_prop2.add( value ); - } - - // - // Multiple typed adders - // - - public void add( final String value ) - { - throw new AssertionFailedError(); - } - - public void add( final MyRole1 value ) - { - m_typed.add( value ); - } - - // - // Multiple content setters - // - - public void addContent( final int value ) - { - m_content = value; - } - - public void addContent( final String value ) - { - throw new AssertionFailedError(); - } - -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestInterfaceAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestInterfaceAdder.java deleted file mode 100644 index e622b15af..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestInterfaceAdder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * A test class with an interface property. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class ConfigTestInterfaceAdder -{ - private final ArrayList m_elems = new ArrayList(); - - public void addPropA( final MyRole1 role1 ) - { - m_elems.add( role1 ); - } - - public boolean equals( Object obj ) - { - final ConfigTestInterfaceAdder test = (ConfigTestInterfaceAdder)obj; - return m_elems.equals( test.m_elems ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMismatchedRefType.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMismatchedRefType.java deleted file mode 100644 index 940465036..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMismatchedRefType.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * A simple test class with string properties. - * - * @author Adam Murdoch - */ -public class ConfigTestMismatchedRefType - implements DataType -{ - public void setSomeProp( final String value ) - { - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMultipleTypedAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMultipleTypedAdder.java deleted file mode 100644 index 256aed403..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestMultipleTypedAdder.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import org.apache.myrmidon.components.configurer.test.MyRole1; -import org.apache.myrmidon.components.configurer.test.MyRole2; - -/** - * Simple class with more than one typed adder method. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestMultipleTypedAdder -{ - public void add( final MyRole1 role1 ) - { - } - - public void add( final MyRole2 role2 ) - { - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNestedErrors.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNestedErrors.java deleted file mode 100644 index e6f14a6d4..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNestedErrors.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -/** - * A simple test class. - * - * @author Adam Murdoch - */ -public class ConfigTestNestedErrors -{ - public void addProp( final ConfigTestEmpty test ) - { - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNonInterfaceAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNonInterfaceAdder.java deleted file mode 100644 index 432dd4e82..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestNonInterfaceAdder.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestNonInterfaceAdder -{ - public void add( final Integer integer ) - { - System.out.println( "This should not have been called as " + - "Integer is not an interface" ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestPropResolution.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestPropResolution.java deleted file mode 100644 index 48c729af0..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestPropResolution.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.List; -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestPropResolution -{ - private String m_prop; - - public boolean equals( final Object obj ) - { - final ConfigTestPropResolution test = (ConfigTestPropResolution)obj; - if( !DefaultConfigurerTestCase.equals( m_prop, test.m_prop ) ) - { - return false; - } - else - { - return true; - } - } - - public void setProp( final String value ) - { - m_prop = value; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java deleted file mode 100644 index 5946cdcd7..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceAttribute.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.List; -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestReferenceAttribute -{ - private String m_someProp; - - public boolean equals( final Object obj ) - { - final ConfigTestReferenceAttribute test = (ConfigTestReferenceAttribute)obj; - if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) ) - { - return false; - } - else - { - return true; - } - } - - public void setSomeProp( final String value ) - { - m_someProp = value; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceConversion.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceConversion.java deleted file mode 100644 index 4862d3d78..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceConversion.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * A simple test class. - * - * @author Adam Murdoch - */ -public class ConfigTestReferenceConversion -{ - private final ArrayList m_elems = new ArrayList(); - - public void setPropA( final MyRole1 role1 ) - { - m_elems.add( role1 ); - } - - public boolean equals( Object obj ) - { - final ConfigTestReferenceConversion test = (ConfigTestReferenceConversion)obj; - return m_elems.equals( test.m_elems ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceElement.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceElement.java deleted file mode 100644 index d6d1cd007..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestReferenceElement.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * A simple test class. - * - * @author Adam Murdoch - */ -public class ConfigTestReferenceElement -{ - private String m_someProp; - - public boolean equals( Object obj ) - { - ConfigTestReferenceElement test = (ConfigTestReferenceElement)obj; - if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) ) - { - return false; - } - return true; - } - - public void addSomeProp( final String value ) - { - m_someProp = value; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAndAdd.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAndAdd.java deleted file mode 100644 index 68ebb1d7a..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAndAdd.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.AbstractMyrmidonTest; - -/** - * A test class with a setter and adder with the same property name. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class ConfigTestSetAndAdd -{ - private String m_prop; - private ArrayList m_nested = new ArrayList(); - - public void setProp( final String prop ) - { - m_prop = prop; - } - - public void addProp( final ConfigTestSetAndAdd elem ) - { - m_nested.add( elem ); - } - - public boolean equals( final Object obj ) - { - ConfigTestSetAndAdd test = (ConfigTestSetAndAdd)obj; - if( ! AbstractMyrmidonTest.equals( m_prop, test.m_prop) ) - { - return false; - } - else if( ! m_nested.equals( test.m_nested ) ) - { - return false; - } - else - { - return true; - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java deleted file mode 100644 index 4a933ef33..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetAttribute.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.List; -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * Simple class to test setter. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestSetAttribute -{ - private String m_someProp; - - public boolean equals( final Object obj ) - { - final ConfigTestSetAttribute test = (ConfigTestSetAttribute)obj; - if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) ) - { - return false; - } - else - { - return true; - } - } - - public void setSomeProp( final String value ) - { - m_someProp = value; - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java deleted file mode 100644 index d360a72ea..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestSetElement.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.components.configurer.test.DefaultConfigurerTestCase; - -/** - * A simple test class. - * - * @author Adam Murdoch - */ -public class ConfigTestSetElement -{ - private List m_propList = new ArrayList(); - private String m_someProp; - - public boolean equals( Object obj ) - { - ConfigTestSetElement test = (ConfigTestSetElement)obj; - if( !m_propList.equals( test.m_propList ) ) - { - return false; - } - else if( !DefaultConfigurerTestCase.equals( m_someProp, test.m_someProp ) ) - { - return false; - } - return true; - } - - public void setSomeProp( final String value ) - { - m_someProp = value; - } - - public void addProp( final ConfigTestSetElement test ) - { - m_propList.add( test ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java deleted file mode 100644 index fdea6422b..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * Simple class to test adder for Configurations. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestTypedAdder -{ - private ArrayList m_roles = new ArrayList(); - - public void add( final MyRole1 role ) - { - m_roles.add( role ); - } - - public boolean equals( final Object object ) - { - final ConfigTestTypedAdder other = (ConfigTestTypedAdder)object; - return m_roles.equals( other.m_roles ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderConversion.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderConversion.java deleted file mode 100644 index 0aeb29d9b..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderConversion.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; -import org.apache.myrmidon.framework.DataType; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestTypedAdderConversion - implements DataType -{ - private ArrayList m_roles = new ArrayList(); - private String m_prop; - - public void setProp( final String prop ) - { - m_prop = prop; - } - public void add( final MyRole1 role1 ) - { - m_roles.add( role1 ); - } - - public boolean equals( final Object object ) - { - final ConfigTestTypedAdderConversion other = (ConfigTestTypedAdderConversion)object; - return m_roles.equals( other.m_roles ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderReference.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderReference.java deleted file mode 100644 index 6ce6bc078..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderReference.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestTypedAdderReference -{ - private ArrayList m_roles = new ArrayList(); - - public void add( final MyRole1 role1 ) - { - m_roles.add( role1 ); - } - - public boolean equals( final Object object ) - { - final ConfigTestTypedAdderReference other = (ConfigTestTypedAdderReference)object; - return m_roles.equals( other.m_roles ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderRole.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderRole.java deleted file mode 100644 index d8ac8d59e..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedAdderRole.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.myrmidon.components.configurer.test.MyRole1; - -/** - * Simple class to test typed adder. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestTypedAdderRole -{ - private ArrayList m_roles = new ArrayList(); - - public void add( final MyRole1 role1 ) - { - m_roles.add( role1 ); - } - - public boolean equals( final Object object ) - { - final ConfigTestTypedAdderRole other = (ConfigTestTypedAdderRole)object; - return m_roles.equals( other.m_roles ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedConfigAdder.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedConfigAdder.java deleted file mode 100644 index 2d7bcf02d..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestTypedConfigAdder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import java.util.ArrayList; -import org.apache.avalon.framework.configuration.Configuration; - -/** - * Simple class to test adder for Configurations. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConfigTestTypedConfigAdder -{ - private ArrayList m_configurations = new ArrayList(); - - public void add( final Configuration configuration ) - { - m_configurations.add( configuration ); - } - - public boolean equals( final Object object ) - { - final ConfigTestTypedConfigAdder other = (ConfigTestTypedConfigAdder)object; - return m_configurations.equals( other.m_configurations ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java deleted file mode 100644 index d304f1c4c..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/data/ConfigTestUnknownReference.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.configurer.test.data; - -import org.apache.myrmidon.framework.DataType; - -/** - * A simple test class with string properties. - * - * @author Adam Murdoch - */ -public class ConfigTestUnknownReference - implements DataType -{ - public void setSomeProp( final String value ) - { - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java deleted file mode 100644 index 37247aea9..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.deployer.test; - -import java.io.File; -import org.apache.aut.converter.Converter; -import org.apache.aut.converter.ConverterException; -import org.apache.myrmidon.components.AbstractComponentTest; -import org.apache.myrmidon.components.deployer.DefaultDeployer; -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition; -import org.apache.myrmidon.interfaces.deployer.Deployer; -import org.apache.myrmidon.interfaces.deployer.TypeDefinition; -import org.apache.myrmidon.interfaces.deployer.TypeDeployer; -import org.apache.myrmidon.interfaces.type.TypeException; -import org.apache.myrmidon.interfaces.type.TypeFactory; - -/** - * Test cases for the default deployer. - * - * @author Adam Murdoch - */ -public class DefaultDeployerTestCase - extends AbstractComponentTest -{ - private static final String TEST_TYPE1_NAME = "test-type1"; - - private Deployer m_deployer; - private Converter m_converter; - - public DefaultDeployerTestCase( final String name ) - { - super( name ); - } - - /** - * Setup the test case - prepares the set of components, including the - * deployer. - */ - protected void setUp() throws Exception - { - super.setUp(); - m_deployer = (Deployer)getServiceManager().lookup( Deployer.ROLE ); - m_converter = (Converter)getServiceManager().lookup( Converter.ROLE ); - } - - /** - * Creates an instance of a component. Sub-classes can override this - * method to add a particular implementation to the set of test components. - */ - protected Object createComponent( final String role, final Class defaultImpl ) - throws Exception - { - if( role.equals( Deployer.ROLE) ) - { - return new DefaultDeployer(); - } - else - { - return super.createComponent( role, defaultImpl ); - } - } - - /** - * Tests deployment of a single type from a ClassLoader. - */ - public void testSingleType() throws Exception - { - final String typeName = TEST_TYPE1_NAME; - final String classname = TestType1.class.getName(); - - // Determine the shorthand for the DataType role - - // Create the type definition - final TypeDefinition typeDef = new TypeDefinition( typeName, DATA_TYPE_ROLE, classname ); - - final ClassLoader classLoader = getClass().getClassLoader(); - final TypeDeployer typeDeployer = m_deployer.createDeployer( classLoader ); - - // Make sure the test types have not been deployed - assertTypesNotRegistered(); - - // Deploy the type - typeDeployer.deployType( typeDef ); - - // Check the type has been registered - final TypeFactory typeFactory = getTypeManager().getFactory( DataType.ROLE ); - final Object result = typeFactory.create( typeName ); - assertTrue( result instanceof TestType1 ); - } - - /** - * Tests deployment of a single converter from a ClassLoader. - */ - public void testSingleConverter() throws Exception - { - // Create the type definition - final String classname = TestConverter1.class.getName(); - final String source = "java.lang.String"; - final String destClass = TestType1.class.getName(); - - final ConverterDefinition typeDef = - new ConverterDefinition( classname, source, destClass ); - - final ClassLoader classLoader = getClass().getClassLoader(); - final TypeDeployer typeDeployer = m_deployer.createDeployer( classLoader ); - - // Make sure the test types have not been deployed - assertTypesNotRegistered(); - - // Deploy the type - typeDeployer.deployType( typeDef ); - - // Try to convert from string to test type - final Object result = m_converter.convert( TestType1.class, "some-string", null ); - assertTrue( result instanceof TestType1 ); - } - - /** - * Tests deployment of types from a typelib descriptor. - */ - public void testLibDescriptor() throws Exception - { - final File typelib = getTestResource( "test.atl" ); - final TypeDeployer typeDeployer = m_deployer.createDeployer( typelib ); - - // Make sure the test types have not been deployed - assertTypesNotRegistered(); - - // Deploy all the types from the descriptor - typeDeployer.deployAll(); - - // Make sure the test types have been deployed - assertTypesRegistered(); - } - - /** - * Ensures that the test types have not ben deployed. - */ - private void assertTypesNotRegistered() throws Exception - { - // Check the data-type - TypeFactory typeFactory = getTypeManager().getFactory( DataType.ROLE ); - try - { - typeFactory.create( TEST_TYPE1_NAME ); - fail(); - } - catch( TypeException e ) - { - // TODO - check error message - } - - // Check the custom role implementation - try - { - typeFactory = getTypeManager().getFactory( TestRole1.ROLE ); - typeFactory.create( TEST_TYPE1_NAME ); - fail(); - } - catch( TypeException e ) - { - // TODO - check error message - } - - // Check the converter - try - { - m_converter.convert( TestType1.class, "some string", null ); - fail(); - } - catch( ConverterException e ) - { - // TODO - check error message - } - } - - /** - * Ensures the types from the test typelib descriptor have been correctly - * deployed. - */ - private void assertTypesRegistered() throws Exception - { - // Check the data-type - TypeFactory typeFactory = getTypeManager().getFactory( DataType.ROLE ); - Object object = typeFactory.create( TEST_TYPE1_NAME ); - assertTrue( object instanceof TestType1 ); - - // Check the custom role implementation - typeFactory = getTypeManager().getFactory( TestRole1.ROLE ); - object = typeFactory.create( TEST_TYPE1_NAME ); - assertTrue( object instanceof TestType1 ); - - // Check the converter - object = m_converter.convert( TestType1.class, "some string", null ); - assertTrue( object instanceof TestType1 ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestConverter1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestConverter1.java deleted file mode 100644 index af61edaa2..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestConverter1.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.deployer.test; - -import org.apache.aut.converter.Converter; -import org.apache.aut.converter.ConverterException; - -/** - * A test converter. - * - * @author Adam Murdoch - */ -public class TestConverter1 - implements Converter -{ - /** - * Convert original to destination type. - */ - public Object convert( Class destination, Object original, Object context ) - throws ConverterException - { - return new TestType1(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestRole1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestRole1.java deleted file mode 100644 index 60fc79166..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestRole1.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.deployer.test; - -/** - * A test role interface. - * - * @author Adam Murdoch - */ -public interface TestRole1 -{ - String ROLE = TestRole1.class.getName(); -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestType1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestType1.java deleted file mode 100644 index 7cf53f163..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/TestType1.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.deployer.test; - -import org.apache.myrmidon.framework.DataType; -import org.apache.myrmidon.components.deployer.test.TestRole1; - -/** - * A test data-type. - * - * @author Adam Murdoch - */ -public class TestType1 - implements DataType, TestRole1 -{ -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml deleted file mode 100644 index 43d07cd67..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-descriptor.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-roles.xml b/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-roles.xml deleted file mode 100644 index 86e6070ec..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/deployer/test/ant-roles.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java deleted file mode 100644 index f32422edf..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.embeddor.test; - -import java.io.File; -import java.util.HashMap; -import org.apache.avalon.framework.context.DefaultContext; -import org.apache.avalon.framework.logger.Logger; -import org.apache.myrmidon.AbstractProjectTest; -import org.apache.myrmidon.LogMessageTracker; -import org.apache.myrmidon.components.embeddor.DefaultEmbeddor; -import org.apache.myrmidon.interfaces.embeddor.Embeddor; -import org.apache.myrmidon.interfaces.model.Project; -import org.apache.myrmidon.interfaces.model.Target; -import org.apache.myrmidon.interfaces.workspace.Workspace; -import org.apache.myrmidon.listeners.ProjectListener; - -/** - * Test cases for the default embeddor. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class DefaultEmbeddorTest - extends AbstractProjectTest -{ - private DefaultEmbeddor m_embeddor; - - public DefaultEmbeddorTest( String name ) - { - super( name ); - } - - /** - * Tear-down the test. - */ - protected void tearDown() throws Exception - { - if( m_embeddor != null ) - { - m_embeddor.dispose(); - m_embeddor = null; - } - } - - /** - * Returns an embeddor which can be used to build and execute projects. - */ - protected Embeddor getEmbeddor() throws Exception - { - if( m_embeddor == null ) - { - // Need to set the context classloader - The default embeddor uses it - Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); - - final Logger logger = getLogger(); - m_embeddor = new DefaultEmbeddor(); - m_embeddor.enableLogging( logger ); - - final DefaultContext context = new DefaultContext(); - context.put( "myrmidon.home", getInstallDirectory() ); - m_embeddor.contextualize( context ); - m_embeddor.initialize(); - m_embeddor.start(); - } - - return m_embeddor; - } - - /** - * Tests that a project is successfully built from a file. - */ - public void testProjectBuilder() throws Exception - { - // Build the project - final File projectFile = getTestResource( "project-builder.ant" ); - final Project project = getEmbeddor().createProject( projectFile.getAbsolutePath(), null, null ); - - // Verify the project. - assertEquals( "test-project", project.getProjectName() ); - assertEquals( "main-target", project.getDefaultTargetName() ); - assertEquals( projectFile.getParentFile(), project.getBaseDirectory() ); - assertEquals( 0, project.getProjectNames().length ); - assertEquals( 0, project.getTypeLibs().length ); - assertEquals( 1, project.getTargetNames().length ); - - final Target implicitTarget = project.getImplicitTarget(); - assertEquals( 1, implicitTarget.getTasks().length ); - assertEquals( "property", implicitTarget.getTasks()[ 0 ].getName() ); - - final Target target = project.getTarget( "main-target" ); - assertEquals( 1, target.getTasks().length ); - assertEquals( "log", target.getTasks()[ 0 ].getName() ); - } - - /** - * Tests that a listener can be created. - */ - public void testCreateListener() throws Exception - { - final ProjectListener listener = getEmbeddor().createListener( "default" ); - assertNotNull( listener ); - } - - /** - * Tests that a workspace can execute a project file. - */ - public void testWorkspaceCreate() throws Exception - { - // Build the project - final File projectFile = getTestResource( "project-builder.ant" ); - final Embeddor embeddor = getEmbeddor(); - final Project project = embeddor.createProject( projectFile.getAbsolutePath(), null, null ); - - // Build the workspace - final Workspace workspace = embeddor.createWorkspace( new HashMap() ); - - // Install a listener - final LogMessageTracker listener = new LogMessageTracker(); - workspace.addProjectListener( listener ); - - listener.addExpectedMessage( "main-target", "A log message" ); - - // Execute the default target - final String target = project.getDefaultTargetName(); - workspace.executeProject( project, target ); - - // Cleanup - listener.assertComplete(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/project-builder.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/project-builder.ant deleted file mode 100644 index 7f52d2702..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/embeddor/test/project-builder.ant +++ /dev/null @@ -1,6 +0,0 @@ - - - - A log message - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java deleted file mode 100644 index da422a1b7..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.property.test; - -import java.io.File; -import java.util.Date; -import org.apache.aut.converter.lib.ObjectToStringConverter; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.framework.service.DefaultServiceManager; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.components.AbstractComponentTest; -import org.apache.myrmidon.components.workspace.DefaultTaskContext; -import org.apache.myrmidon.components.property.DefaultPropertyResolver; -import org.apache.myrmidon.components.store.DefaultPropertyStore; -import org.apache.myrmidon.interfaces.property.PropertyResolver; -import org.apache.myrmidon.interfaces.property.PropertyStore; - -/** - * General-purpose property resolver test cases. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public abstract class AbstractPropertyResolverTestCase - extends AbstractComponentTest -{ - protected PropertyResolver m_resolver; - protected TaskContext m_context; - - public AbstractPropertyResolverTestCase( final String name ) - { - super( name ); - } - - protected void setUp() throws Exception - { - m_resolver = (PropertyResolver)getServiceManager().lookup( PropertyResolver.ROLE ); - - final PropertyStore store = new DefaultPropertyStore(); - m_context = - new DefaultTaskContext( new DefaultServiceManager(), getLogger(), store ); - - m_context.setProperty( "intProp", new Integer( 333 ) ); - m_context.setProperty( "stringProp", "String property" ); - - registerConverter( ObjectToStringConverter.class, Object.class, String.class ); - } - - /** - * Creates an instance of a component. Sub-classes can override this - * method to add a particular implementation to the set of test components. - */ - protected Object createComponent( String role, Class defaultImpl ) - throws Exception - { - if( role.equals( PropertyResolver.ROLE) ) - { - return createResolver(); - } - else - { - return super.createComponent( role, defaultImpl ); - } - } - - /** - * Creates the resolver to test. - */ - protected abstract PropertyResolver createResolver(); - - /** - * Test property resolution with various different typed properties. - */ - public void testPropertyTypes() throws Exception - { - testPropertyValue( new String( "String value" ) ); - testPropertyValue( new Date() ); - testPropertyValue( new Integer( Integer.MIN_VALUE ) ); - testPropertyValue( new Double( 24234.98453 ) ); - testPropertyValue( this.getClass() ); - testPropertyValue( File.createTempFile( "PropertyResolverTest", null ) ); - } - - /** - * Simple tests with property on it's own, and accompanied by text. - */ - private void testPropertyValue( final Object propObject ) - throws Exception - { - m_context.setProperty( "typedProp", propObject ); - final String propString = propObject.toString(); - - doTestResolution( "${typedProp}", propObject, m_context ); - doTestResolution( "${typedProp} with following text", - propString + " with following text", m_context ); - doTestResolution( "Preceding text with ${typedProp}", - "Preceding text with " + propString, m_context ); - } - - /** - * Tests multiple property declarations in a single value. - */ - public void testMultipleProperties() throws Exception - { - m_context.setProperty( "prop1", "value1" ); - m_context.setProperty( "prop2", "value2" ); - m_context.setProperty( "int1", new Integer( 123 ) ); - - doTestResolution( "${prop1}${prop2}", "value1value2", m_context ); - doTestResolution( "${prop1}${prop1}${prop1}", "value1value1value1", m_context ); - doTestResolution( "before ${prop2} between ${prop1} after", - "before value2 between value1 after", m_context ); - doTestResolution( "${prop1}-${int1}-${prop2}", "value1-123-value2", m_context ); - } - - /** - * Tests illegal property syntax. - */ - public void testInvalidTypeDeclarations() throws Exception - { - final Resources rez = getResourcesForTested( DefaultPropertyResolver.class ); - doTestFailure( "${unclosed", - rez.getString( "prop.mismatched-braces.error" ), - m_context ); - doTestFailure( "${", - rez.getString( "prop.mismatched-braces.error" ), - m_context ); - - /* TODO - need to handle these cases. */ - // testFailure( "${bad${}", "", m_context ); - // testFailure( "${ }", "", m_context ); - } - - /** - * Resolves the property using the supplied context, and checks the result. - */ - protected void doTestResolution( final String value, - final Object expected, - final TaskContext context ) - throws Exception - { - final Object resolved = m_resolver.resolveProperties( value, context ); - - assertEquals( expected, resolved ); - } - - /** - * Attempts to resolve the value using the supplied context, expecting to - * fail with the supplied error message. - */ - protected void doTestFailure( final String value, - final String expectedErrorMessage, - final TaskContext context ) - { - try - { - m_resolver.resolveProperties( value, context ); - fail( "Unexpected sucess - test should have failed." ); - } - catch( TaskException e ) - { - assertSameMessage( expectedErrorMessage, e ); - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java deleted file mode 100644 index 12eef075a..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/ClassicPropertyResolverTestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.property.test; - -import org.apache.myrmidon.interfaces.property.PropertyResolver; -import org.apache.myrmidon.components.property.test.AbstractPropertyResolverTestCase; -import org.apache.myrmidon.components.property.ClassicPropertyResolver; - -/** - * A test for {@link org.apache.myrmidon.components.property.ClassicPropertyResolver}. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public class ClassicPropertyResolverTestCase - extends AbstractPropertyResolverTestCase -{ - public ClassicPropertyResolverTestCase( String name ) - { - super( name ); - } - - protected PropertyResolver createResolver() - { - return new ClassicPropertyResolver(); - } - - /** - * Tests handing undefined property. - */ - public void testUndefinedProp() throws Exception - { - final String undefinedProp = "undefinedProperty"; - final String propRef = "${" + undefinedProp + "}"; - doTestResolution( propRef, propRef, m_context ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java deleted file mode 100644 index 985a5a493..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/DefaultPropertyResolverTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.property.test; - -import org.apache.myrmidon.interfaces.property.PropertyResolver; -import org.apache.myrmidon.components.property.test.AbstractPropertyResolverTestCase; -import org.apache.myrmidon.components.property.DefaultPropertyResolver; -import org.apache.myrmidon.components.store.DefaultPropertyStore; -import org.apache.avalon.excalibur.i18n.Resources; - -/** - * Functional tests for {@link org.apache.myrmidon.components.property.DefaultPropertyResolver}. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public class DefaultPropertyResolverTestCase - extends AbstractPropertyResolverTestCase -{ - public DefaultPropertyResolverTestCase( final String name ) - { - super( name ); - } - - protected PropertyResolver createResolver() - { - return new DefaultPropertyResolver(); - } - - /** - * Tests handing undefined property. - */ - public void testUndefinedProp() throws Exception - { - final Resources rez = getResourcesForTested( DefaultPropertyStore.class ); - final String undefinedProp = "undefinedProperty"; - doTestFailure( "${" + undefinedProp + "}", - rez.getString( "unknown-prop.error", undefinedProp ), - m_context ); - - //TODO - "" should be disallowed as a property name - doTestFailure( "${}", - rez.getString( "unknown-prop.error", "" ), - m_context ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java deleted file mode 100644 index ba68eb68c..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.role.test; - -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.components.role.DefaultRoleManager; -import org.apache.myrmidon.api.Task; -import org.apache.myrmidon.interfaces.role.RoleException; -import org.apache.myrmidon.interfaces.role.RoleInfo; -import org.apache.myrmidon.interfaces.role.RoleManager; - -/** - * Test cases for the DefaultRoleManager. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class DefaultRoleManagerTestCase - extends AbstractMyrmidonTest -{ - private final static Resources REZ = getResourcesForTested( DefaultRoleManagerTestCase.class ); - - private RoleManager m_roleManager; - - public DefaultRoleManagerTestCase( String name ) - { - super( name ); - } - - protected void setUp() throws Exception - { - m_roleManager = new DefaultRoleManager(); - } - - /** - * Tests looking up a role by name, shorthand and type. - */ - public void testLookup() throws Exception - { - final String roleName = "role-name"; - final String shorthand = "role-shorthand"; - final RoleInfo origRole = new RoleInfo( roleName, shorthand, Task.class ); - m_roleManager.addRole( origRole ); - - // Lookup the role - RoleInfo role = m_roleManager.getRole( roleName ); - assertTrue( origRole.equals( role ) ); - - // Lookup the role by shorthand - role = m_roleManager.getRoleByShorthandName( shorthand ); - assertTrue( origRole.equals( role ) ); - - // Lookup the role by type - role = m_roleManager.getRoleByType( Task.class ); - assertTrue( origRole.equals( role ) ); - - // Lookup an unknown role - RoleInfo unknownRole = m_roleManager.getRole( "unknown" ); - assertNull( unknownRole ); - - // Lookup an unknown shorthand - unknownRole = m_roleManager.getRoleByShorthandName( "unknown" ); - assertNull( unknownRole ); - - // Lookup an unknown role - unknownRole = m_roleManager.getRoleByType( DefaultRoleManagerTestCase.class ); - assertNull( unknownRole ); - } - - /** - * Tests inheriting roles from parent role manager. - */ - public void testParent() throws Exception - { - final String roleName = "role-name"; - final String shorthand = "shorthand"; - final RoleInfo origRole = new RoleInfo( roleName, shorthand, Task.class ); - m_roleManager.addRole( origRole ); - final RoleManager roleManager = new DefaultRoleManager( m_roleManager ); - - // Lookup by name - RoleInfo roleInfo = roleManager.getRole( roleName ); - assertTrue( origRole.equals( roleInfo ) ); - - // Lookup by shorthand - roleInfo = roleManager.getRoleByShorthandName( shorthand ); - assertTrue( origRole.equals( roleInfo ) ); - - // Lookup by type - roleInfo = roleManager.getRoleByType( Task.class ); - assertTrue( origRole.equals( roleInfo ) ); - } - - /** - * Tests overriding a role in a child role manager. - */ - public void testOverrideName() throws Exception - { - final String roleName = "role-name"; - final String shorthand = "shorthand"; - - // Add original role - final RoleInfo origRole = new RoleInfo( roleName, shorthand, Task.class ); - m_roleManager.addRole( origRole ); - - // Override role - final RoleManager roleManager = new DefaultRoleManager( m_roleManager ); - final RoleInfo overrideNameRole = new RoleInfo( roleName, "shorthand1" ); - roleManager.addRole( overrideNameRole ); - final RoleInfo overrideShorthandRole = new RoleInfo( "role2", shorthand ); - roleManager.addRole( overrideShorthandRole ); - final RoleInfo overrideTypeRole = new RoleInfo( "role3", "shorthand3", Task.class ); - roleManager.addRole( overrideTypeRole ); - - // Lookup role by name - RoleInfo roleInfo = roleManager.getRole( roleName ); - assertTrue( overrideNameRole.equals( roleInfo ) ); - - // Lookup role by shorthand - roleInfo = roleManager.getRoleByShorthandName( shorthand ); - assertTrue( overrideShorthandRole.equals( roleInfo ) ); - - // Lookup role by type - roleInfo = roleManager.getRoleByType( Task.class ); - assertTrue( overrideTypeRole.equals( roleInfo ) ); - } - - /** - * Tests adding duplicate roles. - */ - public void testDuplicate() throws Exception - { - final String roleName = "role-name"; - final String shorthand = "shorthand"; - final RoleInfo origRole = new RoleInfo( roleName, shorthand, Task.class ); - m_roleManager.addRole( origRole ); - - // Duplicate role name - try - { - m_roleManager.addRole( new RoleInfo( roleName ) ); - fail(); - } - catch( RoleException exc ) - { - final String message = REZ.getString( "duplicate-role.error", roleName ); - assertSameMessage( message, exc ); - } - - // Duplicate shorthand - try - { - m_roleManager.addRole( new RoleInfo( "another-role", shorthand ) ); - fail(); - } - catch( RoleException exc ) - { - final String message = REZ.getString( "duplicate-shorthand.error", shorthand ); - assertSameMessage( message, exc ); - } - - // Duplicate type - try - { - m_roleManager.addRole( new RoleInfo( null, Task.class ) ); - fail(); - } - catch( RoleException exc ) - { - final String message = REZ.getString( "duplicate-type.error", Task.class.getName() ); - assertSameMessage( message, exc ); - } - } - -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java deleted file mode 100644 index e453a838b..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.context.DefaultContext; -import org.apache.myrmidon.components.AbstractComponentTest; -import org.apache.myrmidon.components.service.InstantiatingServiceManager; -import org.apache.myrmidon.interfaces.role.RoleInfo; -import org.apache.myrmidon.interfaces.role.RoleManager; -import org.apache.myrmidon.interfaces.service.ServiceFactory; -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; -import org.apache.myrmidon.interfaces.type.TypeManager; - -/** - * Test cases for the default service manager. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class InstantiatingServiceManagerTestCase - extends AbstractComponentTest -{ - private final static Resources REZ = getResourcesForTested( InstantiatingServiceManagerTestCase.class ); - - private InstantiatingServiceManager m_serviceManager; - - public InstantiatingServiceManagerTestCase( final String name ) - { - super( name ); - } - - /** - * Setup the test case - prepares the set of components. - */ - protected void setUp() - throws Exception - { - // Set-up the service manager - m_serviceManager = new InstantiatingServiceManager(); - m_serviceManager.enableLogging( getLogger() ); - m_serviceManager.contextualize( new DefaultContext() ); - m_serviceManager.service( getServiceManager() ); - m_serviceManager.parameterize( new Parameters() ); - } - - /** - * Tests service instantiation. - */ - public void testCreateService() throws Exception - { - final String serviceRoleName = "test-service"; - - // Setup the test service - registerFactory( serviceRoleName, TestService.class, TestServiceFactory1.class ); - - // Create the service - Object service = m_serviceManager.lookup( serviceRoleName ); - - // Check service is of the expected class (don't use instanceof) - assertTrue( service.getClass() == TestServiceImpl1.class ); - } - - /** - * Tests service lookup. - */ - public void testLookup() throws Exception - { - final String serviceRoleName = "test-service"; - - // Setup the test service - registerFactory( serviceRoleName, TestService.class, TestServiceFactory1.class ); - - // Check whether the service can be instantiated - boolean hasService = m_serviceManager.hasService( serviceRoleName ); - assertTrue( hasService ); - } - - /** - * Tests that a service factory and service instance are taken through - * the lifecycle steps. - */ - public void testLifecycle() throws Exception - { - final String serviceRoleName = "test-service"; - - // Setup the test service - registerFactory( serviceRoleName, TestService.class, TestServiceFactory2.class ); - - // Create the service - TestService service = (TestService)m_serviceManager.lookup( serviceRoleName ); - - // Check service is of the expected class (don't use instanceof) - assertTrue( service.getClass() == TestServiceImpl2.class ); - - // Assert the service has been setup correctly - LifecycleValidator validate = (LifecycleValidator)service; - validate.assertSetup(); - - // Cleanup - m_serviceManager.dispose(); - - // Assert the service has been shutdown correctly - validate.assertDisposed(); - } - - /** - * Tests looking up an unknown service. - */ - public void testUnknownService() throws Exception - { - // Make sure that hasService() works correctly - final String serviceRole = "some-unknown-service"; - assertTrue( !m_serviceManager.hasService( serviceRole ) ); - - // Make sure that lookup() fails - try - { - m_serviceManager.lookup( serviceRole ); - fail(); - } - catch( ServiceException e ) - { - final String message = REZ.getString( "create-service.error", serviceRole ); - assertSameMessage( message, e ); - } - } - - /** - * Registers a service factory. - */ - private void registerFactory( final String serviceRoleName, - final Class serviceType, - final Class factoryClass ) - throws Exception - { - // TODO - add stuff to TypeDeployer to do this instead - final RoleManager roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE ); - roleManager.addRole( new RoleInfo( serviceRoleName, null, serviceType ) ); - final DefaultTypeFactory typeFactory = new DefaultTypeFactory( getClass().getClassLoader() ); - typeFactory.addNameClassMapping( serviceRoleName, factoryClass.getName() ); - final TypeManager typeManager = (TypeManager)getServiceManager().lookup( TypeManager.ROLE ); - typeManager.registerType( ServiceFactory.ROLE, serviceRoleName, typeFactory ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/LifecycleValidator.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/LifecycleValidator.java deleted file mode 100644 index 8da938889..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/LifecycleValidator.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import junit.framework.Assert; -import org.apache.avalon.framework.activity.Initializable; -import org.apache.avalon.framework.activity.Disposable; -import org.apache.avalon.framework.logger.LogEnabled; -import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.parameters.ParameterException; -import org.apache.avalon.framework.parameters.Parameterizable; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.service.ServiceException; -import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.Serviceable; -import org.apache.avalon.framework.context.Contextualizable; -import org.apache.avalon.framework.context.Context; -import org.apache.avalon.framework.context.ContextException; - -/** - * A basic class that asserts that the object is correctly set-up. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class LifecycleValidator - extends Assert - implements LogEnabled, Contextualizable, Serviceable, Parameterizable, Initializable, Disposable -{ - private String m_state = STATE_NOT_INIT; - - private final static String STATE_NOT_INIT = "not-prepared"; - private final static String STATE_LOG_ENABLED = "log-enabled"; - private final static String STATE_SERVICED = "serviced"; - private final static String STATE_PARAMETERISED = "parameterised"; - private final static String STATE_INITIALISED = "initialised"; - private final static String STATE_CONTEXTUALISED = "contextualised"; - private final static String STATE_DISPOSED = "disposed"; - - public void enableLogging( final Logger logger ) - { - assertEquals( STATE_NOT_INIT, m_state ); - m_state = STATE_LOG_ENABLED; - } - - public void contextualize( final Context context ) throws ContextException - { - assertEquals( STATE_LOG_ENABLED, m_state ); - m_state = STATE_CONTEXTUALISED; - } - - public void service( final ServiceManager serviceManager ) throws ServiceException - { - assertEquals( STATE_CONTEXTUALISED, m_state ); - m_state = STATE_SERVICED; - } - - public void parameterize( final Parameters parameters ) throws ParameterException - { - assertEquals( STATE_SERVICED, m_state ); - m_state = STATE_PARAMETERISED; - } - - public void initialize() throws Exception - { - assertEquals( STATE_PARAMETERISED, m_state ); - m_state = STATE_INITIALISED; - } - - public void dispose() - { - assertEquals( STATE_INITIALISED, m_state ); - m_state = STATE_DISPOSED; - } - - protected void assertSetup() - { - assertEquals( STATE_INITIALISED, m_state ); - } - - protected void assertDisposed() - { - assertEquals( STATE_DISPOSED, m_state ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestService.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestService.java deleted file mode 100644 index 302c2a5b3..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestService.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -/** - * A service interface. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public interface TestService -{ - void doWork(); -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java deleted file mode 100644 index 10e0f69bc..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import org.apache.myrmidon.interfaces.service.AntServiceException; -import org.apache.myrmidon.interfaces.service.ServiceFactory; - -/** - * A test service factory. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class TestServiceFactory1 - implements ServiceFactory -{ - /** - * Create a service that coresponds to this factory. - */ - public Object createService() - throws AntServiceException - { - return new TestServiceImpl1(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java deleted file mode 100644 index 524d3cc04..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import org.apache.myrmidon.interfaces.service.AntServiceException; -import org.apache.myrmidon.interfaces.service.ServiceFactory; -import org.apache.myrmidon.components.service.test.LifecycleValidator; - -/** - * A test service factory, which asserts that the factory has been properly - * set-up before it is used. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class TestServiceFactory2 - extends LifecycleValidator - implements ServiceFactory -{ - /** - * Create a service that corresponds to this factory. - */ - public Object createService() - throws AntServiceException - { - assertSetup(); - return new TestServiceImpl2(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl1.java deleted file mode 100644 index c22e4d0a7..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl1.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import org.apache.myrmidon.components.service.test.TestService; - -/** - * A test service implementation. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class TestServiceImpl1 - implements TestService -{ - public void doWork() - { - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl2.java deleted file mode 100644 index 933d76383..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/components/service/test/TestServiceImpl2.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.components.service.test; - -import org.apache.myrmidon.components.service.test.LifecycleValidator; -import org.apache.myrmidon.components.service.test.TestService; - -/** - * A test service that asserts it has been set-up correctly. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class TestServiceImpl2 - extends LifecycleValidator - implements TestService -{ - public void doWork() - { - assertSetup(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java deleted file mode 100644 index ff3368e19..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/model/test/DefaultNameValidatorTestCase.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.interfaces.model.test; - -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.interfaces.model.DefaultNameValidator; - -/** - * TestCases for {@link org.apache.myrmidon.interfaces.model.DefaultNameValidator}. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public class DefaultNameValidatorTestCase - extends AbstractMyrmidonTest -{ - private DefaultNameValidator m_validator = new DefaultNameValidator(); - - public DefaultNameValidatorTestCase( String name ) - { - super( name ); - } - - /** - * Test valid names for the default validator. - */ - public void testValidNames() throws Exception - { - testValid( "aName" ); - testValid( "123456" ); - testValid( "s p a ce s" ); - testValid( "d-a-s-h-e-s-" ); - testValid( "d.o.t.s." ); - testValid( "_u_n_d_e_r_s_c_o_r_e_s" ); - testValid( "a" ); - testValid( "1" ); - testValid( "_" ); - - } - - /** - * Test invalid names for the default validator. - */ - public void testInvalidNames() throws Exception - { - testInvalid( "" ); - testInvalid( " " ); - testInvalid( " " ); - testInvalid( " bad" ); - testInvalid( "bad " ); - testInvalid( " bad " ); - testInvalid( "-dashfirst" ); - testInvalid( ".dotfirst" ); - testInvalid( "question?" ); - } - - /** - * Test that certain characters are disallowed in the default validator. - */ - public void testReservedChars() throws Exception - { - String reserved = "!@#$%^&*()+=~`{}[]|\\/?<>,:;"; - - for( int pos = 0; pos < reserved.length(); pos++ ) - { - char chr = reserved.charAt( pos ); - testReservedChar( chr ); - } - } - - private void testReservedChar( char chr ) throws Exception - { - String test = "a" + String.valueOf( chr ); - testInvalid( test ); - } - - /** - * Test validation using a restrictive set of validation rules. - */ - public void testStrictNames() throws Exception - { - m_validator = new DefaultNameValidator( false, false, "", false, false, "." ); - - testValid( "name" ); - testValid( "a" ); - testValid( "yep.ok" ); - - testInvalid( "_nogood" ); - testInvalid( "no_good" ); - testInvalid( "nope1" ); - testInvalid( "123" ); - testInvalid( "not ok" ); - } - - private void testValid( String name ) - { - try - { - m_validator.validate( name ); - } - catch( Exception e ) - { - fail( e.getMessage() ); - } - } - - private void testInvalid( String name ) - { - try - { - m_validator.validate( name ); - fail( "Name \"" + name + "\" should be invalid." ); - } - catch( Exception e ) - { - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType1.java b/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType1.java deleted file mode 100644 index 226b9a3bb..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType1.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.interfaces.type.test; - -/** - * A basic implementation of a type to test the type factory. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class MyType1 -{ - public boolean equals( final Object object ) - { - return object.getClass() == getClass(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType2.java b/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType2.java deleted file mode 100644 index a9418f1ae..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/MyType2.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.interfaces.type.test; - -/** - * A basic implementation of a type to test the type factory. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class MyType2 -{ - public boolean equals( final Object object ) - { - return object.getClass() == getClass(); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java deleted file mode 100644 index 62ed33a88..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/interfaces/type/test/TypeFactoryTestCase.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.myrmidon.interfaces.type.test; - -import java.io.File; -import java.net.URL; -import org.apache.myrmidon.AbstractMyrmidonTest; -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; -import org.apache.myrmidon.interfaces.type.ReloadingTypeFactory; -import org.apache.myrmidon.interfaces.type.TypeException; - -/** - * These are unit tests that test the basic operation of TypeFactories. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class TypeFactoryTestCase - extends AbstractMyrmidonTest -{ - private final static String TYPE_NAME1 = "my-type1"; - private final static String TYPE_NAME2 = "my-type2"; - private final static Class TYPE_CLASS1 = MyType1.class; - private final static Class TYPE_CLASS2 = MyType2.class; - private final static String TYPE_CLASSNAME1 = TYPE_CLASS1.getName(); - private final static String TYPE_CLASSNAME2 = TYPE_CLASS2.getName(); - - public TypeFactoryTestCase( final String name ) - { - super( name ); - } - - /** - * Make sure that you can load a basic type from DefaultTypeManager. - */ - public void testBasicType() - { - final ClassLoader classLoader = getClass().getClassLoader(); - final DefaultTypeFactory factory = new DefaultTypeFactory( classLoader ); - factory.addNameClassMapping( TYPE_NAME2, TYPE_CLASSNAME2 ); - - try - { - final Object type = factory.create( TYPE_NAME2 ); - final Class typeClass = type.getClass(); - assertEquals( "The type loaded for factory should be same class as in current classloader", - typeClass, TYPE_CLASS2 ); - } - catch( TypeException e ) - { - fail( "Unable to create Type due to " + e ); - } - } - - /** - * Make sure that when you load a type from a RelaodableTypeFactory - * that it is actually reloaded. - */ - public void testReloadingTypeFactory() - throws Exception - { - final File file = getTestResource( "types.jar" ); - final URL[] classpath = new URL[]{file.toURL()}; - final ReloadingTypeFactory factory = new ReloadingTypeFactory( classpath, null ); - factory.addNameClassMapping( TYPE_NAME1, TYPE_CLASSNAME1 ); - - try - { - final Object type = factory.create( TYPE_NAME1 ); - final Class typeClass = type.getClass(); - final boolean sameClass = typeClass == TYPE_CLASS1; - assertTrue( "The type loaded for factory should not be same class as in current classloader", - !sameClass ); - } - catch( TypeException e ) - { - fail( "Unable to create Type due to " + e ); - } - } -}