jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven Surefire
  • SUREFIRE-66

JUnitBattery dies when TestSuite has an anonymous inner class

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.2 (2.1.2 plugin), 1.5.3 (2.1.3 plugin)
  • Fix Version/s: 2.0 (2.2 plugin)
  • Component/s: None
  • Labels:
    None

Description

I have this method in my test suite:

private static File[] getWSDLFiles() {

        URL directoryURL = WSDLImportTestSuite.class.getResource("/com/webify/wsf/studio/core/wsdl/wsdls");
        if (directoryURL != null) {
            File directory = new File(directoryURL.getPath());

            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".wsdl");
                }
            };
            return directory.listFiles(filter);
        }
        else {
            return null;
        }
    }

And surefire fails with this exception:

java.lang.NoSuchMethodException: com.webify.wsf.studio.core.wsdl.WSDLImportTestSuite$1.<init>()
at java.lang.Class.getConstructor0(Class.java:1937)
at java.lang.Class.getConstructor(Class.java:1027)
at org.apache.maven.surefire.battery.JUnitBattery.getTestConstructor(JUnitBattery.java:307)
at org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:150)
at org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81)
at org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63)
at org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262)
at org.apache.maven.surefire.Surefire.run(Surefire.java:140)
at org.apache.maven.surefire.Surefire.run(Surefire.java:87)

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    SimpleTestSuite.java
    28/Feb/06 9:12 AM
    1 kB
    Mike Perham
  2. Java Source File
    SurefireTest.java
    23/Mar/06 11:35 AM
    0.4 kB
    Aaron Bell

Issue Links

relates to

Bug - A problem which impairs or prevents the functions of the product. SUREFIRE-19 default excludes prevents inner class test cases

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Improvement - An improvement or enhancement to an existing feature or task. SUREFIRE-237 Improved errors in console

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Mike Perham added a comment - 08/Feb/06 1:45 PM

This works in 2.0 but fails when we upgrade to 2.1.2.

Show
Mike Perham added a comment - 08/Feb/06 1:45 PM This works in 2.0 but fails when we upgrade to 2.1.2.
Hide
Permalink
Carlos Sanchez added a comment - 08/Feb/06 2:03 PM

it's complaining about the constructor, can you paste the constructors you have?

Show
Carlos Sanchez added a comment - 08/Feb/06 2:03 PM it's complaining about the constructor, can you paste the constructors you have?
Hide
Permalink
Mike Perham added a comment - 08/Feb/06 2:10 PM

The outer class has the standard () and (String) JUnit constructors. The inner class's code is posted right there. It's the FilenameFilter.

Show
Mike Perham added a comment - 08/Feb/06 2:10 PM The outer class has the standard () and (String) JUnit constructors. The inner class's code is posted right there. It's the FilenameFilter.
Hide
Permalink
Carlos Sanchez added a comment - 08/Feb/06 2:17 PM

Seems that SUREFIRE-19 was not the right solution

Show
Carlos Sanchez added a comment - 08/Feb/06 2:17 PM Seems that SUREFIRE-19 was not the right solution
Hide
Permalink
Carlos Sanchez added a comment - 08/Feb/06 2:18 PM

Error should be improved

Show
Carlos Sanchez added a comment - 08/Feb/06 2:18 PM Error should be improved
Hide
Permalink
Jason van Zyl added a comment - 27/Feb/06 7:29 PM

Mike can you give me a little test case?

I just deployed a new snapshot which improves forking output so that may help.

Show
Jason van Zyl added a comment - 27/Feb/06 7:29 PM Mike can you give me a little test case? I just deployed a new snapshot which improves forking output so that may help.
Hide
Permalink
Mike Perham added a comment - 28/Feb/06 9:06 AM

In fact 2.1.1 works also so this was a regression in 2.1.2.

Show
Mike Perham added a comment - 28/Feb/06 9:06 AM In fact 2.1.1 works also so this was a regression in 2.1.2.
Hide
Permalink
Mike Perham added a comment - 28/Feb/06 9:08 AM

Our test suite which is failing.

Show
Mike Perham added a comment - 28/Feb/06 9:08 AM Our test suite which is failing.
Hide
Permalink
Brett Porter added a comment - 04/Mar/06 12:57 AM

This may have been fixed in 2.1.3. I can't reproduce using the supplied class under iether 2.1.3 or 2.2

Show
Brett Porter added a comment - 04/Mar/06 12:57 AM This may have been fixed in 2.1.3. I can't reproduce using the supplied class under iether 2.1.3 or 2.2
Hide
Permalink
Aaron Bell added a comment - 23/Mar/06 11:34 AM

Still looks broken to me, using the 2.1.3 SNAPSHOT with the simplest of testcases (attached) gives:

[INFO] task-segment: [test]
[INFO] ----------------------------------------------------------------------------
[INFO] snapshot org.apache.maven.plugins:maven-surefire-plugin:2.1.3-SNAPSHOT: checking for updates from snapshots
Downloading: http://snapshots.maven.codehaus.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.1.3-SNAPSHOT/maven-surefire-plugin-2.1.3-20060228.012944-10.pom
1K downloaded
Downloading: http://snapshots.maven.codehaus.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.1.3-SNAPSHOT/maven-surefire-plugin-2.1.3-20060228.012944-10.jar
9K downloaded
[INFO] [resources:resources]
...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
java.lang.NoSuchMethodException: SurefireTest$1.<init>()
at java.lang.Class.getConstructor0(Class.java:2647)
at java.lang.Class.getConstructor(Class.java:1629)
at org.apache.maven.surefire.battery.JUnitBattery.getTestConstructor(JUnitBattery.java:307)
at org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:150)
at org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81)
at org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63)
at org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262)
at org.apache.maven.surefire.Surefire.run(Surefire.java:140)
at org.apache.maven.surefire.Surefire.run(Surefire.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:304)
at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:220)
at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:368)
...

Show
Aaron Bell added a comment - 23/Mar/06 11:34 AM Still looks broken to me, using the 2.1.3 SNAPSHOT with the simplest of testcases (attached) gives: [INFO] task-segment: [test] [INFO] ---------------------------------------------------------------------------- [INFO] snapshot org.apache.maven.plugins:maven-surefire-plugin:2.1.3-SNAPSHOT: checking for updates from snapshots Downloading: http://snapshots.maven.codehaus.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.1.3-SNAPSHOT/maven-surefire-plugin-2.1.3-20060228.012944-10.pom 1K downloaded Downloading: http://snapshots.maven.codehaus.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.1.3-SNAPSHOT/maven-surefire-plugin-2.1.3-20060228.012944-10.jar 9K downloaded [INFO] [resources:resources] ... ------------------------------------------------------- T E S T S ------------------------------------------------------- java.lang.NoSuchMethodException: SurefireTest$1.<init>() at java.lang.Class.getConstructor0(Class.java:2647) at java.lang.Class.getConstructor(Class.java:1629) at org.apache.maven.surefire.battery.JUnitBattery.getTestConstructor(JUnitBattery.java:307) at org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:150) at org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81) at org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63) at org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262) at org.apache.maven.surefire.Surefire.run(Surefire.java:140) at org.apache.maven.surefire.Surefire.run(Surefire.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:304) at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:220) at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:368) ...
Hide
Permalink
Aaron Bell added a comment - 23/Mar/06 11:35 AM

Simple testcase showing anonymous inner classes breaking the test.

Show
Aaron Bell added a comment - 23/Mar/06 11:35 AM Simple testcase showing anonymous inner classes breaking the test.
Hide
Permalink
Carlos Sanchez added a comment - 17/Apr/06 5:59 PM

Workaround, add to the list of exclusions

<exclude>**/*$*</exclude>

For example

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/Abstract*Test.java</exclude>
            <exclude>**/Abstract*TestCase.java</exclude>
            <exclude>**/*$*</exclude>
          </excludes>
        </configuration>
</plugin>
Show
Carlos Sanchez added a comment - 17/Apr/06 5:59 PM Workaround, add to the list of exclusions
<exclude>**/*$*</exclude>
For example
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/Abstract*Test.java</exclude>
            <exclude>**/Abstract*TestCase.java</exclude>
            <exclude>**/*$*</exclude>
          </excludes>
        </configuration>
</plugin>

People

  • Assignee:
    Brett Porter
    Reporter:
    Mike Perham
Vote (2)
Watch (3)

Dates

  • Created:
    08/Feb/06 1:43 PM
    Updated:
    21/Jan/07 3:33 PM
    Resolved:
    30/Apr/06 10:44 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.