svn commit: rev 22107 - avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test
[email protected] 25 Jun 2004 10:44:54 -0000
Newsgroups
gmane.comp.jakarta.avalon.cvs
Message-ID
<[email protected] >
Author: mcconnell
Date: Fri Jun 25 03:44:53 2004
New Revision: 22107
Modified:
avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/ContextTestCase.java
avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java
Log:
speed up the context testcase and enhance the dynamic test case to do validation of deependency bindings
Modified: avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/ContextTestCase.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/ContextTestCase.java (original)
+++ avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/ContextTestCase.java Fri Jun 25 03:44:53 2004
@@ -67,9 +67,21 @@
//-------------------------------------------------------
// tests
- //-------------------------------------------------------
+ //-------------------------------------------------------
- public void testClassLoader() throws Exception
+ public void testContext() throws Exception
+ {
+ executeClassLoader();
+ executeHomeDirectory();
+ executeTempDirectory();
+ executePartition();
+ executeAlias();
+ executeVolatile();
+ executeImport();
+ executeContextCasting();
+ }
+
+ private void executeClassLoader() throws Exception
{
try
{
@@ -81,7 +93,7 @@
}
}
- public void testHomeDirectory() throws Exception
+ private void executeHomeDirectory() throws Exception
{
try
{
@@ -93,7 +105,7 @@
}
}
- public void testTempDirectory() throws Exception
+ private void executeTempDirectory() throws Exception
{
try
{
@@ -105,7 +117,7 @@
}
}
- public void testPartition() throws Exception
+ private void executePartition() throws Exception
{
try
{
@@ -117,7 +129,7 @@
}
}
- public void testAlias() throws Exception
+ private void executeAlias() throws Exception
{
//
// validate context entry lookup using an alias
@@ -131,9 +143,9 @@
{
fail( "alias based lookup of the component name" );
}
- }
+ }
- public void testVolatile() throws Exception
+ private void executeVolatile() throws Exception
{
//
@@ -169,7 +181,7 @@
}
}
- public void testImport() throws Exception
+ private void executeImport() throws Exception
{
//
// validate an imported context entry
@@ -185,7 +197,7 @@
}
}
- public void testContextCasting() throws Exception
+ private void executeContextCasting() throws Exception
{
//
// validate context safe-casting
Modified: avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java (original)
+++ avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java Fri Jun 25 03:44:53 2004
@@ -17,9 +17,15 @@
package org.apache.avalon.composition.model.test;
-import org.apache.avalon.composition.model.DeploymentModel;
+import org.apache.avalon.composition.data.ComponentProfile;
+import org.apache.avalon.composition.model.DeploymentModel;
+import org.apache.avalon.composition.model.ClassLoaderModel;
+import org.apache.avalon.composition.model.TypeRepository;
+import org.apache.avalon.composition.model.ComponentModel;
+import org.apache.avalon.composition.model.DependencyModel;
-import org.apache.avalon.meta.info.ReferenceDescriptor;
+import org.apache.avalon.meta.info.Type;
+import org.apache.avalon.meta.info.ReferenceDescriptor;
import org.apache.avalon.util.exception.ExceptionHelper;
@@ -56,8 +62,8 @@
m_model.assemble();
String spec = Widget.class.getName();
ReferenceDescriptor ref = new ReferenceDescriptor( spec );
- DeploymentModel widget =
- m_model.getModel( ref );
+ ComponentModel widget = (ComponentModel) m_model.getModel( ref );
+ validate( widget );
}
catch( Throwable e )
{
@@ -78,8 +84,8 @@
m_model.assemble();
String spec = Gizmo.class.getName();
ReferenceDescriptor ref = new ReferenceDescriptor( spec );
- DeploymentModel widget =
- m_model.getModel( ref );
+ ComponentModel gizmo = (ComponentModel) m_model.getModel( ref );
+ validate( gizmo );
}
catch( Throwable e )
{
@@ -88,5 +94,38 @@
System.err.println( error );
fail( error );
}
- }
+ }
+
+ /**
+ * Validate a model.
+ */
+ private void validate( ComponentModel model ) throws Exception
+ {
+ try
+ {
+ if( !model.isAssembled() )
+ {
+ fail( "Non-assembled model: " + model );
+ }
+
+ DependencyModel[] dependencies = model.getDependencyModels();
+ for( int i=0; i<dependencies.length; i++ )
+ {
+ DependencyModel dependency = dependencies[i];
+ if( null == dependency.getProvider() )
+ {
+ fail(
+ "Null provider located in an assembled model: "
+ + model );
+ }
+ }
+ }
+ catch( Throwable e )
+ {
+ final String message = "Dynamic assembly validation failure";
+ final String error = ExceptionHelper.packException( message, e, true );
+ System.err.println( error );
+ fail( error );
+ }
+ }
}