geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: Use TemporaryFolder
Date Tue, 03 May 2016 00:15:51 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1255 6034ee995 -> 40c0ce7a2


Use TemporaryFolder


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

Branch: refs/heads/feature/GEODE-1255
Commit: 40c0ce7a26e763a1cb79e1ab68be8b450319a688
Parents: 6034ee9
Author: Kirk Lund <klund@apache.org>
Authored: Mon May 2 17:15:39 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Mon May 2 17:15:39 2016 -0700

----------------------------------------------------------------------
 .../cli/commands/DeployCommandsDUnitTest.java   | 43 +++++++++++---------
 1 file changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/40c0ce7a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
index 40e61d7..fc8bb05 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
@@ -57,13 +57,15 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 @SuppressWarnings("serial")
 public class DeployCommandsDUnitTest extends CliCommandTestBase {
 
-  File newDeployableJarFile = new File("DeployCommandsDUnit1.jar");
-
-  transient private ClassBuilder classBuilder = new ClassBuilder();
-  transient private CommandProcessor commandProcessor;
+  private final Pattern pattern = Pattern.compile("^" + JarDeployer.JAR_PREFIX + "DeployCommandsDUnit.*#\\d++$");
+  private File newDeployableJarFile;
+  private transient ClassBuilder classBuilder;
+  private transient CommandProcessor commandProcessor;
 
   @Override
   public final void postSetUpCliCommandTestBase() throws Exception {
+    this.newDeployableJarFile = new File(this.temporaryFolder.getRoot().getCanonicalPath()
+ File.separator + "DeployCommandsDUnit1.jar");
+    this.classBuilder = new ClassBuilder();
     this.commandProcessor = new CommandProcessor();
     assertFalse(this.commandProcessor.isStopped());
 
@@ -93,7 +95,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
   }
 
   @Test
-  public void testDeploy() throws IOException {
+  public void testDeploy() throws Exception {
     final Properties props = new Properties();
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
@@ -179,7 +181,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
   }
 
   @Test
-  public void testUndeploy() throws IOException {
+  public void testUndeploy() throws Exception {
     final Properties props = new Properties();
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
@@ -256,7 +258,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
   }
 
   @Test
-  public void testListDeployed() throws IOException {
+  public void testListDeployed() throws Exception {
     final Properties props = new Properties();
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
@@ -325,24 +327,27 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
    * Does an end-to-end test using the complete CLI framework while ensuring that the shared
configuration is updated.
    */
   @Test
-  public void testEndToEnd() throws IOException {
-    final String groupName = "testDeployEndToEndGroup";
+  public void testEndToEnd() throws Exception {
+    final String groupName = getName();
 
     // Start the Locator and wait for shared configuration to be available
     final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    final String locatorLogPath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator
+ "locator-" + locatorPort + ".log";
+
     Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
       @Override
       public void run() {
 
-        final File locatorLogFile = new File("locator-" + locatorPort + ".log");
+        final File locatorLogFile = new File(locatorLogPath);
+
         final Properties locatorProps = new Properties();
         locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
         locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
         locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
         locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+
         try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
locatorLogFile, null,
-              locatorProps);
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort,
locatorLogFile, null, locatorProps);
 
           WaitCriterion wc = new WaitCriterion() {
             @Override
@@ -356,8 +361,9 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
             }
           };
           Wait.waitForCriterion(wc, 5000, 500, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         }
       }
     });
@@ -373,7 +379,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
     this.classBuilder.writeJarFromName("DeployCommandsDUnitA", this.newDeployableJarFile);
 
     // Deploy the JAR
-    CommandResult cmdResult = executeCommand("deploy --jar=DeployCommandsDUnit1.jar");
+    CommandResult cmdResult = executeCommand("deploy --jar=" + this.newDeployableJarFile.getCanonicalPath());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     String stringResult = commandResultToString(cmdResult);
@@ -393,7 +399,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
         "Manager.*DeployCommandsDUnit1.jar.*" + JarDeployer.JAR_PREFIX + "DeployCommandsDUnit1.jar#1"));
 
     // Deploy the JAR to a group
-    cmdResult = executeCommand("deploy --jar=DeployCommandsDUnit1.jar --group=" + groupName);
+    cmdResult = executeCommand("deploy --jar=" + this.newDeployableJarFile.getCanonicalPath()
+ " --group=" + groupName);
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
     stringResult = commandResultToString(cmdResult);
@@ -454,12 +460,11 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
     assertTrue(commandResultToString(cmdResult).contains(CliStrings.LIST_DEPLOYED__NO_JARS_FOUND_MESSAGE));
   }
 
-  final Pattern pattern = Pattern.compile("^" + JarDeployer.JAR_PREFIX + "DeployCommandsDUnit.*#\\d++$");
-
-  void deleteSavedJarFiles() {
+  private void deleteSavedJarFiles() {
     this.newDeployableJarFile.delete();
 
     File dirFile = new File(".");
+
     // Find all deployed JAR files
     File[] oldJarFiles = dirFile.listFiles(new FilenameFilter() {
       @Override


Mime
View raw message