geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [1/2] geode git commit: Add test to expose GEODE-3429
Date Thu, 17 Aug 2017 22:59:48 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 82fad6453 -> 1a67d4627


Add test to expose GEODE-3429


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

Branch: refs/heads/develop
Commit: 1a67d46278ea519a1bfe185a7da11247e9771a4b
Parents: 64f33c3
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Thu Aug 10 11:21:59 2017 -0700
Committer: Jared Stewart <jstewart@pivotal.io>
Committed: Thu Aug 17 15:57:59 2017 -0700

----------------------------------------------------------------------
 .../deployment/FunctionScannerTest.java         | 17 ++++++++++
 .../internal/deployment/AbstractFunction.java   | 33 --------------------
 .../internal/deployment/AnnotatedFunction.java  | 23 ++++++++++++++
 .../apache/geode/test/compiler/JarBuilder.java  | 10 ++++--
 .../geode/test/compiler/JavaCompiler.java       | 11 +++++--
 5 files changed, 57 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/1a67d462/geode-core/src/test/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java
index af9ffdf..d46b801 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/deployment/FunctionScannerTest.java
@@ -23,6 +23,7 @@ import java.net.URL;
 import java.util.Collection;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -95,6 +96,22 @@ public class FunctionScannerTest {
         "org.apache.geode.management.internal.deployment.AbstractImplementsFunction");
   }
 
+  @Test
+  @Ignore("Fails due to GEODE-3429")
+  public void registerFunctionHierarchySplitAcrossTwoJars() throws Exception {
+    File sourceFileOne = loadTestResource("AbstractImplementsFunction.java");
+    File abstractJar = new File(temporaryFolder.getRoot(), "abstract.jar");
+    jarBuilder.buildJar(abstractJar, sourceFileOne);
+
+    jarBuilder.addToClasspath(abstractJar);
+    File sourceFileTwo = loadTestResource("AnnotatedFunction.java");
+
+    jarBuilder.buildJar(outputJar, sourceFileTwo);
+    Collection<String> functionsFoundInJar = functionScanner.findFunctionsInJar(outputJar);
+    assertThat(functionsFoundInJar).containsExactlyInAnyOrder(
+        "org.apache.geode.management.internal.deployment.AnnotatedFunction");
+  }
+
   private File loadTestResource(String fileName) throws URISyntaxException {
     URL resourceFileURL = this.getClass().getResource(fileName);
     assertThat(resourceFileURL).isNotNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/1a67d462/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AbstractFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AbstractFunction.java
b/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AbstractFunction.java
deleted file mode 100644
index afc83ab..0000000
--- a/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AbstractFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain
a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
- * or implied. See the License for the specific language governing permissions and limitations
under
- * the License.
- */
-package org.apache.geode.management.internal.deployment;
-
-import org.apache.geode.cache.execute.FunctionContext;
-
-public class AbstractFunction implements Function {
-  public void execute(FunctionContext context) {
-    context.getResultSender().lastResult("ConcreteResult");
-  }
-
-  public static abstract class AbstractImplementsFunction implements Function {
-    public abstract void execute(FunctionContext context);
-  }
-
-  public static class Concrete extends AbstractImplementsFunction {
-    public void execute(FunctionContext context) {
-      context.getResultSender().lastResult("ConcreteResult");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/1a67d462/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AnnotatedFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AnnotatedFunction.java
b/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AnnotatedFunction.java
new file mode 100644
index 0000000..612b498
--- /dev/null
+++ b/geode-core/src/test/resources/org/apache/geode/management/internal/deployment/AnnotatedFunction.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.geode.management.internal.deployment;
+
+import org.apache.geode.cache.execute.FunctionContext;
+
+public class AnnotatedFunction extends AbstractImplementsFunction {
+  public void execute(FunctionContext context) {
+    context.getResultSender().lastResult("AnnotatedFunctionResult");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/1a67d462/geode-junit/src/main/java/org/apache/geode/test/compiler/JarBuilder.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/org/apache/geode/test/compiler/JarBuilder.java b/geode-junit/src/main/java/org/apache/geode/test/compiler/JarBuilder.java
index beea476..db1eb58 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/compiler/JarBuilder.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/compiler/JarBuilder.java
@@ -24,8 +24,6 @@ import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 
-import org.assertj.core.api.Assertions;
-
 
 /**
  * This class accepts java source code in the format of .java source files or strings containing
the
@@ -76,6 +74,14 @@ import org.assertj.core.api.Assertions;
 public class JarBuilder {
   private final JavaCompiler javaCompiler = new JavaCompiler();
 
+  /**
+   * Adds the given jarFile to the classpath that will be used for compilation by the buildJar
+   * methods.
+   */
+  public void addToClasspath(File jarFile) {
+    javaCompiler.addToClasspath(jarFile);
+  }
+
   public void buildJarFromClassNames(File outputJarFile, String... classNames) throws IOException
{
     UncompiledSourceCode[] uncompiledSourceCodes = Arrays.stream(classNames)
         .map(UncompiledSourceCode::fromClassName).toArray(UncompiledSourceCode[]::new);

http://git-wip-us.apache.org/repos/asf/geode/blob/1a67d462/geode-junit/src/main/java/org/apache/geode/test/compiler/JavaCompiler.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/org/apache/geode/test/compiler/JavaCompiler.java b/geode-junit/src/main/java/org/apache/geode/test/compiler/JavaCompiler.java
index 8449605..6039e87 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/compiler/JavaCompiler.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/compiler/JavaCompiler.java
@@ -32,10 +32,16 @@ import org.apache.commons.io.FileUtils;
 
 public class JavaCompiler {
   private File tempDir;
+  private String classpath;
 
   public JavaCompiler() {
     this.tempDir = Files.createTempDir();
     tempDir.deleteOnExit();
+    this.classpath = System.getProperty("java.class.path");
+  }
+
+  public void addToClasspath(File jarFile) {
+    classpath += File.pathSeparator + jarFile.getAbsolutePath();
   }
 
   public List<CompiledSourceCode> compile(File... sourceFiles) throws IOException {
@@ -57,8 +63,9 @@ public class JavaCompiler {
     File temporarySourcesDirectory = createSubdirectory(tempDir, "sources");
     File temporaryClassesDirectory = createSubdirectory(tempDir, "classes");
 
-    List<String> options = Stream.of("-d", temporaryClassesDirectory.getAbsolutePath(),
-        "-classpath", System.getProperty("java.class.path")).collect(toList());
+    List<String> options =
+        Stream.of("-d", temporaryClassesDirectory.getAbsolutePath(), "-classpath", classpath)
+            .collect(toList());
 
     try {
       for (UncompiledSourceCode sourceCode : uncompiledSources) {


Mime
View raw message