geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [3/4] incubator-geode git commit: Test cleanup
Date Tue, 26 Apr 2016 23:44:10 GMT
Test cleanup


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

Branch: refs/heads/feature/GEODE-1276
Commit: 4f6ca83b082d752b2b0734e5f159fb35585075d9
Parents: 555bc8b
Author: Kirk Lund <klund@apache.org>
Authored: Tue Apr 26 16:39:40 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Tue Apr 26 16:39:40 2016 -0700

----------------------------------------------------------------------
 .../versions/RegionVersionHolderJUnitTest.java  | 52 +++++++++++++-------
 .../RegionVersionHolderRandomJUnitTest.java     | 47 +++++-------------
 ...RegionVersionHolderSmallBitSetJUnitTest.java | 15 ++----
 3 files changed, 52 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6ca83b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderJUnitTest.java
index 731f466..b2a74f0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderJUnitTest.java
@@ -16,33 +16,47 @@
  */
 package com.gemstone.gemfire.internal.cache.versions;
 
-import java.io.FileReader;
-import java.io.Reader;
+import static org.junit.Assert.*;
+
 import java.net.InetAddress;
 import java.util.BitSet;
 
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import junit.framework.TestCase;
-
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.internal.Assert;
 import com.gemstone.gemfire.internal.cache.versions.RVVException.ReceivedVersionsIterator;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
-public class RegionVersionHolderJUnitTest extends TestCase {
-  
-  protected InternalDistributedMember member;
-  
-  int originalBitSetWidth = RegionVersionHolder.BIT_SET_WIDTH;
+public class RegionVersionHolderJUnitTest {
+
+  private int originalBitSetWidth;
+  private InternalDistributedMember member;
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public final void setUp() throws Exception {
+    originalBitSetWidth = RegionVersionHolder.BIT_SET_WIDTH;
     member = new InternalDistributedMember(InetAddress.getLocalHost(), 12345);
+    postSetUp();
   }
-  
+
+  protected void postSetUp() throws Exception {
+  }
+
+  @After
+  public final void tearDown() throws Exception {
+    RegionVersionHolder.BIT_SET_WIDTH = originalBitSetWidth;
+  }
+
+  protected final InternalDistributedMember member() {
+    return member;
+  }
+
+  @Test
   public void test48066_1() {
     RegionVersionHolder vh1 = new RegionVersionHolder(member);
     for (int i=1; i<=3; i++) {
@@ -74,7 +88,8 @@ public class RegionVersionHolderJUnitTest extends TestCase {
       assertEquals(7, vh3.getVersion());
     }
   }
-   
+
+  @Test
   public void test48066() {
     RegionVersionHolder vh = new RegionVersionHolder(member);
     BitSet bs = new BitSet();
@@ -1472,6 +1487,7 @@ public class RegionVersionHolderJUnitTest extends TestCase {
   /**
    * Test merging two version holders
    */
+  @Test
   public void testInitializeFrom() {
     testInitializeFrom(false);
     testInitializeFrom(true);
@@ -1587,6 +1603,7 @@ public class RegionVersionHolderJUnitTest extends TestCase {
    * Test a case in 46522 where the received exceptions end up 
    * not being in the RVV interval.
    */
+  @Test
   public void testConsumeReceivedRevisions() {
     testConsumeReceivedRevisions(false);
     testConsumeReceivedRevisions(true);
@@ -1630,7 +1647,8 @@ public class RegionVersionHolderJUnitTest extends TestCase {
       RVVException.UseTreeSetsForTesting = false;
     }
   }
-  
+
+  @Test
   public void testChangeSetForm() {
     try {
       RVVException.UseTreeSetsForTesting = true;
@@ -1667,12 +1685,12 @@ public class RegionVersionHolderJUnitTest extends TestCase {
    * 
    * See bug 47106
    */
+  @Test
   public void testDominates() {
     testDominates(false);
     testDominates(true);
   }
-  
-  
+
   private void testDominates(boolean useTreeSets) {
     try {
       RVVException.UseTreeSetsForTesting = useTreeSets;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6ca83b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderRandomJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderRandomJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderRandomJUnitTest.java
index d60a354..7821b6d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderRandomJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderRandomJUnitTest.java
@@ -16,18 +16,18 @@
  */
 package com.gemstone.gemfire.internal.cache.versions;
 
-import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import static org.junit.Assert.*;
 
-import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collections;
 import java.util.List;
 import java.util.Random;
 
+import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 /**
@@ -41,32 +41,16 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 public class RegionVersionHolderRandomJUnitTest extends RegionVersionHolderSmallBitSetJUnitTest
{
   
-  Random random = new Random();
-  
+  private Random random;
+
   @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  protected final void postSetUpRegionVersionHolderSmallBitSetJUnitTest() throws Exception
{
     long seed = System.nanoTime();
-//    seed = 1194319178069961L;
-    random.setSeed(seed);
+    random = new Random();
+    random.setSeed(seed); // 1194319178069961L;
     System.out.println("RegionVersionHolderJUnitTest using random seed " + seed);
   }
   
-  
-  int loopNum = 0;
-  /**
-   * Rerun all of the tests several times to see if anything fails.
-   * @throws InterruptedException
-   */
-//  public void testLoop() throws InterruptedException {
-//    for(int i =0; i < 50; i++) {
-//      loopNum=i;
-//      System.err.println("i=" + i);
-//      testInitializeFrom();
-//      testConsumeReceivedRevisions();
-//      testParallelThreads();
-//    }
-//  }
   /**
    * Record versions in random order, rather than in sequential order
    * This should generate and fill some exceptions.
@@ -92,17 +76,16 @@ public class RegionVersionHolderRandomJUnitTest extends RegionVersionHolderSmall
    * This tries to be a more "real life" test. A bunch of threads perform
    * updates, which should create exceptions. Verify that the final
    * exception list is correct.
-   * @throws InterruptedException
    */
+  @Test
   public void testParallelThreads() throws InterruptedException {
-    RegionVersionHolder vh1 = new RegionVersionHolder(member);
-    RegionVersionHolder vh2 = new RegionVersionHolder(member);
+    RegionVersionHolder vh1 = new RegionVersionHolder(member());
+    RegionVersionHolder vh2 = new RegionVersionHolder(member());
     
     int UPDATES = 50000;
     int NUM_UPDATERS=20;
     int NUM_EXCEPTIONS=500;
-//    int NUM_EXCEPTIONS=0;
-    
+
     Random random = new Random();
     IntOpenHashSet exceptions = new IntOpenHashSet();
     for(int i =0; i < NUM_EXCEPTIONS; i++) {
@@ -136,13 +119,9 @@ public class RegionVersionHolderRandomJUnitTest extends RegionVersionHolderSmall
     for(int i = 1; i < UPDATES; i++) {
       assertEquals("vector is incorrect on item "+  i,!exceptions.contains(i), vh2.contains(i));
     }
-    
   }
-  
-  
-  
+
   private static class HolderUpdater extends Thread {
-    
 
     private int updates;
     private int myNumber;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6ca83b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderSmallBitSetJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderSmallBitSetJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderSmallBitSetJUnitTest.java
index 3c9f09e..bd6199b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderSmallBitSetJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionHolderSmallBitSetJUnitTest.java
@@ -27,20 +27,13 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 public class RegionVersionHolderSmallBitSetJUnitTest extends RegionVersionHolderJUnitTest
{
   
-  
   @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-    originalBitSetWidth = RegionVersionHolder.BIT_SET_WIDTH;
+  protected final void postSetUp() throws Exception {
     RegionVersionHolder.BIT_SET_WIDTH = 4;
+    postSetUpRegionVersionHolderSmallBitSetJUnitTest();
   }
-  
-  protected void tearDown() throws Exception {
-    super.tearDown();
-    RegionVersionHolder.BIT_SET_WIDTH = originalBitSetWidth;
+
+  protected void postSetUpRegionVersionHolderSmallBitSetJUnitTest() throws Exception {
   }
-  
-  
-  
 
 }


Mime
View raw message