geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [11/19] geode git commit: GEODE-2430: Remove jar and zip files from test resources
Date Tue, 07 Feb 2017 19:03:32 GMT
GEODE-2430: Remove jar and zip files from test resources

This closes #393


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

Branch: refs/heads/feature/GEODE-2267
Commit: e769796c5611f4fad1a21869ddea29853ed1958e
Parents: 50aebcc
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Mon Feb 6 14:54:49 2017 -0800
Committer: Kirk Lund <klund@apache.org>
Committed: Mon Feb 6 15:21:51 2017 -0800

----------------------------------------------------------------------
 .../configuration/ClusterConfigBaseTest.java    |  69 ++++++++++++++++++-
 .../ClusterConfigDeployJarDUnitTest.java        |  13 ++--
 .../ClusterConfigImportDUnitTest.java           |   8 +--
 .../ClusterConfigStartMemberDUnitTest.java      |   2 +-
 .../ClusterConfigWithSecurityDUnitTest.java     |  31 ++++++---
 .../internal/configuration/cluster.jar          | Bin 617 -> 0 bytes
 .../internal/configuration/cluster_config.zip   | Bin 4172 -> 0 bytes
 .../configuration/cluster_config_security.zip   | Bin 950 -> 0 bytes
 .../internal/configuration/group1.jar           | Bin 617 -> 0 bytes
 .../internal/configuration/group2.jar           | Bin 617 -> 0 bytes
 10 files changed, 100 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
index 0632935..3a3c74c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigBaseTest.java
@@ -18,18 +18,22 @@ package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
 import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
+import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.internal.ClassBuilder;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.junit.Before;
 import org.junit.Rule;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.Properties;
 
 public class ClusterConfigBaseTest extends JUnit4DistributedTestCase {
-  public static final String CLUSTER_CONFIG_ZIP_FILENAME = "cluster_config.zip";
-  public static final String CLUSTER_CONFIG_ZIP_PATH =
-      ClusterConfigBaseTest.class.getResource(CLUSTER_CONFIG_ZIP_FILENAME).getPath();
+  public String clusterConfigZipPath;
 
   public static final ConfigGroup CLUSTER = new ConfigGroup("cluster").regions("regionForCluster")
       .jars("cluster.jar").maxLogFileSize("5000").configFiles("cluster.properties", "cluster.xml");
@@ -56,6 +60,7 @@ public class ClusterConfigBaseTest extends JUnit4DistributedTestCase {
 
   @Before
   public void before() throws Exception {
+    clusterConfigZipPath = buildClusterZipFile();
     locatorProps = new Properties();
     serverProps = new Properties();
 
@@ -63,4 +68,62 @@ public class ClusterConfigBaseTest extends JUnit4DistributedTestCase {
     locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
     serverProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
   }
+
+  private String buildClusterZipFile() throws Exception {
+    ClassBuilder classBuilder = new ClassBuilder();
+    File clusterConfigDir = this.lsRule.getTempFolder().newFolder("cluster_config");
+
+    File clusterDir = new File(clusterConfigDir, "cluster");
+    String clusterXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+        + "<cache xmlns=\"http://geode.apache.org/schema/cache\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
copy-on-read=\"false\" is-server=\"false\" lock-lease=\"120\" lock-timeout=\"60\" search-timeout=\"300\"
version=\"1.0\" xsi:schemaLocation=\"http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd\">\n"
+        + "<region name=\"regionForCluster\">\n"
+        + "    <region-attributes data-policy=\"replicate\" scope=\"distributed-ack\"/>\n"
+        + "  </region>\n" + "</cache>\n";
+    writeFile(clusterDir, "cluster.xml", clusterXml);
+    writeFile(clusterDir, "cluster.properties", "log-file-size-limit=5000");
+    createJarFileWithClass("Cluster", "cluster.jar", clusterDir);
+
+    File group1Dir = new File(clusterConfigDir, "group1");
+    String group1Xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+        + "<cache xmlns=\"http://geode.apache.org/schema/cache\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
copy-on-read=\"false\" is-server=\"false\" lock-lease=\"120\" lock-timeout=\"60\" search-timeout=\"300\"
version=\"1.0\" xsi:schemaLocation=\"http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd\">\n"
+        + "<region name=\"regionForGroup1\">\n"
+        + "    <region-attributes data-policy=\"replicate\" scope=\"distributed-ack\"/>\n"
+        + "  </region>\n" + "</cache>\n";
+    writeFile(group1Dir, "group1.xml", group1Xml);
+    writeFile(group1Dir, "group1.properties", "log-file-size-limit=6000");
+    createJarFileWithClass("Group1", "group1.jar", group1Dir);
+
+
+    File group2Dir = new File(clusterConfigDir, "group2");
+    String group2Xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+        + "<cache xmlns=\"http://geode.apache.org/schema/cache\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
copy-on-read=\"false\" is-server=\"false\" lock-lease=\"120\" lock-timeout=\"60\" search-timeout=\"300\"
version=\"1.0\" xsi:schemaLocation=\"http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd\">\n"
+        + "<region name=\"regionForGroup2\">\n"
+        + "    <region-attributes data-policy=\"replicate\" scope=\"distributed-ack\"/>\n"
+        + "  </region>\n" + "</cache>\n";
+    writeFile(group2Dir, "group1.xml", group2Xml);
+    writeFile(group2Dir, "group2.properties", "log-file-size-limit=7000");
+    createJarFileWithClass("Group2", "group2.jar", group2Dir);
+
+
+    File clusterConfigZip = lsRule.getTempFolder().newFile("cluster_config.zip");
+    ZipUtils.zipDirectory(clusterConfigDir.getCanonicalPath(), clusterConfigZip.getCanonicalPath());
+
+    FileUtils.deleteDirectory(clusterConfigDir);
+    return clusterConfigZip.getCanonicalPath();
+  }
+
+  private File writeFile(File dir, String fileName, String content) throws IOException {
+    dir.mkdirs();
+    File file = new File(dir, fileName);
+    FileUtils.writeStringToFile(file, content);
+
+    return file;
+  }
+
+  protected String createJarFileWithClass(String className, String jarName, File dir)
+      throws IOException {
+    File jarFile = new File(dir, jarName);
+    new ClassBuilder().writeJarFromName(className, jarFile);
+    return jarFile.getCanonicalPath();
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 06e969c..79f0128 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
@@ -30,6 +31,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.File;
+import java.io.IOException;
+
 @Category(DistributedTest.class)
 public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   private GfshShellConnectionRule gfshConnector;
@@ -39,9 +43,10 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest
{
   @Before
   public void before() throws Exception {
     super.before();
-    clusterJar = getClass().getResource("cluster.jar").getPath();
-    group1Jar = getClass().getResource("group1.jar").getPath();
-    group2Jar = getClass().getResource("group2.jar").getPath();
+
+    clusterJar = createJarFileWithClass("Cluster", "cluster.jar", lsRule.getTempFolder().getRoot());
+    group1Jar = createJarFileWithClass("Group1", "group1.jar", lsRule.getTempFolder().getRoot());
+    group2Jar = createJarFileWithClass("Group2", "group2.jar", lsRule.getTempFolder().getRoot());
   }
 
   @After
@@ -53,7 +58,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest
{
 
   @Test
   public void testDeployToNoServer() throws Exception {
-    String clusterJarPath = getClass().getResource("cluster.jar").getPath();
+    String clusterJarPath = clusterJar;
     // set up the locator/servers
     Locator locator = lsRule.startLocatorVM(0, locatorProps);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index d8b4cb3..f68015e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -83,7 +83,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest
{
     });
 
     CommandResult result = gfshConnector
-        .executeCommand("import cluster-configuration --zip-file-name=" + CLUSTER_CONFIG_ZIP_PATH);
+        .executeCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
     assertThat(result.getContent().toString()).contains("existing data in regions: " + regionName);
@@ -105,7 +105,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest
{
     // even though we have a region recreated, we can still import since there is no data
     // in the region
     CommandResult result = gfshConnector
-        .executeCommand("import cluster-configuration --zip-file-name=" + CLUSTER_CONFIG_ZIP_PATH);
+        .executeCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     assertThat(result.getStatus()).isEqualTo(Result.Status.OK)
         .describedAs(result.getContent().toString());
@@ -130,7 +130,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest
{
   @Test
   public void testImportClusterConfig() throws Exception {
     CommandResult result = gfshConnector
-        .executeCommand("import cluster-configuration --zip-file-name=" + CLUSTER_CONFIG_ZIP_PATH);
+        .executeCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
     assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
 
     // Make sure that a backup of the old clusterConfig was created
@@ -164,7 +164,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest
{
     Locator locator2 = lsRule.startLocatorVM(2, locatorProps);
 
     CommandResult result = gfshConnector
-        .executeCommand("import cluster-configuration --zip-file-name=" + CLUSTER_CONFIG_ZIP_PATH);
+        .executeCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
     assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
 
     CONFIG_FROM_ZIP.verify(locator);

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index fb4aa54..c0d22bf 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -89,7 +89,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest
{
     // tempFolder/locator-0/cluster_config/cluster/cluster.jar
     // tempFolder/locator-0/cluster_config/group1/ {group1.xml, group1.properties, group1.jar}
     // tempFolder/locator-0/cluster_config/group2/ ...
-    ZipUtils.unzip(CLUSTER_CONFIG_ZIP_PATH, configDir.getCanonicalPath());
+    ZipUtils.unzip(clusterConfigZipPath, configDir.getCanonicalPath());
 
     Properties properties = new Properties();
     properties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index 995e18e..388fd9d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -21,9 +21,11 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
@@ -37,20 +39,12 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.File;
 import java.util.Properties;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClusterConfigWithSecurityDUnitTest extends JUnit4DistributedTestCase {
-
-  // the zip file is under test/resource/org/apache/geode/management/internal/configuration
-  // it only contains cluster.properites whose content is
-  // mcast-port=0
-  // log-file-size-limit=8000
-  // security-manager=org.apache.geode.example.security.ExampleSecurityManager
-
-  public static final String CLUSTER_CONFIG_ZIP_FILENAME = "cluster_config_security.zip";
-  public static final String CLUSTER_CONFIG_ZIP_PATH =
-      ClusterConfigBaseTest.class.getResource(CLUSTER_CONFIG_ZIP_FILENAME).getPath();
+  public String clusterConfigZipPath;
 
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -60,6 +54,8 @@ public class ClusterConfigWithSecurityDUnitTest extends JUnit4DistributedTestCas
 
   @Before
   public void before() throws Exception {
+    clusterConfigZipPath = buildSecureClusterConfigZip();
+
     locatorProps = new Properties();
     locatorProps.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
     locator0 = lsRule.startLocatorVM(0, locatorProps);
@@ -92,7 +88,7 @@ public class ClusterConfigWithSecurityDUnitTest extends JUnit4DistributedTestCas
         "cluster");
 
     connector.executeAndVerifyCommand(
-        "import cluster-configuration --zip-file-name=" + CLUSTER_CONFIG_ZIP_PATH);
+        "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     locator0.invoke(() -> {
       InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
@@ -106,4 +102,17 @@ public class ClusterConfigWithSecurityDUnitTest extends JUnit4DistributedTestCas
           .isEqualTo(SimpleTestSecurityManager.class.getName());
     });
   }
+
+  private String buildSecureClusterConfigZip() throws Exception {
+    File clusterDir = lsRule.getTempFolder().newFolder("cluster");
+    File clusterSubDir = new File(clusterDir, "cluster");
+
+    String clusterProperties = "mcast-port=0\n" + "log-file-size-limit=8000\n"
+        + "security-manager=org.apache.geode.example.security.ExampleSecurityManager";
+    FileUtils.writeStringToFile(new File(clusterSubDir, "cluster.properties"), clusterProperties);
+    File clusterZip = new File(lsRule.getTempFolder().getRoot(), "cluster_config_security.zip");
+    ZipUtils.zipDirectory(clusterDir.getCanonicalPath(), clusterZip.getCanonicalPath());
+    FileUtils.deleteDirectory(clusterDir);
+    return clusterZip.getCanonicalPath();
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster.jar
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster.jar
b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster.jar
deleted file mode 100755
index 9c9541d..0000000
Binary files a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster.jar
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
deleted file mode 100644
index 11fc6bb..0000000
Binary files a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config.zip
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config_security.zip
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config_security.zip
b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config_security.zip
deleted file mode 100644
index c09114e..0000000
Binary files a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/cluster_config_security.zip
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group1.jar
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group1.jar
b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group1.jar
deleted file mode 100755
index fa105ab..0000000
Binary files a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group1.jar
and /dev/null differ

http://git-wip-us.apache.org/repos/asf/geode/blob/e769796c/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group2.jar
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group2.jar
b/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group2.jar
deleted file mode 100755
index b251f0d..0000000
Binary files a/geode-core/src/test/resources/org/apache/geode/management/internal/configuration/group2.jar
and /dev/null differ


Mime
View raw message