You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/04/05 15:18:02 UTC

[geode] branch develop updated: GEODE-4971: Add version capability to GfshRule (#1731)

This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 273994d  GEODE-4971: Add version capability to GfshRule (#1731)
273994d is described below

commit 273994d710be0c34dfd25fa42c0c709b2ed17163
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Thu Apr 5 08:17:58 2018 -0700

    GEODE-4971: Add version capability to GfshRule (#1731)
    
    - Move GfshRuleTest to geode-assembly module since it depends on a full product distro
---
 .../geode/test/junit/rules/GfshRuleTest.java       | 50 ++++++++++++++++++++++
 geode-junit/build.gradle                           |  1 +
 .../geode/test/junit/rules/gfsh/GfshRule.java      | 22 +++++++++-
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/GfshRuleTest.java b/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/GfshRuleTest.java
new file mode 100644
index 0000000..8b17e2e
--- /dev/null
+++ b/geode-assembly/src/test/java/org/apache/geode/test/junit/rules/GfshRuleTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.test.junit.rules;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.dunit.standalone.VersionManager;
+import org.apache.geode.test.junit.categories.GfshTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.junit.rules.gfsh.GfshRule;
+
+@Category({UnitTest.class, GfshTest.class})
+public class GfshRuleTest {
+
+  @Rule
+  public GfshRule gfsh130 = new GfshRule(VersionManager.GEODE_130);
+
+  @Rule
+  public GfshRule gfshDefault = new GfshRule();
+
+  @Test
+  public void checkGfshDefault() {
+    assertThat(gfshDefault.getGfshPath().toString())
+        .contains("geode-assembly/build/install/apache-geode/bin/gfsh");
+  }
+
+  @Test
+  public void checkGfsh130() {
+    assertThat(gfsh130.getGfshPath().toString())
+        .contains("geode-old-versions/build/apache-geode-1.3.0/bin/gfsh");
+  }
+
+}
diff --git a/geode-junit/build.gradle b/geode-junit/build.gradle
index 9b7ba68..d467f0a 100755
--- a/geode-junit/build.gradle
+++ b/geode-junit/build.gradle
@@ -35,4 +35,5 @@ dependencies {
     exclude module: 'hamcrest-core'
   }
   compile 'org.hamcrest:hamcrest-all:' + project.'hamcrest-all.version'
+  compile project(":geode-old-versions")
 }
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/gfsh/GfshRule.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/gfsh/GfshRule.java
index ef64aa4..afed73b 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/gfsh/GfshRule.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/gfsh/GfshRule.java
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
 import org.junit.rules.ExternalResource;
 import org.junit.rules.TemporaryFolder;
 
+import org.apache.geode.test.dunit.standalone.VersionManager;
 import org.apache.geode.test.junit.rules.RequiresGeodeHome;
 
 /**
@@ -45,10 +47,17 @@ public class GfshRule extends ExternalResource {
   private TemporaryFolder temporaryFolder = new TemporaryFolder();
   private List<GfshExecution> gfshExecutions;
   private Path gfsh;
+  private String version;
+
+  public GfshRule() {}
+
+  public GfshRule(String version) {
+    this.version = version;
+  }
 
   @Override
   protected void before() throws IOException {
-    gfsh = new RequiresGeodeHome().getGeodeHome().toPath().resolve("bin/gfsh");
+    gfsh = findGfsh();
     assertThat(gfsh).exists();
 
     gfshExecutions = new ArrayList<>();
@@ -84,6 +93,17 @@ public class GfshRule extends ExternalResource {
     }
   }
 
+  private Path findGfsh() {
+    Path geodeHome;
+    if (version == null) {
+      geodeHome = new RequiresGeodeHome().getGeodeHome().toPath();
+    } else {
+      geodeHome = Paths.get(VersionManager.getInstance().getInstall(version));
+    }
+
+    return geodeHome.resolve("bin/gfsh");
+  }
+
   public TemporaryFolder getTemporaryFolder() {
     return temporaryFolder;
   }

-- 
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.