mloayzagahona / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

org.powermock.modules.junit4.common.internal.impl.VersionCompatibility is fragile #453

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use a snapshot version of JUnit
2. Use powermock
3. Run your test

What is the expected output? What do you see instead?
Expect test to run but get a test initialization error.
java.lang.NumberFormatException: For input string: "11-SNAPSHOT"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:492)
        at java.lang.Short.parseShort(Short.java:117)
        at java.lang.Short.parseShort(Short.java:143)
        at org.powermock.modules.junit4.common.internal.impl.VersionCompatibility.getJUnitVersion(VersionCompatibility.java:38)

What version of the product are you using? On what operating system?
1.4.12

Please provide any additional information below.
I know it's very odd to use a snapshot version of JUnit. But in fedora, junit 
package uses snapshot 
version(http://pkgs.fedoraproject.org/cgit/junit.git/tree/junit.spec)

I will report an separate issue to the fedora package maintainer as well. But 
the code in powermock can do better to avoid this. The try block is not wrapped 
around the possible exception generating point which makes it useless.

Original issue reported on code.google.com by patrick....@gmail.com on 23 Aug 2013 at 1:29