Bug 702033

Summary: java.lang.reflect.UndeclaredThrowableException in tests
Product: [Fedora] Fedora Reporter: Orion Poplawski <orion>
Component: maven-surefireAssignee: Stanislav Ochotnicky <sochotni>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 15CC: akurtako, java-sig-commits, sochotni
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-05 09:23:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Orion Poplawski 2011-05-04 15:32:31 UTC
Description of problem:

With apacha-commons-vfs:

ava.lang.reflect.UndeclaredThrowableException
        at $Proxy0.invoke(Unknown Source)
        at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
        at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
        ... 4 more
Caused by: org.apache.maven.surefire.util.NestedRuntimeException: When finding method run; nested exception is java.lang.NoSuchMethodException: org.apache.commons.vfs.provider.zip.test.ZipProviderTestCase.run(junit.framework.TestResult)
        at org.apache.maven.surefire.common.junit3.JUnit3Reflector.getMethod(JUnit3Reflector.java:114)
        at org.apache.maven.surefire.common.junit3.JUnit3Reflector.getRunMethod(JUnit3Reflector.java:210)
        at org.apache.maven.surefire.junit.JUnitTestSet.<init>(JUnitTestSet.java:70)
        at org.apache.maven.surefire.junit.JUnit3Provider.createTestSet(JUnit3Provider.java:94)
        at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:84)
        ... 9 more
Caused by: java.lang.NoSuchMethodException: org.apache.commons.vfs.provider.zip.test.ZipProviderTestCase.run(junit.framework.TestResult)
        at java.lang.Class.getMethod(Class.java:1622)
        at org.apache.maven.surefire.common.junit3.JUnit3Reflector.getMethod(JUnit3Reflector.java:110)
        ... 13 more

Version-Release number of selected component (if applicable):
maven-surefire-2.7.2-1.fc15 and 2.8.1-1.fc16.  2.7.1-3.fc15 appears to work.

http://www.cora.nwra.com/~orion/fedora/apache-commons-vfs-1.0-1.fc15.src.rpm

Comment 1 Orion Poplawski 2011-05-05 04:55:58 UTC
I've ended up using ant to build apache-commons-vfs.  It turns out that under ant, it won't run the tests because ant was not built with junit4.  Perhaps that has something to do with this too.  Anyways, I guess this isn't really a problem for me anymore.

Comment 2 Stanislav Ochotnicky 2011-05-05 09:23:57 UTC
FYI when forced to use junit4.* the error doesn't happen, but tests fail due to missing resources (probably some screwed-up definitions). The pom diff is this:

diff --git a/pom.xml b/pom.xml
index 822eaf9..da1dcb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -132,6 +132,14 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.7.2</version>
+        <dependencies>
+           <dependency>
+             <groupId>org.apache.maven.surefire</groupId>
+             <artifactId>surefire-junit4</artifactId>
+             <version>2.7.2</version>
+           </dependency>
+        </dependencies>
+
         <configuration>
           <argLine>-Xss8192k</argLine>
           <systemProperties>
@@ -223,7 +231,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.2</version>
+      <version>4.8.2</version> 
       <scope>test</scope>
     </dependency>
   </dependencies>
---------------


I decided against reporting this upstream, since it seems vfs is misusing some junit bugs/features and they don't even support mvn build so surefire is not supposed to work. Due to this closing as "not a bug". 

As for the ant test run...maybe if you put junit4 on classpath the tests would run?