GEODE-2934: refactor AnalyzeSerializablesJUnitTest and subclasses

Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9e5c75c1
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9e5c75c1
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9e5c75c1

Branch: refs/heads/feature/GEODE-2580
Commit: 9e5c75c156a5a24fc7512ddaec3877218af1e466
Parents: a547972
Author: Kirk Lund <[email protected]>
Authored: Tue May 16 17:53:46 2017 -0700
Committer: Kirk Lund <[email protected]>
Committed: Wed May 17 10:19:09 2017 -0700

----------------------------------------------------------------------
 .../apache/geode/internal/lang/SystemUtils.java |   7 +
 .../AnalyzeSerializablesJUnitTest.java          | 380 +++++++++----------
 .../internal/lang/SystemUtilsJUnitTest.java     |   4 +
 .../AnalyzeCQSerializablesJUnitTest.java        |  55 +--
 .../AnalyzeWANSerializablesJUnitTest.java       |  67 +---
 5 files changed, 195 insertions(+), 318 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9e5c75c1/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java 
b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
index 3485ede..2e47556 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/lang/SystemUtils.java
@@ -301,4 +301,11 @@ public class SystemUtils {
   public static String getLineSeparator() {
     return LINE_SEPARATOR;
   }
+
+  /**
+   * Returns the value of {@code System.getProperty("java.version")}.
+   */
+  public static String getJavaVersion() {
+    return System.getProperty("java.version");
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/9e5c75c1/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
index 5b78f06..ee61a85 100644
--- 
a/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTest.java
@@ -14,11 +14,34 @@
  */
 package org.apache.geode.codeAnalysis;
 
-import static org.junit.Assert.fail;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.diffSortedClassesAndMethods;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.diffSortedClassesAndVariables;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.loadClassesAndMethods;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.loadClassesAndVariables;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.parseClassFilesInDir;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.storeClassesAndMethods;
+import static 
org.apache.geode.codeAnalysis.CompiledClassUtils.storeClassesAndVariables;
+import static org.apache.geode.internal.lang.SystemUtils.getJavaVersion;
+import static org.apache.geode.internal.lang.SystemUtils.isJavaVersionAtLeast;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assume.assumeThat;
+
+import org.apache.geode.codeAnalysis.decode.CompiledClass;
+import org.apache.geode.codeAnalysis.decode.CompiledField;
+import org.apache.geode.codeAnalysis.decode.CompiledMethod;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -26,83 +49,137 @@ import java.util.LinkedList;
 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;
-
-import org.apache.geode.codeAnalysis.decode.CompiledClass;
-import org.apache.geode.codeAnalysis.decode.CompiledField;
-import org.apache.geode.codeAnalysis.decode.CompiledMethod;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.util.test.TestUtil;
-
 @Category(IntegrationTest.class)
 public class AnalyzeSerializablesJUnitTest {
 
   /** all loaded classes */
-  protected static Map<String, CompiledClass> classes = new HashMap<String, 
CompiledClass>();
+  private Map<String, CompiledClass> classes;
 
-  private static boolean ClassesNotFound;
+  private List<ClassAndMethodDetails> expectedDataSerializables;
+  private List<ClassAndVariableDetails> expectedSerializables;
+
+  private File actualDataSerializablesFile;
+  private File actualSerializablesFile;
+
+  @Rule
+  public TestName testName = new TestName();
 
   @Before
-  public void loadClasses() throws Exception {
-    String version = System.getProperty("java.runtime.version");
-    boolean jdk18 = version != null && version.startsWith("1.8");
-    // sanctioned info is based on a 1.7 compiler
-    Assume.assumeTrue(
-        "AnalyzeSerializables requires a Java 8 but tests are running with v" 
+ version, jdk18);
-    if (classes.size() > 0) {
-      return;
+  public void setUp() throws Exception {
+    assumeThat(
+        "AnalyzeSerializables requires Java 8 but tests are running with v" + 
getJavaVersion(),
+        isJavaVersionAtLeast("1.8"), is(true));
+
+    this.classes = new HashMap<>();
+
+    loadClasses();
+
+    // setup expectedDataSerializables
+
+    File expectedDataSerializablesFile = 
getResourceAsFile("sanctionedDataSerializables.txt");
+    assertThat(expectedDataSerializablesFile).exists().canRead();
+
+    this.expectedDataSerializables = 
loadClassesAndMethods(expectedDataSerializablesFile);
+    Collections.sort(this.expectedDataSerializables);
+
+    // setup expectedSerializables
+
+    File expectedSerializablesFile = 
getResourceAsFile("sanctionedSerializables.txt");
+    assertThat(expectedSerializablesFile).exists().canRead();
+
+    this.expectedSerializables = 
loadClassesAndVariables(expectedSerializablesFile);
+    Collections.sort(this.expectedSerializables);
+
+    // setup empty actual files
+
+    this.actualDataSerializablesFile = 
createEmptyFile("actualDataSerializables.dat");
+    this.actualSerializablesFile = createEmptyFile("actualSerializables.dat");
+  }
+
+  /**
+   * Override only this one method in sub-classes
+   */
+  protected String getModuleName() {
+    return "geode-core";
+  }
+
+  @Test
+  public void testDataSerializables() throws Exception {
+    System.out.println(this.testName.getMethodName() + " starting");
+
+    List<ClassAndMethods> actualDataSerializables = findToDatasAndFromDatas();
+    storeClassesAndMethods(actualDataSerializables, 
this.actualDataSerializablesFile);
+
+    String diff =
+        diffSortedClassesAndMethods(this.expectedDataSerializables, 
actualDataSerializables);
+    if (diff.length() > 0) {
+      System.out.println(
+          "++++++++++++++++++++++++++++++testDataSerializables found 
discrepencies++++++++++++++++++++++++++++++++++++");
+      System.out.println(diff);
+      fail(
+          diff + "\n\nIf the class is not persisted or sent over the wire add 
it to the excludedClasses.txt file in the "
+              + "\norg/apache/geode/codeAnalysis directory.  Otherwise if this 
doesn't "
+              + "\nbreak backward compatibility move the file 
actualDataSerializables.dat to the codeAnalysis "
+              + "\ntest directory and rename to 
sanctionedDataSerializables.txt");
     }
+  }
+
+  @Test
+  public void testSerializables() throws Exception {
+    System.out.println(this.testName.getMethodName() + " starting");
+
+    List<ClassAndVariables> actualSerializables = findSerializables();
+    storeClassesAndVariables(actualSerializables, 
this.actualSerializablesFile);
+
+    String diff = diffSortedClassesAndVariables(this.expectedSerializables, 
actualSerializables);
+    if (diff.length() > 0) {
+      System.out.println(
+          "++++++++++++++++++++++++++++++testSerializables found 
discrepencies++++++++++++++++++++++++++++++++++++");
+      System.out.println(diff);
+      fail(
+          diff + "\n\nIf the class is not persisted or sent over the wire add 
it to the excludedClasses.txt file in the "
+              + "\n/org/apache/geode/codeAnalysis/ directory.  Otherwise if 
this doesn't "
+              + "\nbreak backward compatibility move the file 
actualSerializables.dat to the "
+              + "\ncodeAnalysis test directory and rename to 
sanctionedSerializables.txt");
+    }
+  }
+
+  private void loadClasses() throws IOException {
     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")));
+    List<String> excludedClasses = 
loadExcludedClasses(getResourceAsFile("excludedClasses.txt"));
+    List<String> openBugs = loadOpenBugs(getResourceAsFile("openBugs.txt"));
+
     excludedClasses.addAll(openBugs);
 
-    String cp = System.getProperty("java.class.path");
-    System.out.println("java classpath is " + cp);
-    System.out.flush();
-    String[] entries = cp.split(File.pathSeparator);
-    String buildDirName = "geode-core" + File.separatorChar + "build" + 
File.separatorChar
+    String classpath = System.getProperty("java.class.path");
+    System.out.println("java classpath is " + classpath);
+
+    String[] entries = classpath.split(File.pathSeparator);
+    String buildDirName = getModuleName() + File.separatorChar + "build" + 
File.separatorChar
         + "classes" + File.separatorChar + "main";
     String buildDir = null;
 
     for (int i = 0; i < entries.length && buildDir == null; i++) {
       System.out.println("examining '" + entries[i] + "'");
-      System.out.flush();
       if (entries[i].endsWith(buildDirName)) {
         buildDir = entries[i];
       }
     }
-    if (buildDir != null) {
-      System.out.println("loading class files from " + buildDir);
-      System.out.flush();
-      long start = System.currentTimeMillis();
-      loadClassesFromBuild(new File(buildDir), excludedClasses);
-      long finish = System.currentTimeMillis();
-      System.out.println("done loading " + classes.size() + " classes.  
elapsed time = "
-          + (finish - start) / 1000 + " seconds");
-    } else {
-      fail("unable to find geode classes");
-    }
-  }
 
-  @AfterClass
-  public static void cleanup() {
-    if (classes != null) {
-      classes.clear();
-    }
+    assertThat(buildDir).isNotNull();
+    System.out.println("loading class files from " + buildDir);
+
+    long start = System.currentTimeMillis();
+    loadClassesFromBuild(new File(buildDir), excludedClasses);
+    long finish = System.currentTimeMillis();
+
+    System.out.println("done loading " + classes.size() + " classes.  elapsed 
time = "
+        + (finish - start) / 1000 + " seconds");
   }
 
-  protected static List<String> loadExcludedClasses(File exclusionsFile) 
throws Exception {
-    List<String> excludedClasses = new LinkedList<String>();
+  private List<String> loadExcludedClasses(File exclusionsFile) throws 
IOException {
+    List<String> excludedClasses = new LinkedList<>();
     FileReader fr = new FileReader(exclusionsFile);
     BufferedReader br = new BufferedReader(fr);
     try {
@@ -119,8 +196,8 @@ public class AnalyzeSerializablesJUnitTest {
     return excludedClasses;
   }
 
-  protected static List<String> loadOpenBugs(File exclusionsFile) throws 
Exception {
-    List<String> excludedClasses = new LinkedList<String>();
+  private List<String> loadOpenBugs(File exclusionsFile) throws IOException {
+    List<String> excludedClasses = new LinkedList<>();
     FileReader fr = new FileReader(exclusionsFile);
     BufferedReader br = new BufferedReader(fr);
     try {
@@ -131,7 +208,7 @@ public class AnalyzeSerializablesJUnitTest {
         if (line.length() > 0 && !line.startsWith("#")) {
           String[] split = line.split(",");
           if (split.length != 2) {
-            fail("unable to load classes due to misformatted line in 
openBugs.txt: " + line);
+            fail("unable to load classes due to malformed line in 
openBugs.txt: " + line);
           }
           excludedClasses.add(line.split(",")[1].trim());
         }
@@ -142,183 +219,78 @@ public class AnalyzeSerializablesJUnitTest {
     return excludedClasses;
   }
 
-  private static void removeExclusions(Map<String, CompiledClass> classes,
-      List<String> exclusions) {
+  private void removeExclusions(Map<String, CompiledClass> classes, 
List<String> exclusions) {
     for (String exclusion : exclusions) {
       exclusion = exclusion.replace('.', '/');
       classes.remove(exclusion);
     }
   }
 
-  @Test
-  public void testDataSerializables() throws Exception {
-    System.out.println("testDataSerializables starting");
-    if (ClassesNotFound) {
-      System.out.println("... test not run due to not being able to locate 
product class files");
-      return;
-    }
-    String compareToFileName =
-        TestUtil.getResourcePath(getClass(), 
"sanctionedDataSerializables.txt");
-
-    String storeInFileName = "actualDataSerializables.dat";
-    File storeInFile = new File(storeInFileName);
-    if (storeInFile.exists() && !storeInFile.canWrite()) {
-      throw new RuntimeException("can't write " + storeInFileName);
-    }
-    List<ClassAndMethods> toDatas = findToDatasAndFromDatas();
-    CompiledClassUtils.storeClassesAndMethods(toDatas, storeInFile);
-
-    File compareToFile = new File(compareToFileName);
-    if (!compareToFile.exists()) {
-      throw new RuntimeException("can't find " + compareToFileName);
-    }
-    if (!compareToFile.canRead()) {
-      throw new RuntimeException("can't read " + compareToFileName);
-    }
-
-    List<ClassAndMethodDetails> goldRecord =
-        CompiledClassUtils.loadClassesAndMethods(compareToFile);
-    Collections.sort(goldRecord);
-
-    String diff = CompiledClassUtils.diffSortedClassesAndMethods(goldRecord, 
toDatas);
-    if (diff.length() > 0) {
-      System.out.println(
-          "++++++++++++++++++++++++++++++testDataSerializables found 
discrepencies++++++++++++++++++++++++++++++++++++");
-      System.out.println(diff);
-      fail(
-          diff + "\n\nIf the class is not persisted or sent over the wire add 
it to the excludedClasses.txt file in the "
-              + "\norg/apache/geode/codeAnalysis directory.  Otherwise if this 
doesn't "
-              + "\nbreak backward compatibility move the file 
actualDataSerializables.dat to the codeAnalysis "
-              + "\ntest directory and rename to 
sanctionedDataSerializables.txt");
-    }
-  }
-
-  @Test
-  public void testSerializables() throws Exception {
-    System.out.println("testSerializables starting");
-    System.out.flush();
-    if (ClassesNotFound) {
-      System.out.println("... test not run due to not being able to locate 
product class files");
-      return;
-    }
-    String compareToFileName = TestUtil.getResourcePath(getClass(), 
"sanctionedSerializables.txt");
-    File compareToFile = new File(compareToFileName);
-
-    String storeInFileName = "actualSerializables.dat";
-    File storeInFile = new File(storeInFileName);
-    if (storeInFile.exists() && !storeInFile.canWrite()) {
-      throw new RuntimeException("can't write " + storeInFileName);
-    }
-
-    List<ClassAndVariables> serializables = findSerializables();
-    reset();
-    CompiledClassUtils.storeClassesAndVariables(serializables, storeInFile);
-
-
-    if (!compareToFile.exists()) {
-      throw new RuntimeException("can't find " + compareToFileName);
-    }
-    if (!compareToFile.canRead()) {
-      throw new RuntimeException("can't read " + compareToFileName);
-    }
-    List<ClassAndVariableDetails> goldRecord =
-        CompiledClassUtils.loadClassesAndVariables(compareToFile);
-    Collections.sort(goldRecord);
-
-    String diff = CompiledClassUtils.diffSortedClassesAndVariables(goldRecord, 
serializables);
-    classes.clear();
-    if (diff.length() > 0) {
-      System.out.println(
-          "++++++++++++++++++++++++++++++testSerializables found 
discrepencies++++++++++++++++++++++++++++++++++++");
-      System.out.println(diff);
-      fail(
-          diff + "\n\nIf the class is not persisted or sent over the wire add 
it to the excludedClasses.txt file in the "
-              + "\n/org/apache/geode/codeAnalysis/ directory.  Otherwise if 
this doesn't "
-              + "\nbreak backward compatibility move the file 
actualSerializables.dat to the "
-              + "\ncodeAnalysis test directory and rename to 
sanctionedSerializables.txt");
-    }
-  }
-
-  /**
-   * load the classes from the given files and directories
-   * 
-   * @param excludedClasses names of classes to exclude
-   */
-  public static void loadClasses(String directory, boolean recursive,
-      List<String> excludedClasses) {
-    String[] filenames = new String[] {directory};
-    List<File> classFiles = CompiledClassUtils.findClassFiles("", filenames, 
recursive);
-    Map<String, CompiledClass> newClasses = 
CompiledClassUtils.parseClassFiles(classFiles);
-    removeExclusions(newClasses, excludedClasses);
-    classes.putAll(newClasses);
-  }
-
-  public static void loadClassesFromBuild(File buildDir, List<String> 
excludedClasses) {
-    Map<String, CompiledClass> newClasses = 
CompiledClassUtils.parseClassFilesInDir(buildDir);
+  private void loadClassesFromBuild(File buildDir, List<String> 
excludedClasses) {
+    Map<String, CompiledClass> newClasses = parseClassFilesInDir(buildDir);
     removeExclusions(newClasses, excludedClasses);
-    classes.putAll(newClasses);
+    this.classes.putAll(newClasses);
   }
 
-  /**
-   * load the classes from the given jar file
-   */
-  public static void loadClasses(File jar, List<String> excludedClasses) {
-    Map<String, CompiledClass> newClasses = 
CompiledClassUtils.parseClassFilesInJar(jar);
-    removeExclusions(newClasses, excludedClasses);
-    classes.putAll(newClasses);
-  }
+  private List<ClassAndMethods> findToDatasAndFromDatas() {
+    List<ClassAndMethods> result = new ArrayList<>();
+    for (Map.Entry<String, CompiledClass> entry : this.classes.entrySet()) {
+      CompiledClass compiledClass = entry.getValue();
+      ClassAndMethods classAndMethods = null;
 
-  /**
-   * clears all loaded classes
-   */
-  public void reset() {
-    classes.clear();
-  }
+      for (int i = 0; i < compiledClass.methods.length; i++) {
+        CompiledMethod method = compiledClass.methods[i];
 
-  public List<ClassAndMethods> findToDatasAndFromDatas() {
-    List<ClassAndMethods> result = new ArrayList<ClassAndMethods>();
-    for (Map.Entry<String, CompiledClass> dentry : classes.entrySet()) {
-      CompiledClass dclass = dentry.getValue();
-      ClassAndMethods entry = null;
-      for (int i = 0; i < dclass.methods.length; i++) {
-        CompiledMethod method = dclass.methods[i];
         if (!method.isAbstract() && method.descriptor().equals("void")) {
           String name = method.name();
           if (name.startsWith("toData") || name.startsWith("fromData")) {
-            if (entry == null) {
-              entry = new ClassAndMethods(dclass);
+            if (classAndMethods == null) {
+              classAndMethods = new ClassAndMethods(compiledClass);
             }
-            entry.methods.put(method.name(), method);
+            classAndMethods.methods.put(method.name(), method);
           }
         }
       }
-      if (entry != null) {
-        result.add(entry);
+      if (classAndMethods != null) {
+        result.add(classAndMethods);
       }
     }
     Collections.sort(result);
     return result;
   }
 
-  public List<ClassAndVariables> findSerializables() {
-    List<ClassAndVariables> result = new ArrayList<ClassAndVariables>(2000);
-    for (Map.Entry<String, CompiledClass> entry : classes.entrySet()) {
-      CompiledClass dclass = entry.getValue();
-      System.out.println("processing class " + dclass.fullyQualifiedName());
-      System.out.flush();
-      if (!dclass.isInterface() && 
dclass.isSerializableAndNotDataSerializable()) {
-        ClassAndVariables cav = new ClassAndVariables(dclass);
-        for (int i = 0; i < dclass.fields_count; i++) {
-          CompiledField f = dclass.fields[i];
-          if (!f.isStatic() && !f.isTransient()) {
-            cav.variables.put(f.name(), f);
+  private List<ClassAndVariables> findSerializables() {
+    List<ClassAndVariables> result = new ArrayList<>(2000);
+    for (Map.Entry<String, CompiledClass> entry : this.classes.entrySet()) {
+      CompiledClass compiledClass = entry.getValue();
+      System.out.println("processing class " + 
compiledClass.fullyQualifiedName());
+
+      if (!compiledClass.isInterface() && 
compiledClass.isSerializableAndNotDataSerializable()) {
+        ClassAndVariables classAndVariables = new 
ClassAndVariables(compiledClass);
+        for (int i = 0; i < compiledClass.fields_count; i++) {
+          CompiledField compiledField = compiledClass.fields[i];
+          if (!compiledField.isStatic() && !compiledField.isTransient()) {
+            classAndVariables.variables.put(compiledField.name(), 
compiledField);
           }
         }
-        result.add(cav);
+        result.add(classAndVariables);
       }
     }
     Collections.sort(result);
     return result;
   }
 
+  private File createEmptyFile(String fileName) throws IOException {
+    File file = new File(fileName);
+    if (file.exists()) {
+      assertThat(file.delete()).isTrue();
+    }
+    assertThat(file.createNewFile()).isTrue();
+    assertThat(file).exists().canWrite();
+    return file;
+  }
+
+  private File getResourceAsFile(String resourceName) {
+    return new File(getClass().getResource(resourceName).getFile());
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/9e5c75c1/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
index 8a83dc0..5e669b3 100644
--- 
a/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/lang/SystemUtilsJUnitTest.java
@@ -137,4 +137,8 @@ public class SystemUtilsJUnitTest {
     assertThat(getBootClassPath()).isEqualTo(value);
   }
 
+  @Test
+  public void getJavaVersionShouldReturnJavaVersionValue() {
+    assertThat(getJavaVersion()).isEqualTo(System.getProperty("java.version"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/9e5c75c1/geode-cq/src/test/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-cq/src/test/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
 
b/geode-cq/src/test/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
index 747dd8b..4ba17e0 100755
--- 
a/geode-cq/src/test/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
+++ 
b/geode-cq/src/test/java/org/apache/geode/codeAnalysis/AnalyzeCQSerializablesJUnitTest.java
@@ -14,61 +14,14 @@
  */
 package org.apache.geode.codeAnalysis;
 
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.experimental.categories.Category;
-
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.util.test.TestUtil;
+import org.junit.experimental.categories.Category;
 
-/**
- * 
- */
 @Category(IntegrationTest.class)
 public class AnalyzeCQSerializablesJUnitTest extends 
AnalyzeSerializablesJUnitTest {
 
-  @Before
-  public void loadClasses() throws Exception {
-    if (classes.size() > 0) {
-      return;
-    }
-    System.out.println("loadClasses starting");
-    List<String> excludedClasses = loadExcludedClasses(new File(
-        TestUtil.getResourcePath(AnalyzeCQSerializablesJUnitTest.class, 
"excludedClasses.txt")));
-    List<String> openBugs = loadOpenBugs(
-        new 
File(TestUtil.getResourcePath(AnalyzeCQSerializablesJUnitTest.class, 
"openBugs.txt")));
-    excludedClasses.addAll(openBugs);
-
-    String cp = System.getProperty("java.class.path");
-    System.out.println("java classpath is " + cp);
-    System.out.flush();
-    String[] entries = cp.split(File.pathSeparator);
-    String buildDirName = "geode-cq" + File.separatorChar + "build" + 
File.separatorChar + "classes"
-        + File.separatorChar + "main";
-    String buildDir = null;
-
-    for (int i = 0; i < entries.length && buildDir == null; i++) {
-      System.out.println("examining '" + entries[i] + "'");
-      System.out.flush();
-      if (entries[i].endsWith(buildDirName)) {
-        buildDir = entries[i];
-      }
-    }
-    if (buildDir != null) {
-      System.out.println("loading class files from " + buildDir);
-      System.out.flush();
-      long start = System.currentTimeMillis();
-      loadClassesFromBuild(new File(buildDir), excludedClasses);
-      long finish = System.currentTimeMillis();
-      System.out.println("done loading " + classes.size() + " classes.  
elapsed time = "
-          + (finish - start) / 1000 + " seconds");
-    } else {
-      fail("unable to find CQ classes");
-    }
+  @Override
+  protected String getModuleName() {
+    return "geode-cq";
   }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/9e5c75c1/geode-wan/src/test/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-wan/src/test/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
 
b/geode-wan/src/test/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
index 77c541c..5098131 100755
--- 
a/geode-wan/src/test/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
+++ 
b/geode-wan/src/test/java/org/apache/geode/codeAnalysis/AnalyzeWANSerializablesJUnitTest.java
@@ -14,73 +14,14 @@
  */
 package org.apache.geode.codeAnalysis;
 
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.AfterClass;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.codeAnalysis.decode.CompiledClass;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.util.test.TestUtil;
+import org.junit.experimental.categories.Category;
 
-/**
- * 
- */
 @Category(IntegrationTest.class)
 public class AnalyzeWANSerializablesJUnitTest extends 
AnalyzeSerializablesJUnitTest {
 
-  @Before
-  public void loadClasses() throws Exception {
-    if (classes.size() > 0) {
-      return;
-    }
-    System.out.println("loadClasses starting");
-    List<String> excludedClasses = loadExcludedClasses(new File(
-        TestUtil.getResourcePath(AnalyzeWANSerializablesJUnitTest.class, 
"excludedClasses.txt")));
-    List<String> openBugs = loadOpenBugs(
-        new 
File(TestUtil.getResourcePath(AnalyzeWANSerializablesJUnitTest.class, 
"openBugs.txt")));
-    excludedClasses.addAll(openBugs);
-
-    String cp = System.getProperty("java.class.path");
-    System.out.println("java classpath is " + cp);
-    System.out.flush();
-    String[] entries = cp.split(File.pathSeparator);
-    String buildDirName = "geode-wan" + File.separatorChar + "build" + 
File.separatorChar
-        + "classes" + File.separatorChar + "main";
-    String buildDir = null;
-
-    for (int i = 0; i < entries.length && buildDir == null; i++) {
-      System.out.println("examining '" + entries[i] + "'");
-      System.out.flush();
-      if (entries[i].endsWith(buildDirName)) {
-        buildDir = entries[i];
-      }
-    }
-    if (buildDir != null) {
-      System.out.println("loading class files from " + buildDir);
-      System.out.flush();
-      long start = System.currentTimeMillis();
-      loadClassesFromBuild(new File(buildDir), excludedClasses);
-      long finish = System.currentTimeMillis();
-      System.out.println("done loading " + classes.size() + " classes.  
elapsed time = "
-          + (finish - start) / 1000 + " seconds");
-    } else {
-      fail("unable to find WAN classes");
-    }
+  @Override
+  protected String getModuleName() {
+    return "geode-wan";
   }
-
-  @AfterClass
-  public static void cleanup() {
-    if (classes != null) {
-      classes.clear();
-    }
-  }
-
 }

Reply via email to