You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2016/06/14 19:10:30 UTC
[20/90] [abbrv] [partial] incubator-geode git commit: GEODE-837:
update tests from JUnit3 to JUnit4
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueJUnitTest.java
index 59bdcaa..1942c75 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HARegionQueueJUnitTest.java
@@ -17,10 +17,33 @@
package com.gemstone.gemfire.internal.cache.ha;
import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CyclicBarrier;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.SystemFailure;
-import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheListener;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.cache.Conflatable;
@@ -28,31 +51,13 @@ import com.gemstone.gemfire.internal.cache.EventID;
import com.gemstone.gemfire.internal.cache.RegionQueue;
import com.gemstone.gemfire.test.dunit.ThreadUtils;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CyclicBarrier;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
-import static org.junit.Assert.*;
/**
* This is a test for the APIs of a HARegionQueue and verifies that the head,
* tail and size counters are updated properly.
- *
- *
- *
*/
@Category(IntegrationTest.class)
-public class HARegionQueueJUnitTest
-{
+public class HARegionQueueJUnitTest {
/** The cache instance */
protected Cache cache = null;
@@ -72,71 +77,37 @@ public class HARegionQueueJUnitTest
boolean allowExpiryToProceed = false;
boolean complete = false;
- /**
- * Create the cache in setup
- *
- * @throws Exception -
- * thrown if any exception occurs in setUp
- */
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
cache = createCache();
logger = cache.getLogger();
encounteredException = false;
}
- /**
- * Close the cache in tear down *
- *
- * @throws Exception -
- * thrown if any exception occurs in tearDown
- */
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
cache.close();
}
/**
* Creates the cache instance for the test
- *
- * @return the cache instance
- * @throws CacheException -
- * thrown if any exception occurs in cache creation
*/
- private Cache createCache() throws CacheException
- {
+ private Cache createCache() throws CacheException {
return new CacheFactory().set(MCAST_PORT, "0").create();
}
/**
* Creates HA region-queue object
- *
- * @return HA region-queue object
- * @throws IOException
- * @throws ClassNotFoundException
- * @throws CacheException
- * @throws InterruptedException
*/
- protected HARegionQueue createHARegionQueue(String name) throws IOException, ClassNotFoundException, CacheException, InterruptedException
- {
+ private HARegionQueue createHARegionQueue(String name) throws IOException, ClassNotFoundException, CacheException, InterruptedException {
HARegionQueue regionqueue = HARegionQueue.getHARegionQueueInstance(name,cache,HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
return regionqueue;
}
/**
* Creates region-queue object
- *
- * @return region-queue object
- * @throws IOException
- * @throws ClassNotFoundException
- * @throws CacheException
- * @throws InterruptedException
*/
- protected HARegionQueue createHARegionQueue(String name,
- HARegionQueueAttributes attrs) throws IOException, ClassNotFoundException, CacheException, InterruptedException
- {
+ private HARegionQueue createHARegionQueue(String name, HARegionQueueAttributes attrs) throws IOException, ClassNotFoundException, CacheException, InterruptedException {
HARegionQueue regionqueue = HARegionQueue.getHARegionQueueInstance(name, cache, attrs,HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
return regionqueue;
}
@@ -148,13 +119,9 @@ public class HARegionQueueJUnitTest
* 3)Wait till all put-threads complete their job <br>
* 4)verify that the size of the queue is equal to the total number of puts
* done by all producers
- *
- * @throws Exception -
- * thrown if any problem occurs in test execution
*/
@Test
- public void testQueuePutWithoutConflation() throws Exception
- {
+ public void testQueuePutWithoutConflation() throws Exception {
logger.info("HARegionQueueJUnitTest : testQueuePutWithoutConflation BEGIN");
rq = createHARegionQueue("testOfferNoConflation");
@@ -173,13 +140,9 @@ public class HARegionQueueJUnitTest
* 3)Wait till all put-threads complete their job <br>
* 4)verify that the size of the queue is equal to the total number of puts
* done by one thread (as rest of them will conflate)
- *
- * @throws Exception -
- * thrown if any problem occurs in test execution
*/
@Test
- public void testQueuePutWithConflation() throws Exception
- {
+ public void testQueuePutWithConflation() throws Exception {
logger.info("HARegionQueueJUnitTest : testQueuePutWithConflation BEGIN");
rq = createHARegionQueue("testOfferConflation");
@@ -199,15 +162,11 @@ public class HARegionQueueJUnitTest
* 4)verify that the size of the queue is equal to the total number of puts
* done by one thread (as rest of them will be duplicates and hence will be
* replaced)
- *
- * @throws Exception -
- * thrown if any problem occurs in test execution
+ *
+ * TODO:Dinesh : Work on optimizing the handling of receiving duplicate events
*/
-
- //TODO:Dinesh : Work on optmizing the handling of receiving duplicate events
@Test
- public void testQueuePutWithDuplicates() throws Exception //dp
- {
+ public void testQueuePutWithDuplicates() throws Exception {
logger.info("HARegionQueueJUnitTest : testQueuePutWithDuplicates BEGIN");
rq = createHARegionQueue("testQueuePutWithDuplicates");
@@ -238,10 +197,7 @@ public class HARegionQueueJUnitTest
* @throws Exception -
* thrown if any problem occurs in test execution
*/
- private void createAndRunProducers(boolean generateSameKeys,
- boolean generateSameIds, boolean conflationEnabled, int putPerProducer)
- throws Exception
- {
+ private void createAndRunProducers(boolean generateSameKeys, boolean generateSameIds, boolean conflationEnabled, int putPerProducer) throws Exception {
Producer[] putThreads = new Producer[TOTAL_PUT_THREADS];
int i = 0;
@@ -278,7 +234,6 @@ public class HARegionQueueJUnitTest
ThreadUtils.join(putThreads[i], 30 * 1000);
}
assertFalse(encounteredException);
-
}
/*
@@ -286,12 +241,11 @@ public class HARegionQueueJUnitTest
* 'com.gemstone.gemfire.internal.cache.ha.HARegionQueue.addDispatchedMessage(Object)'
*/
@Test
- public void testAddDispatchedMessageObject()
- {
+ public void testAddDispatchedMessageObject() {
try {
//HARegionQueue haRegionQueue = new HARegionQueue("testing", cache);
HARegionQueue haRegionQueue = createHARegionQueue("testing");
- Assert.assertTrue(HARegionQueue.getDispatchedMessagesMapForTesting()
+ assertTrue(HARegionQueue.getDispatchedMessagesMapForTesting()
.isEmpty());
//TODO:
@@ -300,25 +254,21 @@ public class HARegionQueueJUnitTest
haRegionQueue.addDispatchedMessage(new ThreadIdentifier(new byte[1], 2),
2);
- Assert.assertTrue(!HARegionQueue.getDispatchedMessagesMapForTesting()
+ assertTrue(!HARegionQueue.getDispatchedMessagesMapForTesting()
.isEmpty());
// HARegionQueue.getDispatchedMessagesMapForTesting().clear();
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test encountered an exception due to " + e);
+ throw new AssertionError("Test encountered an exception due to ", e);
}
-
}
/**
* tests the blocking peek functionality of BlockingHARegionQueue
- *
*/
@Test
- public void testBlockQueue()
- {
+ public void testBlockQueue() {
exceptionInThread = false;
testFailed = false;
try {
@@ -382,11 +332,8 @@ public class HARegionQueueJUnitTest
}
catch (Exception e) {
- e.printStackTrace();
- fail(" Test failed due to " + e);
-
+ throw new AssertionError(" Test failed due to ", e);
}
-
}
private static volatile int counter = 0;
@@ -397,81 +344,16 @@ public class HARegionQueueJUnitTest
protected StringBuffer message = new StringBuffer();
-// private int totalMessages = 0;
-
protected Exception exception = null;
- private synchronized int getCounter()
- {
+ private synchronized int getCounter() {
return ++counter;
}
/**
- * This test concurrently adds dispatched message to the linked list and a
- * removal thread is concurrently removing the messages
- *
- */
- /*
- * commenting this out since there are four special cases of this test which
- * have been covered and this test is buggy - Mitul public void
- * _testConcurrentAddingToDispatcher()//mitul { exceptionInThread = false;
- *
- * try { createHARegionQueue("dummy"); } catch (Exception e1) { fail("test
- * failed due to "+e1); }
- *
- *
- * Thread[] threads = new Thread[10]; for (int i = 0; i < 10; i++) {
- * threads[i] = new Thread() { public void run() {
- *
- * try { HARegionQueue haRegionQueue = new HARegionQueue("testing" +
- * (getCounter()), cache); for (long j = 0; j < 10000; j++) { Thread.sleep(1);
- * haRegionQueue.addDispatchedMessage(new ThreadIdentifier( new byte[1], j),
- * j); System.out.println(""+j);
- * } } catch (Exception e) { exceptionInThread = true; exception = e; } } }; }
- *
- * Thread qrmSimulatorThread = new Thread() { public void run() { Map.Entry
- * entry = null; MapWrapper dispatchedMessages = null; List
- * queueRemovalMessageList = null; String REGION_NAME = null; Iterator iterator =
- * null; boolean shutdown = false; int messagesSofar = 0; while (!shutdown) {
- * if (messagesSofar == 100000) { shutdown = true; } iterator =
- * HARegionQueue.getDispatchedMessagesMapForTesting() .entrySet().iterator();
- * queueRemovalMessageList = new LinkedList(); while (iterator.hasNext()) {
- * System.out.println(" here "+messagesSofar); entry =
- * (Map.Entry)iterator.next(); REGION_NAME = (String)entry.getKey();
- * queueRemovalMessageList.add(REGION_NAME); dispatchedMessages =
- * (MapWrapper)entry.getValue(); String[] messages = null; synchronized
- * (dispatchedMessages) { messagesSofar = messagesSofar +
- * dispatchedMessages.map.size(); if (messagesSofar == 100000) { shutdown =
- * true; totalMessages = 100000;
- *
- * try { Thread.sleep(1); } catch (InterruptedException e) { } } else { try {
- * Thread.sleep(1); } catch (InterruptedException e) { } } iterator.remove();
- * dispatchedMessages.map.clear(); } queueRemovalMessageList.add(messages); }
- * if (!queueRemovalMessageList.isEmpty()) { QueueRemovalMessage qrm = new
- * QueueRemovalMessage(); qrm.setMessagesList(queueRemovalMessageList); } } } };
- *
- * qrmSimulatorThread.start(); for (int k = 0; k < 10; k++) {
- * threads[k].start(); } for (int k = 0; k < 10; k++) { try {
- * threads[k].join(60000); } catch (InterruptedException e) { } }
- * System.out.println("joining simulator"); try {
- * qrmSimulatorThread.join(60000); } catch (InterruptedException e) { }
- *
- * if (exceptionInThread) { fail("Exception occured " + exception);
- * exception.printStackTrace(); }
- *
- * if (totalMessages != 100000) { fail("Expected total messages to be 10000
- * but it is not so !"); }
- * }
- *
- */
-
- /**
* Thread to perform PUTs into the queue
- *
- *
*/
- class Producer extends Thread
- {
+ class Producer extends Thread {
/** total number of puts by this thread */
long totalPuts = 0;
@@ -508,8 +390,7 @@ public class HARegionQueueJUnitTest
* boolean to indicate whether this thread should create conflation
* enabled entries
*/
- Producer(String name, String keyPrefix, long startingId, long totalPuts,
- boolean createConflatableEvents) {
+ Producer(String name, String keyPrefix, long startingId, long totalPuts, boolean createConflatableEvents) {
super(name);
this.producerName = name;
this.keyPrefix = keyPrefix;
@@ -520,8 +401,8 @@ public class HARegionQueueJUnitTest
}
/** Create Conflatable objects and put them into the Queue. */
- public void run()
- {
+ @Override
+ public void run() {
if (producerName == null) {
producerName = Thread.currentThread().getName();
}
@@ -553,11 +434,9 @@ public class HARegionQueueJUnitTest
/**
* tests whether expiry of entry in the regin queue occurs as expected
- *
*/
@Test
- public void testExpiryPositive()
- {
+ public void testExpiryPositive() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(1);
@@ -566,29 +445,24 @@ public class HARegionQueueJUnitTest
regionqueue.put(new ConflatableObject("key", "value", new EventID(
new byte[] { 1 }, 1, 1), true, "testing"));
Map map = (Map)regionqueue.getConflationMapForTesting().get("testing");
- Assert.assertTrue(!map.isEmpty());
+ assertTrue(!map.isEmpty());
Thread.sleep(3000);
- Assert
- .assertTrue(
- " Expected region size to be zero since expiry time has been exceeded but it is "
+ assertTrue(" Expected region size to be zero since expiry time has been exceeded but it is "
+ regionqueue.getRegion().keys().size(), regionqueue
.getRegion().keys().size() == 0);
- Assert.assertTrue(map.isEmpty());
+ assertTrue(map.isEmpty());
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError(" test failed due to ", e);
}
}
/**
* tests whether things are not deleted before expiry
- *
*/
@Test
- public void testExpiryNegative()
- {
+ public void testExpiryNegative() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(100);
@@ -597,27 +471,22 @@ public class HARegionQueueJUnitTest
regionqueue.put(new ConflatableObject("key", "value", new EventID(
new byte[] { 1 }, 1, 1), false, "testing"));
Thread.sleep(1200);
- Assert
- .assertTrue(
- " Expected region size to be 2, since expiry time has not been exceeded but it is : "
+ assertTrue(" Expected region size to be 2, since expiry time has not been exceeded but it is : "
+ regionqueue.getRegion().keys().size(), regionqueue
.getRegion().keys().size() == 2);
}
catch (Exception e) {
- fail(" test failed due to " + e);
+ throw new AssertionError(" test failed due to ", e);
}
-
}
/**
- * tests whether expiry of a conflated entry in the regin queue occurs as
+ * tests whether expiry of a conflated entry in the region queue occurs as
* expected
- *
*/
@Test
- public void testExpiryPositiveWithConflation()
- {
+ public void testExpiryPositiveWithConflation() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(2);
@@ -627,64 +496,44 @@ public class HARegionQueueJUnitTest
new byte[] { 1 }, 1, 1), true, "testing"));
regionqueue.put(new ConflatableObject("key", "newValue", new EventID(
new byte[] { 1 }, 1, 2), true, "testing"));
- Assert
- .assertTrue(
- " Expected region size not to be zero since expiry time has not been exceeded but it is not so ",
+ assertTrue(" Expected region size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.size() == 0));
- Assert
- .assertTrue(
- " Expected the available id's size not to be zero since expiry time has not been exceeded but it is not so ",
+ assertTrue(" Expected the available id's size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getAvalaibleIds().size() == 0));
- Assert
- .assertTrue(
- " Expected conflation map size not to be zero since expiry time has not been exceeded but it is not so "
+ assertTrue(" Expected conflation map size not to be zero since expiry time has not been exceeded but it is not so "
+ ((((Map)(regionqueue.getConflationMapForTesting()
.get("testing"))).get("key"))),
!((((Map)(regionqueue.getConflationMapForTesting().get("testing")))
.get("key")) == null));
- Assert
- .assertTrue(
- " Expected eventID map size not to be zero since expiry time has not been exceeded but it is not so ",
+ assertTrue(" Expected eventID map size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getEventsMapForTesting().size() == 0));
Thread.sleep(5000);
ThreadIdentifier tid = new ThreadIdentifier(new byte[] { 1 }, 1);
System.out.println(" it still contains thread id : "
+ regionqueue.getRegion().containsKey(tid));
- Assert
- .assertTrue(
- " Expected region size to be zero since expiry time has been exceeded but it is not so ",
+ assertTrue(" Expected region size to be zero since expiry time has been exceeded but it is not so ",
regionqueue.getRegion().keys().size() == 0);
- Assert
- .assertTrue(
- " Expected the available id's size to be zero since expiry time has been exceeded but it is not so ",
+ assertTrue(" Expected the available id's size to be zero since expiry time has been exceeded but it is not so ",
regionqueue.getAvalaibleIds().size() == 0);
System.out.println((((Map)(regionqueue.getConflationMapForTesting()
.get("testing"))).get("key")));
- Assert
- .assertTrue(
- " Expected conflation map size to be zero since expiry time has been exceeded but it is not so ",
+ assertTrue(" Expected conflation map size to be zero since expiry time has been exceeded but it is not so ",
((((Map)(regionqueue.getConflationMapForTesting().get("testing")))
.get("key")) == null));
- Assert
- .assertTrue(
- " Expected eventID to be zero since expiry time has been exceeded but it is not so ",
+ assertTrue(" Expected eventID to be zero since expiry time has been exceeded but it is not so ",
(regionqueue.getEventsMapForTesting().size() == 0));
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError("test failed due to ", e);
}
-
}
/**
* test no expiry of events or data if expiry time not exceeded
- *
*/
@Test
- public void testExpiryNegativeWithConflation()
- {
+ public void testExpiryNegativeWithConflation() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(100);
@@ -695,40 +544,31 @@ public class HARegionQueueJUnitTest
regionqueue.put(new ConflatableObject("key", "newValue", new EventID(
new byte[] { 1 }, 1, 2), true, "testing"));
Thread.sleep(1200);
- Assert
- .assertTrue(
+ assertTrue(
" Expected region size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.size() == 0));
- Assert
- .assertTrue(
+ assertTrue(
" Expected the available id's size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getAvalaibleIds().size() == 0));
- Assert
- .assertTrue(
+ assertTrue(
" Expected conflation map size not to be zero since expiry time has not been exceeded but it is not so ",
!(((Map)(regionqueue
.getConflationMapForTesting().get("testing"))).size() == 0));
- Assert
- .assertTrue(
+ assertTrue(
" Expected eventID map size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getEventsMapForTesting().size() == 0));
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError("test failed due to ", e);
}
-
}
/**
* tests a ThreadId not being expired if it was updated
- *
*/
-
@Test
- public void testNoExpiryOfThreadId()
- {
+ public void testNoExpiryOfThreadId() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(3);
@@ -744,44 +584,38 @@ public class HARegionQueueJUnitTest
Thread.sleep(2000);
regionqueue.put(cf2);
Thread.sleep(1500);
- Assert
- .assertTrue(
+ assertTrue(
" Expected region size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.size() == 0));
- Assert
- .assertTrue(
+ assertTrue(
" Expected the available id's size not to have counter 1 but it has ",
!(regionqueue.getAvalaibleIds()
.contains(new Long(1))));
- Assert
- .assertTrue(
+ assertTrue(
" Expected the available id's size to have counter 2 but it does not have ",
(regionqueue.getAvalaibleIds()
.contains(new Long(2))));
- Assert.assertTrue(
+ assertTrue(
" Expected eventID map not to have the first event, but it has",
!(regionqueue.getCurrentCounterSet(ev1)
.contains(new Long(1))));
- Assert.assertTrue(
+ assertTrue(
" Expected eventID map to have the second event, but it does not",
(regionqueue.getCurrentCounterSet(ev2)
.contains(new Long(2))));
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError("test failed due to ", e);
}
}
/**
* Tests a QueueRemovalMessage coming before a localPut(). The localPut()
* should result in no data being put in the queue
- *
*/
@Test
- public void testQRMComingBeforeLocalPut()
- {
+ public void testQRMComingBeforeLocalPut() {
try {
//RegionQueue regionqueue = new HARegionQueue("testing", cache);
HARegionQueue regionqueue = createHARegionQueue("testing");
@@ -789,26 +623,21 @@ public class HARegionQueueJUnitTest
regionqueue.removeDispatchedEvents(id);
regionqueue
.put(new ConflatableObject("key", "value", id, true, "testing"));
- Assert
- .assertTrue(
+ assertTrue(
" Expected key to be null since QRM for the message id had already arrived ",
!regionqueue.getRegion().containsKey(new Long(1)));
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
-
+ throw new AssertionError("test failed due to ", e);
}
}
/**
* test verifies correct expiry of ThreadIdentifier in the HARQ if no
* corresponding put comes
- *
*/
@Test
- public void testOnlyQRMComing()
- {
+ public void testOnlyQRMComing() {
try {
HARegionQueueAttributes harqAttr = new HARegionQueueAttributes();
harqAttr.setExpiryTime(1);
@@ -816,56 +645,47 @@ public class HARegionQueueJUnitTest
HARegionQueue regionqueue = createHARegionQueue("testing",harqAttr);
EventID id = new EventID(new byte[] { 1 }, 1, 1);
regionqueue.removeDispatchedEvents(id);
- Assert.assertTrue(
+ assertTrue(
" Expected testingID to be present since only QRM achieved ",
regionqueue.getRegion().containsKey(
new ThreadIdentifier(new byte[] { 1 }, 1)));
Thread.sleep(2500);
- Assert
- .assertTrue(
+ assertTrue(
" Expected testingID not to be present since it should have expired after 2.5 seconds",
!regionqueue.getRegion().containsKey(
new ThreadIdentifier(new byte[] { 1 }, 1)));
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
-
+ throw new AssertionError("test failed due to ", e);
}
}
/**
* test all relevant data structures are updated on a local put
- *
*/
@Test
- public void testPutPath()
- {
+ public void testPutPath() {
try {
HARegionQueue regionqueue = createHARegionQueue("testing");
Conflatable cf = new ConflatableObject("key", "value", new EventID(
new byte[] { 1 }, 1, 1), true, "testing");
regionqueue.put(cf);
- Assert.assertTrue(" Expected region peek to return cf but it is not so ",
+ assertTrue(" Expected region peek to return cf but it is not so ",
(regionqueue.peek().equals(cf)));
- Assert
- .assertTrue(
+ assertTrue(
" Expected the available id's size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getAvalaibleIds().size() == 0));
- Assert
- .assertTrue(
+ assertTrue(
" Expected conflation map to have entry for this key since expiry time has not been exceeded but it is not so ",
((((Map)(regionqueue.getConflationMapForTesting().get("testing")))
.get("key")).equals(new Long(1))));
- Assert
- .assertTrue(
+ assertTrue(
" Expected eventID map size not to be zero since expiry time has not been exceeded but it is not so ",
!(regionqueue.getEventsMapForTesting().size() == 0));
}
catch (Exception e) {
- e.printStackTrace();
- fail("Exception occured in test due to " + e);
+ throw new AssertionError("Exception occured in test due to ", e);
}
}
@@ -873,11 +693,9 @@ public class HARegionQueueJUnitTest
* - adds 10 items - sets last dispatched as 5th - verify no data pertaining
* to the first five is there - verify the next five entries and their
* relevant data is present
- *
*/
@Test
- public void testQRMDispatch()
- {
+ public void testQRMDispatch() {
try {
HARegionQueue regionqueue = createHARegionQueue("testing");
Conflatable[] cf = new Conflatable[10];
@@ -891,59 +709,56 @@ public class HARegionQueueJUnitTest
regionqueue.removeDispatchedEvents(new EventID(new byte[] { 1 }, 1, 4));
// verify 1-5 not in region
for (long i = 1; i < 6; i++) {
- Assert.assertTrue(!regionqueue.getRegion().containsKey(new Long(i)));
+ assertTrue(!regionqueue.getRegion().containsKey(new Long(i)));
}
// verify 6-10 still in region queue
for (long i = 6; i < 11; i++) {
- Assert.assertTrue(regionqueue.getRegion().containsKey(new Long(i)));
+ assertTrue(regionqueue.getRegion().containsKey(new Long(i)));
}
// verify 1-5 not in conflation map
for (long i = 0; i < 5; i++) {
- Assert.assertTrue(!((Map)regionqueue.getConflationMapForTesting().get(
+ assertTrue(!((Map)regionqueue.getConflationMapForTesting().get(
"testing")).containsKey("key" + i));
}
// verify 6-10 in conflation map
for (long i = 5; i < 10; i++) {
- Assert.assertTrue(((Map)regionqueue.getConflationMapForTesting().get(
+ assertTrue(((Map)regionqueue.getConflationMapForTesting().get(
"testing")).containsKey("key" + i));
}
EventID eid = new EventID(new byte[] { 1 }, 1, 6);
// verify 1-5 not in eventMap
for (long i = 1; i < 6; i++) {
- Assert.assertTrue(!regionqueue.getCurrentCounterSet(eid).contains(
+ assertTrue(!regionqueue.getCurrentCounterSet(eid).contains(
new Long(i)));
}
// verify 6-10 in event Map
for (long i = 6; i < 11; i++) {
- Assert.assertTrue(regionqueue.getCurrentCounterSet(eid).contains(
+ assertTrue(regionqueue.getCurrentCounterSet(eid).contains(
new Long(i)));
}
// verify 1-5 not in available Id's map
for (long i = 1; i < 6; i++) {
- Assert.assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(i)));
+ assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(i)));
}
// verify 6-10 in available id's map
for (long i = 6; i < 11; i++) {
- Assert.assertTrue(regionqueue.getAvalaibleIds().contains(new Long(i)));
+ assertTrue(regionqueue.getAvalaibleIds().contains(new Long(i)));
}
}
catch (Exception e) {
- e.printStackTrace();
- fail("Exception occured in test due to " + e);
+ throw new AssertionError("Exception occurred in test due to ", e);
}
}
/**
* - send Dispatch message for sequence id 7 - put from sequence id 1 - id 10 -
* verify data for 1-7 not there - verify data for 8-10 is there
- *
*/
@Test
- public void testQRMBeforePut()
- {
+ public void testQRMBeforePut() {
try {
HARegionQueue regionqueue = createHARegionQueue("testing");
@@ -967,59 +782,56 @@ public class HARegionQueueJUnitTest
Set values = (Set)regionqueue.getRegion().values();
for (int i = 0; i < 7; i++) {
System.out.println(i);
- Assert.assertTrue(!values.contains(cf[i]));
+ assertTrue(!values.contains(cf[i]));
}
// verify 8-10 still in region queue
for (int i = 7; i < 10; i++) {
System.out.println(i);
- Assert.assertTrue(values.contains(cf[i]));
+ assertTrue(values.contains(cf[i]));
}
// verify 1-8 not in conflation map
for (long i = 0; i < 7; i++) {
- Assert.assertTrue(!((Map)regionqueue.getConflationMapForTesting().get(
+ assertTrue(!((Map)regionqueue.getConflationMapForTesting().get(
"testing")).containsKey("key" + i));
}
// verify 8-10 in conflation map
for (long i = 7; i < 10; i++) {
- Assert.assertTrue(((Map)regionqueue.getConflationMapForTesting().get(
+ assertTrue(((Map)regionqueue.getConflationMapForTesting().get(
"testing")).containsKey("key" + i));
}
EventID eid = new EventID(new byte[] { 1 }, 1, 6);
// verify 1-7 not in eventMap
for (long i = 4; i < 11; i++) {
- Assert.assertTrue(!regionqueue.getCurrentCounterSet(eid).contains(
+ assertTrue(!regionqueue.getCurrentCounterSet(eid).contains(
new Long(i)));
}
// verify 8-10 in event Map
for (long i = 1; i < 4; i++) {
- Assert.assertTrue(regionqueue.getCurrentCounterSet(eid).contains(
+ assertTrue(regionqueue.getCurrentCounterSet(eid).contains(
new Long(i)));
}
// verify 1-7 not in available Id's map
for (long i = 4; i < 11; i++) {
- Assert.assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(i)));
+ assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(i)));
}
// verify 8-10 in available id's map
for (long i = 1; i < 4; i++) {
- Assert.assertTrue(regionqueue.getAvalaibleIds().contains(new Long(i)));
+ assertTrue(regionqueue.getAvalaibleIds().contains(new Long(i)));
}
}
catch (Exception e) {
- e.printStackTrace();
- fail("Exception occured in test due to " + e);
+ throw new AssertionError("Exception occurred in test due to ", e);
}
}
/**
* test to verify conflation happens as expected
- *
*/
@Test
- public void testConflation()
- {
+ public void testConflation() {
try {
HARegionQueue regionqueue = createHARegionQueue("testing");
EventID ev1 = new EventID(new byte[] { 1 }, 1, 1);
@@ -1031,42 +843,37 @@ public class HARegionQueueJUnitTest
regionqueue.put(cf1);
Map conflationMap = regionqueue
.getConflationMapForTesting();
- Assert.assertTrue(((Map)(conflationMap.get("testing"))).get("key")
+ assertTrue(((Map)(conflationMap.get("testing"))).get("key")
.equals(new Long(1)));
regionqueue.put(cf2);
//verify the conflation map has recorded the new key
- Assert.assertTrue(((Map)(conflationMap.get("testing"))).get("key")
+ assertTrue(((Map)(conflationMap.get("testing"))).get("key")
.equals(new Long(2)));
//the old key should not be present
- Assert.assertTrue(!regionqueue.getRegion().containsKey(new Long(1)));
+ assertTrue(!regionqueue.getRegion().containsKey(new Long(1)));
//available ids should not contain the old id (the old position)
- Assert.assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(1)));
+ assertTrue(!regionqueue.getAvalaibleIds().contains(new Long(1)));
// available id should have the new id (the new position)
- Assert.assertTrue(regionqueue.getAvalaibleIds().contains(new Long(2)));
+ assertTrue(regionqueue.getAvalaibleIds().contains(new Long(2)));
// events map should not contain the old position
- Assert.assertTrue(regionqueue.getCurrentCounterSet(ev1).isEmpty());
+ assertTrue(regionqueue.getCurrentCounterSet(ev1).isEmpty());
// events map should contain the new position
- Assert.assertTrue(regionqueue.getCurrentCounterSet(ev2).contains(
+ assertTrue(regionqueue.getCurrentCounterSet(ev2).contains(
new Long(2)));
}
catch (Exception e) {
- e.printStackTrace();
- fail("Exception occured in test due to " + e);
+ throw new AssertionError("Exception occurred in test due to ", e);
}
-
}
/**
* Tests whether the QRM message removes the events correctly from the DACE &
* Conflation Map. The events which are of ID greater than that contained in
* QRM should stay
- *
*/
@Test
- public void testQRM()
- {
-
+ public void testQRM() {
try {
RegionQueue regionqueue = createHARegionQueue("testing");
for (int i = 0; i < 10; ++i) {
@@ -1077,26 +884,25 @@ public class HARegionQueueJUnitTest
((HARegionQueue)regionqueue).removeDispatchedEvents(qrmID);
Map conflationMap = ((HARegionQueue)regionqueue)
.getConflationMapForTesting();
- Assert.assertTrue(((Map)(conflationMap.get("testing"))).size() == 5);
+ assertTrue(((Map)(conflationMap.get("testing"))).size() == 5);
Set availableIDs = ((HARegionQueue)regionqueue).getAvalaibleIds();
Set counters = ((HARegionQueue)regionqueue).getCurrentCounterSet(qrmID);
- Assert.assertTrue(availableIDs.size() == 5);
- Assert.assertTrue(counters.size() == 5);
+ assertTrue(availableIDs.size() == 5);
+ assertTrue(counters.size() == 5);
for (int i = 5; i < 10; ++i) {
- Assert.assertTrue(((Map)(conflationMap.get("testing")))
+ assertTrue(((Map)(conflationMap.get("testing")))
.containsKey("key" + (i + 1)));
- Assert.assertTrue(availableIDs.contains(new Long((i + 1))));
- Assert.assertTrue(counters.contains(new Long((i + 1))));
+ assertTrue(availableIDs.contains(new Long((i + 1))));
+ assertTrue(counters.contains(new Long((i + 1))));
}
Region rgn = ((HARegionQueue)regionqueue).getRegion();
- Assert.assertTrue(rgn.keys().size() == 6);
+ assertTrue(rgn.keys().size() == 6);
}
catch (Exception e) {
- fail("Exception occured in test due to " + e);
+ throw new AssertionError("Exception occurred in test due to ", e);
}
-
}
protected static HARegionQueue hrqFortestSafeConflationRemoval;
@@ -1104,11 +910,9 @@ public class HARegionQueueJUnitTest
/**
* This test tests safe removal from the conflation map. i.e operations should
* only remove old values and not the latest value
- *
*/
@Test
- public void testSafeConflationRemoval()
- {
+ public void testSafeConflationRemoval() {
try {
hrqFortestSafeConflationRemoval = new HARQTestClass(
"testSafeConflationRemoval",
@@ -1123,31 +927,27 @@ public class HARegionQueueJUnitTest
(Map)hrqFortestSafeConflationRemoval.getConflationMapForTesting().get(
"testSafeConflationRemoval");
- Assert
- .assertTrue(
+ assertTrue(
"Expected the counter to be 2 since it should not have been deleted but it is not so ",
map.get("key1").equals(new Long(2)));
hrqFortestSafeConflationRemoval = null;
}
catch (Exception e) {
- fail("Test failed due to " + e);
+ throw new AssertionError("Test failed due to ", e);
}
}
/**
* Extends HARegionQueue for testing purposes. used by
* testSafeConflationRemoval
- *
*/
- static class HARQTestClass extends HARegionQueue.TestOnlyHARegionQueue
- {
- public HARQTestClass(String REGION_NAME, Cache cache,
- HARegionQueueJUnitTest test) throws IOException, ClassNotFoundException, CacheException, InterruptedException {
+ static class HARQTestClass extends HARegionQueue.TestOnlyHARegionQueue {
+
+ public HARQTestClass(String REGION_NAME, Cache cache, HARegionQueueJUnitTest test) throws IOException, ClassNotFoundException, CacheException, InterruptedException {
super(REGION_NAME, cache);
}
- ConcurrentMap createConcurrentMap()
- {
+ ConcurrentMap createConcurrentMap() {
return new ConcHashMap();
}
}
@@ -1155,17 +955,15 @@ public class HARegionQueueJUnitTest
/**
* Used to override the remove method for testSafeConflationRemoval
*/
- static class ConcHashMap extends ConcurrentHashMap implements ConcurrentMap
- {
- public boolean remove(Object arg0, Object arg1)
- {
+ static class ConcHashMap extends ConcurrentHashMap implements ConcurrentMap {
+ public boolean remove(Object arg0, Object arg1) {
Conflatable cf2 = new ConflatableObject("key1", "value2", new EventID(
new byte[] { 1 }, 1, 2), true, "testSafeConflationRemoval");
try {
hrqFortestSafeConflationRemoval.put(cf2);
}
catch (Exception e) {
- fail("Exception occured in trying to put ");
+ throw new AssertionError("Exception occurred in trying to put ", e);
}
return super.remove(arg0, arg1);
}
@@ -1191,11 +989,9 @@ public class HARegionQueueJUnitTest
* The data in the list is populated on a map against the threadId.
*
* It is then verified to see that all the sequence should be greater than x
- *
*/
@Test
- public void testConcurrentDispatcherAndRemovalForSameRegionSameThreadId()
- {
+ public void testConcurrentDispatcherAndRemovalForSameRegionSameThreadId() {
try {
final long numberOfIterations = 1000;
final HARegionQueue hrq = createHARegionQueue("testConcurrentDispatcherAndRemoval");
@@ -1270,24 +1066,21 @@ public class HARegionQueueJUnitTest
Long next;
while (iterator.hasNext()) {
next = ((Long)iterator.next());
- Assert.assertTrue(" Expected all the sequence ID's to be greater than "
+ assertTrue(" Expected all the sequence ID's to be greater than "
+ max + " but it is not so. Got sequence id " + next, next
.compareTo(max) >= 0);
}
}
catch (Exception e) {
- fail("Test failed due to : " + e);
+ throw new AssertionError("Test failed due to : ", e);
}
-
}
/**
- *
* This test remove operation is updating the sequence ID for a
* ThreadIdentifier and concurrently the QRM thread is iterating over the Map
* to form the Data Set. There should not be any DataLoss
- *
- *
+ *
* In this test, first we add x number of events for unique thread id for the
* same region then we start two concurrent threads. One which does add to
* dispatched events map with sequence id's greater than x and the second one
@@ -1300,11 +1093,9 @@ public class HARegionQueueJUnitTest
* The data in the list is populated on a map against the threadId.
*
* It is then verified to see that the map size should be 2x
- *
*/
@Test
- public void testConcurrentDispatcherAndRemovalForSameRegionDifferentThreadId()
- {
+ public void testConcurrentDispatcherAndRemovalForSameRegionDifferentThreadId() {
try {
final long numberOfIterations = 1000;
final HARegionQueue hrq = createHARegionQueue("testConcurrentDispatcherAndRemoval");
@@ -1376,23 +1167,20 @@ public class HARegionQueueJUnitTest
map.put(new Long(id.getThreadID()), new Long(id.getSequenceID()));
}
}
- Assert.assertTrue(" Expected the map size to be "
+ assertTrue(" Expected the map size to be "
+ (2 * numberOfIterations) + " but it is " + map.size(),
map.size() == (2 * numberOfIterations));
}
catch (Exception e) {
- fail("Test failed due to an unexpected exception : " + e);
+ throw new AssertionError("Test failed due to an unexpected exception : ", e);
}
}
/**
- *
* This test tests remove operation is causing the insertion of a sequence ID
* for a new HA Region and concurrently the QRM thread is iterating over the
* Map to form the Data Set for dispatch. There should not be any Data Loss
- *
- *
- *
+ *
* In this test, first we add x number of events for unique thread id for the
* 2 regions then we start two concurrent threads. One which does add to
* dispatched events map to 3 new regions
@@ -1406,12 +1194,9 @@ public class HARegionQueueJUnitTest
* The data in the list is populated on a map against the threadId.
*
* It is then verified to see that a total of x entries are present in the map
- *
*/
-
@Test
- public void testConcurrentDispatcherAndRemovalForMultipleRegionsSameThreadId()
- {
+ public void testConcurrentDispatcherAndRemovalForMultipleRegionsSameThreadId() {
try {
final long numberOfIterations = 10000;
final HARegionQueue hrq1 = createHARegionQueue("testConcurrentDispatcherAndRemoval1");
@@ -1507,26 +1292,22 @@ public class HARegionQueueJUnitTest
}
}
}
- Assert.assertTrue(" Expected the map size to be " + (numberOfIterations)
+ assertTrue(" Expected the map size to be " + (numberOfIterations)
+ " but it is " + map.size(), map.size() == (numberOfIterations));
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test failed due to : " + e);
+ throw new AssertionError("Test failed due to : ", e);
}
-
}
/**
- *
* This test tests remove operation is causing the insertion of a sequence ID
* for a new ThreadIdentifier Object ( that is the HA Regio name exists but
* ThreadIdentifier object is appearing 1st time) and concurrently the QRM
* thread is iterating over the Map to form the Data Set for dispatch. There
* should not be any DataLoss
*
- *
* In this test, first we add x number of events for unique thread id for the
* multiples regions then we start two concurrent threads. One which does add
* to dispatched events map with sequence id's greater than x and new
@@ -1542,11 +1323,9 @@ public class HARegionQueueJUnitTest
*
* It is then verified to see that the map size should be 2x * number of
* regions
- *
*/
@Test
- public void testConcurrentDispatcherAndRemovalForMultipleRegionsDifferentThreadId()
- {
+ public void testConcurrentDispatcherAndRemovalForMultipleRegionsDifferentThreadId() {
try {
final long numberOfIterations = 1000;
final HARegionQueue hrq1 =
@@ -1677,16 +1456,14 @@ public class HARegionQueueJUnitTest
}
}
- Assert.assertTrue(" Expected the map size to be "
+ assertTrue(" Expected the map size to be "
+ (numberOfIterations * 2 * 5) + " but it is " + map.size(), map
.size() == (numberOfIterations * 2 * 5));
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test failed due to : " + e);
+ throw new AssertionError("Test failed due to : ", e);
}
-
}
/**
@@ -1694,10 +1471,8 @@ public class HARegionQueueJUnitTest
* take is also happening such that the object is removed first then the peek
* should block & not return with null.
*/
-
@Test
- public void testBlockingQueueForConcurrentPeekAndTake()
- {
+ public void testBlockingQueueForConcurrentPeekAndTake() {
exceptionInThread = false;
testFailed = false;
try {
@@ -1765,19 +1540,16 @@ public class HARegionQueueJUnitTest
}
catch (Exception e) {
- fail(" Test failed due to " + e);
- e.printStackTrace();
+ throw new AssertionError(" Test failed due to ", e);
}
-
}
/**
- * Peek on a blokcing queueis in progress & the single element is removed
+ * Peek on a blocking queue is in progress & the single element is removed
* either by take or by QRM thread , the peek should block correctly.
*/
@Test
- public void testBlockingQueueForTakeWhenPeekInProgress()
- {
+ public void testBlockingQueueForTakeWhenPeekInProgress() {
exceptionInThread = false;
testFailed = false;
try {
@@ -1844,10 +1616,8 @@ public class HARegionQueueJUnitTest
}
catch (Exception e) {
- fail(" Test failed due to " + e);
- e.printStackTrace();
+ throw new AssertionError(" Test failed due to ", e);
}
-
}
/**
@@ -1856,16 +1626,13 @@ public class HARegionQueueJUnitTest
* published by adding into the available IDs Set. Similarly if an event is to
* be removed it should first be removed from availableIDs set & then from
* behind the scenes. It will be the responsibility of the thread removing
- * from availabelIDs successfully which will remove the entry from all other
+ * from available IDs successfully which will remove the entry from all other
* places. Now if the expiry task makes the event from underlying null before
- * removing from availabel IDs , there is a potential violation. This test
+ * removing from available IDs , there is a potential violation. This test
* will validate that behaviour
- *
- *
*/
@Test
- public void testConcurrentEventExpiryAndTake()
- {
+ public void testConcurrentEventExpiryAndTake() {
try {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(3);
@@ -1930,8 +1697,7 @@ public class HARegionQueueJUnitTest
assertNull(o);
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test failed due to exception " + e);
+ throw new AssertionError("Test failed due to exception ", e);
}finally{
synchronized (this) {
this.allowExpiryToProceed = true;
@@ -1946,21 +1712,20 @@ public class HARegionQueueJUnitTest
assertTrue("Test failed due to exception ", !encounteredException);
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError("test failed due to ", e);
}
-
}
/**
* This test validates that if sequence violation occurs without GII,the put
* will throw an exception
- *
- *
+ *
* Test is commented as assertion for sequence violation is removed in the
* source(HARegionQueue.putObject) is removed. - Suyog
*/
- public void _testExceptionInPutForSequenceViolationWithoutGII() {
+ @Ignore("TODO: disabled for unknown reason")
+ @Test
+ public void testExceptionInPutForSequenceViolationWithoutGII() {
DistributedSystem ds = cache.getDistributedSystem();
cache.close();
ds.disconnect();
@@ -1971,9 +1736,7 @@ public class HARegionQueueJUnitTest
cache= CacheFactory.create(DistributedSystem.connect(props));
}
catch (Exception e1) {
-
- e1.printStackTrace();
- fail("Test failed because of exception. Exception="+e1);
+ throw new AssertionError("Test failed because of exception. Exception=", e1);
}
HARegionQueue rq= null;
@@ -1982,8 +1745,7 @@ public class HARegionQueueJUnitTest
rq = HARegionQueue.getHARegionQueueInstance("testException",cache,HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test failed because of exception. Exception="+e);
+ throw new AssertionError("Test failed because of exception. Exception=", e);
}
ConflatableObject cf1 = new ConflatableObject("key1","val1", new EventID( new byte[]{1},1,2),false,"test" );
ConflatableObject cf2 = new ConflatableObject("key1","val1", new EventID( new byte[]{1},1,1),false,"test" );
@@ -1991,87 +1753,75 @@ public class HARegionQueueJUnitTest
try{
rq.put(cf1);
}catch(Exception e) {
- e.printStackTrace();
- fail("Test failed because of exception. Exception="+e);
+ throw new AssertionError("Test failed because of exception. Exception=", e);
}
try{
rq.put(cf2);
- fail("Test failed because asertion error was expected but there was'nt any");
+ fail("Test failed because asertion error was expected but there was'nt any"); // TODO: this is broken, the following catch will catch this or what's thrown by put
}catch(AssertionError ignore) {
System.out.println("Got the right assertion failure");
}catch(Exception e) {
e.printStackTrace();
- fail("Test failed because of exception. Exception="+e);
+ throw new AssertionError("Test failed because of exception. Exception=", e);
}
-
}
/**
* Tests the functionality of batch peek & remove with blocking & non blocking
* HARegionQueue
- *
*/
@Test
- public void testBatchPeekWithRemoveForNonBlockingQueue()
- {
+ public void testBatchPeekWithRemoveForNonBlockingQueue() {
testBatchPeekWithRemove(false);
-
}
/**
* Tests the functionality of batch peek & remove with blocking & non blocking
* HARegionQueue
- *
*/
@Test
- public void testBatchPeekWithRemoveForBlockingQueue()
- {
+ public void testBatchPeekWithRemoveForBlockingQueue() {
testBatchPeekWithRemove(true);
-
}
- private void testBatchPeekWithRemove(boolean createBlockingQueue)
- {
+ private void testBatchPeekWithRemove(boolean createBlockingQueue) {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(300);
try {
HARegionQueue regionqueue = createBlockingQueue ?HARegionQueue.getHARegionQueueInstance("testing", cache, haa,HARegionQueue.BLOCKING_HA_QUEUE, false)
: HARegionQueue.getHARegionQueueInstance("testing", cache, haa,HARegionQueue.NON_BLOCKING_HA_QUEUE, false);
- for(int i=0; i<10;++i) {
- EventID ev1 = new EventID(new byte[] { 1 }, 1, i);
- Conflatable cf1 = new ConflatableObject("key", "value", ev1, false,
- "testing");
- regionqueue.put(cf1);
- }
-
- List objs = regionqueue.peek(10,5000);
- assertEquals(10,objs.size());
- Iterator itr = objs.iterator();
- int j=0;
- while(itr.hasNext()) {
- Conflatable conf = (Conflatable)itr.next();
- assertNotNull(conf);
- assertTrue("The sequence ID of the objects in the queue are not as expected",conf.getEventId().getSequenceID() == j++);
- }
- regionqueue.remove();
- assertEquals(0,regionqueue.size());
+ for(int i=0; i<10;++i) {
+ EventID ev1 = new EventID(new byte[] { 1 }, 1, i);
+ Conflatable cf1 = new ConflatableObject("key", "value", ev1, false,
+ "testing");
+ regionqueue.put(cf1);
+ }
+
+ List objs = regionqueue.peek(10,5000);
+ assertEquals(10,objs.size());
+ Iterator itr = objs.iterator();
+ int j=0;
+ while(itr.hasNext()) {
+ Conflatable conf = (Conflatable)itr.next();
+ assertNotNull(conf);
+ assertTrue("The sequence ID of the objects in the queue are not as expected",conf.getEventId().getSequenceID() == j++);
+ }
+ regionqueue.remove();
+ assertEquals(0,regionqueue.size());
}
catch (Exception e) {
- e.printStackTrace();
- fail("Test failed bcoz of exception =" + e);
+ throw new AssertionError("Test failed bcoz of exception =", e);
}
}
/**
* tests whether expiry of entry in the regin queue occurs as expected using
* system property to set expiry
- *
*/
@Test
- public void testExpiryUsingSystemProperty()
- {
+ public void testExpiryUsingSystemProperty() {
try {
System.setProperty(HARegionQueue.REGION_ENTRY_EXPIRY_TIME,"1");
@@ -2080,51 +1830,43 @@ public class HARegionQueueJUnitTest
regionqueue.put(new ConflatableObject("key", "value", new EventID(
new byte[] { 1 }, 1, 1), true, "testing"));
Map map = (Map)regionqueue.getConflationMapForTesting().get("testing");
- Assert.assertTrue(!map.isEmpty());
+ assertTrue(!map.isEmpty());
Thread.sleep(3000);
- Assert
- .assertTrue(
+ assertTrue(
" Expected region size to be zero since expiry time has been exceeded but it is "
+ regionqueue.getRegion().keys().size(), regionqueue
.getRegion().keys().size() == 0);
- Assert.assertTrue(map.isEmpty());
+ assertTrue(map.isEmpty());
// [yogi]system property set to null, to avoid using it in the subsequent tests
System.setProperty(HARegionQueue.REGION_ENTRY_EXPIRY_TIME,"");
}
catch (Exception e) {
- e.printStackTrace();
- fail(" test failed due to " + e);
+ throw new AssertionError(" test failed due to ", e);
}
}
/**
* This tests whether the messageSyncInterval for QueueRemovalThread is
* refreshed properly when set/updated using cache's setter API
- * @throws InterruptedException
- * @throws IOException
- * @throws ClassNotFoundException
- * @throws CacheException
- *
*/
@Test
- public void testUpdationOfMessageSyncInterval() throws CacheException, ClassNotFoundException, IOException, InterruptedException
- {
- int initialMessageSyncInterval = 5;
- cache.setMessageSyncInterval(initialMessageSyncInterval);
- createHARegionQueue("testUpdationOfMessageSyncInterval");
+ public void testUpdationOfMessageSyncInterval() throws Exception {
+ int initialMessageSyncInterval = 5;
+ cache.setMessageSyncInterval(initialMessageSyncInterval);
+ createHARegionQueue("testUpdationOfMessageSyncInterval");
- Assert.assertEquals("messageSyncInterval not set properly",
- initialMessageSyncInterval, HARegionQueue.getMessageSyncInterval());
+ assertEquals("messageSyncInterval not set properly",
+ initialMessageSyncInterval, HARegionQueue.getMessageSyncInterval());
- int updatedMessageSyncInterval = 10;
- cache.setMessageSyncInterval(updatedMessageSyncInterval);
+ int updatedMessageSyncInterval = 10;
+ cache.setMessageSyncInterval(updatedMessageSyncInterval);
- // sleep for a time just more the intial messageSyncInterval1 , so that
- // the value is updated in QRM run loop.
- Thread.sleep((initialMessageSyncInterval + 1) * 1000);
+ // sleep for a time just more the intial messageSyncInterval1 , so that
+ // the value is updated in QRM run loop.
+ Thread.sleep((initialMessageSyncInterval + 1) * 1000);
- Assert.assertEquals("messageSyncInterval not updated.",
- updatedMessageSyncInterval, HARegionQueue.getMessageSyncInterval());
+ assertEquals("messageSyncInterval not updated.",
+ updatedMessageSyncInterval, HARegionQueue.getMessageSyncInterval());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HASlowReceiverDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HASlowReceiverDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HASlowReceiverDUnitTest.java
index 46ad459..1f7e63c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HASlowReceiverDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HASlowReceiverDUnitTest.java
@@ -16,6 +16,14 @@
*/
package com.gemstone.gemfire.internal.cache.ha;
+import static org.junit.Assert.*;
+
+import java.net.SocketException;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.LogWriter;
import com.gemstone.gemfire.cache.*;
import com.gemstone.gemfire.cache.client.PoolManager;
@@ -27,14 +35,20 @@ import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.ClientServerObserverAdapter;
import com.gemstone.gemfire.internal.cache.ClientServerObserverHolder;
import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerTestUtil;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.net.SocketException;
-import java.util.Properties;
-
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
-public class HASlowReceiverDUnitTest extends DistributedTestCase {
+@Category(DistributedTest.class)
+public class HASlowReceiverDUnitTest extends JUnit4DistributedTestCase {
+
protected static Cache cache = null;
private static VM serverVM1 = null;
@@ -57,10 +71,6 @@ public class HASlowReceiverDUnitTest extends DistributedTestCase {
private static boolean isUnresponsiveClientRemoved = false;
- public HASlowReceiverDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void postSetUp() throws Exception {
final Host host = Host.getHost(0);
@@ -107,7 +117,7 @@ public class HASlowReceiverDUnitTest extends DistributedTestCase {
Properties prop = new Properties();
prop.setProperty(REMOVE_UNRESPONSIVE_CLIENT,
"true");
- new HASlowReceiverDUnitTest("temp").createCache(prop);
+ new HASlowReceiverDUnitTest().createCache(prop);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -137,7 +147,7 @@ public class HASlowReceiverDUnitTest extends DistributedTestCase {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new HASlowReceiverDUnitTest("temp").createCache(props);
+ new HASlowReceiverDUnitTest().createCache(props);
AttributesFactory factory = new AttributesFactory();
PoolImpl p = (PoolImpl)PoolManager.createFactory().addServer("localhost",
@@ -230,6 +240,7 @@ public class HASlowReceiverDUnitTest extends DistributedTestCase {
}
// Test slow client
+ @Test
public void testSlowClient() throws Exception {
setBridgeObeserverForAfterQueueDestroyMessage();
Host host = Host.getHost(0);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/OperationsPropagationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/OperationsPropagationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/OperationsPropagationDUnitTest.java
index eb86bd6..971ced1 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/OperationsPropagationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/OperationsPropagationDUnitTest.java
@@ -16,77 +16,57 @@
*/
package com.gemstone.gemfire.internal.cache.ha;
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache30.ClientServerTestCase;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.cache.CacheServerImpl;
-import com.gemstone.gemfire.test.dunit.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache30.ClientServerTestCase;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.cache.CacheServerImpl;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
- *
* This test verifies that all entry operations (create,put,destroy,invalidate)
* which propagate from one server1 to another server2 do get delivered to the
* client connected to server2 (server2 is primary for client)
- *
*/
+@Category(DistributedTest.class)
+public class OperationsPropagationDUnitTest extends JUnit4DistributedTestCase {
-public class OperationsPropagationDUnitTest extends DistributedTestCase
-{
-
- /**
- * Server1
- */
VM server1 = null;
-
- /**
- * Server2
- */
VM server2 = null;
-
- /**
- * Client
- */
VM client1 = null;
- /**
- * Port of server1
- */
public int PORT1;
-
- /**
- * Port of server2
- */
public int PORT2;
- /**
- * Name of the region
- */
- private static final String REGION_NAME = "OperationsPropagationDUnitTest_Region";
+ private static final String REGION_NAME = OperationsPropagationDUnitTest.class.getSimpleName() + "_Region";
- /**
- * cache
- */
private static Cache cache = null;
/**
- * Constructor
- *
- * @param name
- */
- public OperationsPropagationDUnitTest(String name) {
- super(name);
- }
-
- /**
* Create the server1, server2 (in the same DS) and client1 (which is
* connected only to server2
*/
@@ -119,7 +99,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
/**
* closes the cache and disconnects the vm from teh distributed system
- *
*/
public static void closeCache()
{
@@ -131,9 +110,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
/**
* connect to the DS and create a cache
- *
- * @param props
- * @throws Exception
*/
private void createCache(Properties props) throws Exception
{
@@ -152,13 +128,10 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
/**
* Create the server
- *
- * @return
- * @throws Exception
*/
public static Integer createServerCache() throws Exception
{
- new OperationsPropagationDUnitTest("temp").createCache(new Properties());
+ new OperationsPropagationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
@@ -172,14 +145,10 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
server.setNotifyBySubscription(true);
server.start();
return new Integer(server.getPort());
-
}
/**
* create the client and connect it to the server with the given port
- *
- * @param port2
- * @throws Exception
*/
public static void createClientCache(String host, Integer port2) throws Exception
{
@@ -187,7 +156,7 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new OperationsPropagationDUnitTest("temp").createCache(props);
+ new OperationsPropagationDUnitTest().createCache(props);
props.setProperty("retryAttempts", "2");
props.setProperty("endpoints", "ep1="+host+":" + PORT2);
props.setProperty("redundancyLevel", "-1");
@@ -205,7 +174,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
region = cache.createRegion(REGION_NAME, attrs);
assertNotNull(region);
region.registerInterest("ALL_KEYS");
-
}
public static final String CREATE_KEY = "createKey";
@@ -235,15 +203,18 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
public static final String PUTALL_VALUE2 = "putAllValue2";
/**
- * This test: 1) First the initial keys and values 2) Verify that the initial
- * keys and values have reached the client 3) Do the operations which we want
- * to propagate (create, update, invalidate and destroy) 4) Verify the
+ * This test:
+ * 1) First the initial keys and values
+ * 2) Verify that the initial
+ * keys and values have reached the client
+ * 3) Do the operations which we want
+ * to propagate (create, update, invalidate and destroy)
+ * 4) Verify the
* operations reached the client
* 5) Do a removeAll
* 6) Verify it reached the client
- *
- * @throws Exception
*/
+ @Test
public void testOperationsPropagation() throws Exception
{
server1.invoke(() -> OperationsPropagationDUnitTest.initialPutKeyValue());
@@ -256,7 +227,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
/**
* put the initial keys and values
- *
*/
public static void initialPutKeyValue()
{
@@ -268,12 +238,10 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
catch (Exception e) {
Assert.fail(" Test failed due to " + e, e);
}
-
}
/**
* do the operations which you want to propagate
- *
*/
public static void doOperations()
{
@@ -290,12 +258,10 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
catch (Exception e) {
Assert.fail(" Test failed due to " + e, e);
}
-
}
/**
* assert the initial key values are present
- *
*/
public static void assertKeyValuePresent()
{
@@ -312,11 +278,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*
- * if (!(region.get(UPDATE_KEY).equals(UPDATE_VALUE1))) { fail(" Expected
- * value to be " + UPDATE_VALUE1 + " but it is " +
- * region.get(UPDATE_KEY)); }
- */
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -329,11 +290,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*
- * if (!(region.get(INVALIDATE_KEY).equals(INVALIDATE_VALUE))) { fail("
- * Expected value to be " + INVALIDATE_VALUE + " but it is " +
- * region.get(INVALIDATE_KEY)); }
- */
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -345,27 +301,17 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
}
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
-
- /*
- * if (!(region.get(DESTROY_KEY).equals(DESTROY_VALUE))) { fail(" Expected
- * value to be " + DESTROY_VALUE + " but it is " +
- * region.get(DESTROY_KEY)); }
- */
-
}
catch (Exception e) {
Assert.fail(" Test failed due to " + e, e);
}
-
}
/**
* assert the operations reached the client successfully
- *
*/
public static void assertOperationsSucceeded()
{
-
try {
//Thread.sleep(5000);
WaitCriterion wc = new WaitCriterion() {
@@ -380,10 +326,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*if (!(region.get(CREATE_KEY).equals(CREATE_VALUE))) {
- fail("CREATE operation did not propagate to client : Expected value to be "
- + CREATE_VALUE + " but it is " + region.get(CREATE_KEY));
- }*/
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -396,10 +338,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*if (!(region.get(UPDATE_KEY).equals(UPDATE_VALUE2))) {
- fail(" UPDATE operation did not propagate to Client : Expected value to be "
- + UPDATE_VALUE2 + " but it is " + region.get(UPDATE_KEY));
- }*/
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -412,10 +350,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*if (region.containsKey(DESTROY_KEY)) {
- fail(" DESTROY operation did not propagate to Client : Expected "
- + DESTROY_KEY + " not to be present but it is ");
- }*/
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -428,10 +362,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*if (!(region.get(INVALIDATE_KEY) == null)) {
- fail(" INVALIDATE operation did not propagate to Client : Expected value to be null but it is "
- + region.get(INVALIDATE_KEY));
- }*/
wc = new WaitCriterion() {
String excuse;
public boolean done() {
@@ -444,11 +374,6 @@ public class OperationsPropagationDUnitTest extends DistributedTestCase
};
Wait.waitForCriterion(wc, 60 * 1000, 1000, true);
- /*
- * if (!(region.get(PUTALL_KEY).equals(PUTALL_VALUE))) { fail("PUTALL
- * operation did not propagate to client : Expected value to be " +
- * PUTALL_VALUE + " but it is " + region.get(PUTALL_KEY)); }
- */
wc = new WaitCriterion() {
String excuse;
public boolean done() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/PutAllDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/PutAllDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/PutAllDUnitTest.java
index 4cb1849..9868c73 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/PutAllDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/PutAllDUnitTest.java
@@ -16,7 +16,28 @@
*/
package com.gemstone.gemfire.internal.cache.ha;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheListener;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.InterestResultPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.internal.PoolImpl;
import com.gemstone.gemfire.cache.client.internal.QueueStateImpl.SequenceIdAndExpirationObject;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
@@ -27,26 +48,20 @@ import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.CacheServerImpl;
import com.gemstone.gemfire.internal.cache.EntryEventImpl;
import com.gemstone.gemfire.internal.cache.EventID;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
- *
* Test to verify correct propagation of operations eventID's for put all
*
- *
* @since GemFire 5.1
*/
-
-public class PutAllDUnitTest extends DistributedTestCase
-{
+@Category(DistributedTest.class)
+public class PutAllDUnitTest extends JUnit4DistributedTestCase {
/** server1 VM **/
VM server1 = null;
@@ -74,8 +89,8 @@ public class PutAllDUnitTest extends DistributedTestCase
static CacheServerImpl server = null;
/** test constructor **/
- public PutAllDUnitTest(String name) {
- super(name);
+ public PutAllDUnitTest() {
+ super();
}
/** get the hosts and the VMs **/
@@ -132,7 +147,7 @@ public class PutAllDUnitTest extends DistributedTestCase
/** create the server **/
public static Integer createServerCache() throws Exception
{
- new PutAllDUnitTest("temp").createCache(new Properties());
+ new PutAllDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
@@ -169,7 +184,7 @@ public class PutAllDUnitTest extends DistributedTestCase
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new PutAllDUnitTest("temp").createCache(props);
+ new PutAllDUnitTest().createCache(props);
props.setProperty("retryAttempts", "2");
props.setProperty("endpoints", "ep1="+host+":" + PORT1);
props.setProperty("redundancyLevel", "-1");
@@ -200,7 +215,7 @@ public class PutAllDUnitTest extends DistributedTestCase
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- new PutAllDUnitTest("temp").createCache(props);
+ new PutAllDUnitTest().createCache(props);
props.setProperty("retryAttempts", "2");
props.setProperty("endpoints", "ep1="+host+":" + PORT1);
props.setProperty("redundancyLevel", "-1");
@@ -334,6 +349,7 @@ public class PutAllDUnitTest extends DistributedTestCase
*
* @throws Exception
*/
+ @Test
public void testPutAll() throws Exception
{
setReceivedOperationToFalse();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/StatsBugDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/StatsBugDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/StatsBugDUnitTest.java
index 0a66e5e..b7bb6c1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/StatsBugDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/StatsBugDUnitTest.java
@@ -16,22 +16,35 @@
*/
package com.gemstone.gemfire.internal.cache.ha;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.client.internal.PoolImpl;
import com.gemstone.gemfire.cache.server.CacheServer;
import com.gemstone.gemfire.cache30.ClientServerTestCase;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
/**
* This is Dunit test for bug 36109. This test has a cache-client having a primary
@@ -42,13 +55,11 @@ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties
* appearing because invalidate stats was part of Endpoint which used to get
* closed during fail over , with the failed endpoint getting closed. This bug
* has been fixed by moving the invalidate stat to be part of our implementation.
- *
- *
*/
@Category(DistributedTest.class)
@Ignore("Test was disabled by renaming to DisabledTest")
-public class StatsBugDUnitTest extends DistributedTestCase
-{
+public class StatsBugDUnitTest extends JUnit4DistributedTestCase {
+
/** primary cache server */
VM primary = null;
@@ -68,7 +79,7 @@ public class StatsBugDUnitTest extends DistributedTestCase
private static int PORT2;
/** name of the test region */
- private static final String REGION_NAME = "StatsBugDUnitTest_Region";
+ private static final String REGION_NAME = StatsBugDUnitTest.class.getSimpleName() + "_Region";
/** brige-writer instance( used to get connection proxy handle) */
private static PoolImpl pool = null;
@@ -85,22 +96,6 @@ public class StatsBugDUnitTest extends DistributedTestCase
/** prefix added to the keys of events generated on secondary */
private static final String secondaryPrefix = "secondary_";
- /**
- * Constructor
- *
- * @param name -
- * name for this test instance
- */
- public StatsBugDUnitTest(String name) {
- super(name);
- }
-
- /**
- * Creates the primary and the secondary cache servers
- *
- * @throws Exception -
- * thrown if any problem occurs in initializing the test
- */
@Override
public final void postSetUp() throws Exception {
disconnectAllFromDS();
@@ -134,12 +129,6 @@ public class StatsBugDUnitTest extends DistributedTestCase
return cache;
}
- /**
- * close the cache instances in server and client during tearDown
- *
- * @throws Exception
- * thrown if any problem occurs in closing cache
- */
@Override
public final void preTearDown() throws Exception {
// close client
@@ -159,10 +148,8 @@ public class StatsBugDUnitTest extends DistributedTestCase
* operations from secondary<br>
* 5)Verify that the invalidates stats at the client accounts for the
* operations done by both, primary and secondary.
- *
- * @throws Exception -
- * thrown if any problem occurs in test execution
*/
+ @Test
public void testBug36109() throws Exception
{
LogWriterUtils.getLogWriter().info("testBug36109 : BEGIN");
@@ -200,7 +187,7 @@ public class StatsBugDUnitTest extends DistributedTestCase
*/
public static Integer createServerCache() throws Exception
{
- StatsBugDUnitTest test = new StatsBugDUnitTest("temp");
+ StatsBugDUnitTest test = new StatsBugDUnitTest();
Properties props = new Properties();
cache = test.createCache(props);
AttributesFactory factory = new AttributesFactory();
@@ -233,7 +220,7 @@ public class StatsBugDUnitTest extends DistributedTestCase
public static void createClientCache(String host, Integer port1, Integer port2)
throws Exception
{
- StatsBugDUnitTest test = new StatsBugDUnitTest("temp");
+ StatsBugDUnitTest test = new StatsBugDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -257,7 +244,7 @@ public class StatsBugDUnitTest extends DistributedTestCase
public static void createClientCacheForInvalidates(String host, Integer port1, Integer port2)
throws Exception
{
- StatsBugDUnitTest test = new StatsBugDUnitTest("temp");
+ StatsBugDUnitTest test = new StatsBugDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
index 66ee622..110b64d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/ThreadIdentifierJUnitTest.java
@@ -24,8 +24,6 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.cache.ha.ThreadIdentifier.WanType;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
public class ThreadIdentifierJUnitTest {