You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/06/09 20:14:38 UTC
[10/70] [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/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 f303d35..12f2744 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,21 +16,29 @@
*/
package com.gemstone.gemfire.internal.logging.log4j;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.FileUtil;
-import com.gemstone.gemfire.internal.logging.LoggingPerformanceTestCase;
-import com.gemstone.gemfire.internal.util.IOUtils;
-import com.gemstone.gemfire.test.junit.categories.PerformanceTest;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+
import org.apache.commons.io.FileUtils;
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;
-import java.io.*;
-import java.net.URL;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.FileUtil;
+import com.gemstone.gemfire.internal.logging.LoggingPerformanceTestCase;
+import com.gemstone.gemfire.internal.util.IOUtils;
+import com.gemstone.gemfire.test.junit.categories.PerformanceTest;
@Category(PerformanceTest.class)
@Ignore("Tests have no assertions")
@@ -45,13 +53,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
}
@@ -107,7 +110,8 @@ public class Log4J2PerformanceTest extends LoggingPerformanceTestCase {
final Logger logger = LogManager.getLogger();
return logger;
}
-
+
+ @Override
protected PerformanceLogger createPerformanceLogger() throws IOException {
final Logger logger = createLogger();
@@ -124,24 +128,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/b914df23/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/b914df23/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 f186672..3eb6602 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,20 +16,28 @@
*/
package com.gemstone.gemfire.internal.logging.log4j;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.FileUtil;
-import com.gemstone.gemfire.internal.logging.LoggingPerformanceTestCase;
-import com.gemstone.gemfire.internal.util.IOUtils;
-import com.gemstone.gemfire.test.junit.categories.PerformanceTest;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+
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;
-import java.io.*;
-import java.net.URL;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.FileUtil;
+import com.gemstone.gemfire.internal.logging.LoggingPerformanceTestCase;
+import com.gemstone.gemfire.internal.util.IOUtils;
+import com.gemstone.gemfire.test.junit.categories.PerformanceTest;
@Category(PerformanceTest.class)
@Ignore("Tests have no assertions")
@@ -44,13 +52,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
}
@@ -60,7 +63,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) {
@@ -80,7 +83,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());
@@ -106,7 +109,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();
@@ -123,24 +127,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/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
index 43406d3..02a8050 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
@@ -16,11 +16,24 @@
*/
package com.gemstone.gemfire.internal.offheap;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.jayway.awaitility.Awaitility.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.OutOfOffHeapMemoryException;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
@@ -28,40 +41,25 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.cache.DistributedRegion;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.OffHeapTestUtil;
-import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.internal.util.StopWatch;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.IgnoredException;
import com.gemstone.gemfire.test.dunit.Invoke;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import org.apache.logging.log4j.Logger;
-
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
-import static com.jayway.awaitility.Awaitility.with;
-import static org.hamcrest.CoreMatchers.equalTo;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* Test behavior of region when running out of off-heap memory.
- *
*/
+@Category(DistributedTest.class)
@SuppressWarnings("serial")
-public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
- private static final Logger logger = LogService.getLogger();
-
+public class OutOfOffHeapMemoryDUnitTest extends JUnit4CacheTestCase {
+
protected static final AtomicReference<Cache> cache = new AtomicReference<Cache>();
protected static final AtomicReference<DistributedSystem> system = new AtomicReference<DistributedSystem>();
protected static final AtomicBoolean isSmallerVM = new AtomicBoolean();
- public OutOfOffHeapMemoryDUnitTest(String name) {
- super(name);
- }
-
@Override
public final void preSetUp() throws Exception {
disconnectAllFromDS();
@@ -124,6 +122,7 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
return props;
}
+ @Test
public void testSimpleOutOfOffHeapMemoryMemberDisconnects() {
final DistributedSystem system = getSystem();
final Cache cache = getCache();
@@ -194,6 +193,7 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
}
}
+ @Test
public void testOtherMembersSeeOutOfOffHeapMemoryMemberDisconnects() {
final int vmCount = Host.getHost(0).getVMCount();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherDUnitTest.java
index 8d037b2..692b2a5 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherDUnitTest.java
@@ -16,26 +16,33 @@
*/
package com.gemstone.gemfire.internal.process;
+import static org.junit.Assert.*;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* Multi-process tests for ProcessLauncher.
*
* @since GemFire 7.0
*/
+@Category(DistributedTest.class)
@SuppressWarnings("serial")
-public class LocalProcessLauncherDUnitTest extends DistributedTestCase {
+public class LocalProcessLauncherDUnitTest extends JUnit4DistributedTestCase {
- public LocalProcessLauncherDUnitTest(String name) {
- super(name);
+ public LocalProcessLauncherDUnitTest() {
+ super();
}
@Override
@@ -43,6 +50,7 @@ public class LocalProcessLauncherDUnitTest extends DistributedTestCase {
new File(getClass().getSimpleName()).mkdir();
}
+ @Test
public void testExistingPidFileThrows() throws Exception {
final File pidFile = new File(getClass().getSimpleName()
+ File.separator + "testExistingPidFileThrows.pid");
@@ -71,6 +79,7 @@ public class LocalProcessLauncherDUnitTest extends DistributedTestCase {
});
}
+ @Test
public void testForceReplacesExistingPidFile() throws Exception {
final File pidFile = new File(getClass().getSimpleName()
+ File.separator + "testForceReplacesExistingPidFile.pid");
@@ -111,6 +120,7 @@ public class LocalProcessLauncherDUnitTest extends DistributedTestCase {
});
}
+ @Test
public void testPidFileReadByOtherProcess() throws Exception {
final File pidFile = new File(getClass().getSimpleName()
+ File.separator + "testPidFileReadByOtherProcess.pid");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java
index 09cf61a..5f46199 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsDUnitTest.java
@@ -17,31 +17,63 @@
package com.gemstone.gemfire.internal.statistics;
import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
-import com.gemstone.gemfire.*;
-import com.gemstone.gemfire.cache.*;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.StatisticDescriptor;
+import com.gemstone.gemfire.Statistics;
+import com.gemstone.gemfire.StatisticsFactory;
+import com.gemstone.gemfire.StatisticsType;
+import com.gemstone.gemfire.StatisticsTypeFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheListener;
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionEvent;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.Scope;
import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
import com.gemstone.gemfire.cache.util.RegionMembershipListenerAdapter;
import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
-import com.gemstone.gemfire.internal.*;
+import com.gemstone.gemfire.internal.GemFireStatSampler;
+import com.gemstone.gemfire.internal.NanoTimer;
+import com.gemstone.gemfire.internal.StatArchiveReader;
import com.gemstone.gemfire.internal.StatArchiveReader.StatSpec;
import com.gemstone.gemfire.internal.StatArchiveReader.StatValue;
+import com.gemstone.gemfire.internal.StatSamplerStats;
+import com.gemstone.gemfire.internal.StatisticsTypeFactoryImpl;
import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.atomic.AtomicReferenceArray;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.SerializableCallable;
+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.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* Integration tests for Statistics. VM0 performs puts and VM1 receives
@@ -56,7 +88,8 @@ import java.util.regex.Pattern;
* @since GemFire 7.0
*/
@SuppressWarnings("serial")
-public class StatisticsDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class StatisticsDUnitTest extends JUnit4CacheTestCase {
private static final String dir = "StatisticsDUnitTest";
@@ -94,8 +127,8 @@ public class StatisticsDUnitTest extends CacheTestCase {
return puts.get();
}
- public StatisticsDUnitTest(String name) {
- super(name);
+ public StatisticsDUnitTest() {
+ super();
}
@Override
@@ -104,6 +137,7 @@ public class StatisticsDUnitTest extends CacheTestCase {
disconnectAllFromDS(); // because this test enabled stat sampling!
}
+ @Test
public void testPubAndSubCustomStats() throws Exception {
final String testName = "testPubAndSubCustomStats";
@@ -404,7 +438,7 @@ public class StatisticsDUnitTest extends CacheTestCase {
double mean = sv.getSnapshotsAverage();
double stdDev = sv.getSnapshotsStandardDeviation();
- assertEquals(mostRecent, max);
+ assertEquals(mostRecent, max, 0f);
double summation = 0;
double[] rawSnapshots = sv.getRawSnapshots();
@@ -412,7 +446,7 @@ public class StatisticsDUnitTest extends CacheTestCase {
//log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]);
summation += rawSnapshots[j];
}
- assertEquals(mean, summation / sv.getSnapshotsSize());
+ assertEquals(mean, summation / sv.getSnapshotsSize(), 0);
combinedPuts += mostRecent;
}
@@ -420,7 +454,7 @@ public class StatisticsDUnitTest extends CacheTestCase {
}
// assert that sum of mostRecent values for all puts equals totalPuts
- assertEquals((double)totalPuts, combinedPuts);
+ assertEquals((double)totalPuts, combinedPuts, 0);
puts.getAndAdd(totalPuts);
}
});
@@ -487,7 +521,7 @@ public class StatisticsDUnitTest extends CacheTestCase {
double mean = sv.getSnapshotsAverage();
double stdDev = sv.getSnapshotsStandardDeviation();
- assertEquals(mostRecent, max);
+ assertEquals(mostRecent, max,0);
double summation = 0;
double[] rawSnapshots = sv.getRawSnapshots();
@@ -495,13 +529,13 @@ public class StatisticsDUnitTest extends CacheTestCase {
//log.convertToLogWriter().info("DEBUG " + ri.getName() + " " + statName + " rawSnapshots[" + j + "] = " + rawSnapshots[j]);
summation += rawSnapshots[j];
}
- assertEquals(mean, summation / sv.getSnapshotsSize());
+ assertEquals(mean, summation / sv.getSnapshotsSize(),0);
combinedUpdateEvents += mostRecent;
}
}
}
- assertEquals((double)totalUpdateEvents, combinedUpdateEvents);
+ assertEquals((double)totalUpdateEvents, combinedUpdateEvents,0);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java
index b13f72f..b671250 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/ValueMonitorJUnitTest.java
@@ -16,6 +16,8 @@
*/
package com.gemstone.gemfire.internal.statistics;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@@ -31,8 +33,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
import com.gemstone.gemfire.StatisticDescriptor;
import com.gemstone.gemfire.Statistics;
import com.gemstone.gemfire.StatisticsType;
@@ -43,8 +43,6 @@ import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-
/**
* Integration test for the SampleCollector class.
*
@@ -55,7 +53,6 @@ public class ValueMonitorJUnitTest {
private Mockery mockContext;
-
@Before
public void setUp() throws Exception {
this.mockContext = new Mockery() {{
@@ -300,8 +297,7 @@ public class ValueMonitorJUnitTest {
assertEquals(1, statCount);
}
- protected StatisticId createStatisticId(
- final StatisticDescriptor descriptor, final Statistics stats) {
+ private StatisticId createStatisticId(final StatisticDescriptor descriptor, final Statistics stats) {
return new StatisticId() {
@Override
@@ -317,8 +313,7 @@ public class ValueMonitorJUnitTest {
};
}
- protected StatisticsNotification createStatisticsNotification(
- final long timeStamp, final Type type, final Number value) {
+ protected StatisticsNotification createStatisticsNotification(final long timeStamp, final Type type, final Number value) {
return new StatisticsNotification() {
@Override
@@ -333,22 +328,22 @@ public class ValueMonitorJUnitTest {
@Override
public Iterator<StatisticId> iterator() {
- return null; // TODO
+ return null;
}
@Override
public Iterator<StatisticId> iterator(StatisticDescriptor statDesc) {
- return null; // TODO
+ return null;
}
@Override
public Iterator<StatisticId> iterator(Statistics statistics) {
- return null; // TODO
+ return null;
}
@Override
public Iterator<StatisticId> iterator(StatisticsType statisticsType) {
- return null; // TODO
+ return null;
}
@Override
@@ -361,9 +356,11 @@ public class ValueMonitorJUnitTest {
private static void waitForNotification(final List<StatisticsNotification> notifications, long ms, long interval, boolean throwOnTimeout) {
WaitCriterion wc = new WaitCriterion() {
+ @Override
public boolean done() {
return notifications.size() > 0;
}
+ @Override
public String description() {
return "waiting for notification";
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ConcurrentHashMapIteratorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ConcurrentHashMapIteratorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ConcurrentHashMapIteratorJUnitTest.java
index e5aa0fe..ca1fb64 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ConcurrentHashMapIteratorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ConcurrentHashMapIteratorJUnitTest.java
@@ -16,22 +16,28 @@
*/
package com.gemstone.gemfire.internal.util.concurrent;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import junit.framework.TestCase;
-import org.junit.experimental.categories.Category;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
import java.util.concurrent.ConcurrentMap;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-@SuppressWarnings({ "rawtypes", "unchecked" })
@Category(IntegrationTest.class)
-public class ConcurrentHashMapIteratorJUnitTest extends TestCase {
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class ConcurrentHashMapIteratorJUnitTest {
+ @Test
public void test() throws InterruptedException {
-
//Apparently, we need a distributed system to create
//this CHM, because it's locks use DS properties.
Properties props = new Properties();
@@ -46,14 +52,9 @@ public class ConcurrentHashMapIteratorJUnitTest extends TestCase {
assertEquals(baselineMap, testMap);
initialSet = new HashMap(baselineMap);
-// putter = new Putter(baselineMap, testMap, 1000, 2000);
-// putter.run();
-
-
RandomMutations randomer = new RandomMutations(baselineMap, testMap, 1001, 50000);
randomer.start();
-
for(int i = 0; i < 1000; i++) {
checkForInitialSet(i, testMap, initialSet);
}
@@ -71,23 +72,22 @@ public class ConcurrentHashMapIteratorJUnitTest extends TestCase {
fail("On run " + i + " did not find these elements of the initial set using the iterator " + missed);
}
}
-
- public void createBaseline(ConcurrentMap baselineMap, ConcurrentMap testMap,
+
+ private void createBaseline(ConcurrentMap baselineMap, ConcurrentMap testMap,
int start, int end) {
for(int i = start; i < end; i++) {
baselineMap.put(i, i);
testMap.put(i, i);
}
}
-
- public static class RandomMutations extends Thread {
+
+ private static class RandomMutations extends Thread {
private final ConcurrentMap baselineMap;
private final ConcurrentMap testMap;
private int start;
private int end;
private volatile boolean done;
-
-
+
public RandomMutations(ConcurrentMap baselineMap, ConcurrentMap testMap, int start, int end) {
this.baselineMap = baselineMap;
this.testMap = testMap;
@@ -95,6 +95,7 @@ public class ConcurrentHashMapIteratorJUnitTest extends TestCase {
this.end = end;
}
+ @Override
public void run() {
Random random = new Random();
while(!done) {
@@ -115,6 +116,4 @@ public class ConcurrentHashMapIteratorJUnitTest extends TestCase {
this.join();
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMapJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMapJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMapJUnitTest.java
index 6a3142e..c223aff 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMapJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CopyOnWriteHashMapJUnitTest.java
@@ -23,6 +23,8 @@
*/
package com.gemstone.gemfire.internal.util.concurrent;
+import static org.junit.Assert.*;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -36,6 +38,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.util.concurrent.cm.ConcurrentHashMapJUnitTest;
@@ -46,11 +49,7 @@ import com.gemstone.gemfire.util.JSR166TestCase;
* Adopted from the JSR166 test cases. {@link ConcurrentHashMapJUnitTest}
*/
@Category(IntegrationTest.class)
-public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
-
- public CopyOnWriteHashMapJUnitTest(String name) {
- super(name);
- }
+public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase { // TODO: reformat
/**
* Create a map from Integers 1-5 to Strings "A"-"E".
@@ -75,6 +74,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* clear removes all pairs
*/
+ @Test
public void testClear() {
CopyOnWriteHashMap map = map5();
map.clear();
@@ -84,6 +84,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* Maps with same contents are equal
*/
+ @Test
public void testEquals() {
CopyOnWriteHashMap map1 = map5();
CopyOnWriteHashMap map2 = map5();
@@ -97,6 +98,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* containsKey returns true for contained key
*/
+ @Test
public void testContainsKey() {
CopyOnWriteHashMap map = map5();
assertTrue(map.containsKey(one));
@@ -106,6 +108,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* containsValue returns true for held values
*/
+ @Test
public void testContainsValue() {
CopyOnWriteHashMap map = map5();
assertTrue(map.containsValue("A"));
@@ -116,6 +119,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
* get returns the correct element at the given key,
* or null if not present
*/
+ @Test
public void testGet() {
CopyOnWriteHashMap map = map5();
assertEquals("A", (String)map.get(one));
@@ -126,6 +130,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* isEmpty is true of empty map and false for non-empty
*/
+ @Test
public void testIsEmpty() {
CopyOnWriteHashMap empty = newMap();
CopyOnWriteHashMap map = map5();
@@ -136,6 +141,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* keySet returns a Set containing all the keys
*/
+ @Test
public void testKeySet() {
CopyOnWriteHashMap map = map5();
Set s = map.keySet();
@@ -150,6 +156,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* keySet.toArray returns contains all keys
*/
+ @Test
public void testKeySetToArray() {
CopyOnWriteHashMap map = map5();
Set s = map.keySet();
@@ -163,6 +170,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* Values.toArray contains all values
*/
+ @Test
public void testValuesToArray() {
CopyOnWriteHashMap map = map5();
Collection v = map.values();
@@ -179,6 +187,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* entrySet.toArray contains all entries
*/
+ @Test
public void testEntrySetToArray() {
CopyOnWriteHashMap map = map5();
Set s = map.entrySet();
@@ -193,6 +202,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* values collection contains all values
*/
+ @Test
public void testValues() {
CopyOnWriteHashMap map = map5();
Collection s = map.values();
@@ -207,6 +217,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* entrySet contains all pairs
*/
+ @Test
public void testEntrySet() {
CopyOnWriteHashMap map = map5();
Set s = map.entrySet();
@@ -226,6 +237,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* putAll adds all key-value pairs from the given map
*/
+ @Test
public void testPutAll() {
CopyOnWriteHashMap empty = newMap();
CopyOnWriteHashMap map = map5();
@@ -241,6 +253,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent works when the given key is not present
*/
+ @Test
public void testPutIfAbsent() {
CopyOnWriteHashMap map = map5();
map.putIfAbsent(six, "Z");
@@ -250,6 +263,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent does not add the pair if the key is already present
*/
+ @Test
public void testPutIfAbsent2() {
CopyOnWriteHashMap map = map5();
assertEquals("A", map.putIfAbsent(one, "Z"));
@@ -258,6 +272,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace fails when the given key is not present
*/
+ @Test
public void testReplace() {
CopyOnWriteHashMap map = map5();
assertNull(map.replace(six, "Z"));
@@ -267,6 +282,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace succeeds if the key is already present
*/
+ @Test
public void testReplace2() {
CopyOnWriteHashMap map = map5();
assertNotNull(map.replace(one, "Z"));
@@ -277,6 +293,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace value fails when the given key not mapped to expected value
*/
+ @Test
public void testReplaceValue() {
CopyOnWriteHashMap map = map5();
assertEquals("A", map.get(one));
@@ -287,6 +304,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace value succeeds when the given key mapped to expected value
*/
+ @Test
public void testReplaceValue2() {
CopyOnWriteHashMap map = map5();
assertEquals("A", map.get(one));
@@ -298,6 +316,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* remove removes the correct key-value pair from the map
*/
+ @Test
public void testRemove() {
CopyOnWriteHashMap map = map5();
map.remove(five);
@@ -308,6 +327,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* remove(key,value) removes only if pair present
*/
+ @Test
public void testRemove2() {
CopyOnWriteHashMap map = map5();
map.remove(five, "E");
@@ -322,6 +342,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* size returns the correct values
*/
+ @Test
public void testSize() {
CopyOnWriteHashMap map = map5();
CopyOnWriteHashMap empty = newMap();
@@ -332,6 +353,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* toString contains toString of elements
*/
+ @Test
public void testToString() {
CopyOnWriteHashMap map = map5();
String s = map.toString();
@@ -345,6 +367,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* get(null) throws NPE
*/
+ @Test
public void testGetNull() {
CopyOnWriteHashMap c = newMap();
assertNull(c.get(null));
@@ -353,6 +376,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* containsKey(null) throws NPE
*/
+ @Test
public void testContainsKeyNull() {
CopyOnWriteHashMap c = newMap();
assertFalse(c.containsKey(null));
@@ -361,6 +385,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* containsValue(null) throws NPE
*/
+ @Test
public void testContainsValue_NullPointerException() {
CopyOnWriteHashMap c = newMap();
assertFalse(c.containsValue(null));
@@ -369,6 +394,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* put(null,x) throws NPE
*/
+ @Test
public void testPut1NullKey() {
CopyOnWriteHashMap c = newMap();
c.put(null, "whatever");
@@ -379,6 +405,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* put(x, null) throws NPE
*/
+ @Test
public void testPut2NullValue() {
CopyOnWriteHashMap c = newMap();
c.put("whatever", null);
@@ -389,6 +416,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent(null, x) throws NPE
*/
+ @Test
public void testPutIfAbsent1NullKey() {
CopyOnWriteHashMap c = newMap();
c.putIfAbsent(null, "whatever");
@@ -399,6 +427,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace(null, x) throws NPE
*/
+ @Test
public void testReplace_NullPointerException() {
CopyOnWriteHashMap c = newMap();
assertNull(c.replace(null, "whatever"));
@@ -407,6 +436,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace(null, x, y) throws NPE
*/
+ @Test
public void testReplaceValueNullKey() {
CopyOnWriteHashMap c = newMap();
c.replace(null, one, "whatever");
@@ -416,6 +446,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent(x, null) throws NPE
*/
+ @Test
public void testPutIfAbsent2_NullPointerException() {
CopyOnWriteHashMap c = newMap();
c.putIfAbsent("whatever", null);
@@ -427,6 +458,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, null) throws NPE
*/
+ @Test
public void testReplace2Null() {
CopyOnWriteHashMap c = newMap();
c.replace("whatever", null);
@@ -437,6 +469,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, null, y) throws NPE
*/
+ @Test
public void testReplaceValue2Null() {
CopyOnWriteHashMap c = newMap();
c.replace("whatever", null, "A");
@@ -446,6 +479,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, y, null) throws NPE
*/
+ @Test
public void testReplaceValue3Null() {
CopyOnWriteHashMap c = newMap();
c.replace("whatever", one, null);
@@ -456,6 +490,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* remove(null) throws NPE
*/
+ @Test
public void testRemoveNull() {
CopyOnWriteHashMap c = newMap();
c.put("sadsdf", "asdads");
@@ -465,6 +500,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* remove(null, x) throws NPE
*/
+ @Test
public void testRemove2_NullPointerException() {
CopyOnWriteHashMap c = newMap();
c.put("sadsdf", "asdads");
@@ -474,6 +510,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* remove(x, null) returns false
*/
+ @Test
public void testRemove3() {
try {
CopyOnWriteHashMap c = newMap();
@@ -487,6 +524,7 @@ public class CopyOnWriteHashMapJUnitTest extends JSR166TestCase{
/**
* A deserialized map equals original
*/
+ @Test
public void testSerialization() throws Exception {
CopyOnWriteHashMap q = map5();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/ConcurrentHashMapJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/ConcurrentHashMapJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/ConcurrentHashMapJUnitTest.java
index bd29b6b..b8a52fb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/ConcurrentHashMapJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/ConcurrentHashMapJUnitTest.java
@@ -23,27 +23,31 @@
*/
package com.gemstone.gemfire.internal.util.concurrent.cm;
-import java.io.*;
+import static org.junit.Assert.*;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Set;
import java.util.Collection;
-import java.util.ArrayList;
-import java.util.Map;
+import java.util.Enumeration;
import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.util.concurrent.CustomEntryConcurrentHashMap;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
-
- public ConcurrentHashMapJUnitTest(String name) {
- super(name);
- }
+public class ConcurrentHashMapJUnitTest extends JSR166TestCase { // TODO: reformat
/**
* Create a map from Integers 1-5 to Strings "A"-"E".
@@ -64,6 +68,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* clear removes all pairs
*/
+ @Test
public void testClear() {
CustomEntryConcurrentHashMap map = map5();
map.clear();
@@ -73,6 +78,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* Maps with same contents are equal
*/
+ @Test
public void testEquals() {
CustomEntryConcurrentHashMap map1 = map5();
CustomEntryConcurrentHashMap map2 = map5();
@@ -86,6 +92,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* contains returns true for contained value
*/
+ @Test
public void testContains() {
CustomEntryConcurrentHashMap map = map5();
assertTrue(map.contains("A"));
@@ -95,6 +102,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* containsKey returns true for contained key
*/
+ @Test
public void testContainsKey() {
CustomEntryConcurrentHashMap map = map5();
assertTrue(map.containsKey(one));
@@ -104,6 +112,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* containsValue returns true for held values
*/
+ @Test
public void testContainsValue() {
CustomEntryConcurrentHashMap map = map5();
assertTrue(map.containsValue("A"));
@@ -114,6 +123,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
* enumeration returns an enumeration containing the correct
* elements
*/
+ @Test
public void testEnumeration() {
CustomEntryConcurrentHashMap map = map5();
Enumeration e = map.elements();
@@ -129,6 +139,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
* get returns the correct element at the given key,
* or null if not present
*/
+ @Test
public void testGet() {
CustomEntryConcurrentHashMap map = map5();
assertEquals("A", (String)map.get(one));
@@ -139,6 +150,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* isEmpty is true of empty map and false for non-empty
*/
+ @Test
public void testIsEmpty() {
CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
CustomEntryConcurrentHashMap map = map5();
@@ -149,6 +161,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* keys returns an enumeration containing all the keys from the map
*/
+ @Test
public void testKeys() {
CustomEntryConcurrentHashMap map = map5();
Enumeration e = map.keys();
@@ -163,6 +176,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* keySet returns a Set containing all the keys
*/
+ @Test
public void testKeySet() {
CustomEntryConcurrentHashMap map = map5();
Set s = map.keySet();
@@ -177,6 +191,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* keySet.toArray returns contains all keys
*/
+ @Test
public void testKeySetToArray() {
CustomEntryConcurrentHashMap map = map5();
Set s = map.keySet();
@@ -190,6 +205,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* Values.toArray contains all values
*/
+ @Test
public void testValuesToArray() {
CustomEntryConcurrentHashMap map = map5();
Collection v = map.values();
@@ -206,6 +222,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* entrySet.toArray contains all entries
*/
+ @Test
public void testEntrySetToArray() {
CustomEntryConcurrentHashMap map = map5();
Set s = map.entrySet();
@@ -220,6 +237,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* values collection contains all values
*/
+ @Test
public void testValues() {
CustomEntryConcurrentHashMap map = map5();
Collection s = map.values();
@@ -234,6 +252,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* entrySet contains all pairs
*/
+ @Test
public void testEntrySet() {
CustomEntryConcurrentHashMap map = map5();
Set s = map.entrySet();
@@ -253,6 +272,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* putAll adds all key-value pairs from the given map
*/
+ @Test
public void testPutAll() {
CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
CustomEntryConcurrentHashMap map = map5();
@@ -268,6 +288,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent works when the given key is not present
*/
+ @Test
public void testPutIfAbsent() {
CustomEntryConcurrentHashMap map = map5();
map.putIfAbsent(six, "Z");
@@ -277,6 +298,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent does not add the pair if the key is already present
*/
+ @Test
public void testPutIfAbsent2() {
CustomEntryConcurrentHashMap map = map5();
assertEquals("A", map.putIfAbsent(one, "Z"));
@@ -285,6 +307,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace fails when the given key is not present
*/
+ @Test
public void testReplace() {
CustomEntryConcurrentHashMap map = map5();
assertNull(map.replace(six, "Z"));
@@ -294,6 +317,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace succeeds if the key is already present
*/
+ @Test
public void testReplace2() {
CustomEntryConcurrentHashMap map = map5();
assertNotNull(map.replace(one, "Z"));
@@ -304,6 +328,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace value fails when the given key not mapped to expected value
*/
+ @Test
public void testReplaceValue() {
CustomEntryConcurrentHashMap map = map5();
assertEquals("A", map.get(one));
@@ -314,6 +339,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace value succeeds when the given key mapped to expected value
*/
+ @Test
public void testReplaceValue2() {
CustomEntryConcurrentHashMap map = map5();
assertEquals("A", map.get(one));
@@ -325,6 +351,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* remove removes the correct key-value pair from the map
*/
+ @Test
public void testRemove() {
CustomEntryConcurrentHashMap map = map5();
map.remove(five);
@@ -335,6 +362,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* remove(key,value) removes only if pair present
*/
+ @Test
public void testRemove2() {
CustomEntryConcurrentHashMap map = map5();
map.remove(five, "E");
@@ -349,6 +377,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* size returns the correct values
*/
+ @Test
public void testSize() {
CustomEntryConcurrentHashMap map = map5();
CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
@@ -359,6 +388,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* toString contains toString of elements
*/
+ @Test
public void testToString() {
CustomEntryConcurrentHashMap map = map5();
String s = map.toString();
@@ -372,6 +402,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* Cannot create with negative capacity
*/
+ @Test
public void testConstructor1() {
try {
new CustomEntryConcurrentHashMap(-1,0,1);
@@ -382,6 +413,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* Cannot create with negative concurrency level
*/
+ @Test
public void testConstructor2() {
try {
new CustomEntryConcurrentHashMap(1,0,-1);
@@ -392,6 +424,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* Cannot create with only negative capacity
*/
+ @Test
public void testConstructor3() {
try {
new CustomEntryConcurrentHashMap(-1);
@@ -402,6 +435,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* get(null) throws NPE
*/
+ @Test
public void testGet_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -413,6 +447,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* containsKey(null) throws NPE
*/
+ @Test
public void testContainsKey_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -424,6 +459,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* containsValue(null) throws NPE
*/
+ @Test
public void testContainsValue_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -435,6 +471,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* contains(null) throws NPE
*/
+ @Test
public void testContains_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -446,6 +483,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* put(null,x) throws NPE
*/
+ @Test
public void testPut1_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -457,6 +495,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* put(x, null) throws NPE
*/
+ @Test
public void testPut2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -468,6 +507,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent(null, x) throws NPE
*/
+ @Test
public void testPutIfAbsent1_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -479,6 +519,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace(null, x) throws NPE
*/
+ @Test
public void testReplace_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -490,6 +531,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace(null, x, y) throws NPE
*/
+ @Test
public void testReplaceValue_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -501,6 +543,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* putIfAbsent(x, null) throws NPE
*/
+ @Test
public void testPutIfAbsent2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -513,6 +556,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, null) throws NPE
*/
+ @Test
public void testReplace2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -524,6 +568,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, null, y) throws NPE
*/
+ @Test
public void testReplaceValue2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -535,6 +580,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* replace(x, y, null) throws NPE
*/
+ @Test
public void testReplaceValue3_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -547,6 +593,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* remove(null) throws NPE
*/
+ @Test
public void testRemove1_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -559,6 +606,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* remove(null, x) throws NPE
*/
+ @Test
public void testRemove2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -571,6 +619,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* remove(x, null) returns false
*/
+ @Test
public void testRemove3() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
@@ -584,6 +633,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* A deserialized map equals original
*/
+ @Test
public void testSerialization() {
CustomEntryConcurrentHashMap q = map5();
@@ -609,6 +659,7 @@ public class ConcurrentHashMapJUnitTest extends JSR166TestCase{
/**
* SetValue of an EntrySet entry sets value in the map.
*/
+ @Test
public void testSetValueWriteThrough() {
// Adapted from a bug report by Eric Zoerner
CustomEntryConcurrentHashMap map = new CustomEntryConcurrentHashMap(2, 5.0f, 1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/CountedMapLoopsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/CountedMapLoopsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/CountedMapLoopsJUnitTest.java
index fed909f..bba6ffb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/CountedMapLoopsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/CountedMapLoopsJUnitTest.java
@@ -37,13 +37,14 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class CountedMapLoopsJUnitTest extends JSR166TestCase {
+public class CountedMapLoopsJUnitTest extends JSR166TestCase { // TODO: reformat
static int nkeys = 100000;
static int pinsert = 60;
@@ -55,10 +56,7 @@ public class CountedMapLoopsJUnitTest extends JSR166TestCase {
static final ExecutorService pool = Executors.newCachedThreadPool();
- public CountedMapLoopsJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testCountedMapLoops() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/IntMapCheckJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/IntMapCheckJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/IntMapCheckJUnitTest.java
index 1534f93..c04f724 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/IntMapCheckJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/IntMapCheckJUnitTest.java
@@ -25,22 +25,29 @@
*/
package com.gemstone.gemfire.internal.util.concurrent.cm;
-import java.io.*;
-import java.util.Map;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.Set;
+import java.util.IdentityHashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Random;
-import java.util.IdentityHashMap;
-import java.util.Enumeration;
+import java.util.Set;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class IntMapCheckJUnitTest extends JSR166TestCase {
+public class IntMapCheckJUnitTest extends JSR166TestCase { // TODO: reformat
static int absentSize;
static int absentMask;
@@ -52,10 +59,7 @@ public class IntMapCheckJUnitTest extends JSR166TestCase {
if (!b) throw new Error("Failed Assertion");
}
- public IntMapCheckJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testIntMapCheck() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapCheckJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapCheckJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapCheckJUnitTest.java
index e1330c3..db2c63a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapCheckJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapCheckJUnitTest.java
@@ -25,22 +25,29 @@
*/
package com.gemstone.gemfire.internal.util.concurrent.cm;
-import java.io.*;
-import java.util.Map;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.IdentityHashMap;
import java.util.Iterator;
-import java.util.Set;
+import java.util.Map;
import java.util.Random;
-import java.util.IdentityHashMap;
-import java.util.Enumeration;
+import java.util.Set;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class MapCheckJUnitTest extends JSR166TestCase {
+public class MapCheckJUnitTest extends JSR166TestCase { // TODO: reformat
static final int absentSize = 1 << 17;
static final int absentMask = absentSize - 1;
@@ -54,10 +61,7 @@ public class MapCheckJUnitTest extends JSR166TestCase {
if (!b) throw new Error("Failed Assertion");
}
- public MapCheckJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testMapCheck() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapLoopsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapLoopsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapLoopsJUnitTest.java
index 58f4647..39baedb 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapLoopsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/MapLoopsJUnitTest.java
@@ -28,7 +28,6 @@
* Expert Group and released to the public domain. Use, modify, and
* redistribute this code in any way without acknowledgement.
*/
-
package com.gemstone.gemfire.internal.util.concurrent.cm;
import java.util.Map;
@@ -37,13 +36,15 @@ import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class MapLoopsJUnitTest extends JSR166TestCase {
+public class MapLoopsJUnitTest extends JSR166TestCase { // TODO: reformat
+
static int nkeys = 1000;
static int pinsert = 60;
static int premove = 2;
@@ -54,10 +55,7 @@ public class MapLoopsJUnitTest extends JSR166TestCase {
static final ExecutorService pool = Executors.newCachedThreadPool();
- public MapLoopsJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testMapLoops() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/RLJBarJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/RLJBarJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/RLJBarJUnitTest.java
index 2de98f3..077c8be 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/RLJBarJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/RLJBarJUnitTest.java
@@ -23,16 +23,16 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class RLJBarJUnitTest extends JSR166TestCase
-{
+public class RLJBarJUnitTest extends JSR166TestCase { // TODO: reformat
- public static final int ITERS = 10;
+ public static final int ITERS = 10;
public static boolean OneKey = false ; // alloc once or once per iteration
public static boolean UseBar = false ;
@@ -47,10 +47,7 @@ public class RLJBarJUnitTest extends JSR166TestCase
public static int quiesce = 0 ;
public static Condition EndCondition = End.newCondition();
- public RLJBarJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testRLJBar() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/StringMapLoopsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/StringMapLoopsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/StringMapLoopsJUnitTest.java
index b8d3462..2945ee6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/StringMapLoopsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/cm/StringMapLoopsJUnitTest.java
@@ -36,13 +36,14 @@ import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.util.JSR166TestCase;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.JSR166TestCase;
@Category(IntegrationTest.class)
-public class StringMapLoopsJUnitTest extends JSR166TestCase {
+public class StringMapLoopsJUnitTest extends JSR166TestCase { // TODO: reformat
static int nkeys = 1000;
static int pinsert = 60;
@@ -54,10 +55,7 @@ public class StringMapLoopsJUnitTest extends JSR166TestCase {
static final ExecutorService pool = Executors.newCachedThreadPool();
- public StringMapLoopsJUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testStringMapLoops() throws Exception {
main(new String[0]);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-core/src/test/java/com/gemstone/gemfire/management/CacheManagementDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/CacheManagementDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/CacheManagementDUnitTest.java
index 9d314dd..8cbbf03 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/CacheManagementDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/CacheManagementDUnitTest.java
@@ -16,7 +16,33 @@
*/
package com.gemstone.gemfire.management;
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.jayway.awaitility.Awaitility.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMException;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.FixedPartitionAttributes;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -25,17 +51,13 @@ import com.gemstone.gemfire.management.internal.MBeanJMXAdapter;
import com.gemstone.gemfire.management.internal.ManagementConstants;
import com.gemstone.gemfire.management.internal.NotificationHub.NotificationHubListener;
import com.gemstone.gemfire.management.internal.SystemManagementService;
-import com.gemstone.gemfire.test.dunit.*;
-
-import javax.management.*;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-import static com.jayway.awaitility.Awaitility.to;
-import static com.jayway.awaitility.Awaitility.waitAtMost;
-import static org.hamcrest.Matchers.equalTo;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+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.WaitCriterion;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
/**
* This class checks and verifies various data and operations exposed through
@@ -44,13 +66,10 @@ import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties
* Goal of the Test : MemberMBean gets created once cache is created. Data like
* config data and stats are of proper value To check proper federation of
* MemberMBean including remote ops and remote data access
- *
- *
*/
+@Category(DistributedTest.class)
public class CacheManagementDUnitTest extends ManagementTestBase {
- private static final long serialVersionUID = 1L;
-
private final String VERIFY_CONFIG_METHOD = "verifyConfigData";
private final String VERIFY_REMOTE_CONFIG_METHOD = "verifyConfigDataRemote";
@@ -63,7 +82,6 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
static List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
-
static final List<Notification> notifList = new ArrayList<Notification>();
// This must be bigger than the dunit ack-wait-threshold for the revoke
@@ -71,12 +89,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
// 60 seconds.
private static final int MAX_WAIT = 70 * 1000;
-
-
- public CacheManagementDUnitTest(String name) {
- super(name);
- }
-
+ @Test
public void testGemFireConfigData() throws Exception {
initManagement(false);
@@ -91,16 +104,13 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
args[0] = configMap;
getManagingNode().invoke(
CacheManagementDUnitTest.class, VERIFY_REMOTE_CONFIG_METHOD, args);
-
}
/**
* Tests each and every operations that is defined on the MemberMXBean
- *
- * @throws Exception
*/
+ @Test
public void testMemberMBeanOperations() throws Exception {
-
initManagement(false);
for (VM vm : managedNodeList) {
@@ -109,22 +119,17 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
createLocalRegion(vm,"testRegion");
-
-
String log = (String) vm.invoke(() -> CacheManagementDUnitTest.fetchLog());
assertNotNull(log);
LogWriterUtils.getLogWriter().info(
"<ExpectedString> Log Of Member is " + log.toString()
+ "</ExpectedString> ");
-
-
vm.invoke(() -> CacheManagementDUnitTest.fetchJVMMetrics());
vm.invoke(() -> CacheManagementDUnitTest.fetchOSMetrics());
vm.invoke(() -> CacheManagementDUnitTest.shutDownMember());
-
}
VM managingNode = getManagingNode();
@@ -132,13 +137,12 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
args[0] = 1;// Only locator member wont be shutdown
managingNode.invoke(CacheManagementDUnitTest.class,
"assertExpectedMembers", args);
-
}
/**
* Invoke remote operations on MemberMBean
- * @throws Exception
*/
+ @Test
public void testMemberMBeanOpsRemote() throws Exception {
initManagement(false);
getManagingNode().invoke(() -> CacheManagementDUnitTest.invokeRemoteOps());
@@ -147,9 +151,8 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
/**
* Creates and starts a manager.
* Multiple Managers
- *
- * @throws Exception
*/
+ @Test
public void testManager() throws Exception {
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
@@ -173,15 +176,13 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
startManagingNode(managingNode);
checkManagerView(managingNode, member);
stopManagingNode(managingNode);
-
}
/**
* Creates and starts a manager.
* Multiple Managers
- *
- * @throws Exception
*/
+ @Test
public void testManagerShutdown() throws Exception {
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
@@ -204,6 +205,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
checkNonManagerView(managingNode);
}
+ @Test
public void testServiceCloseManagedNode() throws Exception{
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
@@ -223,9 +225,9 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
closeCache(node3);
validateServiceResource(node3);
-
}
+ @Test
public void testGetMBean() throws Exception{
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
@@ -242,9 +244,9 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
startManagingNode(managingNode);
checkGetMBean(managingNode);
-
}
+ @Test
public void testQueryMBeans() throws Exception{
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
@@ -261,7 +263,6 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
startManagingNode(managingNode);
checkQueryMBeans(managingNode);
-
}
protected void checkQueryMBeans(final VM vm) {
@@ -286,13 +287,10 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
assertTrue(names.contains(memberMBeanName));
}
-
-
+
Set<ObjectName> names = managementService.queryMBeanNames(cache
.getDistributedSystem().getDistributedMember());
assertTrue(!superSet.contains(names));
-
-
}
};
vm.invoke(validateServiceResource);
@@ -330,7 +328,6 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
}
};
vm.invoke(validateServiceResource);
-
}
protected void validateServiceResource(final VM vm) {
@@ -344,19 +341,13 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
SystemManagementService service = (SystemManagementService)managementService;
assertNull(service.getLocalManager());
-
-
-
}
};
vm.invoke(validateServiceResource);
-
}
/**
* Creates a Distributed Region
- *
- * @param vm
*/
protected AsyncInvocation checkManagerView(final VM vm,
final DistributedMember oneManager) {
@@ -387,10 +378,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
/**
* Add any Manager clean up asserts here
- *
- * @param vm
*/
-
protected void checkNonManagerView(final VM vm) {
SerializableRunnable checkNonManagerView = new SerializableRunnable(
"Check Non Manager View") {
@@ -420,10 +408,8 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
}
};
vm.invoke(checkNonManagerView);
-
}
-
public static Map<DistributedMember, DistributionConfig> verifyConfigData() {
GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
ManagementService service = getManagementService();
@@ -431,7 +417,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
.getDistributedSystem()).getConfig();
MemberMXBean bean = service.getMemberMXBean();
GemFireProperties data = bean.listGemFireProperties();
- assertEquals(config, data);
+ assertConfigEquals(config, data);
Map<DistributedMember, DistributionConfig> configMap = new HashMap<DistributedMember, DistributionConfig>();
configMap.put(cache.getMyId(), config);
return configMap;
@@ -451,21 +437,19 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
MemberMXBean bean = MBeanUtil.getMemberMbeanProxy(member);
GemFireProperties data = bean.listGemFireProperties();
DistributionConfig config = configMap.get(member);
- assertEquals(config, data);
-
+ assertConfigEquals(config, data);
}
-
}
/**
* Asserts that distribution config and gemfireProperty composite types hold
* the same values
*/
- public static void assertEquals(DistributionConfig config,
+ public static void assertConfigEquals(DistributionConfig config,
GemFireProperties data) {
assertEquals(data.getMemberName(), config.getName());
- // **TODO **/
+ // **TODO **
String memberGroups = null;
assertEquals(data.getMcastPort(), config.getMcastPort());
@@ -475,7 +459,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
assertEquals(data.getTcpPort(), config.getTcpPort());
assertEquals(removeVMDir(data.getCacheXMLFile()), removeVMDir(config.getCacheXmlFile()
.getAbsolutePath()));
- // **TODO **/
+ // **TODO **
String configFile = null;
String configFile1 = null;
assertEquals(data.getMcastTTL(), config.getMcastTtl());
@@ -489,7 +473,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
.getStatisticSamplingEnabled());
assertEquals(removeVMDir(data.getStatisticArchiveFile()), removeVMDir(config
.getStatisticArchiveFile().getAbsolutePath()));
- // ** TODO **//
+ // ** TODO **
String includeFile = null;
assertEquals(data.getAckWaitThreshold(), config.getAckWaitThreshold());
assertEquals(data.getAckSevereAlertThreshold(), config
@@ -512,7 +496,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
assertEquals(data.getMcastByteAllowance(), config.getMcastFlowControl()
.getByteAllowance());
assertEquals(data.getMcastRechargeThreshold(), config.getMcastFlowControl()
- .getRechargeThreshold());
+ .getRechargeThreshold(), 0);
assertEquals(data.getMcastRechargeBlockMs(), config.getMcastFlowControl()
.getRechargeBlockMs());
assertEquals(data.getUdpFragmentSize(), config.getUdpFragmentSize());
@@ -573,7 +557,6 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
assertEquals(data.getStatisticSampleRate(), config.getStatisticSampleRate());
}
-
private static String removeVMDir(String string) {
return string.replaceAll("vm.", "");
}
@@ -631,7 +614,6 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
LogWriterUtils.getLogWriter().info(
"<ExpectedString> JVMMetrics is " + metrics.toString()
+ "</ExpectedString> ");
-
}
public static void fetchOSMetrics() {
@@ -642,14 +624,12 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
LogWriterUtils.getLogWriter().info(
"<ExpectedString> OSMetrics is " + metrics.toString()
+ "</ExpectedString> ");
-
}
public static void shutDownMember() {
MemberMXBean bean = getManagementService()
.getMemberMXBean();
bean.shutDownMember();
-
}
public static void assertExpectedMembers(int expectedMemberCount) {
@@ -667,10 +647,8 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
}
}, MAX_WAIT, 500, true);
-
}
-
public static void invokeRemoteOps() throws Exception {
GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
Set<DistributedMember> otherMemberSet = cache.getDistributionManager()
@@ -690,21 +668,11 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
LogWriterUtils.getLogWriter().info(
"<ExpectedString> Boolean Data Check " +bean.isManager()
+ "</ExpectedString> ");
-
}
}
- public void verifyStatistics() {
-
- }
-
- public void invokeOperations() {
-
- }
-
-
+ @Test
public void testNotification() throws Exception {
-
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
VM node2 = managedNodeList.get(1);
@@ -724,11 +692,10 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
// Step : 3 : Verify Notification count, notification region sizes
countNotificationsAndCheckRegionSize(node1, node2, node3, managingNode);
-
}
+ @Test
public void testNotificationManagingNodeFirst() throws Exception {
-
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
VM node2 = managedNodeList.get(1);
@@ -748,11 +715,10 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
// Step : 3 : Verify Notification count, notification region sizes
countNotificationsAndCheckRegionSize(node1, node2, node3, managingNode);
-
}
+ @Test
public void testRedundancyZone() throws Exception {
-
List<VM> managedNodeList = getManagedNodeList();
VM node1 = managedNodeList.get(0);
VM node2 = managedNodeList.get(1);
@@ -765,17 +731,11 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
node1.invoke(new SerializableRunnable("Assert Redundancy Zone") {
public void run() {
-
ManagementService service = ManagementService.getExistingManagementService(getCache());
MemberMXBean bean = service.getMemberMXBean();
assertEquals("ARMY_ZONE", bean.getRedundancyZone());
-
-
-
}
});
-
-
}
protected void attchListenerToDSMBean(final VM vm) {
@@ -799,7 +759,7 @@ public class CacheManagementDUnitTest extends ManagementTestBase {
try {
mbeanServer.addNotificationListener(MBeanJMXAdapter.getDistributedSystemName(), nt, null, null);
} catch (InstanceNotFoundException e) {
- fail("Failed With Exception " + e);
+ throw new AssertionError("Failed With Exception ", e);
}
}