You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/04/28 00:32:40 UTC
[2/2] incubator-geode git commit: Test cleanup
Test cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3260d6d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3260d6d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3260d6d3
Branch: refs/heads/feature/GEODE-1276
Commit: 3260d6d33f51827d747e7926971a4b99155967bc
Parents: a400823
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Apr 27 15:32:25 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed Apr 27 15:32:25 2016 -0700
----------------------------------------------------------------------
.../xmlcache/AbstractEntityResolverTest.java | 17 +-
.../cache/xmlcache/CacheCreationJUnitTest.java | 9 +-
.../cache/xmlcache/CacheXmlParserJUnitTest.java | 3 +-
.../xmlcache/GeodeEntityResolverJUnitTest.java | 4 +-
.../PivotalEntityResolverJUnitTest.java | 4 +-
.../cache/xmlcache/RegionCreationJUnitTest.java | 3 -
.../xmlcache/XmlGeneratorUtilsJUnitTest.java | 29 +-
.../compression/SnappyCompressorJUnitTest.java | 28 +-
.../internal/i18n/BasicI18nJUnitTest.java | 333 ++++++++++---------
.../io/CompositeOutputStreamJUnitTest.java | 2 +-
.../gemfire/internal/jndi/ContextJUnitTest.java | 158 +++++----
.../internal/lang/ObjectUtilsJUnitTest.java | 2 +-
.../internal/lang/ThreadUtilsJUnitTest.java | 14 +-
.../internal/logging/LogServiceJUnitTest.java | 15 +-
.../internal/logging/SortLogFileJUnitTest.java | 3 +-
.../logging/log4j/AlertAppenderJUnitTest.java | 5 +-
.../logging/log4j/ConfigLocatorJUnitTest.java | 4 +-
.../logging/log4j/FastLoggerJUnitTest.java | 4 +-
.../log4j/LocalizedMessageJUnitTest.java | 5 +-
.../offheap/AbstractStoredObjectTestBase.java | 256 +++++++-------
...tingOutOfOffHeapMemoryListenerJUnitTest.java | 6 +-
.../internal/offheap/FragmentJUnitTest.java | 29 +-
.../internal/offheap/FreeListManagerTest.java | 35 +-
.../offheap/LifecycleListenerJUnitTest.java | 96 +++---
.../MemoryAllocatorFillPatternJUnitTest.java | 4 +-
.../offheap/MemoryAllocatorJUnitTest.java | 7 +-
.../offheap/MemoryBlockNodeJUnitTest.java | 35 +-
.../offheap/MemoryInspectorImplJUnitTest.java | 13 +-
.../offheap/OffHeapHelperJUnitTest.java | 14 +-
.../OffHeapRegionEntryHelperJUnitTest.java | 9 +-
.../offheap/OffHeapStorageJUnitTest.java | 19 +-
...ffHeapStoredObjectAddressStackJUnitTest.java | 25 --
.../offheap/OffHeapStoredObjectJUnitTest.java | 17 +-
.../OffHeapStoredObjectSliceJUnitTest.java | 3 +-
...ffHeapStoredObjectWithHeapFormJUnitTest.java | 6 +-
.../OffHeapWriteObjectAsByteArrayJUnitTest.java | 6 -
.../offheap/RefCountChangeInfoJUnitTest.java | 14 +-
.../offheap/TinyMemoryBlockJUnitTest.java | 32 +-
.../LocalProcessControllerJUnitTest.java | 36 +-
.../process/LocalProcessLauncherDUnitTest.java | 4 -
...tractSignalNotificationHandlerJUnitTest.java | 10 +-
.../statistics/SampleCollectorJUnitTest.java | 4 +-
.../statistics/StatisticsMonitorJUnitTest.java | 2 +-
43 files changed, 570 insertions(+), 754 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractEntityResolverTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractEntityResolverTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractEntityResolverTest.java
index 9d11715..8b69cd8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractEntityResolverTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractEntityResolverTest.java
@@ -16,20 +16,17 @@
*/
package com.gemstone.gemfire.internal.cache.xmlcache;
-import com.gemstone.gemfire.internal.ClassPathLoader;
+import static org.junit.Assert.*;
+
+import java.util.ServiceLoader;
+
import org.junit.Test;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
-import java.io.IOException;
-import java.util.ServiceLoader;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import com.gemstone.gemfire.internal.ClassPathLoader;
/**
* Unit test for {@link PivotalEntityResolver} and
@@ -37,9 +34,9 @@ import static org.junit.Assert.assertTrue;
*/
public abstract class AbstractEntityResolverTest {
- public abstract EntityResolver getEntityResolver();
+ protected abstract EntityResolver getEntityResolver();
- public abstract String getSystemId();
+ protected abstract String getSystemId();
/**
* Assert that {@link PivotalEntityResolver} extends
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
index f159b3b..d2b43b0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
@@ -16,11 +16,7 @@
*/
package com.gemstone.gemfire.internal.cache.xmlcache;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,7 +38,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
public class CacheCreationJUnitTest {
@Mock
- GemFireCacheImpl cache;
+ private GemFireCacheImpl cache;
@Before
public void setUp() {
@@ -167,7 +163,6 @@ public class CacheCreationJUnitTest {
cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort, configuredServerBindAddress, disableDefaultCacheServer);
verify(cache, never()).addCacheServer();
-
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
index b02c7b3..88c1adf 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.cache.xmlcache;
import static org.junit.Assert.*;
@@ -104,8 +103,10 @@ public class CacheXmlParserJUnitTest {
* @since 8.1
*/
private static class TestCacheXmlParser extends CacheXmlParser {
+
static Field delegatesField;
static Method getDelegateMethod;
+
static {
try {
delegatesField = CacheXmlParser.class.getDeclaredField("delegates");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/GeodeEntityResolverJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/GeodeEntityResolverJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/GeodeEntityResolverJUnitTest.java
index a5431e7..dd3f2e2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/GeodeEntityResolverJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/GeodeEntityResolverJUnitTest.java
@@ -39,12 +39,12 @@ public class GeodeEntityResolverJUnitTest extends AbstractEntityResolverTest {
}
@Override
- public EntityResolver getEntityResolver() {
+ protected EntityResolver getEntityResolver() {
return entityResolver;
}
@Override
- public String getSystemId() {
+ protected String getSystemId() {
return systemId;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/PivotalEntityResolverJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/PivotalEntityResolverJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/PivotalEntityResolverJUnitTest.java
index 182e81c..155b051 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/PivotalEntityResolverJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/PivotalEntityResolverJUnitTest.java
@@ -41,12 +41,12 @@ public class PivotalEntityResolverJUnitTest extends AbstractEntityResolverTest {
}
@Override
- public EntityResolver getEntityResolver() {
+ protected EntityResolver getEntityResolver() {
return entityResolver;
}
@Override
- public String getSystemId() {
+ protected String getSystemId() {
return systemId;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/RegionCreationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/RegionCreationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/RegionCreationJUnitTest.java
index 5a81b94..563d55f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/RegionCreationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/RegionCreationJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.cache.xmlcache;
import static org.junit.Assert.*;
@@ -31,7 +30,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Unit test for {@link RegionCreation}.
*
- *
* @since 8.1
*/
@Category(UnitTest.class)
@@ -42,7 +40,6 @@ public class RegionCreationJUnitTest {
*
* Assert that method returns a {@link SimpleExtensionPoint} instance and
* assume that {@link SimpleExtensionPointJUnitTest} has covered the rest.
- *
*/
@Test
public void testGetExtensionPoint() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/XmlGeneratorUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/XmlGeneratorUtilsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/XmlGeneratorUtilsJUnitTest.java
index 15875f7..57561bd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/XmlGeneratorUtilsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/XmlGeneratorUtilsJUnitTest.java
@@ -14,14 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.cache.xmlcache;
import static javax.xml.XMLConstants.*;
import static org.junit.Assert.*;
import java.util.concurrent.atomic.AtomicReference;
-
import javax.xml.XMLConstants;
import org.junit.Test;
@@ -37,15 +35,13 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Unit Tests for {@link XmlGeneratorUtils}.
*
- *
* @since 8.1
*/
@Category(UnitTest.class)
public class XmlGeneratorUtilsJUnitTest {
/**
- * Test method for
- * {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, Object)}.
+ * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, Object)}.
*/
@Test
public void testAddAttributeAttributesImplStringObject() {
@@ -64,9 +60,7 @@ public class XmlGeneratorUtilsJUnitTest {
}
/**
- * Test method for
- * {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, String, Object)}
- * .
+ * Test method for {@link XmlGeneratorUtils#addAttribute(AttributesImpl, String, String, Object)}.
*/
@Test
public void testAddAttributeAttributesImplStringStringObject() {
@@ -85,11 +79,7 @@ public class XmlGeneratorUtilsJUnitTest {
}
/**
- * Test method for
- * {@link XmlGeneratorUtils#startElement(ContentHandler, String, String, AttributesImpl)}
- * .
- *
- * @throws SAXException
+ * Test method for {@link XmlGeneratorUtils#startElement(ContentHandler, String, String, AttributesImpl)}.
*/
@Test
public void testStartElementContentHandlerStringStringAttributesImpl() throws SAXException {
@@ -116,10 +106,7 @@ public class XmlGeneratorUtilsJUnitTest {
}
/**
- * Test method for
- * {@link XmlGeneratorUtils#endElement(ContentHandler, String, String)}.
- *
- * @throws SAXException
+ * Test method for {@link XmlGeneratorUtils#endElement(ContentHandler, String, String)}.
*/
@Test
public void testEndElementContentHandlerStringString() throws SAXException {
@@ -143,11 +130,7 @@ public class XmlGeneratorUtilsJUnitTest {
}
/**
- * Test method for
- * {@link XmlGeneratorUtils#emptyElement(ContentHandler, String, String, AttributesImpl)}
- * .
- *
- * @throws SAXException
+ * Test method for {@link XmlGeneratorUtils#emptyElement(ContentHandler, String, String, AttributesImpl)}.
*/
@Test
public void testEmptyElement() throws SAXException {
@@ -189,7 +172,7 @@ public class XmlGeneratorUtilsJUnitTest {
assertEquals(NULL_NS_URI, uriRef.get());
}
- private class MockContentHandler implements ContentHandler {
+ private static class MockContentHandler implements ContentHandler {
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/compression/SnappyCompressorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/compression/SnappyCompressorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/compression/SnappyCompressorJUnitTest.java
index 53b50d6..ae8bf7b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/compression/SnappyCompressorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/compression/SnappyCompressorJUnitTest.java
@@ -16,31 +16,31 @@
*/
package com.gemstone.gemfire.internal.compression;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import junit.framework.TestCase;
-
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.xerial.snappy.SnappyLoader;
import com.gemstone.gemfire.compression.Compressor;
import com.gemstone.gemfire.compression.SnappyCompressor;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* Tests the Snappy {@link Compressor}.
*/
-@Category(UnitTest.class)
-public class SnappyCompressorJUnitTest extends TestCase {
+@Category(IntegrationTest.class)
+public class SnappyCompressorJUnitTest {
+
/**
- * Tests {@link Compressor#compress(byte[])} and {@link Compressor#decompress(byte[])} using
- * the Snappy compressor.
+ * Tests {@link Compressor#compress(byte[])} and {@link Compressor#decompress(byte[])} using the Snappy compressor.
*/
@Test
- public void testCompressByteArray() {
+ public void testCompressByteArray() throws Exception {
String compressMe = "Hello, how are you?";
byte[] compressMeData = SnappyCompressor.getDefaultInstance().compress(compressMe.getBytes());
String uncompressedMe = new String(SnappyCompressor.getDefaultInstance().decompress(compressMeData));
@@ -50,24 +50,24 @@ public class SnappyCompressorJUnitTest extends TestCase {
/**
* Tests {@link SnappyCompressor#SnappyCompressor()} constructor.
- * @throws SecurityException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
*/
@Test
- public void testConstructor() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ public void testConstructor() throws Exception {
SnappyCompressor.getDefaultInstance();
+
// repeat findNativeLibrary and make sure it's pointing at a file in tmpdir
Method findNativeLibraryMethod = SnappyLoader.class.getDeclaredMethod("findNativeLibrary", new Class[0]);
findNativeLibraryMethod.setAccessible(true);
File nativeLibrary = (File) findNativeLibraryMethod.invoke(null);
+
System.out.println(nativeLibrary);
+
assertNotNull(nativeLibrary);
assertTrue(nativeLibrary + " does not exist", nativeLibrary.exists());
+
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
assertTrue(tmpDir.exists());
+
File parent = nativeLibrary.getParentFile();
assertNotNull(parent);
assertEquals(tmpDir, parent);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/i18n/BasicI18nJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/i18n/BasicI18nJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/i18n/BasicI18nJUnitTest.java
index 05abe30..46b5ba4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/i18n/BasicI18nJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/i18n/BasicI18nJUnitTest.java
@@ -16,10 +16,7 @@
*/
package com.gemstone.gemfire.internal.i18n;
-import com.gemstone.gemfire.i18n.StringId;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -28,185 +25,41 @@ import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
+import org.junit.After;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
+import com.gemstone.gemfire.i18n.StringId;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
/**
* This class tests all basic i18n functionality.
*/
-@Category(UnitTest.class)
-public class BasicI18nJUnitTest extends TestCase {
+@Category(IntegrationTest.class)
+public class BasicI18nJUnitTest {
private static final Locale DEFAULT_LOCALE = Locale.getDefault();
//static final Class DEFAULT_RESOURCEBUNDLE = StringIdResourceBundle_ja.class;
//static final Class JAPAN_RESOURCEBUNDLE = StringIdResourceBundle_ja.class;
- private static final StringId messageId
- = (StringId)LocalizedStrings.TESTING_THIS_IS_A_TEST_MESSAGE;
+
+ private static final StringId messageId = (StringId)LocalizedStrings.TESTING_THIS_IS_A_TEST_MESSAGE;
private static final String englishMessage = "This is a test message.";
private static final String japaneseMessage = "msgID " + messageId.id + ": " + "これはテストメッセージである。";
private static final Integer messageArg = new Integer(1);
- private static final StringId messageIdWithArg
- = (StringId)LocalizedStrings.TESTING_THIS_MESSAGE_HAS_0_MEMBERS;
+ private static final StringId messageIdWithArg = (StringId)LocalizedStrings.TESTING_THIS_MESSAGE_HAS_0_MEMBERS;
private static final String englishMessageWithArg = "Please ignore: This message has 1 members.";
- private static final String japaneseMessageWithArg
- = "msgID " + messageIdWithArg.id + ": Please ignore: このメッセージに 1 メンバーがある。";
- private static final String englishMessageWithArgMissing
- = "Please ignore: This message has {0} members.";
- private static final String japaneseMessageWithArgMissing
- = "msgID " + messageIdWithArg.id + ": Please ignore: このメッセージに {0} メンバーがある。";
-
- /**
- * Get all of the StringId instances via reflection.
- * @return a set of all StringId declarations within the product
- */
- private Set<StringId> getAllStringIds() {
- final Set<StringId> allStringIds = new HashSet<StringId>();
- for(String className : getStringIdDefiningClasses()) {
- try {
- Class<?> c = Class.forName(className);
- Field[] fields = c.getDeclaredFields();
- final String msg = "Found no StringIds in " + className;
- assertTrue(msg, fields.length > 0);
- for(Field f : fields) {
- f.setAccessible(true);
- StringId instance = (StringId) f.get(null);
- allStringIds.add(instance);
- }
- } catch (ClassNotFoundException cnfe) {
- throw new AssertionError(cnfe.toString(), cnfe);
- } catch (Exception e) {
- String exMsg = "Reflection attempt failed while attempting to find all"
- + " StringId instances. ";
- throw new AssertionError(exMsg + e.toString(), e);
- }
- }
- return allStringIds;
- }
-
- /**
- * Lists all of the classes that define StringId instances
- * @return a set of all classes that contain StringId declarations
- */
- private Set<String> getStringIdDefiningClasses() {
- final Set<String> StringIdDefiningClasses = new LinkedHashSet<String>();
- final String pkg = "com.gemstone.gemfire.internal.i18n.";
- StringIdDefiningClasses.add(pkg + "ParentLocalizedStrings");
- StringIdDefiningClasses.add(pkg + "LocalizedStrings");
- // JGroupsStrings are no longer localizable
-// StringIdDefiningClasses.add(pkg + "JGroupsStrings");
- StringIdDefiningClasses.add("com.gemstone.gemfire.management.internal.ManagementStrings");
- return StringIdDefiningClasses;
- }
-
- /**
- * Helper to access a private method via reflection, thus allowing
- * us to not expose them to customers.
- */
- private Locale getCurrentLocale() {
- Class<?> c = StringId.class;
- Locale locale = null;
- try {
- Method m = c.getDeclaredMethod("getCurrentLocale");
- m.setAccessible(true);
- locale = (Locale)m.invoke(null);
- } catch (Exception e) {
- String msg = "Reflection attempt failed for StringId.getCurrentLocale ";
- throw new AssertionError( msg + e.toString(), e);
- }
- return locale;
- }
-
- /**
- * Helper to access a private method via reflection, thus allowing
- * us to not expose them to customers.
- */
- private AbstractStringIdResourceBundle getActiveResourceBundle() {
- Class<?> c = StringId.class;
- AbstractStringIdResourceBundle rb = null;
- try {
- Method m = c.getDeclaredMethod("getActiveResourceBundle");
- m.setAccessible(true);
- rb = (AbstractStringIdResourceBundle)m.invoke(null);
- } catch (Exception e) {
- String msg = "Reflection attempt failed for StringId.getActiveResourceBundle ";
- throw new AssertionError(msg + e.toString(), e);
- }
- return rb;
- }
-
- /**
- * Check that the "raw" string matches the "formatted" string after taking
- * into account known changes due to the fomatting process.
- * For example:
- * <code>
- * "I''m using a contraction." should become "I'm using a contraction."
- * </code>
- */
- private void verifyStringsAreProperlyEscaped(Locale loc) {
- StringId.setLocale(loc);
-
- final Set<StringId> misquoted = new HashSet<StringId>();
-
- final Object[] identityArgs = new Object[100];
-
- for (int index = 0; index < identityArgs.length; index++) {
- identityArgs[index] = index;
- }
-
- final AbstractStringIdResourceBundle rb = getActiveResourceBundle();
- for(StringId instance : getAllStringIds()) {
- String raw = rb.getString(instance);
- String altered = raw.replaceAll("''", "'");
- altered = altered.replaceAll("\\{([0-9]+)[^\\}]*\\}", "$1");
- if (!rb.usingRawMode()) {
- altered = "msgID " + ((StringId)instance).id + ": " + altered;
- }
- String formatted = null;
- try {
- formatted = instance.toLocalizedString(identityArgs);
- } catch(IllegalArgumentException iae) {
- String testName = this.getClass().getName().replaceAll("\\.", "/")
- + ".class";
- String exMsg = "Improper message id=" + ((StringId)instance).id + "\n"
- + "Usually this is caused by an unmatched or nested \"{\"\n"
- + "Examples:\t\"{0]\" or \"{ {0} }\"\n"
- + "This is just the first failure, it is in your interest"
- + " to rebuild and run just this one test.\n"
- + "build.sh run-java-tests -Djunit.testcase="
- + testName;
- throw new AssertionError(exMsg, iae);
- }
- if(! altered.equals(formatted)) {
- System.err.println("altered: " + altered);
- System.err.println("formatted: " + formatted);
- misquoted.add(instance);
- }
- }
- if(! misquoted.isEmpty()) {
- StringBuffer err = new StringBuffer();
- err.append("These errors are usually resolved by replacing ");
- err.append("\"'\" with \"''\".\n");
- err.append("If the error is in the non-english version then ");
- err.append("alter the text in StringIdResouceBundle_{lang}.txt.\n");
- err.append("The following misquoted StringIds were found:");
- for(StringId i : misquoted) {
- err.append("\n")
- .append("StringId id=")
- .append(((StringId)i).id)
- .append(" : text=\"")
- .append(i.getRawText())
- .append("\"");
- }
- fail(err.toString());
- }
- }
+ private static final String japaneseMessageWithArg = "msgID " + messageIdWithArg.id + ": Please ignore: このメッセージに 1 メンバーがある。";
+ private static final String englishMessageWithArgMissing = "Please ignore: This message has {0} members.";
+ private static final String japaneseMessageWithArgMissing = "msgID " + messageIdWithArg.id + ": Please ignore: このメッセージに {0} メンバーがある。";
- @Override
+ @After
public void tearDown() {
//reset to the original
StringId.setLocale(DEFAULT_LOCALE);
}
+ @Test
public void testSetLocale() {
//Verify we are starting in a known state
assertTrue(DEFAULT_LOCALE.equals(getCurrentLocale()));
@@ -242,6 +95,7 @@ public class BasicI18nJUnitTest extends TestCase {
* 7) toString() wrong number or arguments, too few
* 8) toLocalizedString() wrong number or arguments, too few
*/
+ @Test
public void testToLocalizedString() {
Object[] missingArgs = new Object[] {};
Object[] extraArgs = new Object[] { messageArg, "should not print" };
@@ -320,11 +174,13 @@ public class BasicI18nJUnitTest extends TestCase {
}
}
+ @Test
public void testEnglishLanguage() {
StringId.setLocale(Locale.ENGLISH);
assertEquals(messageId.toLocalizedString(), englishMessage);
}
+ @Test
public void testJapaneseLanguage() {
StringId.setLocale(Locale.JAPANESE);
if (getActiveResourceBundle().usingRawMode()) {
@@ -334,6 +190,7 @@ public class BasicI18nJUnitTest extends TestCase {
}
}
+ @Test
public void testAlternateEnglishCountries() {
StringId.setLocale(Locale.CANADA);
assertEquals(messageId.toLocalizedString(), englishMessage);
@@ -347,6 +204,7 @@ public class BasicI18nJUnitTest extends TestCase {
* the classes listed in StringIdDefiningClasses and verify
* there are not any duplicate indexes used.
*/
+ @Test
public void testVerifyStringIdsAreUnique() {
final Set<Integer> allStringIds = new HashSet<Integer>(3000);
@@ -382,6 +240,7 @@ public class BasicI18nJUnitTest extends TestCase {
* This test is to catch issues like bug #40146
* This tests the English version in the US locale.
*/
+ @Test
public void testVerifyStringsAreProperlyEscaped_US() {
verifyStringsAreProperlyEscaped(Locale.US);
}
@@ -391,6 +250,7 @@ public class BasicI18nJUnitTest extends TestCase {
* This test is to catch issues like bug #40146
* This tests the English version in the UK locale.
*/
+ @Test
public void testVerifyStringsAreProperlyEscaped_UK() {
verifyStringsAreProperlyEscaped(Locale.UK);
}
@@ -400,7 +260,154 @@ public class BasicI18nJUnitTest extends TestCase {
* This test is to catch issues like bug #40146
* This tests the English version in the JAPAN locale.
*/
+ @Test
public void testVerifyStringsAreProperlyEscaped_JAPAN() {
verifyStringsAreProperlyEscaped(Locale.JAPAN);
}
+
+ /**
+ * Get all of the StringId instances via reflection.
+ * @return a set of all StringId declarations within the product
+ */
+ private Set<StringId> getAllStringIds() {
+ final Set<StringId> allStringIds = new HashSet<StringId>();
+ for(String className : getStringIdDefiningClasses()) {
+ try {
+ Class<?> c = Class.forName(className);
+ Field[] fields = c.getDeclaredFields();
+ final String msg = "Found no StringIds in " + className;
+ assertTrue(msg, fields.length > 0);
+ for(Field f : fields) {
+ f.setAccessible(true);
+ StringId instance = (StringId) f.get(null);
+ allStringIds.add(instance);
+ }
+ } catch (ClassNotFoundException cnfe) {
+ throw new AssertionError(cnfe.toString(), cnfe);
+ } catch (Exception e) {
+ String exMsg = "Reflection attempt failed while attempting to find all"
+ + " StringId instances. ";
+ throw new AssertionError(exMsg + e.toString(), e);
+ }
+ }
+ return allStringIds;
+ }
+
+ /**
+ * Lists all of the classes that define StringId instances
+ * @return a set of all classes that contain StringId declarations
+ */
+ private Set<String> getStringIdDefiningClasses() {
+ final Set<String> StringIdDefiningClasses = new LinkedHashSet<String>();
+ final String pkg = "com.gemstone.gemfire.internal.i18n.";
+ StringIdDefiningClasses.add(pkg + "ParentLocalizedStrings");
+ StringIdDefiningClasses.add(pkg + "LocalizedStrings");
+ // JGroupsStrings are no longer localizable
+// StringIdDefiningClasses.add(pkg + "JGroupsStrings");
+ StringIdDefiningClasses.add("com.gemstone.gemfire.management.internal.ManagementStrings");
+ return StringIdDefiningClasses;
+ }
+
+ /**
+ * Helper to access a private method via reflection, thus allowing
+ * us to not expose them to customers.
+ */
+ private Locale getCurrentLocale() {
+ Class<?> c = StringId.class;
+ Locale locale = null;
+ try {
+ Method m = c.getDeclaredMethod("getCurrentLocale");
+ m.setAccessible(true);
+ locale = (Locale)m.invoke(null);
+ } catch (Exception e) {
+ String msg = "Reflection attempt failed for StringId.getCurrentLocale ";
+ throw new AssertionError( msg + e.toString(), e);
+ }
+ return locale;
+ }
+
+ /**
+ * Helper to access a private method via reflection, thus allowing
+ * us to not expose them to customers.
+ */
+ private AbstractStringIdResourceBundle getActiveResourceBundle() {
+ Class<?> c = StringId.class;
+ AbstractStringIdResourceBundle rb = null;
+ try {
+ Method m = c.getDeclaredMethod("getActiveResourceBundle");
+ m.setAccessible(true);
+ rb = (AbstractStringIdResourceBundle)m.invoke(null);
+ } catch (Exception e) {
+ String msg = "Reflection attempt failed for StringId.getActiveResourceBundle ";
+ throw new AssertionError(msg + e.toString(), e);
+ }
+ return rb;
+ }
+
+ /**
+ * Check that the "raw" string matches the "formatted" string after taking
+ * into account known changes due to the fomatting process.
+ * For example:
+ * <code>
+ * "I''m using a contraction." should become "I'm using a contraction."
+ * </code>
+ */
+ private void verifyStringsAreProperlyEscaped(Locale loc) {
+ StringId.setLocale(loc);
+
+ final Set<StringId> misquoted = new HashSet<StringId>();
+
+ final Object[] identityArgs = new Object[100];
+
+ for (int index = 0; index < identityArgs.length; index++) {
+ identityArgs[index] = index;
+ }
+
+ final AbstractStringIdResourceBundle rb = getActiveResourceBundle();
+ for(StringId instance : getAllStringIds()) {
+ String raw = rb.getString(instance);
+ String altered = raw.replaceAll("''", "'");
+ altered = altered.replaceAll("\\{([0-9]+)[^\\}]*\\}", "$1");
+ if (!rb.usingRawMode()) {
+ altered = "msgID " + ((StringId)instance).id + ": " + altered;
+ }
+ String formatted = null;
+ try {
+ formatted = instance.toLocalizedString(identityArgs);
+ } catch(IllegalArgumentException iae) {
+ String testName = this.getClass().getName().replaceAll("\\.", "/")
+ + ".class";
+ String exMsg = "Improper message id=" + ((StringId)instance).id + "\n"
+ + "Usually this is caused by an unmatched or nested \"{\"\n"
+ + "Examples:\t\"{0]\" or \"{ {0} }\"\n"
+ + "This is just the first failure, it is in your interest"
+ + " to rebuild and run just this one test.\n"
+ + "build.sh run-java-tests -Djunit.testcase="
+ + testName;
+ throw new AssertionError(exMsg, iae);
+ }
+ if(! altered.equals(formatted)) {
+ System.err.println("altered: " + altered);
+ System.err.println("formatted: " + formatted);
+ misquoted.add(instance);
+ }
+ }
+ if(! misquoted.isEmpty()) {
+ StringBuffer err = new StringBuffer();
+ err.append("These errors are usually resolved by replacing ");
+ err.append("\"'\" with \"''\".\n");
+ err.append("If the error is in the non-english version then ");
+ err.append("alter the text in StringIdResouceBundle_{lang}.txt.\n");
+ err.append("The following misquoted StringIds were found:");
+ for(StringId i : misquoted) {
+ err.append("\n")
+ .append("StringId id=")
+ .append(((StringId)i).id)
+ .append(" : text=\"")
+ .append(i.getRawText())
+ .append("\"");
+ }
+ fail(err.toString());
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/io/CompositeOutputStreamJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/io/CompositeOutputStreamJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/io/CompositeOutputStreamJUnitTest.java
index 11f9a79..29725f1 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/io/CompositeOutputStreamJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/io/CompositeOutputStreamJUnitTest.java
@@ -43,7 +43,7 @@ public class CompositeOutputStreamJUnitTest {
private Mockery mockContext;
@Before
- public void setup() {
+ public void setUp() {
mockContext = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/jndi/ContextJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/jndi/ContextJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/jndi/ContextJUnitTest.java
index 6a2545a..0afe7f0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/jndi/ContextJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/jndi/ContextJUnitTest.java
@@ -42,32 +42,29 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class ContextJUnitTest {
- private Context initialCtx;
-
- private Context gfCtx;
-
- private Context envCtx;
-
- private Context datasourceCtx;
+ private Context initialContext;
+ private Context gemfireContext;
+ private Context envContext;
+ private Context dataSourceContext;
@Before
public void setUp() throws Exception {
Hashtable table = new Hashtable();
table.put(Context.INITIAL_CONTEXT_FACTORY, "com.gemstone.gemfire.internal.jndi.InitialContextFactoryImpl");
- initialCtx = new InitialContext(table);
- initialCtx.bind("java:gf/env/datasource/oracle", "a");
- gfCtx = (Context) initialCtx.lookup("java:gf");
- envCtx = (Context) gfCtx.lookup("env");
- datasourceCtx = (Context) envCtx.lookup("datasource");
+ initialContext = new InitialContext(table);
+ initialContext.bind("java:gf/env/datasource/oracle", "a");
+ gemfireContext = (Context) initialContext.lookup("java:gf");
+ envContext = (Context) gemfireContext.lookup("env");
+ dataSourceContext = (Context) envContext.lookup("datasource");
}
@After
public void tearDown() throws Exception {
- clearContext(initialCtx);
- datasourceCtx = null;
- envCtx = null;
- gfCtx = null;
- initialCtx = null;
+ clearContext(initialContext);
+ dataSourceContext = null;
+ envContext = null;
+ gemfireContext = null;
+ initialContext = null;
}
/**
@@ -92,17 +89,17 @@ public class ContextJUnitTest {
public void testSubcontextCreationOfDuplicates() throws NamingException {
// Try to create duplicate subcontext
try {
- initialCtx.createSubcontext("java:gf");
+ initialContext.createSubcontext("java:gf");
fail();
}
- catch (NameAlreadyBoundException ex) {
+ catch (NameAlreadyBoundException expected) {
}
// Try to create duplicate subcontext using multi-component name
try {
- gfCtx.createSubcontext("env/datasource");
+ gemfireContext.createSubcontext("env/datasource");
fail();
}
- catch (NameAlreadyBoundException ex) {
+ catch (NameAlreadyBoundException expected) {
}
}
@@ -112,26 +109,26 @@ public class ContextJUnitTest {
@Test
public void testSubcontextNonEmptyDestruction() throws Exception {
// Bind some object in ejb subcontext
- datasourceCtx.bind("Test", "Object");
+ dataSourceContext.bind("Test", "Object");
// Attempt to destroy any subcontext
try {
- initialCtx.destroySubcontext("java:gf");
+ initialContext.destroySubcontext("java:gf");
fail();
}
- catch (ContextNotEmptyException ex) {
+ catch (ContextNotEmptyException expected) {
}
try {
- initialCtx
+ initialContext
.destroySubcontext("java:gf/env/datasource");
fail();
}
- catch (ContextNotEmptyException ex) {
+ catch (ContextNotEmptyException expected) {
}
try {
- envCtx.destroySubcontext("datasource");
+ envContext.destroySubcontext("datasource");
fail();
}
- catch (ContextNotEmptyException ex) {
+ catch (ContextNotEmptyException expected) {
}
}
@@ -141,32 +138,31 @@ public class ContextJUnitTest {
@Test
public void testSubcontextDestruction() throws Exception {
// Create three new subcontexts
- datasourceCtx.createSubcontext("sub1");
- datasourceCtx.createSubcontext("sub2");
- envCtx.createSubcontext("sub3");
+ dataSourceContext.createSubcontext("sub1");
+ dataSourceContext.createSubcontext("sub2");
+ envContext.createSubcontext("sub3");
// Destroy
- initialCtx
- .destroySubcontext("java:gf/env/datasource/sub1");
- datasourceCtx.destroySubcontext("sub2");
- envCtx.destroySubcontext("sub3");
+ initialContext.destroySubcontext("java:gf/env/datasource/sub1");
+ dataSourceContext.destroySubcontext("sub2");
+ envContext.destroySubcontext("sub3");
// Perform lookup
try {
- datasourceCtx.lookup("sub1");
+ dataSourceContext.lookup("sub1");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
try {
- envCtx.lookup("datasource/sub2");
+ envContext.lookup("datasource/sub2");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
try {
- initialCtx.lookup("java:gf/sub3");
+ initialContext.lookup("java:gf/sub3");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
}
@@ -176,58 +172,57 @@ public class ContextJUnitTest {
@Test
public void testSubcontextInvokingMethodsOnDestroyedContext() throws Exception {
//Create subcontext and destroy it.
- Context sub = datasourceCtx.createSubcontext("sub4");
- initialCtx
- .destroySubcontext("java:gf/env/datasource/sub4");
+ Context sub = dataSourceContext.createSubcontext("sub4");
+ initialContext.destroySubcontext("java:gf/env/datasource/sub4");
try {
sub.bind("name", "object");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.unbind("name");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.createSubcontext("sub5");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.destroySubcontext("sub6");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.list("");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.lookup("name");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
sub.composeName("name", "prefix");
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
try {
NameParserImpl parser = new NameParserImpl();
sub.composeName(parser.parse("a"), parser.parse("b"));
fail();
}
- catch (NoPermissionException ex) {
+ catch (NoPermissionException expected) {
}
}
@@ -239,19 +234,19 @@ public class ContextJUnitTest {
Object obj1 = new String("Object1");
Object obj2 = new String("Object2");
Object obj3 = new String("Object3");
- datasourceCtx.bind("sub21", null);
- datasourceCtx.bind("sub22", obj1);
- initialCtx.bind("java:gf/env/sub23", null);
- initialCtx.bind("java:gf/env/sub24", obj2);
+ dataSourceContext.bind("sub21", null);
+ dataSourceContext.bind("sub22", obj1);
+ initialContext.bind("java:gf/env/sub23", null);
+ initialContext.bind("java:gf/env/sub24", obj2);
// Bind to subcontexts that do not exist
- initialCtx.bind("java:gf/env/datasource/sub25/sub26", obj3);
+ initialContext.bind("java:gf/env/datasource/sub25/sub26", obj3);
// Try to lookup
- assertNull(datasourceCtx.lookup("sub21"));
- assertSame(datasourceCtx.lookup("sub22"), obj1);
- assertNull(gfCtx.lookup("env/sub23"));
- assertSame(initialCtx.lookup("java:gf/env/sub24"), obj2);
- assertSame(datasourceCtx.lookup("sub25/sub26"), obj3);
+ assertNull(dataSourceContext.lookup("sub21"));
+ assertSame(dataSourceContext.lookup("sub22"), obj1);
+ assertNull(gemfireContext.lookup("env/sub23"));
+ assertSame(initialContext.lookup("java:gf/env/sub24"), obj2);
+ assertSame(dataSourceContext.lookup("sub25/sub26"), obj3);
}
/**
@@ -259,36 +254,31 @@ public class ContextJUnitTest {
*/
@Test
public void testUnbind() throws Exception {
- envCtx.bind("sub31", null);
- gfCtx.bind("env/ejb/sub32", new String("UnbindObject"));
+ envContext.bind("sub31", null);
+ gemfireContext.bind("env/ejb/sub32", new String("UnbindObject"));
// Unbind
- initialCtx.unbind("java:gf/env/sub31");
- datasourceCtx.unbind("sub32");
+ initialContext.unbind("java:gf/env/sub31");
+ dataSourceContext.unbind("sub32");
try {
- envCtx.lookup("sub31");
+ envContext.lookup("sub31");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
try {
- initialCtx.lookup("java:gf/env/sub32");
+ initialContext.lookup("java:gf/env/sub32");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
// Unbind non-existing name
- try {
- datasourceCtx.unbind("doesNotExist");
- }
- catch (Exception ex) {
- fail();
- }
+ dataSourceContext.unbind("doesNotExist");
// Unbind non-existing name, when subcontext does not exists
try {
- gfCtx.unbind("env/x/y");
+ gemfireContext.unbind("env/x/y");
fail();
}
- catch (NameNotFoundException ex) {
+ catch (NameNotFoundException expected) {
}
}
@@ -298,14 +288,14 @@ public class ContextJUnitTest {
*/
@Test
public void testListBindings() throws Exception {
- gfCtx.bind("env/datasource/sub41", "ListBindings1");
- envCtx.bind("sub42", "ListBindings2");
- datasourceCtx.bind("sub43", null);
+ gemfireContext.bind("env/datasource/sub41", "ListBindings1");
+ envContext.bind("sub42", "ListBindings2");
+ dataSourceContext.bind("sub43", null);
// Verify bindings for context specified by reference
- verifyListBindings(envCtx, "", "ListBindings1", "ListBindings2");
+ verifyListBindings(envContext, "", "ListBindings1", "ListBindings2");
// Verify bindings for context specified by name
- verifyListBindings(initialCtx, "java:gf/env", "ListBindings1", "ListBindings2");
+ verifyListBindings(initialContext, "java:gf/env", "ListBindings1", "ListBindings2");
}
private void verifyListBindings(Context c, String name, Object obj1, Object obj2) throws NamingException {
@@ -318,7 +308,7 @@ public class ContextJUnitTest {
for (NamingEnumeration en = c.listBindings(name); en.hasMore();) {
Binding b = (Binding) en.next();
if (b.getName().equals("datasource")) {
- assertEquals(b.getObject(), datasourceCtx);
+ assertEquals(b.getObject(), dataSourceContext);
datasourceFoundFlg = true;
Context nextCon = (Context) b.getObject();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ObjectUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ObjectUtilsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ObjectUtilsJUnitTest.java
index faaec6a..7f68a52 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ObjectUtilsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ObjectUtilsJUnitTest.java
@@ -163,7 +163,7 @@ public class ObjectUtilsJUnitTest {
" is the loneliest number!"));
}
- public static final class ValueHolder<T> {
+ private static final class ValueHolder<T> {
private final T value;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThreadUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThreadUtilsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThreadUtilsJUnitTest.java
index f345735..c172885 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThreadUtilsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThreadUtilsJUnitTest.java
@@ -16,24 +16,21 @@
*/
package com.gemstone.gemfire.internal.lang;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
-import static org.assertj.core.api.Assertions.*;
import java.lang.Thread.State;
import java.util.concurrent.atomic.AtomicBoolean;
-import com.gemstone.gemfire.test.junit.Retry;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
import edu.umd.cs.mtc.MultithreadedTestCase;
import edu.umd.cs.mtc.TestFramework;
-
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.concurrent.Synchroniser;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -56,7 +53,7 @@ public class ThreadUtilsJUnitTest {
protected Mockery mockContext;
@Before
- public void setup() {
+ public void setUp() {
mockContext = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
setThreadingPolicy(new Synchroniser());
@@ -68,9 +65,6 @@ public class ThreadUtilsJUnitTest {
mockContext.assertIsSatisfied();
}
- @Rule
- public RetryRule retryRule = new RetryRule();
-
@Test
public void testGetThreadNameWithNull() {
assertNull(ThreadUtils.getThreadName(null));
@@ -172,8 +166,8 @@ public class ThreadUtilsJUnitTest {
assertTrue(sleepDuration > 0);
}
+ @Ignore("This is really just testing Thread.sleep(long)")
@Test
- @Retry(3)
public void testSleepWithInterrupt() throws Throwable {
TestFramework.runOnce(new SleepInterruptedMultithreadedTestCase(10 * 1000));
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
index e0c6972..aaa146a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
@@ -16,11 +16,13 @@
*/
package com.gemstone.gemfire.internal.logging;
-import static junitparams.JUnitParamsRunner.$;
+import static junitparams.JUnitParamsRunner.*;
import static org.assertj.core.api.Assertions.*;
import java.net.URL;
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
import org.apache.logging.log4j.Level;
import org.junit.Before;
import org.junit.Rule;
@@ -33,21 +35,18 @@ import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.logging.log4j.AppenderContext;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-
/**
* Unit tests for LogService
*/
@Category(UnitTest.class)
@RunWith(JUnitParamsRunner.class)
public class LogServiceJUnitTest {
-
- @Rule
- public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
+
private URL defaultConfigUrl;
private URL cliConfigUrl;
+
+ @Rule
+ public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
@Before
public void setUp() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/SortLogFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/SortLogFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/SortLogFileJUnitTest.java
index c8966da..7dfc7d3 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/SortLogFileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/SortLogFileJUnitTest.java
@@ -16,12 +16,11 @@
*/
package com.gemstone.gemfire.internal.logging;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringReader;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppenderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppenderJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppenderJUnitTest.java
index eb0fea3..6721d04 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppenderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppenderJUnitTest.java
@@ -16,10 +16,7 @@
*/
package com.gemstone.gemfire.internal.logging.log4j;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/ConfigLocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/ConfigLocatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/ConfigLocatorJUnitTest.java
index 885afa4..24916ae 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/ConfigLocatorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/ConfigLocatorJUnitTest.java
@@ -32,14 +32,14 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* UnitTest for ConfigLocator which is used to find the Log4J 2 configuration file.
*
* @since 8.2
*/
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
public class ConfigLocatorJUnitTest {
private static Set<String> suffixesNotFoundTested = new HashSet<String>();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerJUnitTest.java
index fc905a8..f054db6 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerJUnitTest.java
@@ -16,9 +16,9 @@
*/
package com.gemstone.gemfire.internal.logging.log4j;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*;
import org.apache.logging.log4j.Level;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LocalizedMessageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LocalizedMessageJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LocalizedMessageJUnitTest.java
index 603abf3..428de32 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LocalizedMessageJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LocalizedMessageJUnitTest.java
@@ -16,10 +16,7 @@
*/
package com.gemstone.gemfire.internal.logging.log4j;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.experimental.categories.Category;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObjectTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObjectTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObjectTestBase.java
index 24cb2fd..0659b81 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObjectTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObjectTestBase.java
@@ -14,190 +14,186 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.offheap;
-import com.gemstone.gemfire.internal.DataSerializableFixedID;
-import com.gemstone.gemfire.internal.offheap.StoredObject;
-import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.io.DataOutput;
import java.io.IOException;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import org.junit.Test;
+
+import com.gemstone.gemfire.internal.DataSerializableFixedID;
public abstract class AbstractStoredObjectTestBase {
- /* Returns Value as an Object Eg: Integer or UserDefinedRegionValue */
- protected abstract Object getValue();
+ /* Returns Value as an Object Eg: Integer or UserDefinedRegionValue */
+ protected abstract Object getValue();
- /* Returns Value as an ByteArray (not serialized) */
- protected abstract byte[] getValueAsByteArray();
+ /* Returns Value as an ByteArray (not serialized) */
+ protected abstract byte[] getValueAsByteArray();
- protected abstract Object convertByteArrayToObject(byte[] valueInByteArray);
+ protected abstract Object convertByteArrayToObject(byte[] valueInByteArray);
- protected abstract Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray);
+ protected abstract Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray);
- protected abstract StoredObject createValueAsUnserializedStoredObject(Object value);
+ protected abstract StoredObject createValueAsUnserializedStoredObject(Object value);
- protected abstract StoredObject createValueAsSerializedStoredObject(Object value);
+ protected abstract StoredObject createValueAsSerializedStoredObject(Object value);
- @Test
- public void getValueAsDeserializedHeapObjectShouldReturnDeserializedValueIfValueIsSerialized() {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void getValueAsDeserializedHeapObjectShouldReturnDeserializedValueIfValueIsSerialized() {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- Object actualRegionEntryValue = storedObject.getValueAsDeserializedHeapObject();
- assertEquals(regionEntryValue, actualRegionEntryValue);
- }
+ Object actualRegionEntryValue = storedObject.getValueAsDeserializedHeapObject();
+ assertEquals(regionEntryValue, actualRegionEntryValue);
+ }
- @Test
- public void getValueAsDeserializedHeapObjectShouldReturnValueAsIsIfNotSerialized() {
- byte[] regionEntryValue = getValueAsByteArray();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ @Test
+ public void getValueAsDeserializedHeapObjectShouldReturnValueAsIsIfNotSerialized() {
+ byte[] regionEntryValue = getValueAsByteArray();
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- byte[] deserializedValue = (byte[]) storedObject.getValueAsDeserializedHeapObject();
- assertArrayEquals(regionEntryValue, deserializedValue);
- }
+ byte[] deserializedValue = (byte[]) storedObject.getValueAsDeserializedHeapObject();
+ assertArrayEquals(regionEntryValue, deserializedValue);
+ }
- @Test
- public void getValueAsHeapByteArrayShouldReturnSerializedByteArrayIfValueIsSerialized() {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void getValueAsHeapByteArrayShouldReturnSerializedByteArrayIfValueIsSerialized() {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- byte[] valueInSerializedByteArray = (byte[]) storedObject.getValueAsHeapByteArray();
- Object actualRegionEntryValue = convertSerializedByteArrayToObject(valueInSerializedByteArray);
+ byte[] valueInSerializedByteArray = (byte[]) storedObject.getValueAsHeapByteArray();
+ Object actualRegionEntryValue = convertSerializedByteArrayToObject(valueInSerializedByteArray);
- assertEquals(regionEntryValue, actualRegionEntryValue);
- }
+ assertEquals(regionEntryValue, actualRegionEntryValue);
+ }
- @Test
- public void getValueAsHeapByteArrayShouldReturnDeserializedByteArrayIfValueIsNotSerialized() {
- Object regionEntryValue = getValue();
+ @Test
+ public void getValueAsHeapByteArrayShouldReturnDeserializedByteArrayIfValueIsNotSerialized() {
+ Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- byte[] valueInByteArray = (byte[]) storedObject.getValueAsHeapByteArray();
+ byte[] valueInByteArray = (byte[]) storedObject.getValueAsHeapByteArray();
- Object actualRegionEntryValue = convertByteArrayToObject(valueInByteArray);
+ Object actualRegionEntryValue = convertByteArrayToObject(valueInByteArray);
- assertEquals(regionEntryValue, actualRegionEntryValue);
- }
+ assertEquals(regionEntryValue, actualRegionEntryValue);
+ }
- @Test
- public void getStringFormShouldReturnStringFromDeserializedValue() {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void getStringFormShouldReturnStringFromDeserializedValue() {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- String stringForm = storedObject.getStringForm();
- assertEquals(String.valueOf(regionEntryValue), stringForm);
- }
+ String stringForm = storedObject.getStringForm();
+ assertEquals(String.valueOf(regionEntryValue), stringForm);
+ }
- @Test
- public void getValueShouldReturnSerializedValue() {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void getValueShouldReturnSerializedValue() {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- byte[] valueAsSerializedByteArray = (byte[]) storedObject.getValue();
+ byte[] valueAsSerializedByteArray = (byte[]) storedObject.getValue();
- Object actualValue = convertSerializedByteArrayToObject(valueAsSerializedByteArray);
+ Object actualValue = convertSerializedByteArrayToObject(valueAsSerializedByteArray);
- assertEquals(regionEntryValue, actualValue);
- }
+ assertEquals(regionEntryValue, actualValue);
+ }
- @Test(expected = IllegalStateException.class)
- public void getValueShouldThrowExceptionIfValueIsNotSerialized() {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ @Test(expected = IllegalStateException.class)
+ public void getValueShouldThrowExceptionIfValueIsNotSerialized() {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- byte[] deserializedValue = (byte[]) storedObject.getValue();
- }
+ byte[] deserializedValue = (byte[]) storedObject.getValue();
+ }
- @Test
- public void getDeserializedWritableCopyShouldReturnDeserializedValue() {
- byte[] regionEntryValue = getValueAsByteArray();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void getDeserializedWritableCopyShouldReturnDeserializedValue() {
+ byte[] regionEntryValue = getValueAsByteArray();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- assertArrayEquals(regionEntryValue, (byte[]) storedObject.getDeserializedWritableCopy(null, null));
- }
+ assertArrayEquals(regionEntryValue, (byte[]) storedObject.getDeserializedWritableCopy(null, null));
+ }
- @Test
- public void writeValueAsByteArrayWritesToProvidedDataOutput() throws IOException {
- byte[] regionEntryValue = getValueAsByteArray();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void writeValueAsByteArrayWritesToProvidedDataOutput() throws IOException {
+ byte[] regionEntryValue = getValueAsByteArray();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.writeValueAsByteArray(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.writeValueAsByteArray(dataOutput);
- verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0 , storedObject.getSerializedValue().length);
- }
+ verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
+ }
- @Test
- public void sendToShouldWriteSerializedValueToDataOutput() throws IOException {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void sendToShouldWriteSerializedValueToDataOutput() throws IOException {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendTo(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendTo(dataOutput);
- verify(dataOutput, times(1)).write(storedObject.getSerializedValue());
- }
+ verify(dataOutput, times(1)).write(storedObject.getSerializedValue());
+ }
- @Test
- public void sendToShouldWriteDeserializedObjectToDataOutput() throws IOException {
- byte[] regionEntryValue = getValueAsByteArray();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ @Test
+ public void sendToShouldWriteDeserializedObjectToDataOutput() throws IOException {
+ byte[] regionEntryValue = getValueAsByteArray();
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendTo(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendTo(dataOutput);
- verify(dataOutput, times(1)).write(regionEntryValue, 0, regionEntryValue.length);
- }
+ verify(dataOutput, times(1)).write(regionEntryValue, 0, regionEntryValue.length);
+ }
- @Test
- public void sendAsByteArrayShouldWriteSerializedValueToDataOutput() throws IOException {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void sendAsByteArrayShouldWriteSerializedValueToDataOutput() throws IOException {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendAsByteArray(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendAsByteArray(dataOutput);
- verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
- }
+ verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
+ }
- @Test
- public void sendAsByteArrayShouldWriteDeserializedObjectToDataOutput() throws IOException {
- byte[] regionEntryValue = getValueAsByteArray();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ @Test
+ public void sendAsByteArrayShouldWriteDeserializedObjectToDataOutput() throws IOException {
+ byte[] regionEntryValue = getValueAsByteArray();
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendAsByteArray(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendAsByteArray(dataOutput);
- verify(dataOutput, times(1)).write(regionEntryValue, 0, regionEntryValue.length);
- }
+ verify(dataOutput, times(1)).write(regionEntryValue, 0, regionEntryValue.length);
+ }
- @Test
- public void sendAsCachedDeserializableShouldWriteSerializedValueToDataOutputAndSetsHeader() throws IOException {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
+ @Test
+ public void sendAsCachedDeserializableShouldWriteSerializedValueToDataOutputAndSetsHeader() throws IOException {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendAsCachedDeserializable(dataOutput);
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendAsCachedDeserializable(dataOutput);
- verify(dataOutput, times(1)).writeByte((DataSerializableFixedID.VM_CACHED_DESERIALIZABLE));
- verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
- }
+ verify(dataOutput, times(1)).writeByte((DataSerializableFixedID.VM_CACHED_DESERIALIZABLE));
+ verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
+ }
- @Test(expected = IllegalStateException.class)
- public void sendAsCachedDeserializableShouldThrowExceptionIfValueIsNotSerialized() throws IOException {
- Object regionEntryValue = getValue();
- StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
+ @Test(expected = IllegalStateException.class)
+ public void sendAsCachedDeserializableShouldThrowExceptionIfValueIsNotSerialized() throws IOException {
+ Object regionEntryValue = getValue();
+ StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
- DataOutput dataOutput = mock(DataOutput.class);
- storedObject.sendAsCachedDeserializable(dataOutput);
- }
+ DataOutput dataOutput = mock(DataOutput.class);
+ storedObject.sendAsCachedDeserializable(dataOutput);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
index 8e48863..05725e4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
@@ -33,14 +33,14 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class DisconnectingOutOfOffHeapMemoryListenerJUnitTest {
- @Rule
- public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
private final InternalDistributedSystem ids = mock(InternalDistributedSystem.class);
private final OutOfOffHeapMemoryException ex = new OutOfOffHeapMemoryException();
private final LogWriter lw = mock(LogWriter.class);
private final DM dm = mock(DM.class);
+ @Rule
+ public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
@Before
public void setUp() throws Exception {
when(ids.getLogWriter()).thenReturn(lw);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
index 569b003..eac234b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FragmentJUnitTest.java
@@ -14,19 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.offheap;
-import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
import java.util.Arrays;
import org.assertj.core.api.JUnitSoftAssertions;
import org.junit.After;
-import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -39,25 +36,12 @@ public class FragmentJUnitTest {
private SlabImpl[] slabs;
- static {
- ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
- }
-
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
public JUnitSoftAssertions softly = new JUnitSoftAssertions();
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
@Before
public void setUp() throws Exception {
SlabImpl slab1 = new SlabImpl((int)OffHeapStorage.MIN_SLAB_SIZE);
@@ -71,15 +55,14 @@ public class FragmentJUnitTest {
slabs[i].free();
}
}
-
-
+
@Test
public void fragmentConstructorThrowsExceptionForNon8ByteAlignedAddress() {
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("address was not 8 byte aligned");
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("address was not 8 byte aligned");
- new Fragment(slabs[0].getMemoryAddress() + 2, 0);
- fail("Constructor failed to throw exception for non-8-byte alignment");
+ new Fragment(slabs[0].getMemoryAddress() + 2, 0);
+ fail("Constructor failed to throw exception for non-8-byte alignment");
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3260d6d3/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
index 75eb73a..4cf1df0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/FreeListManagerTest.java
@@ -16,10 +16,10 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
import static com.googlecode.catchexception.CatchException.*;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.List;
@@ -27,10 +27,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
import org.apache.logging.log4j.Logger;
import org.junit.After;
-import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -39,23 +36,10 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class FreeListManagerTest {
- static {
- ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
- }
-
private final int DEFAULT_SLAB_SIZE = 1024*1024*5;
private final MemoryAllocatorImpl ma = mock(MemoryAllocatorImpl.class);
private final OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
private TestableFreeListManager freeListManager;
-
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
@Before
public void setUp() throws Exception {
@@ -830,9 +814,11 @@ public class FreeListManagerTest {
*/
private static class TestableFragment extends Fragment {
private boolean allocateCalled = false;
+
public TestableFragment(long addr, int size) {
super(addr, size);
}
+
@Override
public boolean allocate(int oldOffset, int newOffset) {
if (!allocateCalled) {
@@ -842,9 +828,15 @@ public class FreeListManagerTest {
return super.allocate(oldOffset, newOffset);
}
}
+
private static class TestableFreeListManager extends FreeListManager {
private boolean firstTime = true;
-
+ private boolean firstDefragmentation = true;
+
+ public TestableFreeListManager(MemoryAllocatorImpl ma, Slab[] slabs) {
+ super(ma, slabs);
+ }
+
@Override
protected Fragment createFragment(long addr, int size) {
return new TestableFragment(addr, size);
@@ -862,7 +854,6 @@ public class FreeListManagerTest {
return super.createFreeListForEmptySlot(freeLists, idx);
}
- public boolean firstDefragmentation = true;
@Override
protected void afterDefragmentationCountFetched() {
if (this.firstDefragmentation) {
@@ -872,9 +863,5 @@ public class FreeListManagerTest {
}
}
- public TestableFreeListManager(MemoryAllocatorImpl ma, Slab[] slabs) {
- super(ma, slabs);
- }
-
}
}