You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/01 01:09:47 UTC

[2/7] incubator-geode git commit: GEODE-953: Cleanup geode-junit

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RuleAndClassRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RuleAndClassRuleTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RuleAndClassRuleTest.java
deleted file mode 100755
index 9c050e9..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RuleAndClassRuleTest.java
+++ /dev/null
@@ -1,138 +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 com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runner.Result;
-import org.junit.runners.model.Statement;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class RuleAndClassRuleTest {
-
-  @Test
-  public void usingRuleAsRuleAndClassRuleShouldInvokeBeforeClass() {
-    Result result = runTest(UsingRuleAsRuleAndClassRule.class);
-    
-    assertThat(result.wasSuccessful()).isTrue();
-    assertThat(UsingRuleAsRuleAndClassRule.staticRule.beforeClassInvoked).isEqualTo(true);
-  }
-  
-  @Test
-  public void usingRuleAsRuleAndClassRuleShouldInvokeAfterClass() {
-    Result result = runTest(UsingRuleAsRuleAndClassRule.class);
-    
-    assertThat(result.wasSuccessful()).isTrue();
-    assertThat(UsingRuleAsRuleAndClassRule.staticRule.afterClassInvoked).isEqualTo(true);
-  }
-
-  @Test
-  public void usingRuleAsRuleAndClassRuleShouldInvokeBefore() {
-    Result result = runTest(UsingRuleAsRuleAndClassRule.class);
-    
-    assertThat(result.wasSuccessful()).isTrue();
-    assertThat(UsingRuleAsRuleAndClassRule.staticRule.beforeInvoked).isEqualTo(true);
-  }
-
-  @Test
-  public void usingRuleAsRuleAndClassRuleShouldInvokeAfter() {
-    Result result = runTest(UsingRuleAsRuleAndClassRule.class);
-    
-    assertThat(result.wasSuccessful()).isTrue();
-    assertThat(UsingRuleAsRuleAndClassRule.staticRule.afterInvoked).isEqualTo(true);
-  }
-
-  public static class SpyRule implements TestRule {
-    boolean beforeClassInvoked;
-    boolean afterClassInvoked;
-    boolean beforeInvoked;
-    boolean afterInvoked;
-    
-    @Override
-    public Statement apply(final Statement base, final Description description) {
-      if (description.isTest()) {
-        return statement(base);
-      } else if (description.isSuite()) {
-        return statementClass(base);
-      }
-      return base;
-    }
-
-    private Statement statement(final Statement base) {
-      return new Statement() {
-        @Override
-        public void evaluate() throws Throwable {
-          before();
-          try {
-            base.evaluate();
-          } finally {
-            after();
-          }
-        }
-      };
-    }
-    
-    private Statement statementClass(final Statement base) {
-      return new Statement() {
-        @Override
-        public void evaluate() throws Throwable {
-          beforeClass();
-          try {
-            base.evaluate();
-          } finally {
-            afterClass();
-          }
-        }
-      };
-    }
-    
-    private void beforeClass() {
-      this.beforeClassInvoked = true;
-    }
-    
-    private void afterClass() {
-      this.afterClassInvoked = true;
-    }
-    
-    private void before() {
-      this.beforeInvoked = true;
-    }
-    
-    private void after() {
-      this.afterInvoked = true;
-    }
-  };
-  
-  public static class UsingRuleAsRuleAndClassRule {
-    @ClassRule
-    public static SpyRule staticRule = new SpyRule();
-    @Rule
-    public SpyRule rule = staticRule;
-    @Test
-    public void doTest() throws Exception {
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/TestRunner.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/TestRunner.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/TestRunner.java
deleted file mode 100755
index 684f452..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/TestRunner.java
+++ /dev/null
@@ -1,37 +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 com.gemstone.gemfire.test.junit.rules.tests;
-
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Request;
-import org.junit.runner.Result;
-
-/**
- * Used by Rule Unit Tests to execute Test Cases.
- * 
- * @author Kirk Lund
- */
-public class TestRunner {
-
-  protected TestRunner() {
-  }
-  
-  public static Result runTest(Class<?> test) {
-    JUnitCore junitCore = new JUnitCore();
-    return junitCore.run(Request.aClass(test).getRunner());
-  }
-}