[jboss-cvs] JBossAS SVN: r70541 - in projects/jboss-mdr/trunk: src/tests/org/jboss/test/annotation/factory/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 7 08:24:07 EST 2008


Author: adrian at jboss.org
Date: 2008-03-07 08:24:07 -0500 (Fri, 07 Mar 2008)
New Revision: 70541

Modified:
   projects/jboss-mdr/trunk/.classpath
   projects/jboss-mdr/trunk/pom.xml
   projects/jboss-mdr/trunk/src/tests/org/jboss/test/annotation/factory/test/NoJavassistAnnotationCreatorTestCase.java
Log:
Fixup the maven dependencies and fool the no-javassist test into thinking javassist isn't in the classpath

Modified: projects/jboss-mdr/trunk/.classpath
===================================================================
--- projects/jboss-mdr/trunk/.classpath	2008-03-07 13:22:28 UTC (rev 70540)
+++ projects/jboss-mdr/trunk/.classpath	2008-03-07 13:24:07 UTC (rev 70541)
@@ -1,16 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" output="target/tests-classes" path="src/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0-SNAPSHOT/jboss-reflect-2.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0-SNAPSHOT/jboss-reflect-2.0.0-SNAPSHOT-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.3.GA/jboss-logging-spi-2.0.3.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.3.GA/jboss-logging-spi-2.0.3.GA-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.3.GA/jboss-common-core-2.2.3.GA.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA-sources.jar"/>
-	<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
-	<classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="src" path="src/main"/>
+  <classpathentry kind="src" output="target/tests-classes" path="src/tests"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0-SNAPSHOT/jboss-reflect-2.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0-SNAPSHOT/jboss-reflect-2.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.3.GA/jboss-common-core-2.2.3.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA-sources.jar"/>
+  <classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: projects/jboss-mdr/trunk/pom.xml
===================================================================
--- projects/jboss-mdr/trunk/pom.xml	2008-03-07 13:22:28 UTC (rev 70540)
+++ projects/jboss-mdr/trunk/pom.xml	2008-03-07 13:24:07 UTC (rev 70541)
@@ -30,9 +30,6 @@
           <includes>
             <include>org/jboss/test/**/*TestCase.java</include>
           </includes>
-          <excludes>
-            <exclude>org/jboss/test/**/NoJavassistAnnotationCreatorTestCase.java</exclude>
-          </excludes>
           <useSystemClassLoader>true</useSystemClassLoader>
         </configuration>
       </plugin>
@@ -58,8 +55,14 @@
       <groupId>org.jboss</groupId>
       <artifactId>javassist</artifactId>
       <version>3.6.0.GA</version>
+      <optional>true</optional>
     </dependency>
     <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-common-logging-spi</artifactId>
+      <version>2.0.4.GA</version>
+    </dependency>
+    <dependency>
       <groupId>org.jboss</groupId>
       <artifactId>jboss-common-core</artifactId>
       <version>2.2.3.GA</version>
@@ -68,18 +71,42 @@
           <groupId>jboss</groupId>
           <artifactId>jboss-common-logging-spi</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>apache-httpclient</groupId>
+          <artifactId>commons-httpclient</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>apache-slide</groupId>
+          <artifactId>webdavlib</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>apache-xerces</groupId>
+          <artifactId>xml-apis</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
+    <!-- Test dependencies -->
     <dependency>
       <groupId>jboss</groupId>
-      <artifactId>jboss-logging-spi</artifactId>
-      <version>2.0.3.GA</version>
+      <artifactId>jboss-common-logging-log4j</artifactId>
+      <version>2.0.4.GA</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-common-core</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-common-logging-spi</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
-	  <!-- Test dependencies -->
     <dependency>
       <groupId>org.jboss</groupId>
       <artifactId>jboss-test</artifactId>
       <version>1.0.4.GA</version>
+      <scope>test</scope>
       <exclusions>
         <exclusion>
           <groupId>jboss</groupId>
@@ -95,6 +122,7 @@
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 </project>

Modified: projects/jboss-mdr/trunk/src/tests/org/jboss/test/annotation/factory/test/NoJavassistAnnotationCreatorTestCase.java
===================================================================
--- projects/jboss-mdr/trunk/src/tests/org/jboss/test/annotation/factory/test/NoJavassistAnnotationCreatorTestCase.java	2008-03-07 13:22:28 UTC (rev 70540)
+++ projects/jboss-mdr/trunk/src/tests/org/jboss/test/annotation/factory/test/NoJavassistAnnotationCreatorTestCase.java	2008-03-07 13:24:07 UTC (rev 70541)
@@ -21,6 +21,12 @@
 */ 
 package org.jboss.test.annotation.factory.test;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 import junit.framework.Test;
 
 import org.jboss.annotation.factory.AnnotationCreator;
@@ -47,15 +53,66 @@
    
    public void testDefaultValues() throws Exception
    {
+      ClassLoader old = Thread.currentThread().getContextClassLoader();
+      ClassLoader test = new TestClassLoader();
+      Thread.currentThread().setContextClassLoader(test);
       try
       {
          String expr = "@org.jboss.test.annotation.factory.support.ComplexWithDefault";
-         AnnotationCreator.createAnnotation(expr, ComplexWithDefault.class);
+         Class<?> annotation = test.loadClass(ComplexWithDefault.class.getName());
+         Class<?> annotationCreator = test.loadClass(AnnotationCreator.class.getName());
+         Method createAnnotation = annotationCreator.getDeclaredMethod("createAnnotation", new Class[] { String.class, Class.class });
+         createAnnotation.invoke(null, new Object[] { expr, annotation });
          fail("Should have had a validation exception");
       }
-      catch (AnnotationValidationException expected)
+      catch (InvocationTargetException expected)
       {
+         Throwable cause = expected.getCause();
+         assertEquals(AnnotationValidationException.class.getName(), cause.getClass().getName());
       }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(old);
+      }
     }
    
+   public class TestClassLoader extends ClassLoader
+   {
+      public TestClassLoader()
+      {
+         super(TestClassLoader.class.getClassLoader());
+      }
+      
+      public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+      {
+         System.out.println(name);
+         if (name.startsWith("javassist"))
+            throw new ClassNotFoundException("exluding javassist");
+         if (name.startsWith("org.jboss"))
+         {
+            String classPath = name.replace('.', '/') + ".class";
+            try
+            {
+               InputStream is = getResourceAsStream(classPath);
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               byte[] bytes = new byte[1024];
+               int read = is.read(bytes);
+               while (read >= 0)
+               {
+                  baos.write(bytes, 0, read);
+                  read = is.read(bytes);
+               }
+               is.close();
+               baos.flush();
+               bytes = baos.toByteArray();
+               return defineClass(name, bytes, 0, bytes.length);
+            }
+            catch (IOException e)
+            {
+               throw new RuntimeException(e);
+            }
+         }
+         return super.loadClass(name, resolve);
+      }
+   }
 }




More information about the jboss-cvs-commits mailing list