jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/util ConfigurationUtilTestCase.java,NONE,1.1 ReflectionUtilTestCase.java,NONE,1.1 Type1UtilTestCase.java,NONE,1.1 Type2UtilTestCase.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container/impl/src/test/org/jicarilla/container/test/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20232/platform/container/impl/src/test/org/jicarilla/container/test/util

Added Files:
	ConfigurationUtilTestCase.java ReflectionUtilTestCase.java 
	Type1UtilTestCase.java Type2UtilTestCase.java 
Log Message:
start serious testing of the utility magic (and add some docs at the same time)

--- NEW FILE: ConfigurationUtilTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.util;

import junit.framework.TestCase;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.easymock.MockControl;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.ConfigurationUtil;

/**
 *
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: ConfigurationUtilTestCase.java,v 1.1 2004/02/29 18:08:09 lsimons Exp $
 */
public class ConfigurationUtilTestCase extends TestCase
{
    protected Resolver resolver;
    protected MockControl resolverControl;

    public void setUp() throws Exception
    {
        super.setUp();

        resolverControl = MockControl.createControl( Resolver.class );
        resolver = (Resolver)resolverControl.getMock();
    }

    public void testGetConfigurationFromContainerUsingXStream() throws Exception
    {
        MyComponentConfiguration config = new MyComponentConfiguration(1);
        resolver.get( MyComponent.class.getName() + "Configuration" );
        resolverControl.setReturnValue( config );
        resolverControl.replay();

        Configuration configuration = ConfigurationUtil.getConfiguration(
                resolver, MyComponent.class.getName() );
        assertEquals( "1",
                configuration.getChild( "something" ).getValue() );

        resolverControl.verify();
    }

    public void testGetConfigurationFromContainerUsingExistingConfigurationObject()
            throws Exception
    {
        Configuration config = new DefaultConfiguration("blah");
        resolver.get( MyComponent.class.getName() + "Configuration" );
        resolverControl.setReturnValue( config );
        resolverControl.replay();

        Configuration configuration = ConfigurationUtil.getConfiguration(
                resolver, MyComponent.class.getName() );
        assertEquals( config,
                configuration );

        resolverControl.verify();
    }

    public void testGetConfigurationFromContainerThatDoesNotExist()
            throws Exception
    {
        resolver.get( MyComponent.class.getName() + "Configuration" );
        resolverControl.setReturnValue( null );
        resolverControl.replay();

        try
        {
            ConfigurationUtil.getConfiguration(
                    resolver, MyComponent.class.getName() );
            fail( "Expected an exception!" );
        }
        catch( ConfigurationException th ) {}

        resolverControl.verify();
    }

    public class MyComponent {}
    public class MyComponentConfiguration
    {
        private int something;

        public MyComponentConfiguration( int something )
        {
            this.something = something;
        }

        public int getSomething()
        {
            return something;
        }

        public void setSomething( int something )
        {
            this.something = something;
        }
    }
}

--- NEW FILE: ReflectionUtilTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.util;

import junit.framework.TestCase;
import org.jicarilla.container.util.ReflectionUtil;

import java.util.Arrays;

/**
 *
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: ReflectionUtilTestCase.java,v 1.1 2004/02/29 18:08:09 lsimons Exp $
 */
public class ReflectionUtilTestCase extends TestCase
{
    public void testLoadClass() throws Throwable
    {
        assertEquals( this.getClass(),
                ReflectionUtil.loadClass( this.getClass().getName() ) );

        try
        {
            ReflectionUtil.loadClass( null );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}

        try
        {
            ReflectionUtil.loadClass(
                    "org.jicarilla.nonexistent.package.ClassName" );
            fail( "Expected an exception!" );
        }
        catch( ClassNotFoundException th ) {}

        try
        {
            ReflectionUtil.loadClass(
                    "bla bla" );
            fail( "Expected an exception!" );
        }
        catch( ClassNotFoundException th ) {}
    }

    public void testGetAllInterfaces()
    {
        Class[] intf = ReflectionUtil.getAllInterfaces( Clazz.class );
        assertEquals( 4, intf.length );
        assertTrue( Arrays.asList( intf ).contains( AnInterface.class ) );
        assertTrue( Arrays.asList( intf ).contains( AnotherInterface.class ) );
        assertTrue( Arrays.asList( intf ).contains( ThirdInterface.class ) );
        assertTrue( Arrays.asList( intf ).contains( MixinInterface.class ) );
        assertFalse( Arrays.asList( intf ).contains( Clazz.class ) );

        intf = ReflectionUtil.getAllInterfaces( ThirdInterface.class );
        assertEquals( 3, intf.length );
        assertTrue( Arrays.asList( intf ).contains( AnInterface.class ) );
        assertTrue( Arrays.asList( intf ).contains( AnotherInterface.class ) );
        assertTrue( Arrays.asList( intf ).contains( ThirdInterface.class ) );
        assertFalse( Arrays.asList( intf ).contains( MixinInterface.class ) );
        assertFalse( Arrays.asList( intf ).contains( Clazz.class ) );
    }

    public interface AnInterface {}
    public interface AnotherInterface extends AnInterface {}
    public interface MixinInterface extends AnInterface {}
    public interface ThirdInterface extends AnotherInterface {}
    public class Clazz implements ThirdInterface, MixinInterface {}
}

--- NEW FILE: Type1UtilTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.util;

import junit.framework.TestCase;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
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.ConsoleLogger;
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.easymock.AbstractMatcher;
import org.easymock.MockControl;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type1Util;

/**
 *
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Type1UtilTestCase.java,v 1.1 2004/02/29 18:08:09 lsimons Exp $
 */
public class Type1UtilTestCase extends TestCase
{
    protected Resolver resolver;
    protected MockControl resolverControl;

    public void setUp() throws Exception
    {
        super.setUp();

        resolverControl = MockControl.createControl( Resolver.class );
        resolver = (Resolver)resolverControl.getMock();
    }

    public void testFallbackLoggerExists()
    {
        assertNotNull( Type1Util.FallbackLogger );
    }

    public void testGetServiceManagerFromResolver() throws Exception
    {
        resolver.get( "key" );
        resolverControl.setReturnValue( "value" );
        resolverControl.replay();

        ServiceManager sm = Type1Util.getServiceManager( resolver );
        assertNotNull( sm );

        // sanity check
        assertEquals( "value", sm.lookup( "key" ) );

        resolverControl.verify();
    }

    public void testGetContextFromResolver() throws Exception
    {
        resolver.get( "key" );
        resolverControl.setReturnValue( "value" );
        resolverControl.replay();

        Context c = Type1Util.getContext( resolver );
        assertNotNull( c );

        // sanity check
        assertEquals( "value", c.get( "key" ) );

        resolverControl.verify();
    }

    public void testGetLoggerFromResolver() throws Exception
    {
        resolver.get( Logger.class );
        ConsoleLogger logger = new ConsoleLogger();
        resolverControl.setReturnValue( logger );
        resolverControl.replay();

        Logger l = Type1Util.getLogger( resolver, "blah" );
        assertNotNull( l );
        assertEquals( logger, l );

        resolverControl.verify();
    }

    public void testGetFallbackLoggerIfNoLoggerExistsInResolver()
                throws Exception
    {
        resolver.get( Logger.class );
        resolverControl.setReturnValue( null );
        resolverControl.replay();

        Logger l = Type1Util.getLogger( resolver, "blah" );
        assertNotNull( l );

        resolverControl.verify();
    }

    public void testStartAvalonLifecycleEnablesLogging()
            throws Exception
    {
        MockControl instanceControl =
                MockControl.createControl( LogEnabled.class );
        LogEnabled instance = (LogEnabled)instanceControl.getMock();

        resolver.get( Logger.class );
        ConsoleLogger logger = new ConsoleLogger();
        resolverControl.setReturnValue( logger );
        resolverControl.replay();

        instance.enableLogging( logger );
        instanceControl.replay();

        Type1Util.startAvalonLifecycle( instance, resolver );

        resolverControl.verify();
        instanceControl.verify();
    }

    public void testCompleteStartAvalonLifecycleContract()
            throws Exception
    {
        MockControl instanceControl =
                MockControl.createStrictControl( MyComponent.class );
        MyComponent instance = (MyComponent)instanceControl.getMock();

        resolver.get( Logger.class );
        ConsoleLogger logger = new ConsoleLogger();
        resolverControl.setReturnValue( logger );
        resolver.get( instance.getClass().getName() + "Configuration" );
        resolverControl.setReturnValue( new DefaultConfiguration("blah") );
        resolverControl.replay();

        instance.enableLogging( logger );
        instanceControl.setDefaultMatcher( notNullMatcher );
        instance.contextualize( new DefaultContext() );
        instance.service( new DefaultServiceManager() );
        instance.configure( new DefaultConfiguration("blah") );
        instance.initialize();
        instance.start();
        instanceControl.replay();

        Type1Util.startAvalonLifecycle( instance, resolver );

        resolverControl.verify();
        instanceControl.verify();
    }

    public static NotNullMatcher notNullMatcher = new NotNullMatcher();
    public static class NotNullMatcher extends AbstractMatcher
    {
        protected boolean parameterMatches(Object expected, Object actual)
        {
            if( actual != null )
                return true;
            else
                return false;
        }
    }

    public interface MyComponent extends LogEnabled, Contextualizable,
            Configurable, Serviceable, Startable, Initializable, Runnable {}
}

--- NEW FILE: Type2UtilTestCase.java ---
/* ====================================================================
The Jicarilla Software License

Copyright (c) 2003 Leo Simons.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.test.util;

import org.easymock.MockControl;
import org.jicarilla.container.DefaultContainer;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.tck.AbstractTCKTestCase;
import org.jicarilla.container.tck.components.interfaces.Homer;
import org.jicarilla.container.tck.components.interfaces.Marge;
import org.jicarilla.container.tck.components.type2.aware.BartImpl;
import org.jicarilla.container.tck.components.type2.aware.HomerAware;
import org.jicarilla.container.tck.components.type2.aware.HomerImpl;
import org.jicarilla.container.tck.components.type2.aware.MargeAware;
import org.jicarilla.container.tck.components.type2.aware.MargeImpl;
import org.jicarilla.container.tck.components.type2.aware.ReimplementingYoungHomer;
import org.jicarilla.container.tck.components.type2.aware.YoungHomer;
import org.jicarilla.container.tck.components.type2.aware.bad.EmptyAwareImpl;
import org.jicarilla.container.tck.components.type2.aware.bad.MultiparameterAwareImpl;
import org.jicarilla.container.tck.components.type2.aware.bad.NonVoidAwareImpl;
import org.jicarilla.container.tck.components.type2.aware.bad.TypoAwarImpl;
import org.jicarilla.container.util.Type2Util;

import java.lang.reflect.Method;

/**
 *
 *
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Type2UtilTestCase.java,v 1.1 2004/02/29 18:08:09 lsimons Exp $
 */
public class Type2UtilTestCase extends AbstractTCKTestCase
{
    // ----------------------------------------------------------------------
    //  Test: getAwarenessMethods()
    // ----------------------------------------------------------------------

    public void testGetAwarenessMethodsThrowsExceptionForNullArgument()
    {
        try
        {
            Type2Util.getAwarenessMethods( null );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}
    }

    public void testGetAwarenessMethodsOnNonAwareClass()
    {
        assertEquals( 0,
                Type2Util.getAwarenessMethods( this.getClass() ).length );
    }

    public void testGetAwarenessMethodsOnSimpleAwareClass() throws Exception
    {
        Method[] methods = Type2Util.getAwarenessMethods(
                HomerImpl.class );
        assertEquals( 1, methods.length );
        assertEquals(
                MargeAware.class.getMethod(
                        "setMarge", new Class[] { Marge.class }
                ),
                methods[0]
        );
    }

    public void testGetAwarenessMethodsHandlesMultipleMethods()
            throws Exception
    {
        Method[] methods = Type2Util.getAwarenessMethods(
                BartImpl.class );
        assertEquals( 2, methods.length );
        if( methods[0].getName().indexOf( "setMarge") != -1 )
        {
            assertEquals(
                    MargeAware.class.getMethod(
                            "setMarge", new Class[] { Marge.class }
                    ),
                    methods[0]
            );
            assertEquals(
                    HomerAware.class.getMethod(
                            "setHomer", new Class[] { Homer.class }
                    ),
                    methods[1]
            );
        }
        else
        {
            assertEquals(
                    MargeAware.class.getMethod(
                            "setMarge", new Class[] { Marge.class }
                    ),
                    methods[1]
            );
            assertEquals(
                    HomerAware.class.getMethod(
                            "setHomer", new Class[] { Homer.class }
                    ),
                    methods[0]
            );
        }
    }

    public void testGetAwarenessMethodsInSuperClass() throws Exception
    {
        Method[] methods = Type2Util.getAwarenessMethods(
                YoungHomer.class );
        assertEquals( 1, methods.length );
        assertEquals(
                MargeAware.class.getMethod(
                        "setMarge", new Class[] { Marge.class }
                ),
                methods[0]
        );
    }

    public void testGetAwarenessMethodsIgnoresBadlyNamedAwarenessInterface()
    {
        Method[] methods = Type2Util.getAwarenessMethods(
                TypoAwarImpl.class );
        assertEquals( 0, methods.length );
    }

    public void testGetAwarenessMethodsThrowsExceptionForEmptyAwarenessInterface()
    {
        try
        {
            Type2Util.getAwarenessMethods(
                EmptyAwareImpl.class );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}
    }

    public void testGetAwarenessMethodsThrowsExceptionForMultiparameterMethods()
    {
        try
        {
            Type2Util.getAwarenessMethods(
                MultiparameterAwareImpl.class );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}
    }

    public void testGetAwarenessMethodsThrowsExceptionForMethodsWithNonVoidReturnType()
    {
        try
        {
            Type2Util.getAwarenessMethods(
                NonVoidAwareImpl.class );
            fail( "Expected an exception!" );
        }
        catch( Throwable th ) {}
    }

    public void testGetAwarenessMethodsDoesNotDuplicateAwarenessMethodsInComplexClassHierarchies()
            throws Exception
    {
        Method[] methods = Type2Util.getAwarenessMethods( ReimplementingYoungHomer.class );
        assertEquals( 1, methods.length );
        assertEquals(
                MargeAware.class.getMethod(
                        "setMarge", new Class[] { Marge.class }
                ),
                methods[0]
        );
    }

    public void testGetAwarenessMethodsWorksOnInterfaces()
    {
        Method[] methods = Type2Util.getAwarenessMethods( MargeAware.class );
        assertEquals( 1, methods.length );
    }

    // ----------------------------------------------------------------------
    //  Test: callAwarenessMethods()
    // ----------------------------------------------------------------------

    public void testCallAwarenessMethodsThrowsExceptionForNullArguments()
            throws Exception
    {
        try
        {
            Type2Util.callAwarenessMethods( null,
                    new DefaultContainer().getResolver() );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}

        try
        {
            Type2Util.callAwarenessMethods( this,
                    null );

            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}

        try
        {
            Type2Util.callAwarenessMethods( null,
                    null );
            fail( "Expected an exception!" );
        }
        catch( Throwable th ) {}
    }

    public void testCallAwarenessMethodsOnSimpleComponent()
            throws Exception
    {
        HomerImpl homer = new HomerImpl();

        MockControl resolverControl = MockControl.createControl(
                Resolver.class );
        Resolver resolver = (Resolver)resolverControl.getMock();
        resolver.get( Marge.class );
        resolverControl.setReturnValue( new MargeImpl() );
        resolverControl.replay();

        Type2Util.callAwarenessMethods( homer, resolver );
        assertMethodCalledOnceWithNonNullArguments( homer, "setMarge" );

        resolverControl.verify();
    }

    public void testCallAwarenessMethodsCallsSuperClassMethods()
            throws Exception
    {
        YoungHomer homer = new YoungHomer();

        MockControl resolverControl = MockControl.createControl(
                Resolver.class );
        Resolver resolver = (Resolver)resolverControl.getMock();
        resolver.get( Marge.class );
        resolverControl.setReturnValue( new MargeImpl() );
        resolverControl.replay();

        Type2Util.callAwarenessMethods( homer, resolver );
        assertMethodCalledOnceWithNonNullArguments( homer, "setMarge" );

        resolverControl.verify();
    }

    // ----------------------------------------------------------------------
    //  Test: getType2DependencyClasses()
    // ----------------------------------------------------------------------

    public void testGetType2DependencyClassesThrowsExceptionForNullArgument()
    {
        try
        {
            Type2Util.getType2DependencyClasses( null );
            fail( "Expected an exception!" );
        }
        catch( AssertionError ae ) {}
    }

    public void testGetType2DependencyClassesReturnsEmptyArrayFromEmptyArray()
    {
        Class[] classes = Type2Util.getType2DependencyClasses( new Method[0] );
        assertEquals( 0, classes.length );
    }

    public void testGetType2DependencyClassesForSimpleComponent()
            throws Exception
    {
        Method[] methods = new Method[2];
        methods[0] = BartImpl.setHomer;
        methods[1] = BartImpl.setMarge;

        Class[] classes = Type2Util.getType2DependencyClasses( methods );
        assertEquals( 2, classes.length );

        assertEquals( Homer.class, classes[0] );
        assertEquals( Marge.class, classes[1] );
    }

    public void testGetType2DependencyClassesForSimpleComponentDoesNotFilterOutDuplicates()
            throws Exception
    {
        Method[] methods = new Method[2];
        methods[0] = BartImpl.setHomer;
        methods[1] = BartImpl.setHomer;

        Class[] classes = Type2Util.getType2DependencyClasses( methods );
        assertEquals( 2, classes.length );

        assertEquals( Homer.class, classes[0] );
        assertEquals( Homer.class, classes[1] );
    }

    public void testGetType2DependencyClassesIgnoresMultipleParameters()
    {
        Method[] methods = new Method[] {
            MultiparameterAwareImpl.setHomerAndMarge
        };

        Class[] classes = Type2Util.getType2DependencyClasses( methods );
        assertEquals( 1, classes.length );

        assertEquals( Homer.class, classes[0] );
    }
}



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.