GEODE-3048: Introduce a rule to identify tests that require GEODE_HOME

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

Branch: refs/heads/feature/GEM-1483
Commit: 2c4b53722b43ea654114b9e730bbba4ee0472482
Parents: eb3312a
Author: Jared Stewart <jstew...@pivotal.io>
Authored: Mon Jun 12 14:18:07 2017 -0700
Committer: Jared Stewart <jstew...@pivotal.io>
Committed: Mon Jun 12 15:36:00 2017 -0700

----------------------------------------------------------------------
 .../test/dunit/rules/RequiresGeodeHome.java     | 50 ++++++++++++++++++++
 1 file changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/2c4b5372/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/RequiresGeodeHome.java
----------------------------------------------------------------------
diff --git 
a/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/RequiresGeodeHome.java
 
b/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/RequiresGeodeHome.java
new file mode 100644
index 0000000..02f474f
--- /dev/null
+++ 
b/geode-assembly/src/test/java/org/apache/geode/test/dunit/rules/RequiresGeodeHome.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.dunit.rules;
+
+import static org.apache.commons.lang.SystemUtils.LINE_SEPARATOR;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.junit.rules.ExternalResource;
+
+/**
+ * This {@code Rule} is used to indicate tests that require the GEODE_HOME 
environment varible to be
+ * set. (For example, any test that relies on the assembled Pulse WAR or GFSH 
binary.)
+ */
+public class RequiresGeodeHome extends ExternalResource {
+  private static final String GEODE_HOME_NOT_SET_MESSAGE =
+      "This test requires a GEODE_HOME environment variable that points to the 
location "
+          + "of geode-assembly/build/install/apache-geode." + LINE_SEPARATOR
+          + "For instructions on how to set this variable if running tests 
through IntelliJ, see "
+          + "https://stackoverflow.com/a/32761503/3988499";;
+
+  @Override
+  protected void before() {
+    getGeodeHome();
+  }
+
+  public File getGeodeHome() {
+    String geodeHomePath = System.getenv("GEODE_HOME");
+    assertNotNull(GEODE_HOME_NOT_SET_MESSAGE, geodeHomePath);
+
+    File geodeHome = new File(geodeHomePath);
+    assertThat(geodeHome).exists();
+
+    return geodeHome;
+  }
+}

Reply via email to