Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 59712200B0F for ; Fri, 3 Jun 2016 01:17:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 57EFA160A51; Thu, 2 Jun 2016 23:17:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DC933160A52 for ; Fri, 3 Jun 2016 01:17:08 +0200 (CEST) Received: (qmail 23619 invoked by uid 500); 2 Jun 2016 23:17:08 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 23610 invoked by uid 99); 2 Jun 2016 23:17:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 23:17:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 8A7491A0773 for ; Thu, 2 Jun 2016 23:17:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id EfcriyvGTIDz for ; Thu, 2 Jun 2016 23:16:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 7213B5F247 for ; Thu, 2 Jun 2016 23:16:54 +0000 (UTC) Received: (qmail 23192 invoked by uid 99); 2 Jun 2016 23:16:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 23:16:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B7CEBE0105; Thu, 2 Jun 2016 23:16:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Date: Thu, 02 Jun 2016 23:16:54 -0000 Message-Id: <5e239611fc7c48cbac9e25380ce80740@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] incubator-geode git commit: Test cleanup. archived-at: Thu, 02 Jun 2016 23:17:11 -0000 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/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 b7fae40..8fd0aa2 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 @@ -16,12 +16,7 @@ */ package com.gemstone.gemfire.internal.cache.ha; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.IOException; import java.util.HashMap; @@ -34,10 +29,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CyclicBarrier; -import junit.framework.Assert; - import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -60,13 +54,9 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest; /** * 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; @@ -86,71 +76,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; } @@ -162,13 +118,9 @@ public class HARegionQueueJUnitTest * 3)Wait till all put-threads complete their job
* 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"); @@ -187,13 +139,9 @@ public class HARegionQueueJUnitTest * 3)Wait till all put-threads complete their job
* 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"); @@ -213,15 +161,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"); @@ -252,10 +196,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; @@ -292,7 +233,6 @@ public class HARegionQueueJUnitTest ThreadUtils.join(putThreads[i], 30 * 1000); } assertFalse(encounteredException); - } /* @@ -300,12 +240,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: @@ -314,25 +253,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 { @@ -396,11 +331,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; @@ -415,77 +347,14 @@ public class HARegionQueueJUnitTest 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; @@ -522,8 +391,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; @@ -534,8 +402,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(); } @@ -567,11 +435,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); @@ -580,29 +446,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); @@ -611,27 +472,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); @@ -641,64 +497,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); @@ -709,40 +545,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); @@ -758,44 +585,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"); @@ -803,26 +624,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); @@ -830,56 +646,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); } } @@ -887,11 +694,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]; @@ -905,59 +710,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"); @@ -981,59 +783,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); @@ -1045,42 +844,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) { @@ -1091,26 +885,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; @@ -1118,11 +911,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", @@ -1137,31 +928,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(); } } @@ -1169,17 +956,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); } @@ -1205,11 +990,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"); @@ -1284,24 +1067,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 @@ -1314,11 +1094,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"); @@ -1390,23 +1168,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 @@ -1420,12 +1195,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"); @@ -1521,26 +1293,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 @@ -1556,11 +1324,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 = @@ -1691,16 +1457,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); } - } /** @@ -1708,10 +1472,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 { @@ -1779,19 +1541,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 { @@ -1858,10 +1617,8 @@ public class HARegionQueueJUnitTest } catch (Exception e) { - fail(" Test failed due to " + e); - e.printStackTrace(); + throw new AssertionError(" Test failed due to ", e); } - } /** @@ -1870,16 +1627,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); @@ -1944,8 +1698,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; @@ -1960,21 +1713,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(); @@ -1985,9 +1737,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; @@ -1996,8 +1746,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" ); @@ -2005,87 +1754,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"); @@ -2094,51 +1831,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/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/Bug39356DUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/Bug39356DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/Bug39356DUnitTest.java index 6bad5a0..90b8ecc 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/Bug39356DUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/Bug39356DUnitTest.java @@ -16,20 +16,14 @@ */ package com.gemstone.gemfire.internal.cache.partitioned; -import org.junit.experimental.categories.Category; -import org.junit.Test; - import static org.junit.Assert.*; -import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; -import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; -import com.gemstone.gemfire.test.junit.categories.DistributedTest; - import java.io.Serializable; import java.util.List; import java.util.Set; -import junit.framework.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.LogWriter; @@ -39,7 +33,6 @@ import com.gemstone.gemfire.cache.DataPolicy; import com.gemstone.gemfire.cache.PartitionAttributes; import com.gemstone.gemfire.cache.PartitionAttributesFactory; import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.distributed.internal.DistributionManager; import com.gemstone.gemfire.distributed.internal.DistributionMessage; import com.gemstone.gemfire.distributed.internal.DistributionMessageObserver; @@ -48,25 +41,19 @@ import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedM import com.gemstone.gemfire.internal.cache.ForceReattemptException; import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore; -import com.gemstone.gemfire.internal.cache.partitioned.ManageBucketMessage; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.SerializableCallable; import com.gemstone.gemfire.test.dunit.SerializableRunnable; import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.dunit.Wait; +import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; - -/** - * - */ @Category(DistributedTest.class) public class Bug39356DUnitTest extends JUnit4CacheTestCase { + protected static final String REGION_NAME = "myregion"; - public Bug39356DUnitTest() { - super(); - } - /** * This tests the case where the VM forcing other * VMs to create a bucket crashes while creating the bucket. @@ -138,9 +125,9 @@ public class Bug39356DUnitTest extends JUnit4CacheTestCase { log.info("skipping bucket " + i + " because it has no data"); continue; } - Assert.assertEquals("Expecting bucket " + i + " to have two copies", 2, owners.size()); + assertEquals("Expecting bucket " + i + " to have two copies", 2, owners.size()); log.info("bucket " + i + " had two copies"); - } + } } }; vm1.invoke(verifyBuckets); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java index 8e537e2..2ef451a 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/InterestListEndpointDUnitTest.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.Properties; -import junit.framework.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -83,11 +82,6 @@ public class InterestListEndpointDUnitTest extends JUnit4DistributedTestCase { static InterestListEndpointDUnitTest impl; - /** constructor */ - public InterestListEndpointDUnitTest() { - super(); - } - @Override public final void postSetUp() throws Exception { disconnectAllFromDS(); @@ -266,8 +260,8 @@ public class InterestListEndpointDUnitTest extends JUnit4DistributedTestCase { public static void verifyUpdaterThreadIsAlive() throws InterruptedException { QueueConnectionImpl conn2 = (QueueConnectionImpl) pool.getPrimaryConnection(); - Assert.assertNotSame(conn1, conn2); - Assert.assertFalse(conn1.getServer().equals(conn2.getServer())); + assertNotSame(conn1, conn2); + assertFalse(conn1.getServer().equals(conn2.getServer())); assertNull(((QueueConnectionImpl)conn1).getUpdater()); assertTrue((conn2).getUpdater().isAlive()); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterDisabledPerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterDisabledPerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterDisabledPerformanceTest.java index 2d76d12..53c10f5 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterDisabledPerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterDisabledPerformanceTest.java @@ -16,14 +16,16 @@ */ package com.gemstone.gemfire.internal.logging; +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + import com.gemstone.gemfire.LogWriter; +import com.gemstone.gemfire.test.junit.categories.PerformanceTest; +@Category(PerformanceTest.class) +@Ignore("Tests have no assertions") public class LogWriterDisabledPerformanceTest extends LogWriterPerformanceTest { - public LogWriterDisabledPerformanceTest(String name) { - super(name); - } - @Override protected PerformanceLogger createPerformanceLogger() { final LogWriter logWriter = createLogWriter(); @@ -41,24 +43,4 @@ public class LogWriterDisabledPerformanceTest extends LogWriterPerformanceTest { return perfLogger; } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterPerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterPerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterPerformanceTest.java index 4498ca6..bcc4786 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterPerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogWriterPerformanceTest.java @@ -16,12 +16,15 @@ */ package com.gemstone.gemfire.internal.logging; +import static org.junit.Assert.*; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; import org.junit.Ignore; +import org.junit.Test; import org.junit.experimental.categories.Category; import com.gemstone.gemfire.LogWriter; @@ -32,16 +35,11 @@ import com.gemstone.gemfire.test.junit.categories.PerformanceTest; /** * Tests performance of logging when level is OFF. - * */ @Category(PerformanceTest.class) @Ignore("Tests have no assertions") public class LogWriterPerformanceTest extends LoggingPerformanceTestCase { - public LogWriterPerformanceTest(String name) { - super(name); - } - protected Properties createGemFireProperties() { final Properties props = new Properties(); this.logFile = new File(this.configDirectory, "gemfire.log"); @@ -86,7 +84,8 @@ public class LogWriterPerformanceTest extends LoggingPerformanceTestCase { appendToFile, isLoner, isSecurityLog, config, logConfig, fosHolder); return logWriter; } - + + @Override protected PerformanceLogger createPerformanceLogger() { final LogWriter logWriter = createLogWriter(); @@ -103,24 +102,4 @@ public class LogWriterPerformanceTest extends LoggingPerformanceTestCase { return perfLogger; } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingPerformanceTestCase.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingPerformanceTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingPerformanceTestCase.java index c7f326f..e8b2f0c 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingPerformanceTestCase.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingPerformanceTestCase.java @@ -16,18 +16,22 @@ */ package com.gemstone.gemfire.internal.logging; +import static org.junit.Assert.*; + import java.io.File; import java.io.IOException; -import com.gemstone.gemfire.internal.util.StopWatch; +import org.junit.After; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; -import junit.framework.TestCase; +import com.gemstone.gemfire.internal.util.StopWatch; /** * Tests performance of logging when level is OFF. - * */ -public abstract class LoggingPerformanceTestCase extends TestCase { +public abstract class LoggingPerformanceTestCase { protected static final boolean TIME_BASED = Boolean.getBoolean("gemfire.test.LoggingPerformanceTestCase.TIME_BASED"); protected static final long TIME_TO_RUN = 1000 * 60 * 10; // ten minutes @@ -38,23 +42,16 @@ public abstract class LoggingPerformanceTestCase extends TestCase { protected File configDirectory = new File(getUniqueName());//null; protected File logFile = new File(configDirectory, getUniqueName()+".log"); - public LoggingPerformanceTestCase(String name) { - super(name); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - } - - @Override - public void tearDown() throws Exception { - super.tearDown(); + @Rule + public TestName testName = new TestName(); + + @After + public void tearDownLoggingPerformanceTestCase() throws Exception { this.configDirectory = null; // leave this directory in place for now } protected String getUniqueName() { - return getClass().getSimpleName() + "_" + getName(); + return getClass().getSimpleName() + "_" + testName.getMethodName(); } protected long performLoggingTest(final PerformanceLogger perfLogger) { @@ -171,22 +168,26 @@ public abstract class LoggingPerformanceTestCase extends TestCase { } protected abstract PerformanceLogger createPerformanceLogger() throws IOException; - + + @Test public void testCountBasedLogging() throws Exception { performCountBasedLoggingTest(createPerformanceLogger()); assertTrue(this.logFile.exists()); } + @Test public void testTimeBasedLogging() throws Exception { performTimeBasedLoggingTest(createPerformanceLogger()); assertTrue(this.logFile.exists()); } + @Test public void testCountBasedIsEnabled() throws Exception { performCountBasedIsEnabledTest(createPerformanceLogger()); assertTrue(this.logFile.exists()); } + @Test public void testTimeBasedIsEnabled() throws Exception { performTimeBasedIsEnabledTest(createPerformanceLogger()); assertTrue(this.logFile.exists()); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/TestLogWriterFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/TestLogWriterFactory.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/TestLogWriterFactory.java index 786565a..d0f5970 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/TestLogWriterFactory.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/TestLogWriterFactory.java @@ -22,7 +22,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; -import junit.framework.Assert; +import org.junit.Assert; import com.gemstone.gemfire.GemFireIOException; import com.gemstone.gemfire.LogWriter; @@ -36,7 +36,6 @@ import com.gemstone.gemfire.internal.util.LogFileUtils; /** * Creates LogWriter instances for testing. - * */ public class TestLogWriterFactory extends Assert { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2DisabledPerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2DisabledPerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2DisabledPerformanceTest.java index caedadc..90428b4 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2DisabledPerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2DisabledPerformanceTest.java @@ -29,45 +29,22 @@ import com.gemstone.gemfire.test.junit.categories.PerformanceTest; @Ignore("Tests have no assertions") public class Log4J2DisabledPerformanceTest extends Log4J2PerformanceTest { - public Log4J2DisabledPerformanceTest(String name) { - super(name); - } - @Override protected PerformanceLogger createPerformanceLogger() throws IOException { final Logger logger = createLogger(); - + final PerformanceLogger perfLogger = new PerformanceLogger() { @Override public void log(String message) { logger.debug(message); } + @Override public boolean isEnabled() { return logger.isEnabled(Level.DEBUG); } }; - - return perfLogger; - } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); + return perfLogger; } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2PerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2PerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2PerformanceTest.java index 1ad30bd..c46f880 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2PerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/Log4J2PerformanceTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.internal.logging.log4j; +import static org.junit.Assert.*; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -28,6 +30,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.ConfigurationFactory; +import org.junit.After; import org.junit.Ignore; import org.junit.experimental.categories.Category; @@ -49,13 +52,8 @@ public class Log4J2PerformanceTest extends LoggingPerformanceTestCase { private File config = null; - public Log4J2PerformanceTest(String name) { - super(name); - } - - @Override - public void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDownLog4J2PerformanceTest() throws Exception { this.config = null; // leave this file in place for now } @@ -111,7 +109,8 @@ public class Log4J2PerformanceTest extends LoggingPerformanceTestCase { final Logger logger = LogManager.getLogger(); return logger; } - + + @Override protected PerformanceLogger createPerformanceLogger() throws IOException { final Logger logger = createLogger(); @@ -128,24 +127,4 @@ public class Log4J2PerformanceTest extends LoggingPerformanceTestCase { return perfLogger; } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java index 4be34c7..42472f8 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerDisabledPerformanceTest.java @@ -29,10 +29,7 @@ import com.gemstone.gemfire.test.junit.categories.PerformanceTest; @Ignore("Tests have no assertions") public class LogWriterLoggerDisabledPerformanceTest extends LogWriterLoggerPerformanceTest { - public LogWriterLoggerDisabledPerformanceTest(String name) { - super(name); - } - + @Override protected PerformanceLogger createPerformanceLogger() throws IOException { final Logger logger = createLogger(); @@ -49,24 +46,4 @@ public class LogWriterLoggerDisabledPerformanceTest extends LogWriterLoggerPerfo return perfLogger; } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerPerformanceTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerPerformanceTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerPerformanceTest.java index 3d8ee46..a079213 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerPerformanceTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterLoggerPerformanceTest.java @@ -16,6 +16,8 @@ */ package com.gemstone.gemfire.internal.logging.log4j; +import static org.junit.Assert.*; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -27,6 +29,7 @@ import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.ConfigurationFactory; +import org.junit.After; import org.junit.Ignore; import org.junit.experimental.categories.Category; @@ -48,13 +51,8 @@ public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase { private File config = null; - public LogWriterLoggerPerformanceTest(String name) { - super(name); - } - - @Override - public void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDownLogWriterLoggerPerformanceTest() throws Exception { this.config = null; // leave this file in place for now } @@ -64,7 +62,7 @@ public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase { pw.close(); } - protected void setPropertySubstitutionValues(final String logFile, + protected void setPropertySubstitutionValues(final String logFile, final int logFileSizeLimitMB, final int logFileCountLimit) { if (logFileSizeLimitMB < 0) { @@ -84,7 +82,7 @@ public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase { System.setProperty(SYS_LOG_FILE_SIZE_LIMIT, logFileSizeLimitMBValue); System.setProperty(SYS_LOG_FILE_COUNT_LIMIT, logFileCountLimitValue); } - + protected Logger createLogger() throws IOException { // create configuration with log-file and log-level this.configDirectory = new File(getUniqueName()); @@ -110,7 +108,8 @@ public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase { final Logger logger = LogWriterLogger.create(this.getClass().getName(), false); return logger; } - + + @Override protected PerformanceLogger createPerformanceLogger() throws IOException { final Logger logger = createLogger(); @@ -127,24 +126,4 @@ public class LogWriterLoggerPerformanceTest extends LoggingPerformanceTestCase { return perfLogger; } - - @Override - public void testCountBasedLogging() throws Exception { - super.testCountBasedLogging(); - } - - @Override - public void testTimeBasedLogging() throws Exception { - super.testTimeBasedLogging(); - } - - @Override - public void testCountBasedIsEnabled() throws Exception { - super.testCountBasedIsEnabled(); - } - - @Override - public void testTimeBasedIsEnabled() throws Exception { - super.testTimeBasedIsEnabled(); - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/497208f2/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONFormatterJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONFormatterJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONFormatterJUnitTest.java index 458c020..b84307c 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONFormatterJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/JSONFormatterJUnitTest.java @@ -16,7 +16,7 @@ */ package com.gemstone.gemfire.pdx; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.text.SimpleDateFormat; @@ -47,10 +47,6 @@ public class JSONFormatterJUnitTest { private GemFireCacheImpl c; private final String PRIMITIVE_KV_STORE_REGION = "primitiveKVStore"; - public JSONFormatterJUnitTest() { - super(); - } - @Before public void setUp() throws Exception { this.c = (GemFireCacheImpl) new CacheFactory().set("mcast-port", "0").setPdxReadSerialized(true).create(); @@ -153,43 +149,43 @@ public class JSONFormatterJUnitTest { //Testcase-1: Validate json string against the pdxInstance. //validation for primitive types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Int type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Int type values are not matched", testObject.getP_int(), jsonObject.getInt(testObject.getP_intFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: long type values are not matched", + assertEquals("VerifyPdxInstanceToJson: long type values are not matched", testObject.getP_long(), jsonObject.getLong(testObject.getP_longFN())); //validation for wrapper types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Boolean type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Boolean type values are not matched", testObject.getW_bool().booleanValue(), jsonObject.getBoolean(testObject.getW_boolFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Float type values are not matched", - testObject.getW_double().doubleValue(), jsonObject.getDouble(testObject.getW_doubleFN())); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: bigDec type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Float type values are not matched", + testObject.getW_double().doubleValue(), jsonObject.getDouble(testObject.getW_doubleFN()), 0); + assertEquals("VerifyPdxInstanceToJson: bigDec type values are not matched", testObject.getW_bigDec().longValue(), jsonObject.getLong(testObject.getW_bigDecFN())); //vlidation for array types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Byte[] type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Byte[] type values are not matched", (int)testObject.getW_byteArray()[1], jsonObject.getJSONArray(testObject.getW_byteArrayFN()).getInt(1)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Double[] type values are not matched", - testObject.getW_doubleArray()[0], jsonObject.getJSONArray(testObject.getW_doubleArrayFN()).getDouble(0)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: String[] type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Double[] type values are not matched", + testObject.getW_doubleArray()[0], jsonObject.getJSONArray(testObject.getW_doubleArrayFN()).getDouble(0), 0); + assertEquals("VerifyPdxInstanceToJson: String[] type values are not matched", testObject.getW_strArray()[2], jsonObject.getJSONArray(testObject.getW_strArrayFN()).getString(2)); //validation for collection types - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: list type values are not matched", + assertEquals("VerifyPdxInstanceToJson: list type values are not matched", testObject.getC_list().get(0), jsonObject.getJSONArray(testObject.getC_listFN()).getString(0)); - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: stack type values are not matched", + assertEquals("VerifyPdxInstanceToJson: stack type values are not matched", testObject.getC_stack().get(2), jsonObject.getJSONArray(testObject.getC_stackFN()).getString(2)); //validation for Map - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Map type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Map type values are not matched", testObject.getM_empByCity().get("Ahmedabad").get(0).getFname(), jsonObject.getJSONObject(testObject.getM_empByCityFN()).getJSONArray("Ahmedabad").getJSONObject(0).getString("fname")); //validation Enum - junit.framework.Assert.assertEquals("VerifyPdxInstanceToJson: Enum type values are not matched", + assertEquals("VerifyPdxInstanceToJson: Enum type values are not matched", testObject.getDay().toString(), jsonObject.getString(testObject.getDayFN()));