jstrachan 02/05/30 00:49:04
Modified: betwixt/src/test/org/apache/commons/betwixt
TestMavenProject.java
Log:
Patched the code to fix all the unit test cases. The handling of collections of
primitive types are now handled correctly.
I think Betwixt now works for all Maven test cases
Revision Changes Path
1.7 +24 -15
jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestMavenProject.java
Index: TestMavenProject.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestMavenProject.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestMavenProject.java 29 May 2002 01:40:53 -0000 1.6
+++ TestMavenProject.java 30 May 2002 07:49:03 -0000 1.7
@@ -120,26 +120,24 @@
ElementDescriptor descriptor = findDescriptorsForLocalName(
root.getElementDescriptors(), "dependencies"
);
- assertTrue( "Could not find a descriptor for 'dependencies'", descriptor !=
null );
assertTrue( "Should have an updater on the dependencies descriptor",
descriptor.getUpdater() != null );
assertEquals( "dependencies", descriptor.getPropertyName() );
-
- ElementDescriptor[] dependencies = descriptor.getElementDescriptors();
- assertTrue( "Should only find one child descriptor of dependencies",
dependencies.length == 1 );
-
-
- ElementDescriptor dependency = dependencies[0];
-/*
- System.out.println( "Found: " + dependency );
- ElementDescriptor[] children = dependency .getElementDescriptors();
- for ( int i = 0, size = children.length; i < size; i++ ) {
- System.out.println( "Child: " + children[i] );
- }
-*/
+
+ ElementDescriptor dependency = getFirstChildDependency(descriptor,
"dependencies" );
assertEquals( "dependency", dependency.getLocalName() );
assertTrue( "Should not have an updater on the dependency descriptor",
dependency.getUpdater() == null );
+
+ ElementDescriptor build = findDescriptorsForLocalName(
+ root.getElementDescriptors(), "build"
+ );
+/*
+ ElementDescriptor sourceDirectories = findDescriptorsForLocalName(
+ build.getElementDescriptors(), "sourceDirectories"
+ );
+ ElementDescriptor sourceDirectory =
getFirstChildDependency(sourceDirectories, "sourceDirectories" );
+*/
}
/**
@@ -238,6 +236,7 @@
assertEquals( "commons-logging", dependency.getName() );
List sourceDirectories = project.getBuild().getSourceDirectories();
+ assertTrue("Found at least one sourceDirectory", sourceDirectories.size() >
0 );
assertEquals("src/java", (String) sourceDirectories.get(0));
}
@@ -251,14 +250,24 @@
/**
* Finds a descriptor in the given array which matches the given local name.
*/
- protected ElementDescriptor findDescriptorsForLocalName( ElementDescriptor[]
descriptors, String localName ) {
+ protected ElementDescriptor findDescriptorsForLocalName( ElementDescriptor[]
descriptors, String localName ) throws Exception {
for ( int i = 0, size = descriptors.length; i < size; i++ ) {
ElementDescriptor descriptor = descriptors[i];
if ( localName.equals( descriptor.getLocalName() ) ) {
return descriptor;
}
}
+ fail( "Could not find a descriptor for '" + localName + "'" );
return null;
+ }
+
+ /**
+ * Returns the first child descriptor for the given descriptor or fails if one
could not be found
+ */
+ protected ElementDescriptor getFirstChildDependency(ElementDescriptor
descriptor, String localName ) throws Exception {
+ ElementDescriptor[] children = descriptor.getElementDescriptors();
+ assertTrue( "Should find at least one child descriptor of '" + localName +
"'", children != null && children.length > 0 );
+ return children[0];
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>