GEODE-468: Using 1.8 generated files for AnalyzeSerializablesJUnitTest This test was passing every time with 1.8 because of a short circuit in the test. I've regenerated the files with 1.8 and updated the test to use junit Assume to ignore the test with the wrong JDK - at least it will get reported as ignored.
The test was failing due to HDFS code removal. The newly generated files also have the HDFS fields removed. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/37f77a90 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/37f77a90 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/37f77a90 Branch: refs/heads/feature/GEODE-409 Commit: 37f77a90a8567c1e4612c01dbffa6ce659a83eb2 Parents: 593d176 Author: Dan Smith <[email protected]> Authored: Thu Oct 22 13:09:49 2015 -0700 Committer: Dan Smith <[email protected]> Committed: Thu Oct 22 13:12:59 2015 -0700 ---------------------------------------------------------------------- .../AnalyzeSerializablesJUnitTest.java | 26 +- .../sanctionedDataSerializables.txt | 1755 ++++++++---------- .../codeAnalysis/sanctionedSerializables.txt | 27 +- 3 files changed, 797 insertions(+), 1011 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/37f77a90/gemfire-core/src/test/java/com/gemstone/gemfire/codeAnalysis/AnalyzeSerializablesJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/codeAnalysis/AnalyzeSerializablesJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/codeAnalysis/AnalyzeSerializablesJUnitTest.java index 7cd0ca7..2f02de4 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/codeAnalysis/AnalyzeSerializablesJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/codeAnalysis/AnalyzeSerializablesJUnitTest.java @@ -20,8 +20,10 @@ import java.util.List; import java.util.Map; import org.junit.AfterClass; +import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -40,7 +42,6 @@ import com.gemstone.gemfire.util.test.TestUtil; public class AnalyzeSerializablesJUnitTest { /** all loaded classes */ protected static Map<String, CompiledClass> classes = new HashMap<String, CompiledClass>(); - protected static boolean DISABLED = true; private static boolean ClassesNotFound; public AnalyzeSerializablesJUnitTest() { @@ -48,17 +49,15 @@ public class AnalyzeSerializablesJUnitTest { @Before public void loadClasses() throws Exception { - if (classes.size() > 0) { - return; - } - System.out.println("loadClasses starting"); String version = System.getProperty("java.runtime.version"); - if (version == null || !version.startsWith("1.7")) { + boolean jdk17 = version != null && version.startsWith("1.8"); // sanctioned info is based on a 1.7 compiler - System.out.println("AnalyzeSerializables requires a Java 7 but tests are running with v"+version); - DISABLED=true; + Assume.assumeTrue("AnalyzeSerializables requires a Java 7 but tests are running with v"+version, jdk17); + if (classes.size() > 0) { return; } + System.out.println("loadClasses starting"); + List<String> excludedClasses = loadExcludedClasses(new File(TestUtil.getResourcePath(AnalyzeSerializablesJUnitTest.class, "excludedClasses.txt"))); List<String> openBugs = loadOpenBugs(new File(TestUtil.getResourcePath(AnalyzeSerializablesJUnitTest.class, "openBugs.txt"))); excludedClasses.addAll(openBugs); @@ -94,7 +93,6 @@ public class AnalyzeSerializablesJUnitTest { else { fail("unable to find geode classes"); } - DISABLED = false; } @AfterClass @@ -129,7 +127,6 @@ public class AnalyzeSerializablesJUnitTest { else { fail("unable to find jgroups jar"); } - DISABLED = false; } protected static List<String> loadExcludedClasses(File exclusionsFile) throws Exception { @@ -162,7 +159,6 @@ public class AnalyzeSerializablesJUnitTest { if (line.length() > 0 && !line.startsWith("#")) { String[] split = line.split(","); if (split.length != 2) { - DISABLED = true; // don't run the other tests fail("unable to load classes due to misformatted line in openBugs.txt: " + line); } excludedClasses.add(line.split(",")[1].trim()); @@ -189,10 +185,6 @@ public class AnalyzeSerializablesJUnitTest { System.out.println("... test not run due to not being able to locate product class files"); return; } - if (DISABLED) { - System.out.println("... test is disabled"); - return; - } String compareToFileName = TestUtil.getResourcePath(getClass(), "sanctionedDataSerializables.txt"); String storeInFileName = "actualDataSerializables.dat"; @@ -233,10 +225,6 @@ public class AnalyzeSerializablesJUnitTest { System.out.println("... test not run due to not being able to locate product class files"); return; } - if (DISABLED) { - System.out.println("... test is disabled"); - return; - } String compareToFileName = TestUtil.getResourcePath(getClass(), "sanctionedSerializables.txt"); File compareToFile = new File(compareToFileName);
