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/04/27 01:17:19 UTC
[07/16] incubator-geode git commit: Updating and fixing tests
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/RegionOperationsEqualityShouldUseArrayEqualsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/RegionOperationsEqualityShouldUseArrayEqualsIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/RegionOperationsEqualityShouldUseArrayEqualsIntegrationTest.java
new file mode 100644
index 0000000..aaa6a3c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/RegionOperationsEqualityShouldUseArrayEqualsIntegrationTest.java
@@ -0,0 +1,194 @@
+/*
+ * 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.internal;
+
+import static org.junit.Assert.fail;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * See bug 52093.
+ * Make sure that the contents of arrays are
+ * used to test equality on regions ops.
+ */
+@Category(IntegrationTest.class)
+public class RegionOperationsEqualityShouldUseArrayEqualsIntegrationTest {
+
+ private GemFireCacheImpl createCache() {
+ Properties props = new Properties();
+ props.setProperty("locators", "");
+ props.setProperty("mcast-port", "0");
+ GemFireCacheImpl result = (GemFireCacheImpl) new CacheFactory(props).create();
+ return result;
+ }
+
+ private void closeCache(GemFireCacheImpl gfc) {
+ gfc.close();
+ }
+
+ private void doOps(Region r) {
+ {
+ byte[] bytesValue = new byte[]{1,2,3,4};
+ r.put("bytesValue", bytesValue.clone());
+ if (r.replace("bytesValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("bytesValue", bytesValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("bytesValue", bytesValue.clone());
+ if (r.remove("bytesValue", "")) fail("expected remove to fail");
+ if (!r.remove("bytesValue", bytesValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ boolean[] booleanValue = new boolean[]{true,false,true,false};
+ r.put("booleanValue", booleanValue.clone());
+ if (r.replace("booleanValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("booleanValue", booleanValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("booleanValue", booleanValue.clone());
+ if (r.remove("booleanValue", "")) fail("expected remove to fail");
+ if (!r.remove("booleanValue", booleanValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ short[] shortValue = new short[]{1,2,3,4};
+ r.put("shortValue", shortValue.clone());
+ if (r.replace("shortValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("shortValue", shortValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("shortValue", shortValue.clone());
+ if (r.remove("shortValue", "")) fail("expected remove to fail");
+ if (!r.remove("shortValue", shortValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ char[] charValue = new char[]{1,2,3,4};
+ r.put("charValue", charValue.clone());
+ if (r.replace("charValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("charValue", charValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("charValue", charValue.clone());
+ if (r.remove("charValue", "")) fail("expected remove to fail");
+ if (!r.remove("charValue", charValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ int[] intValue = new int[]{1,2,3,4};
+ r.put("intValue", intValue.clone());
+ if (r.replace("intValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("intValue", intValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("intValue", intValue.clone());
+ if (r.remove("intValue", "")) fail("expected remove to fail");
+ if (!r.remove("intValue", intValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ long[] longValue = new long[]{1,2,3,4};
+ r.put("longValue", longValue.clone());
+ if (r.replace("longValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("longValue", longValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("longValue", longValue.clone());
+ if (r.remove("longValue", "")) fail("expected remove to fail");
+ if (!r.remove("longValue", longValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ float[] floatValue = new float[]{1,2,3,4};
+ r.put("floatValue", floatValue.clone());
+ if (r.replace("floatValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("floatValue", floatValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("floatValue", floatValue.clone());
+ if (r.remove("floatValue", "")) fail("expected remove to fail");
+ if (!r.remove("floatValue", floatValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ double[] doubleValue = new double[]{1,2,3,4};
+ r.put("doubleValue", doubleValue.clone());
+ if (r.replace("doubleValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("doubleValue", doubleValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("doubleValue", doubleValue.clone());
+ if (r.remove("doubleValue", "")) fail("expected remove to fail");
+ if (!r.remove("doubleValue", doubleValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ {
+ Object[] oaValue = new Object[]{new byte[]{1,2,3,4},new short[]{1,2,3,4},new int[]{1,2,3,4}, "hello sweet world!"};
+ r.put("oaValue", oaValue);
+ Object[] deepCloneOaValue = new Object[]{new byte[]{1,2,3,4},new short[]{1,2,3,4},new int[]{1,2,3,4}, "hello sweet world!"};
+ if (r.replace("oaValue", "", "")) fail("expected replace to fail");
+ if (!r.replace("oaValue", deepCloneOaValue, "")) {
+ fail("expected replace to happen");
+ }
+ r.put("oaValue", oaValue);
+ if (r.remove("oaValue", "")) fail("expected remove to fail");
+ if (!r.remove("oaValue", deepCloneOaValue)) {
+ fail("expected remove to happen");
+ }
+ }
+ }
+
+ @Test
+ public void testPartition() {
+ GemFireCacheImpl gfc = createCache();
+ try {
+ Region r = gfc.createRegionFactory(RegionShortcut.PARTITION).create("ArrayEqualsJUnitTestPartitionRegion");
+ doOps(r);
+ } finally {
+ closeCache(gfc);
+ }
+ }
+ @Test
+ public void testLocal() {
+ GemFireCacheImpl gfc = createCache();
+ try {
+ Region r = gfc.createRegionFactory(RegionShortcut.LOCAL).create("ArrayEqualsJUnitTestLocalRegion");
+ doOps(r);
+ } finally {
+ closeCache(gfc);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
index 83f4a08..cc71738 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
@@ -16,15 +16,13 @@
*/
package com.gemstone.gemfire.internal;
+import static org.junit.Assert.*;
-import java.io.IOException;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.*;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -150,7 +148,7 @@ public class SocketCloserJUnitTest {
* closed socket is a noop.
*/
@Test
- public void testClosedSocket() throws IOException {
+ public void testClosedSocket() throws Exception {
final AtomicBoolean runnableCalled = new AtomicBoolean();
Runnable r = new Runnable() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
index 52a367d..0ba41ba 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
@@ -28,6 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
*/
@Category(UnitTest.class)
public class SocketCloserWithWaitJUnitTest extends SocketCloserJUnitTest {
+
@Override
protected SocketCloser createSocketCloser() {
return new SocketCloser(
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java
index b35c851..90bd869 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/StatSamplerJUnitTest.java
@@ -29,6 +29,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
@@ -39,21 +40,25 @@ import com.gemstone.gemfire.StatisticsType;
import com.gemstone.gemfire.internal.StatArchiveReader.StatValue;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.internal.util.StopWatch;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* @since 7.0
*/
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
public class StatSamplerJUnitTest {
+
private static final Logger logger = LogService.getLogger();
-
- @Rule
- public TestName testName = new TestName();
private Map<String,String> statisticTypes;
private Map<String,Map<String,Number>> allStatistics;
+ @Rule
+ public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
+ public TestName testName = new TestName();
+
@Before
public void setUp() {
this.statisticTypes = new HashMap<String,String>();
@@ -62,13 +67,6 @@ public class StatSamplerJUnitTest {
@After
public void tearDown() {
- System.clearProperty("stats.log-level");
- System.clearProperty("stats.disable");
- System.clearProperty("stats.name");
- System.clearProperty("stats.archive-file");
- System.clearProperty("stats.file-size-limit");
- System.clearProperty("stats.disk-space-limit");
- System.clearProperty("stats.sample-rate");
this.statisticTypes = null;
this.allStatistics = null;
StatisticsTypeFactoryImpl.clear();
@@ -114,18 +112,16 @@ public class StatSamplerJUnitTest {
final Statistics st1_1 = factory.createAtomicStatistics(ST1, "st1_1", 1);
boolean done = false;
- try {
- Statistics[] samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
- for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 4000; done = (samplerStatsInstances != null && samplerStatsInstances.length > 0)) {
- Thread.sleep(10);
- samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
+
+ Statistics[] samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
+ for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 4000; done = (samplerStatsInstances != null && samplerStatsInstances.length > 0)) {
+ Thread.sleep(10);
+ samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
}
+
assertTrue("Waiting for statSampler stats", done);
- Statistics[] samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
+ samplerStatsInstances = factory.findStatisticsByTextId("statSampler");
assertNotNull(samplerStatsInstances);
assertEquals(1, samplerStatsInstances.length);
final Statistics samplerStats = samplerStatsInstances[0];
@@ -265,10 +261,8 @@ public class StatSamplerJUnitTest {
final StatArchiveReader reader = new StatArchiveReader(
new File[]{archiveFile}, null, false);
- @SuppressWarnings("rawtypes")
List resources = reader.getResourceInstList();
- for (@SuppressWarnings("rawtypes")
- Iterator iter = resources.iterator(); iter.hasNext();) {
+ for (Iterator iter = resources.iterator(); iter.hasNext();) {
StatArchiveReader.ResourceInst ri = (StatArchiveReader.ResourceInst) iter.next();
String resourceName = ri.getName();
assertNotNull(resourceName);
@@ -303,15 +297,11 @@ public class StatSamplerJUnitTest {
}
}
- private void waitForStatSample(final Statistics samplerStats) {
+ private void waitForStatSample(final Statistics samplerStats) throws InterruptedException {
int startSampleCount = samplerStats.getInt("sampleCount");
boolean done = false;
- try {
- for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 3000; done = (samplerStats.getInt("sampleCount") > startSampleCount)) {
- Thread.sleep(10);
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
+ for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 3000; done = (samplerStats.getInt("sampleCount") > startSampleCount)) {
+ Thread.sleep(10);
}
assertTrue("Waiting for statSampler sampleCount to increment", done);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/UniqueIdGeneratorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/UniqueIdGeneratorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/UniqueIdGeneratorJUnitTest.java
index 16bf32c..222d46a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/UniqueIdGeneratorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/UniqueIdGeneratorJUnitTest.java
@@ -16,11 +16,11 @@
*/
package com.gemstone.gemfire.internal;
-import org.junit.experimental.categories.Category;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.internal.UniqueIdGenerator;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
@@ -28,17 +28,9 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
* @since 5.0.2 (cbb5x_PerfScale)
*/
@Category(UnitTest.class)
-public class UniqueIdGeneratorJUnitTest extends TestCase {
-
- public UniqueIdGeneratorJUnitTest() {
- }
-
- public void setup() {
- }
-
- public void tearDown() {
- }
+public class UniqueIdGeneratorJUnitTest {
+ @Test
public void testBasics() throws Exception {
UniqueIdGenerator uig = new UniqueIdGenerator(1);
assertEquals(0, uig.obtain());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractDistributedRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractDistributedRegionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractDistributedRegionJUnitTest.java
index 8eaeeb5..ac060eb 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractDistributedRegionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractDistributedRegionJUnitTest.java
@@ -16,10 +16,9 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.*;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
@@ -34,9 +33,8 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.test.fake.Fakes;
-import junit.framework.TestCase;
+public abstract class AbstractDistributedRegionJUnitTest {
-public abstract class AbstractDistributedRegionJUnitTest extends TestCase {
protected static final Logger logger = LogService.getLogger();
private RegionAttributes createRegionAttributes(
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionJUnitTest.java
index ca486cd..f17b6c5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionJUnitTest.java
@@ -54,7 +54,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Unit tests for {@link AbstractRegion}.
- *
*
* @since 8.1
*/
@@ -66,7 +65,6 @@ public class AbstractRegionJUnitTest {
*
* Assert that method returns a {@link SimpleExtensionPoint} instance and
* assume that {@link com.gemstone.gemfire.internal.cache.extension.SimpleExtensionPointJUnitTest} has covered the rest.
- *
*/
@Test
public void testGetExtensionPoint() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionMapTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionMapTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionMapTest.java
index b54bbe2..e8591e4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionMapTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/AbstractRegionMapTest.java
@@ -19,10 +19,6 @@ package com.gemstone.gemfire.internal.cache;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -34,22 +30,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class AbstractRegionMapTest {
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void invalidateOfNonExistentRegionThrowsEntryNotFound() {
TestableAbstractRegionMap arm = new TestableAbstractRegionMap();
@@ -172,7 +152,8 @@ public class AbstractRegionMapTest {
}
}
- public static class TestableAbstractRegionMap extends AbstractRegionMap {
+ private static class TestableAbstractRegionMap extends AbstractRegionMap {
+
public LocalRegion owner;
protected TestableAbstractRegionMap() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/BucketRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/BucketRegionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/BucketRegionJUnitTest.java
index a5a3cc0..bb14b22 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/BucketRegionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/BucketRegionJUnitTest.java
@@ -16,26 +16,25 @@
*/
package com.gemstone.gemfire.internal.cache;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
+import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-/**
- *
- */
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
@Category(UnitTest.class)
public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
+ @Override
protected void setInternalRegionArguments(InternalRegionArguments ira) {
// PR specific
PartitionedRegion pr = mock(PartitionedRegion.class);
@@ -49,13 +48,14 @@ public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
.setPartitionedRegionBucketRedundancy(1)
.setBucketAdvisor(ba);
}
-
+
+ @Override
protected DistributedRegion createAndDefineRegion(boolean isConcurrencyChecksEnabled,
RegionAttributes ra, InternalRegionArguments ira, GemFireCacheImpl cache) {
BucketRegion br = new BucketRegion("testRegion", ra, null, cache, ira);
// since br is a real bucket region object, we need to tell mockito to monitor it
- br = Mockito.spy(br);
+ br = spy(br);
// doNothing().when(dm).addMembershipListener(any());
doNothing().when(br).distributeUpdateOperation(any(), anyLong());
@@ -69,6 +69,7 @@ public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
return br;
}
+ @Override
protected void verifyDistributeUpdate(DistributedRegion region, EntryEventImpl event, int cnt) {
assertTrue(region instanceof BucketRegion);
BucketRegion br = (BucketRegion)region;
@@ -80,7 +81,8 @@ public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
verify(br, never()).distributeUpdateOperation(eq(event), eq(12345L));
}
}
-
+
+ @Override
protected void verifyDistributeDestroy(DistributedRegion region, EntryEventImpl event, int cnt) {
assertTrue(region instanceof BucketRegion);
BucketRegion br = (BucketRegion)region;
@@ -92,7 +94,8 @@ public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
verify(br, never()).distributeDestroyOperation(eq(event));
}
}
-
+
+ @Override
protected void verifyDistributeInvalidate(DistributedRegion region, EntryEventImpl event, int cnt) {
assertTrue(region instanceof BucketRegion);
BucketRegion br = (BucketRegion)region;
@@ -104,7 +107,8 @@ public class BucketRegionJUnitTest extends DistributedRegionJUnitTest {
verify(br, never()).distributeInvalidateOperation(eq(event));
}
}
-
+
+ @Override
protected void verifyDistributeUpdateEntryVersion(DistributedRegion region, EntryEventImpl event, int cnt) {
assertTrue(region instanceof BucketRegion);
BucketRegion br = (BucketRegion)region;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaFaultInDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaFaultInDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaFaultInDUnitTest.java
index a1fca4c..78855fd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaFaultInDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaFaultInDUnitTest.java
@@ -119,7 +119,7 @@ public class DeltaFaultInDUnitTest extends CacheTestCase {
long entriesEvicted = ((AbstractLRURegionMap)((PartitionedRegion)region).entries)._getLruList().stats()
.getEvictions();
-// assertEquals(1, entriesEvicted);
+// assertIndexDetailsEquals(1, entriesEvicted);
TestDelta result = region.get(new Integer(0));
assertEquals("initial_plus_some_more_data", result.info);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java
index 94aeccd..7d53098 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DeltaSizingDUnitTest.java
@@ -155,7 +155,7 @@ public class DeltaSizingDUnitTest extends CacheTestCase {
// throws CacheWriterException {
// assertTrue(event.getOldValue() instanceof MyClass);
// assertTrue(event.getNewValue() instanceof MyClass);
-// assertEquals(event.getOldValue(), event.getNewValue());
+// assertIndexDetailsEquals(event.getOldValue(), event.getNewValue());
// }
//
// });
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskIdJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskIdJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskIdJUnitTest.java
index 14c25ef..4a11280 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskIdJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskIdJUnitTest.java
@@ -16,29 +16,24 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
/**
- *
- * Test verifies the setting and getting of disk id values are correctly
- *
- *
+ * Test verifies the setting and getting of disk id values are correctly
*/
@Category(UnitTest.class)
-public class DiskIdJUnitTest extends TestCase
-{
+public class DiskIdJUnitTest {
/**
* Test the getOplogId returns what has been set
- *
- * @throws Exception
*/
- public void testGetSetOplogId() throws Exception
- {
+ @Test
+ public void testGetSetOplogId() throws Exception {
DiskId did = getDiskId();
did.setOplogId(-1);
assertEquals(-1, did.getOplogId());
@@ -52,12 +47,9 @@ public class DiskIdJUnitTest extends TestCase
/**
* Test the getUserbits returns what has been set
- *
- * @throws Exception
*/
-
- public void testGetSetUserBits() throws Exception
- {
+ @Test
+ public void testGetSetUserBits() throws Exception {
DiskId did = getDiskId();
byte userBits = 0;
userBits = EntryBits.setSerialized(userBits, true);
@@ -119,9 +111,8 @@ public class DiskIdJUnitTest extends TestCase
/**
* Test the whether setting of one set of values does not affect another set of values
*/
-
- public void testAllOperationsValidatingResult1()
- {
+ @Test
+ public void testAllOperationsValidatingResult1() {
DiskId did = getDiskId();
for (int i = -16777215; i < 16777215; i++) {
boolean boolValuePerIteration = false;
@@ -168,15 +159,14 @@ public class DiskIdJUnitTest extends TestCase
break;
}
}
-
}
/**
* Tests that an instance of 'PersistenceIntOplogOffsetDiskId' is created when
* max-oplog-size (in bytes) passed is smaller than Integer.MAX_VALUE
*/
- public void testPersistIntDiskIdInstance()
- {
+ @Test
+ public void testPersistIntDiskIdInstance() {
int maxOplogSizeinMB = 2;
DiskId diskId = DiskId.createDiskId(maxOplogSizeinMB, true /*is persistence type*/, true);
@@ -189,8 +179,8 @@ public class DiskIdJUnitTest extends TestCase
* Tests that an instance of 'LongOplogOffsetDiskId' is created when
* max-oplog-size (in bytes) passed is greater than Integer.MAX_VALUE
*/
- public void testPersistLongDiskIdInstance()
- {
+ @Test
+ public void testPersistLongDiskIdInstance() {
long maxOplogSizeInBytes = (long)Integer.MAX_VALUE + 1;
int maxOplogSizeinMB = (int)(maxOplogSizeInBytes / (1024 * 1024));
@@ -204,8 +194,8 @@ public class DiskIdJUnitTest extends TestCase
* Tests that an instance of 'PersistenceIntOplogOffsetDiskId' is created when
* max-oplog-size (in bytes) passed is smaller than Integer.MAX_VALUE
*/
- public void testOverflowIntDiskIdInstance()
- {
+ @Test
+ public void testOverflowIntDiskIdInstance() {
int maxOplogSizeinMB = 2;
DiskId diskId = DiskId.createDiskId(maxOplogSizeinMB, false /*is overflow type*/, true);
@@ -218,8 +208,8 @@ public class DiskIdJUnitTest extends TestCase
* Tests that an instance of 'LongOplogOffsetDiskId' is created when
* max-oplog-size (in bytes) passed is greater than Integer.MAX_VALUE
*/
- public void testOverflowLongDiskIdInstance()
- {
+ @Test
+ public void testOverflowLongDiskIdInstance() {
long maxOplogSizeInBytes = (long)Integer.MAX_VALUE + 1;
int maxOplogSizeinMB = (int)(maxOplogSizeInBytes / (1024 * 1024));
@@ -229,8 +219,7 @@ public class DiskIdJUnitTest extends TestCase
DiskId.isInstanceofOverflowOnlyWithLongOffset(diskId));
}
- private DiskId getDiskId()
- {
+ private DiskId getDiskId() {
return DiskId.createDiskId(1024, true /* is persistence type*/, true);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskInitFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskInitFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskInitFileJUnitTest.java
index c9f3961..5a4e622 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskInitFileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskInitFileJUnitTest.java
@@ -16,43 +16,44 @@
*/
package com.gemstone.gemfire.internal.cache;
-import java.io.File;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
+import java.io.File;
+import java.util.Collections;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-
-import java.util.Collections;
+import org.junit.rules.TemporaryFolder;
import com.gemstone.gemfire.StatisticsFactory;
-import com.gemstone.gemfire.internal.FileUtil;
import com.gemstone.gemfire.internal.cache.persistence.DiskRegionView;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-@Category(UnitTest.class)
-public class DiskInitFileJUnitTest extends TestCase {
+@Category(IntegrationTest.class)
+public class DiskInitFileJUnitTest {
private File testDirectory;
private Mockery context = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
-
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Before
public void setUp() throws Exception {
- testDirectory = new File("_DiskInitFileJUnitTest");
- FileUtil.delete(testDirectory);
- FileUtil.mkdirs(testDirectory);
- }
-
- public void tearDown() throws Exception {
- FileUtil.delete(testDirectory);
+ testDirectory = temporaryFolder.newFolder("_" + getClass().getSimpleName());
}
-
+
/**
* Test the behavior of canonical ids in the init file.
*/
+ @Test
public void testCanonicalIds() {
//create a mock statistics factory for creating directory holders
final StatisticsFactory sf = context.mock(StatisticsFactory.class);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskWriteAttributesJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskWriteAttributesJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskWriteAttributesJUnitTest.java
index d7d07f9..4c6710c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskWriteAttributesJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DiskWriteAttributesJUnitTest.java
@@ -16,136 +16,117 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.DiskWriteAttributes;
import com.gemstone.gemfire.cache.DiskWriteAttributesFactory;
-import com.gemstone.gemfire.internal.Assert;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
/**
* Tests if DiskWriteAttributeFactory returns the correct DWA object with the
* desired values
- *
- *
*/
@Category(UnitTest.class)
-public class DiskWriteAttributesJUnitTest extends TestCase
-{
+public class DiskWriteAttributesJUnitTest {
- public DiskWriteAttributesJUnitTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultInstance()'
*/
- public void testGetDefaultInstance()
- {
+ @Test
+ public void testGetDefaultInstance() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(!dwa.isSynchronous());
- Assert.assertTrue(dwa.isRollOplogs());
+ assertTrue(!dwa.isSynchronous());
+ assertTrue(dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultSync()'
*/
- public void testGetDefaultSync()
- {
+ @Test
+ public void testGetDefaultSync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setSynchronous(true);
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(dwa.isSynchronous());
- Assert.assertTrue(dwa.isRollOplogs());
+ assertTrue(dwa.isSynchronous());
+ assertTrue(dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultAsync()'
*/
- public void testGetDefaultAsync()
- {
+ @Test
+ public void testGetDefaultAsync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(!dwa.isSynchronous());
- Assert.assertTrue(dwa.isRollOplogs());
+ assertTrue(!dwa.isSynchronous());
+ assertTrue(dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultRollingSync()'
*/
- public void testGetDefaultRollingSync()
- {
+ @Test
+ public void testGetDefaultRollingSync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setSynchronous(true);
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(dwa.isSynchronous());
- Assert.assertTrue(dwa.isRollOplogs());
+ assertTrue(dwa.isSynchronous());
+ assertTrue(dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultRollingAsync()'
*/
- public void testGetDefaultRollingAsync()
- {
+ @Test
+ public void testGetDefaultRollingAsync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(!dwa.isSynchronous());
- Assert.assertTrue(dwa.isRollOplogs());
-
+ assertTrue(!dwa.isSynchronous());
+ assertTrue(dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultNonRollingSync()'
*/
- public void testGetDefaultNonRollingSync()
- {
-
+ @Test
+ public void testGetDefaultNonRollingSync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setRollOplogs(false);
dwaf.setSynchronous(true);
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(dwa.isSynchronous());
- Assert.assertTrue(!dwa.isRollOplogs());
-
+ assertTrue(dwa.isSynchronous());
+ assertTrue(!dwa.isRollOplogs());
}
- /*
+ /**
* Test method for
* 'com.gemstone.gemfire.cache.DiskWriteAttributes.getDefaultNonRollingAsync()'
*/
- public void testGetDefaultNonRollingAsync()
- {
+ @Test
+ public void testGetDefaultNonRollingAsync() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setRollOplogs(false);
DiskWriteAttributes dwa = dwaf.create();
- Assert.assertTrue(!dwa.isSynchronous());
- Assert.assertTrue(!dwa.isRollOplogs());
+ assertTrue(!dwa.isSynchronous());
+ assertTrue(!dwa.isRollOplogs());
}
/**
* Tests the behaviour of DiskWriteAttributesFactory & DiskWritesAttrbutes with
* various combinations of time interval & buffer size.
*/
+ @Test
public void testDiskWriteAttributesCreation() {
DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
dwaf.setSynchronous(true);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedRegionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedRegionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedRegionJUnitTest.java
index cf2525a..d5e1b9a 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedRegionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/DistributedRegionJUnitTest.java
@@ -16,28 +16,25 @@
*/
package com.gemstone.gemfire.internal.cache;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import junit.framework.TestCase;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.*;
-/**
- *
- */
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
@Category(UnitTest.class)
public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTest {
+ @Override
protected void setInternalRegionArguments(InternalRegionArguments ira) {
}
-
+
+ @Override
protected DistributedRegion createAndDefineRegion(boolean isConcurrencyChecksEnabled,
RegionAttributes ra, InternalRegionArguments ira, GemFireCacheImpl cache) {
DistributedRegion region = new DistributedRegion("testRegion", ra, null, cache, ira);
@@ -46,7 +43,7 @@ public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTe
}
// since it is a real region object, we need to tell mockito to monitor it
- region = Mockito.spy(region);
+ region = spy(region);
doNothing().when(region).distributeUpdate(any(), anyLong(), anyBoolean(), anyBoolean(), any(), anyBoolean());
doNothing().when(region).distributeDestroy(any(), any());
@@ -55,7 +52,8 @@ public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTe
return region;
}
-
+
+ @Override
protected void verifyDistributeUpdate(DistributedRegion region, EntryEventImpl event, int cnt) {
region.virtualPut(event, false, false, null, false, 12345L, false);
// verify the result
@@ -66,6 +64,7 @@ public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTe
}
}
+ @Override
protected void verifyDistributeDestroy(DistributedRegion region, EntryEventImpl event, int cnt) {
region.basicDestroy(event, false, null);
// verify the result
@@ -76,6 +75,7 @@ public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTe
}
}
+ @Override
protected void verifyDistributeInvalidate(DistributedRegion region, EntryEventImpl event, int cnt) {
region.basicInvalidate(event);
// verify the result
@@ -86,6 +86,7 @@ public class DistributedRegionJUnitTest extends AbstractDistributedRegionJUnitTe
}
}
+ @Override
protected void verifyDistributeUpdateEntryVersion(DistributedRegion region, EntryEventImpl event, int cnt) {
region.basicUpdateEntryVersion(event);
// verify the result
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
index c3e057c..800527f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EntryEventImplTest.java
@@ -17,23 +17,30 @@
package com.gemstone.gemfire.internal.cache;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
import com.gemstone.gemfire.cache.Operation;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import static org.mockito.Mockito.*;
-
@Category(UnitTest.class)
public class EntryEventImplTest {
- String expectedRegionName = "ExpectedFullRegionPathName";
- String key = "key1";
- String value = "value1";
- KeyInfo keyInfo = new KeyInfo(key, value, null);
+ private String expectedRegionName;
+ private String key;
+ private String value;
+ private KeyInfo keyInfo;
+
+ @Before
+ public void setUp() throws Exception {
+ expectedRegionName = "ExpectedFullRegionPathName";
+ key = "key1";
+ value = "value1";
+ keyInfo = new KeyInfo(key, value, null);
+ }
@Test
public void verifyToStringOutputHasRegionName() {
@@ -50,7 +57,7 @@ public class EntryEventImplTest {
assertTrue("String " + expectedRegionName + " was not in toString text: " + toStringValue, toStringValue.indexOf(expectedRegionName) > 0);
// verify that toString called getFullPath method of region object
- verify(region, Mockito.times(1)).getFullPath();
+ verify(region, times(1)).getFullPath();
}
private EntryEventImpl createEntryEvent(LocalRegion l) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EnumListenerEventJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EnumListenerEventJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EnumListenerEventJUnitTest.java
index 1687db7..9a58987 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EnumListenerEventJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/EnumListenerEventJUnitTest.java
@@ -16,26 +16,22 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- *
- */
@Category(UnitTest.class)
-public class EnumListenerEventJUnitTest extends TestCase
-{
+public class EnumListenerEventJUnitTest {
+
/**
* tests whether EnumListenerEvent.getEnumListenerEvent(int cCode) returns the
* right result
- *
*/
- public void testGetEnumListEvent()
- {
+ @Test
+ public void testGetEnumListEvent() {
checkAndAssert(0, null);
checkAndAssert(1, EnumListenerEvent.AFTER_CREATE);
checkAndAssert(2, EnumListenerEvent.AFTER_UPDATE);
@@ -63,9 +59,9 @@ public class EnumListenerEventJUnitTest extends TestCase
// check that the code and object both match
private void checkAndAssert(int code, EnumListenerEvent event) {
EnumListenerEvent localEvent = EnumListenerEvent.getEnumListenerEvent(code);
- Assert.assertTrue( localEvent == event);
+ assertTrue( localEvent == event);
if (localEvent != null) {
- Assert.assertTrue( localEvent.getEventCode() == code);
+ assertTrue( localEvent.getEventCode() == code);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
index 550d133..362962d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OffHeapValueWrapperJUnitTest.java
@@ -16,8 +16,7 @@
*/
package com.gemstone.gemfire.internal.cache;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -27,11 +26,11 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.OffHeapValueWrapper;
import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.Flushable;
+import com.gemstone.gemfire.internal.cache.DiskEntry.Helper.OffHeapValueWrapper;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
import com.gemstone.gemfire.internal.offheap.SlabImpl;
import com.gemstone.gemfire.internal.offheap.StoredObject;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -39,7 +38,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class OffHeapValueWrapperJUnitTest {
- private static OffHeapValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized) {
+ private OffHeapValueWrapper createChunkValueWrapper(byte[] bytes, boolean isSerialized) {
StoredObject c = MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, isSerialized, false);
return new OffHeapValueWrapper(c);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldVLJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldVLJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldVLJUnitTest.java
index 9841ec5..3f919ed 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldVLJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldVLJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
@@ -24,15 +26,15 @@ import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import junit.framework.TestCase;
-
import com.gemstone.gemfire.internal.InternalDataSerializer;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
-public class OldVLJUnitTest extends TestCase {
+public class OldVLJUnitTest {
+
private ByteArrayOutputStream baos;
private DataOutputStream dos;
@@ -44,46 +46,53 @@ public class OldVLJUnitTest extends TestCase {
private DataInput createDIS() throws IOException {
this.dos.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(this.baos
- .toByteArray());
+ ByteArrayInputStream bais = new ByteArrayInputStream(this.baos.toByteArray());
return new DataInputStream(bais);
}
+ @Test
public void testMinByte() throws IOException {
InternalDataSerializer.writeVLOld(1, createDOS());
assertEquals(1, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMaxByte() throws IOException {
InternalDataSerializer.writeVLOld(125, createDOS());
assertEquals(125, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMinShort() throws IOException {
InternalDataSerializer.writeVLOld(126, createDOS());
assertEquals(126, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMaxShort() throws IOException {
InternalDataSerializer.writeVLOld(0x7fff, createDOS());
assertEquals(0x7fff, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMinInt() throws IOException {
InternalDataSerializer.writeVLOld(0x7fff + 1, createDOS());
assertEquals(0x7fff + 1, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMaxInt() throws IOException {
InternalDataSerializer.writeVLOld(0x7fffffff, createDOS());
assertEquals(0x7fffffff, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMinLong() throws IOException {
InternalDataSerializer.writeVLOld(0x7fffffffL + 1, createDOS());
assertEquals(0x7fffffffL + 1, InternalDataSerializer.readVLOld(createDIS()));
}
+ @Test
public void testMaxLong() throws IOException {
InternalDataSerializer.writeVLOld(Long.MAX_VALUE, createDOS());
assertEquals(Long.MAX_VALUE, InternalDataSerializer.readVLOld(createDIS()));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
index 6dbe100..7c8beec 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OldValueImporterTestBase.java
@@ -20,36 +20,27 @@ import static org.junit.Assert.*;
import java.io.IOException;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import com.gemstone.gemfire.internal.HeapDataOutputStream;
import com.gemstone.gemfire.internal.cache.EntryEventImpl.OldValueImporter;
-import com.gemstone.gemfire.internal.offheap.OffHeapStoredObject;
-import com.gemstone.gemfire.internal.offheap.TinyStoredObject;
+import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
import com.gemstone.gemfire.internal.offheap.NullOffHeapMemoryStats;
import com.gemstone.gemfire.internal.offheap.NullOutOfOffHeapMemoryListener;
-import com.gemstone.gemfire.internal.offheap.MemoryAllocatorImpl;
+import com.gemstone.gemfire.internal.offheap.OffHeapStoredObject;
import com.gemstone.gemfire.internal.offheap.SlabImpl;
+import com.gemstone.gemfire.internal.offheap.TinyStoredObject;
import com.gemstone.gemfire.internal.util.BlobHelper;
public abstract class OldValueImporterTestBase {
- @Before
- public void setUp() throws Exception {
- }
- @After
- public void tearDown() throws Exception {
- }
-
protected abstract OldValueImporter createImporter();
protected abstract Object getOldValueFromImporter(OldValueImporter ovi);
protected abstract void toData(OldValueImporter ovi, HeapDataOutputStream hdos) throws IOException;
protected abstract void fromData(OldValueImporter ovi, byte[] bytes) throws IOException, ClassNotFoundException;
@Test
- public void testValueSerialization() throws IOException, ClassNotFoundException {
+ public void testValueSerialization() throws Exception {
byte[] bytes = new byte[1024];
HeapDataOutputStream hdos = new HeapDataOutputStream(bytes);
OldValueImporter imsg = createImporter();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java
index 9cd0cf7..9e76edf 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdMapJUnitTest.java
@@ -16,8 +16,9 @@
*/
package com.gemstone.gemfire.internal.cache;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.cache.Oplog.OplogEntryIdMap;
@@ -25,16 +26,11 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests DiskStoreImpl.OplogEntryIdMap
- *
- *
*/
@Category(UnitTest.class)
-public class OplogEntryIdMapJUnitTest extends TestCase
-{
- public OplogEntryIdMapJUnitTest(String arg0) {
- super(arg0);
- }
+public class OplogEntryIdMapJUnitTest {
+ @Test
public void testBasics() {
OplogEntryIdMap m = new OplogEntryIdMap();
for (long i=1; i <= 777777; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdSetJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdSetJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdSetJUnitTest.java
index 9413c3b..12e5a3d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdSetJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogEntryIdSetJUnitTest.java
@@ -16,8 +16,9 @@
*/
package com.gemstone.gemfire.internal.cache;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.cache.DiskStoreImpl.OplogEntryIdSet;
@@ -25,16 +26,11 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests DiskStoreImpl.OplogEntryIdSet
- *
- *
*/
@Category(UnitTest.class)
-public class OplogEntryIdSetJUnitTest extends TestCase
-{
- public OplogEntryIdSetJUnitTest(String arg0) {
- super(arg0);
- }
+public class OplogEntryIdSetJUnitTest {
+ @Test
public void testBasics() {
OplogEntryIdSet s = new OplogEntryIdSet();
for (long i=1; i < 777777; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
index f4f652e..d1be04d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogJUnitTest.java
@@ -609,8 +609,8 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// region.remove(new Integer(2));
// assertNull(writer
// .getAsynchOpForEntryFromPendingFlushMap(entry2.getDiskId()));
-// assertEquals(opSizeBeforeCreateRemove, dr.getChild().getOplogSize());
-// assertEquals(pendingFlushSize, dr.getChild().getAsynchWriter()
+// assertIndexDetailsEquals(opSizeBeforeCreateRemove, dr.getChild().getOplogSize());
+// assertIndexDetailsEquals(pendingFlushSize, dr.getChild().getAsynchWriter()
// .getCurrentBufferedBytesSize());
// closeDown();
@@ -1111,7 +1111,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// fail("exception not expected" + e);
// fail("The test failed as the oplog could not eb synched to disk");
// }
-// assertEquals((this.numCreate + this.numDel + this.numModify),
+// assertIndexDetailsEquals((this.numCreate + this.numDel + this.numModify),
// this.totalSuccessfulOperations);
// assertTrue(" The expected oplog size =" + inMemOplogSize
// + " Actual Oplog file size =" + actFileSize,
@@ -1296,7 +1296,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// // if (j < currentOplogID) {
// // // oplogs are now closed to save memory and file descriptors
// // // once they are no longer needed
-// // assertEquals(null, oplog);
+// // assertIndexDetailsEquals(null, oplog);
// // } else {
// inMemOplogSize += oplog.getOplogSize();
// logWriter.info(" Oplog size="+ oplog.getOplogSize() + " Max Oplog size acceptable="+MAX_OPLOG_SIZE );
@@ -1319,7 +1319,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// assertTrue(
// " The max Oplog Size limit is violated when taken the actual file size",
// oplog.getActualFileLength() <= MAX_OPLOG_SIZE);
-// assertEquals(oplog.getOplogSize(), oplog.getActualFileLength());
+// assertIndexDetailsEquals(oplog.getOplogSize(), oplog.getActualFileLength());
// // }
// }
@@ -1329,7 +1329,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// + this.expectedOplogSize + " Actual sizes of all oplogs ="
// + inMemOplogSize, this.expectedOplogSize == inMemOplogSize);
-// assertEquals((this.numCreate + this.numDel + this.numModify),
+// assertIndexDetailsEquals((this.numCreate + this.numDel + this.numModify),
// this.totalSuccessfulOperations);
// closeDown();
@@ -1412,7 +1412,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// // if (j < currentOplogID) {
// // // oplogs are now closed to save memory and file descriptors
// // // once they are no longer needed
-// // assertEquals(null, oplog);
+// // assertIndexDetailsEquals(null, oplog);
// // } else {
// inMemOplogSize += oplog.getOplogSize();
// //oplog.forceFlush();
@@ -1433,7 +1433,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// assertTrue(
// " The max Oplog Size limit is violated when taken the actual file size",
// oplog.getActualFileLength() <= MAX_OPLOG_SIZE);
-// assertEquals(oplog.getOplogSize(), oplog.getActualFileLength());
+// assertIndexDetailsEquals(oplog.getOplogSize(), oplog.getActualFileLength());
// // }
// }
@@ -1442,7 +1442,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// assertTrue(" The sum of all oplogs size as expected ="
// + this.expectedOplogSize + " Actual sizes of all oplogs ="
// + inMemOplogSize, this.expectedOplogSize == inMemOplogSize);
-// assertEquals((this.numCreate + this.numDel + this.numModify),
+// assertIndexDetailsEquals((this.numCreate + this.numDel + this.numModify),
// this.totalSuccessfulOperations);
// assertFalse(failureCause, testFailed);
// closeDown();
@@ -1575,7 +1575,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// long currentOplogID = currOplog.getOplogId();
// long expectedSize = currOplog.getOplogSize();
// // Ensure that now switching has happned during the operations
-// assertEquals(1, currentOplogID);
+// assertIndexDetailsEquals(1, currentOplogID);
// assertTrue(
// "The number of operations did not cause asynch writer to run atleast once , the expected file size = "
// + expectedSize, expectedSize > 1000);
@@ -2174,11 +2174,11 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// Oplog.ByteBufferPool pool = (Oplog.ByteBufferPool)bbPools.get(1);
// ByteBuffer bb1 = pool.getBufferFromPool();
// ByteBuffer bb2 = pool.getBufferFromPool();
-// assertEquals(2, pool.getTotalBuffers());
-// assertEquals(2, pool.getBuffersInUse());
+// assertIndexDetailsEquals(2, pool.getTotalBuffers());
+// assertIndexDetailsEquals(2, pool.getBuffersInUse());
// ((LocalRegion)region).getDiskRegion().getChild().releaseBuffer(bb1);
// ((LocalRegion)region).getDiskRegion().getChild().releaseBuffer(bb2);
-// assertEquals(0, pool.getBuffersInUse());
+// assertIndexDetailsEquals(0, pool.getBuffersInUse());
// region.close();
// System.setProperty("/testRegion_MAX_POOL_SIZE", "1");
@@ -2191,11 +2191,11 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// pool = (Oplog.ByteBufferPool)bbPools.get(1);
// bb1 = pool.getBufferFromPool();
// bb2 = pool.getBufferFromPool();
-// assertEquals(1, pool.getTotalBuffers());
-// assertEquals(1, pool.getBuffersInUse());
+// assertIndexDetailsEquals(1, pool.getTotalBuffers());
+// assertIndexDetailsEquals(1, pool.getBuffersInUse());
// ((LocalRegion)region).getDiskRegion().getChild().releaseBuffer(bb1);
// ((LocalRegion)region).getDiskRegion().getChild().releaseBuffer(bb2);
-// assertEquals(0, pool.getBuffersInUse());
+// assertIndexDetailsEquals(0, pool.getBuffersInUse());
// closeDown();
// }
@@ -2553,7 +2553,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
//((LocalRegion)region).getDiskRegion().getChild().forceFlush();
// int x = ((LocalRegion)region).getDiskRegion().getChild().getAsynchWriter()
// .getApproxFreeBuffers();
-// assertEquals(10, x);
+// assertIndexDetailsEquals(10, x);
}
// we no longer have a pendingFlushMap
@@ -2621,7 +2621,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// if (!proceedForValidation) {
// try {
// OplogJUnitTest.class.wait(9000);
-// assertEquals(true, proceedForValidation);
+// assertIndexDetailsEquals(true, proceedForValidation);
// }
// catch (InterruptedException e) {
// fail("interrupted");
@@ -2631,7 +2631,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// }
// cache.getLogger().info("valueRead : " + valueRead);
-// assertEquals("valueRead is stale, doesnt match with latest PUT", NEW_VALUE,
+// assertIndexDetailsEquals("valueRead is stale, doesnt match with latest PUT", NEW_VALUE,
// valueRead);
// LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
// CacheObserverHolder.setInstance(old);
@@ -3631,7 +3631,7 @@ public class OplogJUnitTest extends DiskRegionTestingBase {
// size2 += dh.getDirStatsDiskSpaceUsage();
// }
// System.out.println("Size after recreation= "+ size2);
-// assertEquals(size1, size2);
+// assertIndexDetailsEquals(size1, size2);
// region.close();
// }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogRVVJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogRVVJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogRVVJUnitTest.java
index b08efbf..404a1c9 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogRVVJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OplogRVVJUnitTest.java
@@ -23,12 +23,15 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
import com.gemstone.gemfire.StatisticsFactory;
import com.gemstone.gemfire.i18n.LogWriterI18n;
@@ -38,27 +41,31 @@ import com.gemstone.gemfire.internal.cache.DiskStoreImpl.OplogEntryIdSet;
import com.gemstone.gemfire.internal.cache.persistence.DiskRecoveryStore;
import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID;
import com.gemstone.gemfire.internal.cache.versions.DiskRegionVersionVector;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class OplogRVVJUnitTest {
-@Category(UnitTest.class)
-public class OplogRVVJUnitTest extends TestCase {
private File testDirectory;
private Mockery context = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
-
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Before
public void setUp() throws Exception {
- testDirectory = new File("_DiskStoreImplJUnitTest");
- FileUtil.delete(testDirectory);
- FileUtil.mkdirs(testDirectory);
+ testDirectory = temporaryFolder.newFolder("_" + getClass().getSimpleName());
DiskStoreImpl.SET_IGNORE_PREALLOCATE = true;
}
-
+
+ @After
public void tearDown() throws Exception {
- super.tearDown();
DiskStoreImpl.SET_IGNORE_PREALLOCATE = false;
}
-
+
+ @Test
public void testRecoverRVV() throws UnknownHostException {
final DiskInitFile df = context.mock(DiskInitFile.class);
final LogWriterI18n logger = context.mock(LogWriterI18n.class);
@@ -149,7 +156,6 @@ public class OplogRVVJUnitTest extends TestCase {
Oplog oplog = new Oplog(1, oplogSet, dirHolder);
oplog.close();
-
context.checking(new Expectations() {{
one(drs).recordRecoveredGCVersion(m1, 1);
one(drs).recordRecoveredGCVersion(m2, 0);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OrderedTombstoneMapJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OrderedTombstoneMapJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OrderedTombstoneMapJUnitTest.java
index bd50d05..29e26e1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OrderedTombstoneMapJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/OrderedTombstoneMapJUnitTest.java
@@ -16,17 +16,19 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.cache.persistence.DiskStoreID;
import com.gemstone.gemfire.internal.cache.versions.VersionTag;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
-public class OrderedTombstoneMapJUnitTest extends TestCase {
-
+public class OrderedTombstoneMapJUnitTest {
+
+ @Test
public void test() {
OrderedTombstoneMap<String> map = new OrderedTombstoneMap<String>();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionAttributesImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionAttributesImplJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionAttributesImplJUnitTest.java
index e75e17f..a8d8720 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionAttributesImplJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionAttributesImplJUnitTest.java
@@ -16,11 +16,7 @@
*/
package com.gemstone.gemfire.internal.cache;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.util.Properties;
@@ -38,7 +34,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Unit test suite for PartitionAttributesImpl.
- *
*/
@Category(UnitTest.class)
public class PartitionAttributesImplJUnitTest {
@@ -153,8 +148,8 @@ public class PartitionAttributesImplJUnitTest {
destination.merge(instance);
assertEquals(this.colocatedRegionFullPath, destination.getColocatedWith());
- //assertEquals(this.globalProps, destination.getGlobalProperties());
- //assertEquals(this.localProps, destination.getLocalProperties());
+ //assertIndexDetailsEquals(this.globalProps, destination.getGlobalProperties());
+ //assertIndexDetailsEquals(this.localProps, destination.getLocalProperties());
assertEquals(this.partitionResolver, destination.getPartitionResolver());
assertEquals(this.recoveryDelay, destination.getRecoveryDelay());
assertEquals(this.redundancy, destination.getRedundancy());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionCacheCloseDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionCacheCloseDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionCacheCloseDUnitTest.java
index 43252a2..17085c7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionCacheCloseDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionCacheCloseDUnitTest.java
@@ -237,7 +237,7 @@ public class PartitionedRegionCacheCloseDUnitTest extends
// VersionedArrayList nodeList = (VersionedArrayList)itr.next();
// logger.info("Size of nodeList for b2n entries for region = "
// + regionName + " = " + nodeList.size());
-// assertEquals("Node list: " + nodeList, 1, nodeList.size());
+// assertIndexDetailsEquals("Node list: " + nodeList, 1, nodeList.size());
// }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDUnitTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDUnitTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDUnitTestCase.java
index f401e0d..d964e5d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDUnitTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDUnitTestCase.java
@@ -235,7 +235,7 @@ public class PartitionedRegionDUnitTestCase extends CacheTestCase
rootRegion.size());
// Region allPR = rootRegion.getSubregion(PartitionedRegionHelper.PARTITIONED_REGION_CONFIG_NAME);
// assertNotNull(allPR);
-// assertEquals("allPR size is not correct", innerEndIndexForRegion,
+// assertIndexDetailsEquals("allPR size is not correct", innerEndIndexForRegion,
// allPR.size());
assertEquals("prIdToPR size is not correct", innerEndIndexForRegion,
PartitionedRegion.prIdToPR.size());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDestroyDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDestroyDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDestroyDUnitTest.java
index 498203d..abfb7d2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDestroyDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionDestroyDUnitTest.java
@@ -239,7 +239,7 @@ public class PartitionedRegionDestroyDUnitTest extends
while (itr.hasNext()) {
Region rg = (Region)itr.next();
LogWriterUtils.getLogWriter().info("Root Region SubRegionName = " + rg.getName());
-// assertEquals("REGION NAME FOUND:"+rg.getName(),-1, rg.getName().indexOf(
+// assertIndexDetailsEquals("REGION NAME FOUND:"+rg.getName(),-1, rg.getName().indexOf(
// PartitionedRegionHelper.BUCKET_2_NODE_TABLE_PREFIX));
assertEquals("regionFound that should be gone!:"+rg.getName(),-1, rg.getName().indexOf(
PartitionedRegionHelper.BUCKET_REGION_PREFIX));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionEvictionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionEvictionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionEvictionDUnitTest.java
index 0319171..ce10abb 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionEvictionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionEvictionDUnitTest.java
@@ -1109,7 +1109,7 @@ public class PartitionedRegionEvictionDUnitTest extends CacheTestCase {
// factory.setEvictionAttributes(okHeapLRUea);
// final Region pr = createRootRegion(name, factory.create());
// assertNotNull(pr);
-// assertEquals(okHeapLRUea, pr.getAttributes().getEvictionAttributes());
+// assertIndexDetailsEquals(okHeapLRUea, pr.getAttributes().getEvictionAttributes());
// pr.localDestroyRegion();
// }
@@ -1123,7 +1123,7 @@ public class PartitionedRegionEvictionDUnitTest extends CacheTestCase {
// factory.setEvictionAttributes(okHeapLRUea);
// final Region pr = createRootRegion(name, factory.create());
// assertNotNull(pr);
-// assertEquals(okHeapLRUea, pr.getAttributes().getEvictionAttributes());
+// assertIndexDetailsEquals(okHeapLRUea, pr.getAttributes().getEvictionAttributes());
// pr.localDestroyRegion();
// }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionHelperJUnitTest.java
index a904478..c1dbd78 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionHelperJUnitTest.java
@@ -16,18 +16,17 @@
*/
package com.gemstone.gemfire.internal.cache;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
-/**
- *
- */
@Category(UnitTest.class)
-public class PartitionedRegionHelperJUnitTest extends TestCase {
-
+public class PartitionedRegionHelperJUnitTest {
+
+ @Test
public void testEscapeUnescape() {
{
String bucketName = PartitionedRegionHelper.getBucketName("/root/region", 5);
@@ -41,7 +40,5 @@ public class PartitionedRegionHelperJUnitTest extends TestCase {
assertEquals("/root/region_one" , PartitionedRegionHelper.getPRPath(bucketName));
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionQueryEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionQueryEvaluatorTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionQueryEvaluatorTest.java
index fa4a26a..e3e8d4e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionQueryEvaluatorTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionQueryEvaluatorTest.java
@@ -16,12 +16,9 @@
*/
package com.gemstone.gemfire.internal.cache;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -54,19 +51,19 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class PartitionedRegionQueryEvaluatorTest {
- InternalDistributedMember localNode;
- InternalDistributedMember remoteNodeA;
- InternalDistributedMember remoteNodeB;
- GemFireCacheImpl cache;
- InternalDistributedSystem system;
- PartitionedRegion pr;
- DefaultQuery query;
+ private InternalDistributedMember localNode;
+ private InternalDistributedMember remoteNodeA;
+ private InternalDistributedMember remoteNodeB;
+ private GemFireCacheImpl cache;
+ private InternalDistributedSystem system;
+ private PartitionedRegion pr;
+ private DefaultQuery query;
//Needed to help mock out certain scenarios
- ExtendedPartitionedRegionDataStore dataStore;
+ private ExtendedPartitionedRegionDataStore dataStore;
//This is the set of nodes that remain after a failure
- ArrayList allNodes = new ArrayList();
+ private ArrayList allNodes = new ArrayList();
//convenience list for empty set
- Set<InternalDistributedMember> noFailingMembers = new HashSet<>();
+ private Set<InternalDistributedMember> noFailingMembers = new HashSet<>();
@Before
public void setup() throws Exception {
@@ -196,7 +193,7 @@ public class PartitionedRegionQueryEvaluatorTest {
}
- private Map<InternalDistributedMember, List<Integer>> createFakeBucketMap() {
+ private Map<InternalDistributedMember, List<Integer>> createFakeBucketMap() {
Map<InternalDistributedMember, List<Integer>> bucketToNodeMap = new HashMap<>();
bucketToNodeMap.put(localNode, createBucketList(1, 2, 3));
bucketToNodeMap.put(remoteNodeA, createBucketList(4, 5, 6));
@@ -205,7 +202,7 @@ public class PartitionedRegionQueryEvaluatorTest {
}
//fake bucket map to use after we fake a node failure
- private Map<InternalDistributedMember, List<Integer>> createFakeBucketMapFailedNodesToLocalMember() {
+ private Map<InternalDistributedMember, List<Integer>> createFakeBucketMapFailedNodesToLocalMember() {
Map<InternalDistributedMember, List<Integer>> bucketToNodeMap = new HashMap<>();
bucketToNodeMap.put(localNode, createBucketList(1, 2, 3, 7, 8, 9));
bucketToNodeMap.put(remoteNodeA, createBucketList(4, 5, 6));
@@ -227,8 +224,16 @@ public class PartitionedRegionQueryEvaluatorTest {
}
return results;
}
-
- class ExtendedPartitionedRegionDataStore extends PartitionedRegionDataStore {
+
+ private Queue<PartitionedQueryScenario> createScenariosQueue(PartitionedQueryScenario... scenarios) {
+ Queue<PartitionedQueryScenario> queue = new LinkedList<>();
+ for (PartitionedQueryScenario scenario: scenarios) {
+ queue.add(scenario);
+ }
+ return queue;
+ }
+
+ private static class ExtendedPartitionedRegionDataStore extends PartitionedRegionDataStore {
//Must be the same referenced queue as that used by the ExtendedPartitionedRegionQueryEvaluator
//That way they will be synched to the same scenario;
Queue<PartitionedQueryScenario> scenarios;
@@ -243,8 +248,10 @@ public class PartitionedRegionQueryEvaluatorTest {
}
}
- class ExtendedPartitionedRegionQueryEvaluator extends PartitionedRegionQueryEvaluator {
+ private static class ExtendedPartitionedRegionQueryEvaluator extends PartitionedRegionQueryEvaluator {
+
Queue<PartitionedQueryScenario> scenarios;
+
//pass through so we can fake out the executeQuery locally
PRQueryProcessor extendedPRQueryProcessor;
@@ -260,8 +267,8 @@ public class PartitionedRegionQueryEvaluatorTest {
}
// (package access for unit test purposes)
- Map<InternalDistributedMember, List<Integer>> buildNodeToBucketMap() throws QueryException
- {
+ @Override
+ Map<InternalDistributedMember, List<Integer>> buildNodeToBucketMap() throws QueryException {
return currentScenario().bucketMap;
}
@@ -291,8 +298,8 @@ public class PartitionedRegionQueryEvaluatorTest {
protected Set<InternalDistributedMember> getBucketOwners(Integer bid) {
return currentScenario().getBucketOwners(bid);
}
-
- class ExtendedPRQueryProcessor extends PRQueryProcessor {
+
+ private class ExtendedPRQueryProcessor extends PRQueryProcessor {
public ExtendedPRQueryProcessor(PartitionedRegion pr, DefaultQuery query, Object[] parameters, List buckets) {
super(pr, query, parameters, buckets);
@@ -309,7 +316,7 @@ public class PartitionedRegionQueryEvaluatorTest {
}
}
- class FakeNumFailStreamingQueryPartitionResponse extends StreamingQueryPartitionResponse {
+ private class FakeNumFailStreamingQueryPartitionResponse extends StreamingQueryPartitionResponse {
private PartitionedRegionQueryEvaluator processor;
Queue<PartitionedQueryScenario> scenarios;
@@ -336,13 +343,13 @@ public class PartitionedRegionQueryEvaluatorTest {
}
}
- interface ProcessDataFaker {
+ private interface ProcessDataFaker {
void processData(PartitionedRegionQueryEvaluator processor);
void executeQueryLocally(Collection resultsCollector);
}
//holds information on how the PRQE is to behave and what responses are "returned"
- private class PartitionedQueryScenario {
+ private static class PartitionedQueryScenario {
private InternalDistributedMember localNode;
private ArrayList allNodes;
private Set<InternalDistributedMember> failingNodes;
@@ -378,12 +385,4 @@ public class PartitionedRegionQueryEvaluatorTest {
}
}
- private Queue<PartitionedQueryScenario> createScenariosQueue(PartitionedQueryScenario... scenarios) {
- Queue<PartitionedQueryScenario> queue = new LinkedList<>();
- for (PartitionedQueryScenario scenario: scenarios) {
- queue.add(scenario);
- }
- return queue;
-
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionRedundancyZoneDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionRedundancyZoneDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionRedundancyZoneDUnitTest.java
index 027ae30..a2dafbf 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionRedundancyZoneDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionRedundancyZoneDUnitTest.java
@@ -85,9 +85,9 @@ public class PartitionedRegionRedundancyZoneDUnitTest extends CacheTestCase {
//member to bring it's primary count up to two.
assertTrue(counts, vm0Count >= 2 && vm1Count >=2);
-// assertEquals(counts, 3, vm0Count);
-// assertEquals(counts, 3, vm1Count);
-// assertEquals(counts, 6, vm2Count);
+// assertIndexDetailsEquals(counts, 3, vm0Count);
+// assertIndexDetailsEquals(counts, 3, vm1Count);
+// assertIndexDetailsEquals(counts, 6, vm2Count);
}
protected void checkBucketCount(VM vm0, final int numLocalBuckets) {