You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/07/11 23:36:28 UTC
cvs commit: avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test TypeTestCase.java EntryDescriptorTestCase.java
bloritsch 2003/07/11 14:36:28
Modified: merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl
DefaultAppliance.java
meta/api/src/test/org/apache/avalon/meta/info/test
EntryDescriptorTestCase.java
Added: meta/api/src/test/org/apache/avalon/meta/info/test
TypeTestCase.java
Removed: merlin/meta-spi/src/java/org/apache/avalon/meta/info/doc-files
Type.gif
merlin/meta-spi/src/java/org/apache/avalon/meta/info
ContextDescriptor.java DependencyDescriptor.java
Descriptor.java EntryDescriptor.java
ExtensionDescriptor.java InfoDescriptor.java
LoggerDescriptor.java ReferenceDescriptor.java
Resources.properties Service.java
ServiceDescriptor.java StageDescriptor.java
Type.java package.html
Log:
Add last testcase and remove duplicate classes
Revision Changes Path
1.19 +21 -21 avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java
Index: DefaultAppliance.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DefaultAppliance.java 27 Jun 2003 22:52:11 -0000 1.18
+++ DefaultAppliance.java 11 Jul 2003 21:36:27 -0000 1.19
@@ -153,7 +153,7 @@
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class DefaultAppliance extends AbstractLogEnabled
+public class DefaultAppliance extends AbstractLogEnabled
implements Appliance, Contextualizable, Initializable
{
//=====================================================================
@@ -355,7 +355,7 @@
DefaultLocator context = new DefaultLocator();
context.put( Appliance.KEY, new ApplianceHolder( this ) );
- context.put( "urn:assembly:lifecycle.deployment",
+ context.put( "urn:assembly:lifecycle.deployment",
createDeploymentService() );
context.put( "urn:avalon:classloader", m_engine );
@@ -364,7 +364,7 @@
if( policy.equals( InfoDescriptor.SINGLETON ) )
{
lifestyle = new SingletonLifestyleHandler();
- }
+ }
else if( policy.equals( InfoDescriptor.TRANSIENT ) )
{
lifestyle = new TransientLifestyleHandler();
@@ -372,12 +372,12 @@
else if( policy.equals( InfoDescriptor.THREAD ) )
{
lifestyle = new ThreadLocalLifestyleHandler();
- }
+ }
else if( policy.equals( InfoDescriptor.POOLED ) )
{
lifestyle = new PooledLifestyleHandler();
- context.put(
- PoolManager.ROLE,
+ context.put(
+ PoolManager.ROLE,
m_system.get( PoolManager.ROLE ) );
}
@@ -463,7 +463,7 @@
try
{
m_handler.release( object, source );
- }
+ }
catch( Throwable e )
{
final String error =
@@ -529,9 +529,9 @@
*/
public URL getURL()
{
- if( !m_initialized )
+ if( !m_initialized )
{
- final String error =
+ final String error =
"URL cannot been accessed before initialization.";
throw new IllegalStateException( error );
}
@@ -542,7 +542,7 @@
{
URL base = m_repository.getURL();
m_url = new URL( base, base.getPath() + m_name );
- }
+ }
catch( Throwable e )
{
final String error =
@@ -612,7 +612,7 @@
* Get the component context.
*
* @return the component context
- * @exception IllegalStateException if the operation is accessed
+ * @exception IllegalStateException if the operation is accessed
* prior to assembly of the appliance
*/
public Map getContextMap() throws IllegalStateException
@@ -745,7 +745,7 @@
if( k > 0 )
{
buffer.append( ", " + providers[k] );
- }
+ }
else
{
buffer.append( providers[k].toString() );
@@ -783,7 +783,7 @@
{
if( m_graph == null )
{
- final String error =
+ final String error =
"Missing assembly graph.";
throw new IllegalStateException( error );
}
@@ -1022,7 +1022,7 @@
try
{
assemble();
- }
+ }
catch( ApplianceException e )
{
final String error =
@@ -1036,7 +1036,7 @@
}
/**
- * Decommission the appliance. Under the decommissioning phase,
+ * Decommission the appliance. Under the decommissioning phase,
* all active components will be taken down.
*/
public void decommission()
@@ -1057,7 +1057,7 @@
}
catch( Throwable e )
{
- final String error =
+ final String error =
"Unexpected error while attempting to decommission the handler in appliance: "
+ this;
getLogger().warn( error, e );
@@ -1101,14 +1101,14 @@
final String message = "resolving context handler for: " + this;
getLogger().debug( message );
Appliance supplier;
- ReferenceDescriptor ref = ReferenceDescriptor.newInstance( ext );
+ ReferenceDescriptor ref = new ReferenceDescriptor( ext );
StageDescriptor stage = new StageDescriptor( ref );
try
{
supplier =
m_engine.resolve( graph, stage, getURL().getPath() );
- }
+ }
catch( Throwable e )
{
setEnabled( false );
@@ -1157,7 +1157,7 @@
try
{
supplier = m_engine.resolve( graph, dependency, getURL().getPath() );
- }
+ }
catch( Throwable e )
{
setEnabled( false );
@@ -1275,7 +1275,7 @@
/**
* Internal class the wraps an appliance. Used when passing an appliance as
- * an argument in a locator so that the invocation of resolve returns the
+ * an argument in a locator so that the invocation of resolve returns the
* appliance and not the conponent managed by the applaince.
*/
private class ApplianceHolder implements Resolvable
1.3 +7 -7 avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/EntryDescriptorTestCase.java
Index: EntryDescriptorTestCase.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/EntryDescriptorTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EntryDescriptorTestCase.java 11 Jul 2003 13:25:10 -0000 1.2
+++ EntryDescriptorTestCase.java 11 Jul 2003 21:36:28 -0000 1.3
@@ -122,19 +122,19 @@
public void testSerialization() throws IOException, ClassNotFoundException
{
EntryDescriptor entry = new EntryDescriptor( m_key, m_type, m_optional, m_volatile, m_alias );
- checkEntry(entry, m_key, m_type, m_optional, m_volatile, m_alias );
+ checkEntry( entry, m_key, m_type, m_optional, m_volatile, m_alias );
- File file = new File("test.out");
- ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
- oos.writeObject(entry);
+ File file = new File( "test.out" );
+ ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream( file ) );
+ oos.writeObject( entry );
oos.close();
- ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
- EntryDescriptor serialized = (EntryDescriptor)ois.readObject();
+ ObjectInputStream ois = new ObjectInputStream( new FileInputStream( file ) );
+ EntryDescriptor serialized = (EntryDescriptor) ois.readObject();
ois.close();
file.delete();
- checkEntry(serialized, m_key, m_type, m_optional, m_volatile, m_alias );
+ checkEntry( serialized, m_key, m_type, m_optional, m_volatile, m_alias );
assertEquals( entry, serialized );
assertEquals( entry.hashCode(), serialized.hashCode() );
1.1 avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/TypeTestCase.java
Index: TypeTestCase.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Jakarta", "Avalon", "Excalibur" 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
apache@apache.org.
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 (INCLU-
DING, 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.meta.info.test;
import junit.framework.TestCase;
import org.apache.avalon.meta.info.*;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import java.util.Properties;
import java.io.*;
/**
* TypeTestCase does XYZ
*
* @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
* @version CVS $ Revision: 1.1 $
*/
public class TypeTestCase extends TestCase
{
private InfoDescriptor m_descriptor;
private CategoryDescriptor[] m_loggers;
private ContextDescriptor m_context;
private ServiceDescriptor[] m_services;
private DependencyDescriptor[] m_dependencies;
private StageDescriptor[] m_stages;
private ExtensionDescriptor[] m_extensions;
private Configuration m_defaults;
private ReferenceDescriptor m_reference;
public TypeTestCase( String name )
{
super( name );
}
public void setUp()
{
m_reference = new ReferenceDescriptor(TypeTestCase.class.getName());
m_descriptor = new InfoDescriptor(TypeTestCase.class.getName());
m_loggers = new CategoryDescriptor[] {
new CategoryDescriptor("name", new Properties())
};
m_context = new ContextDescriptor(m_reference, new EntryDescriptor[0]);
m_services = new ServiceDescriptor[] {
new ServiceDescriptor(m_reference)
};
m_dependencies = new DependencyDescriptor[] {
new DependencyDescriptor("role", m_reference)
};
m_stages = new StageDescriptor[] {
new StageDescriptor(m_reference)
};
m_extensions = new ExtensionDescriptor[] {
new ExtensionDescriptor( m_reference )
};
m_defaults = new DefaultConfiguration("default");
}
private void checkType(Type type)
{
assertNotNull(type);
checkArray(m_loggers, type.getCategories());
assertEquals( m_defaults, type.getConfiguration() );
assertEquals( m_context, type.getContext());
checkArray(m_dependencies, type.getDependencies());
assertEquals(m_dependencies[0], type.getDependency(m_dependencies[0].getKey()));
assertEquals(m_extensions[0], type.getExtension(m_stages[0]));
checkArray(m_extensions, type.getExtensions());
assertEquals( m_descriptor, type.getInfo() );
assertEquals( m_services[0], type.getService(m_reference));
assertEquals( m_services[0], type.getService( m_services[0].getReference().getClassname()));
checkArray(m_services, type.getServices());
checkArray(m_stages, type.getStages());
assertTrue(type.isaCategory(m_loggers[0].getName()));
assertTrue( !type.isaCategory( "fake name" ) );
}
private void checkArray( Object[] orig, Object[] other )
{
assertEquals(orig.length, other.length);
for (int i = 0; i < orig.length; i++)
{
assertEquals( orig[i], other[i] );
}
}
public void testType()
{
Type type = new Type(m_descriptor, m_loggers, m_context, m_services, m_dependencies, m_stages, m_extensions, m_defaults);
checkType(type);
}
public void testSerialization() throws IOException, ClassNotFoundException
{
Type type = new Type( m_descriptor, m_loggers, m_context, m_services, m_dependencies, m_stages, m_extensions, m_defaults );
checkType( type );
File file = new File( "test.out" );
ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream( file ) );
oos.writeObject( type );
oos.close();
ObjectInputStream ois = new ObjectInputStream( new FileInputStream( file ) );
Type serialized = (Type) ois.readObject();
ois.close();
file.delete();
checkType( serialized );
assertEquals( type, serialized );
assertEquals( type.hashCode(), serialized.hashCode() );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org