leosimons 2003/08/21 14:13:52
Modified: magic/impl/src/java/org/apache/avalon/magic/impl
Avalon2PicoAdapter.java
magic/impl/src/test/org/apache/avalon/magic/test/impl
Avalon2PicoAdapterTestCase.java
Added: magic/impl/src/test/org/apache/avalon/magic/test/impl
Pussycat.java PussycatImpl.java TweetyImpl5.java
Log:
more tests, squash more bugs
Revision Changes Path
1.3 +8 -8
avalon-sandbox/magic/impl/src/java/org/apache/avalon/magic/impl/Avalon2PicoAdapter.java
Index: Avalon2PicoAdapter.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/magic/impl/src/java/org/apache/avalon/magic/impl/Avalon2PicoAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Avalon2PicoAdapter.java 21 Aug 2003 20:58:31 -0000 1.2
+++ Avalon2PicoAdapter.java 21 Aug 2003 21:13:51 -0000 1.3
@@ -402,28 +402,28 @@
if( paramTypes[i].isAssignableFrom( Parameters.class ) )
{
args.add( i, Parameters.fromConfiguration( getConfiguration() ) );
- break;
+ continue;
}
if( paramTypes[i].isAssignableFrom( Configuration.class ) )
{
args.add( i, getConfiguration() );
- break;
+ continue;
}
if( paramTypes[i].isAssignableFrom( ServiceManager.class ) )
{
args.add( i, getServiceManager() );
- break;
+ continue;
}
if( getServiceManager().hasService( getRole( paramTypes[i] ) ) )
{
Object comp = getServiceManager().lookup( paramTypes[i].getName() );
args.add( i, comp );
- break;
+ continue;
}
if( paramTypes[i].isAssignableFrom( Context.class ) )
{
args.add( i, getContext() );
- break;
+ continue;
}
Object comp = null;
@@ -439,12 +439,12 @@
if( comp != null )
{
args.add( i, comp );
- break;
+ continue;
}
if( paramTypes[i].isAssignableFrom( Logger.class ) )
{
args.add( i, getLog() );
- break;
+ continue;
}
throw new ServiceException( paramTypes[i].getName(), "Missing
dependency!" );
1.3 +28 -1
avalon-sandbox/magic/impl/src/test/org/apache/avalon/magic/test/impl/Avalon2PicoAdapterTestCase.java
Index: Avalon2PicoAdapterTestCase.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/magic/impl/src/test/org/apache/avalon/magic/test/impl/Avalon2PicoAdapterTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Avalon2PicoAdapterTestCase.java 21 Aug 2003 20:58:31 -0000 1.2
+++ Avalon2PicoAdapterTestCase.java 21 Aug 2003 21:13:52 -0000 1.3
@@ -245,4 +245,31 @@
assertTrue( "The second File was not used by the proxied pico-style
component", sm.isLookupCalled() );
}
+
+ public void testCommonSenseSomewhatRealisticUsage() throws Exception
+ {
+ Tweety tweety = (Tweety)Avalon2PicoAdapter.getProxy( TweetyImpl5.class );
+
+ Logger logger = new ConsoleLogger();
+ ContainerUtil.enableLogging( tweety, logger );
+
+ DefaultContext context = new DefaultContext();
+ context.put( File.class.getName(), new File(".") );
+ context.makeReadOnly();
+ ContainerUtil.contextualize( tweety, context );
+
+ DefaultServiceManager sm = new DefaultServiceManager();
+ sm.put( Pussycat.class.getName(), new PussycatImpl() );
+ sm.makeReadOnly();
+ ContainerUtil.service( tweety, sm );
+
+ AssertionConfiguration conf = new AssertionConfiguration( "blah" );
+ conf.setAttribute( "message", "dummy message");
+ conf.makeReadOnly();
+ ContainerUtil.configure( tweety, conf );
+ ContainerUtil.initialize( tweety );
+ ContainerUtil.start( tweety );
+
+ tweety.chilp();
+ }
}
1.1
avalon-sandbox/magic/impl/src/test/org/apache/avalon/magic/test/impl/Pussycat.java
Index: Pussycat.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.magic.test.impl;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: Pussycat.java,v 1.1 2003/08/21 21:13:52 leosimons Exp $
*/
public interface Pussycat
{
}
1.1
avalon-sandbox/magic/impl/src/test/org/apache/avalon/magic/test/impl/PussycatImpl.java
Index: PussycatImpl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.magic.test.impl;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: PussycatImpl.java,v 1.1 2003/08/21 21:13:52 leosimons Exp $
*/
public class PussycatImpl implements Pussycat
{
}
1.1
avalon-sandbox/magic/impl/src/test/org/apache/avalon/magic/test/impl/TweetyImpl5.java
Index: TweetyImpl5.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1997-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software
* itself, if and wherever such third-party acknowledgments
* normally appear.
*
* 4. The names "Avalon", and "Apache Software Foundation"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.avalon.magic.test.impl;
import java.io.File;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.Logger;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: TweetyImpl5.java,v 1.1 2003/08/21 21:13:52 leosimons Exp $
*/
public class TweetyImpl5 implements Tweety
{
private Logger m_logger;
private Configuration m_config;
private File m_homedir;
private String m_msg;
private Pussycat m_cat;
public TweetyImpl5( Logger logger, Configuration config, File homedir, Pussycat
cat )
throws ConfigurationException
{
m_logger = logger;
m_config = config;
m_homedir = homedir;
m_msg = m_config.getAttribute( "message" );
m_cat = cat;
}
public void chilp()
{
m_logger.info( "homedir: " + m_homedir.getName() );
m_logger.info( m_msg );
if( m_cat != null )
m_logger.info( "I tawt I saw a pussycat!");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]