leosutic 2003/08/14 15:09:18
Added: attributes/unittest project.xml maven.xml
attributes/unittest/src/test/org/apache/avalon/attributes/test
Dependency.java ClassLoaderUtilTestCase.java
Log:
Moved the unit tests into a separate project to get away from some really
ugly dependencies. (API being dependent test-wise on Compiler, and
Compiler being dependent on API biuld-wise)
Revision Changes Path
1.1 avalon-sandbox/attributes/unittest/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../project.xml</extend>
<id>avalon-attributes-unittest</id>
<name>Avalon Attribute Compiler Unit Tests</name>
<package>org.apache.avalon.attributes</package>
<currentVersion>0.1</currentVersion>
<inceptionYear>2003</inceptionYear>
<shortDescription>Proof-of-concept client API for Attributes in
Java.</shortDescription>
<description>
A precompiler for java that enables the use of attributes as seen in C#.
</description>
<build>
<unitTestSourceDirectory>${basedir}/target/temp</unitTestSourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<id>xdoclet+xjavadoc</id>
<version>1.0</version>
</dependency>
<dependency>
<id>commons-collections</id>
<version>2.1</version>
</dependency>
<dependency>
<groupId>avalon-attributes</groupId>
<artifactId>avalon-attributes-compiler</artifactId>
<version>SNAPSHOT</version>
</dependency>
<dependency>
<groupId>avalon-attributes</groupId>
<artifactId>avalon-attributes-api</artifactId>
<version>SNAPSHOT</version>
</dependency>
</dependencies>
<packageGroups>
<packageGroup>
<title>Application Program Interface (API)</title>
<packages>org.apache.avalon.attributes</packages>
</packageGroup>
</packageGroups>
</project>
1.1 avalon-sandbox/attributes/unittest/maven.xml
Index: maven.xml
===================================================================
<project default="do-install" xmlns:maven="jelly:maven" xmlns:j="jelly:core"
xmlns:util="jelly:util">
<property file="${basedir}/../build.properties"/>
<property file="${basedir}/../project.properties"/>
<property file="project.properties"/>
<property name="maven.jar.manifest.extensions.add" value="true"/>
<property name="maven.checkstyle.format" value="avalon"/>
<property name="pom.organization.identifier" value="ASF"/>
<property name="pom.specificationVersion" value="1.0"/>
<goal name="wrapper">
<echo message="${maven.build.dest}"/>
<taskdef name="attributes"
classname="org.apache.avalon.attributes.compiler.AttributeCompiler">
<classpath>
<path refid="maven.dependency.classpath"/>
</classpath>
</taskdef>
<!-- Set up the classloader tests -->
<attributes destDir="target/cl1/">
<fileset dir="src/cl1/" includes="**/*.java"/>
</attributes>
<attributes destDir="target/cl2/">
<fileset dir="src/cl2/" includes="**/*.java"/>
</attributes>
<javac destdir="target/cl1/"
debug="true"
deprecation="true">
<src>
<pathelement path="target/cl1/"/>
<pathelement path="src/cl1/"/>
<pathelement path="src/java/"/>
</src>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement path="target/cl1/"/>
</classpath>
</javac>
<javac destdir="target/cl2/"
classpath="target/cl2/"
debug="true"
deprecation="true">
<src>
<pathelement path="target/cl2/"/>
<pathelement path="src/cl2/"/>
<pathelement path="src/java/"/>
</src>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement path="target/cl1/"/>
</classpath>
</javac>
<taskdef name="attributes-index"
classname="org.apache.avalon.attributes.compiler.AttributeIndexer">
<classpath>
<path refid="maven.dependency.classpath"/>
</classpath>
</taskdef>
<attributes-index destFile="target/cl2/META-INF/attrs.index">
<fileset dir="target/cl2/" includes="**/*.class"/>
</attributes-index>
<jar jarfile="target/cl2/cl2.jar">
<fileset dir="target/cl2/" includes="**/*.class"/>
<fileset dir="target/cl2/" includes="META-INF/**/*"/>
</jar>
<!-- Create the Attribute Repository Classes. -->
<attributes destDir="target/temp/">
<fileset dir="src/test/" includes="**/*.java"/>
</attributes>
<copy todir="target/temp/">
<fileset dir="src/test/" includes="**/*.java"/>
</copy>
<attainGoal name="jar:install-snapshot"/>
</goal>
</project>
1.1
avalon-sandbox/attributes/unittest/src/test/org/apache/avalon/attributes/test/Dependency.java
Index: Dependency.java
===================================================================
package org.apache.avalon.attributes.test;
/**
* Declares a dependency.
*
* @org.apache.avalon.attributes.Inheritable
*/
public class Dependency {
private final Class clazz;
private final String name;
public Dependency (Class clazz, String name) {
this.clazz = clazz;
this.name = name;
}
public Class getDependencyClass () {
return clazz;
}
public String getDependencyName () {
return name;
}
public boolean equals (Object o) {
return o instanceof Dependency &&
((Dependency) o).clazz == clazz &&
((Dependency) o).name.equals (name);
}
public int hashCode () {
return clazz.hashCode () ^ name.hashCode ();
}
public String toString () {
return "[Dependency on " + clazz.getName () + " via name \"" + name + "\"]";
}
}
1.1
avalon-sandbox/attributes/unittest/src/test/org/apache/avalon/attributes/test/ClassLoaderUtilTestCase.java
Index: ClassLoaderUtilTestCase.java
===================================================================
package org.apache.avalon.attributes.test;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
import org.apache.avalon.attributes.Attributes;
import org.apache.avalon.attributes.ClassLoaderUtil;
import junit.framework.TestCase;
public class ClassLoaderUtilTestCase extends TestCase {
public void testScanning () throws Exception {
URLClassLoader cl1 = new URLClassLoader (new URL[]{new File
("unittest/target/cl1/").toURL ()}, getClass().getClassLoader ());
URLClassLoader cl2 = new URLClassLoader (new URL[]{new File
("unittest/target/cl2/cl2.jar").toURL ()}, getClass().getClassLoader ());
ClassLoaderUtil clUtil = ClassLoaderUtil.getClassLoaderUtil ();
Collection cl1Classes = clUtil.getClasses (cl1);
Collection cl2Classes = clUtil.getClasses (cl2);
System.out.println (cl1Classes);
System.out.println (cl2Classes);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]