crafterm 2002/10/08 08:02:02
Modified: xfc build.xml default.properties
xfc/src/test/org/apache/excalibur/xfc/test xfcTestCase.java
Log:
Added test for converting from ECM style roles to Fortress style.
Revision Changes Path
1.5 +4 -0 jakarta-avalon-excalibur/xfc/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/build.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- build.xml 8 Oct 2002 12:49:22 -0000 1.4
+++ build.xml 8 Oct 2002 15:02:02 -0000 1.5
@@ -29,6 +29,8 @@
<pathelement location="${excalibur-xmlutil.jar}"/>
<pathelement location="${excalibur-pool.jar}"/>
<pathelement location="${excalibur-sourceresolve.jar}"/>
+ <pathelement location="${excalibur-datasource.jar}"/>
+ <pathelement location="${excalibur-instrument.jar}"/>
<pathelement location="${junit.jar}"/>
<path refid="project.class.path"/>
</path>
@@ -56,7 +58,9 @@
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkJUnit"/>
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkXMLUtil"/>
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkPool"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkDatasource"/>
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkSourceResolve"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkInstrument"/>
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkConfiguration"/>
</target>
1.4 +10 -0 jakarta-avalon-excalibur/xfc/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/xfc/default.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- default.properties 8 Oct 2002 12:49:22 -0000 1.3
+++ default.properties 8 Oct 2002 15:02:02 -0000 1.4
@@ -51,6 +51,16 @@
excalibur-sourceresolve.lib=${excalibur-sourceresolve.home}/build/lib
excalibur-sourceresolve.jar=${excalibur-sourceresolve.lib}/excalibur-sourceresolve-1.0.jar
+# ----- Excalibur DataSource -----
+excalibur-datasource.home=${basedir}/../datasource
+excalibur-datasource.lib=${excalibur-datasource.home}/build/lib
+excalibur-datasource.jar=${excalibur-datasource.lib}/excalibur-datasource-1.0.jar
+
+# ----- Excalibur Instrumentable -----
+excalibur-instrument.home=${basedir}/../instrument
+excalibur-instrument.lib=${excalibur-instrument.home}/build/lib
+excalibur-instrument.jar=${excalibur-instrument.lib}/excalibur-instrument-0.3.jar
+
# ----- Misc tools -----
tools.dir=${basedir}/../../jakarta-avalon/tools
xml-apis.jar = ${tools.dir}/lib/xml-apis.jar
1.5 +74 -2
jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java
Index: xfcTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- xfcTestCase.java 8 Oct 2002 12:49:22 -0000 1.4
+++ xfcTestCase.java 8 Oct 2002 15:02:02 -0000 1.5
@@ -90,7 +90,7 @@
// misc internals
private DefaultConfigurationBuilder m_builder = new
DefaultConfigurationBuilder();
- private Logger m_logger = new ConsoleLogger();
+ private Logger m_logger;
public xfcTestCase()
{
@@ -100,6 +100,8 @@
public xfcTestCase( String name )
{
super( name );
+
+ m_logger = new ConsoleLogger( ConsoleLogger.LEVEL_WARN );
}
/**
@@ -377,6 +379,76 @@
handlers[i].equals( result )
);
}
+ }
+
+ /**
+ * Method to test the conversion of an ECM style configuration to a
+ * equivalent Fortress style one.
+ *
+ * @exception Exception if an error occurs
+ */
+ public void testXFC_ECM2Fortress()
+ throws Exception
+ {
+ // create an ECM module instance
+ ECMTestRig ecm = new ECMTestRig();
+ ecm.enableLogging( m_logger );
+
+ // create a Fortress module instance
+ FortressTestRig fortress = new FortressTestRig();
+ fortress.enableLogging( m_logger );
+
+ // generate model from predefined ECM configuration
+ Model model = ecm.generate( ECM_ROLES + ":" + ECM_XCONF );
+
+ // serialize the model out to a Fortress temporary file
+ //fortress.serialize( model, FORTRESS_ROLES_GENERATED + ":" +
FORTRESS_XCONF );
+
+ // load the same config and manually verify that model is correct
+ Configuration[] rolesREAL =
+ m_builder.buildFromFile( FORTRESS_ROLES ).getChildren( "role" );
+ RoleRef[] rolesMODEL = model.getDefinitions();
+
+ // check that the generated model has the right number of roles
+ assertEquals(
+ "Model contains incorrect number of roles",
+ rolesREAL.length, rolesMODEL.length
+ );
+
+ // check each role has the right values, compared against the master copy
+ for ( int i = 0; i < rolesMODEL.length; ++i )
+ {
+ String modelRoleName = rolesMODEL[i].getRole();
+ Configuration masterRoleConfig = null;
+
+ // get the real role configuration object
+ for ( int j = 0; j < rolesREAL.length; ++j )
+ {
+ if ( modelRoleName.equals( rolesREAL[j].getAttribute( "name" ) ) )
+ {
+ masterRoleConfig = rolesREAL[j];
+ break;
+ }
+ }
+
+ // check that we found a Configuration fragment for the role in the
model
+ assertNotNull(
+ "Master Configuration for role '" + modelRoleName + "' not found",
+ masterRoleConfig
+ );
+
+ // convert our RoleRef object into a Configuration and compare with the
master
+ Configuration modelRoleConfig = fortress.buildRole( rolesMODEL[i] );
+
+ assertTrue(
+ "Role configuration trees differ\n" +
+ "(master)" + ConfigurationUtil.list( masterRoleConfig ) +
+ "(model)" + ConfigurationUtil.list( modelRoleConfig ),
+ ConfigurationUtil.equals( masterRoleConfig, modelRoleConfig )
+ );
+ }
+
+ // all done, good show
}
public static final void main( String[] args )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>