You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2016/05/24 18:53:48 UTC
[07/55] [abbrv] incubator-geode git commit: GEODE-1276: Change
UnitTests file system to IntegrationTest category GEODE-1307: Rename
HeterogenousLuceneSerializer to HeterogeneousLuceneSerializer GEODE-1279:
Tests for old TRAC bugs should be renamed to use
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVectorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVectorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVectorJUnitTest.java
index df85998..82f2003 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVectorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/versions/RegionVersionVectorJUnitTest.java
@@ -16,17 +16,17 @@
*/
package com.gemstone.gemfire.internal.cache.versions;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.DataSerializer;
@@ -39,8 +39,9 @@ import com.gemstone.gemfire.test.dunit.NetworkUtils;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
-public class RegionVersionVectorJUnitTest extends TestCase {
+public class RegionVersionVectorJUnitTest {
+ @Test
public void testExceptionsWithContains() {
DiskStoreID ownerId = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
@@ -53,6 +54,7 @@ public class RegionVersionVectorJUnitTest extends TestCase {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
public void testRegionVersionVectors() throws Exception {
// this is just a quick set of unit tests for basic RVV functionality
@@ -266,10 +268,10 @@ public class RegionVersionVectorJUnitTest extends TestCase {
assertTrue(rv1.contains(server2, bitSetRollPoint));
assertTrue(rv1.contains(server2, bitSetRollPoint+1));
assertFalse(rv1.contains(server2, bitSetRollPoint+2));
-
}
-
- public void testRVVSerialization() throws IOException, ClassNotFoundException {
+
+ @Test
+ public void testRVVSerialization() throws Exception {
DiskStoreID ownerId = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
DiskStoreID id2 = new DiskStoreID(1, 0);
@@ -300,6 +302,7 @@ public class RegionVersionVectorJUnitTest extends TestCase {
/**
* Test that we can copy the member to version map correctly.
*/
+ @Test
public void testCopyMemberToVersion() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
@@ -331,7 +334,8 @@ public class RegionVersionVectorJUnitTest extends TestCase {
assertTrue(rvv1.dominates(rvv0));
assertFalse(rvv0.dominates(rvv1));
}
-
+
+ @Test
public void testSpecialException() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
@@ -357,7 +361,8 @@ public class RegionVersionVectorJUnitTest extends TestCase {
assertTrue(rvv1.dominates(rvv0));
assertTrue(rvv0.dominates(rvv1));
}
-
+
+ @Test
public void test48066_1() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskRegionVersionVector rvv0 = new DiskRegionVersionVector(id0);
@@ -384,7 +389,8 @@ public class RegionVersionVectorJUnitTest extends TestCase {
System.out.println("after record 7, rvv2="+rvv2.fullToString());
assertEquals(7, rvv2.getCurrentVersion());
}
-
+
+ @Test
public void test48066_2() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskRegionVersionVector rvv0 = new DiskRegionVersionVector(id0);
@@ -415,8 +421,8 @@ public class RegionVersionVectorJUnitTest extends TestCase {
/**
* Test for bug 47023. Make sure recordGCVersion works
* correctly and doesn't generate exceptions for the local member.
- *
*/
+ @Test
public void testRecordGCVersion() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
@@ -432,7 +438,6 @@ public class RegionVersionVectorJUnitTest extends TestCase {
rvv0.recordVersion(id1, 1);
rvv0.recordVersion(id1, 3);
rvv0.recordVersion(id1, 5);
-
//Assert that the exceptions are present
{
@@ -470,9 +475,9 @@ public class RegionVersionVectorJUnitTest extends TestCase {
//exceptions greater than the GC version should still be there.
assertFalse(holder1.contains(4));
-
}
+ @Test
public void testRemoveOldVersions() {
DiskStoreID id0 = new DiskStoreID(0, 0);
DiskStoreID id1 = new DiskStoreID(0, 1);
@@ -511,7 +516,8 @@ public class RegionVersionVectorJUnitTest extends TestCase {
assertEquals("expected exceptions to be erased for " + rvv.fullToString(),
rvv.getExceptionCount(id2), 0);
}
-
+
+ @Test
public void testRegionVersionInTags() {
VMVersionTag tag = new VMVersionTag();
long version = 0x8080000000L;
@@ -519,10 +525,7 @@ public class RegionVersionVectorJUnitTest extends TestCase {
assertEquals("failed test for bug #48576", version, tag.getRegionVersion());
}
-
-
- private void doExceptionsWithContains(DiskStoreID id,
- DiskRegionVersionVector rvv) {
+ private void doExceptionsWithContains(DiskStoreID id, DiskRegionVersionVector rvv) {
rvv.recordVersion(id, 10);
//Make sure we have exceptions from 0-10
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueueJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueueJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueueJUnitTest.java
index b2399fd..08e81d4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueueJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/parallel/ParallelGatewaySenderQueueJUnitTest.java
@@ -17,8 +17,8 @@
package com.gemstone.gemfire.internal.cache.wan.parallel;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
-import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -29,8 +29,6 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.CancelCriterion;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.PartitionAttributesFactory;
-import com.gemstone.gemfire.cache.RegionExistsException;
-import com.gemstone.gemfire.cache.TimeoutException;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.cache.PartitionedRegion;
import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
@@ -38,8 +36,6 @@ import com.gemstone.gemfire.internal.cache.wan.AbstractGatewaySender;
import com.gemstone.gemfire.internal.cache.wan.parallel.ParallelGatewaySenderQueue.MetaRegionFactory;
import com.gemstone.gemfire.internal.cache.wan.parallel.ParallelGatewaySenderQueue.ParallelGatewaySenderQueueMetaRegion;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import static org.mockito.Mockito.*;
-
@Category(UnitTest.class)
public class ParallelGatewaySenderQueueJUnitTest {
@@ -62,7 +58,7 @@ public class ParallelGatewaySenderQueueJUnitTest {
}
@Test
- public void testLocalSize() throws TimeoutException, RegionExistsException, ClassNotFoundException, IOException {
+ public void testLocalSize() throws Exception {
ParallelGatewaySenderQueueMetaRegion mockMetaRegion = mock(ParallelGatewaySenderQueueMetaRegion.class);
PartitionedRegionDataStore dataStore = mock(PartitionedRegionDataStore.class);
when(mockMetaRegion.getDataStore()).thenReturn(dataStore);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessorJUnitTest.java
index e26d287..37962e9 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/ConcurrentSerialGatewaySenderEventProcessorJUnitTest.java
@@ -19,6 +19,7 @@ package com.gemstone.gemfire.internal.cache.wan.serial;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -29,12 +30,19 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class ConcurrentSerialGatewaySenderEventProcessorJUnitTest {
- @Test
- public void eventQueueSizeReturnsSizeOfQueues() {
+ private ConcurrentSerialGatewaySenderEventProcessor processor;
+ private RegionQueue queue;
+
+ @Before
+ public void setUp() throws Exception {
AbstractGatewaySender sender = mock(AbstractGatewaySender.class);
- ConcurrentSerialGatewaySenderEventProcessor processor = new ConcurrentSerialGatewaySenderEventProcessor(sender);
- RegionQueue queue = mock(RegionQueue.class);
+ processor = new ConcurrentSerialGatewaySenderEventProcessor(sender);
+ queue = mock(RegionQueue.class);
when(queue.size()).thenReturn(3);
+ }
+
+ @Test
+ public void eventQueueSizeReturnsSizeOfQueues() {
processor.getQueues().add(queue);
assertEquals(3,processor.eventQueueSize());
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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 f42d52c..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
@@ -14,23 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
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
@@ -38,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
@@ -77,12 +73,10 @@ public abstract class AbstractEntityResolverTest {
* Resolve the cache.xml XSD using the {@link PivotalEntityResolver}. Verifies
* that the META-INF/schemas files are correctly found.
*
- * @throws SAXException
- * @throws IOException
* @since 8.1
*/
@Test
- public void testResolveEntity() throws SAXException, IOException {
+ public void testResolveEntity() throws Exception {
final InputSource inputSource = getEntityResolver().resolveEntity(null, getSystemId());
assertNotNull(inputSource);
assertEquals(getSystemId(), inputSource.getSystemId());
@@ -93,12 +87,10 @@ public abstract class AbstractEntityResolverTest {
* <code>null</code> <code>systemId</code>. Asserts that returns to
* <code>null<code>.
*
- * @throws SAXException
- * @throws IOException
* @since 8.1
*/
@Test
- public void testResolveEntityNullSystemId() throws SAXException, IOException {
+ public void testResolveEntityNullSystemId() throws SAXException, Exception {
final String systemId = null;
final InputSource inputSource = getEntityResolver().resolveEntity(null, systemId);
assertNull(inputSource);
@@ -109,12 +101,10 @@ public abstract class AbstractEntityResolverTest {
* <code>"--not-a-valid-system-id--"</code> <code>systemId</code>, which is
* not in the Pivotal namespace.. Asserts that returns to <code>null<code>.
*
- * @throws SAXException
- * @throws IOException
* @since 8.1
*/
@Test
- public void testResolveEntityUnkownSystemId() throws SAXException, IOException {
+ public void testResolveEntityUnkownSystemId() throws Exception {
final String systemId = "--not-a-valid-system-id--";
final InputSource inputSource = getEntityResolver().resolveEntity(null, systemId);
assertNull(inputSource);
@@ -126,12 +116,10 @@ public abstract class AbstractEntityResolverTest {
* <code>systemId</code>, which should not be found. Asserts that returns to
* <code>null<code>.
*
- * @throws SAXException
- * @throws IOException
* @since 8.1
*/
@Test
- public void testResolveEntityNotFoundSystemId() throws SAXException, IOException {
+ public void testResolveEntityNotFoundSystemId() throws Exception {
final String systemId = "http://schema.pivotal.io/this/should/be/not/found.xsd";
final InputSource inputSource = getEntityResolver().resolveEntity(null, systemId);
assertNull(inputSource);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractXmlParserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractXmlParserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractXmlParserJUnitTest.java
index 6148da1..104a706 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractXmlParserJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/AbstractXmlParserJUnitTest.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 tests for {@link AbstractXmlParser}.
- *
*
* @since 8.1
*/
@@ -52,6 +50,7 @@ public class AbstractXmlParserJUnitTest {
/**
* Test method for {@link AbstractXmlParser#setDocumentLocator(Locator)}.
*/
+ @Test
public void testSetDocumentLocator() {
final MockXmlParser mockXmlParser = new MockXmlParser();
final Locator mockLocator = new Locator() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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/bf258f62/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 5a4f7b3..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.*;
@@ -34,7 +33,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Test cases for {@link CacheXmlParser}.
- *
*
* @since 8.1
*/
@@ -105,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/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlVersionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlVersionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlVersionJUnitTest.java
index a51ce2b..15f3161 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlVersionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlVersionJUnitTest.java
@@ -25,7 +25,6 @@ import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
- *
* @since 8.1
*/
@Category(UnitTest.class)
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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 2fef8b3..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
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.cache.xmlcache;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
import org.junit.Before;
import org.junit.experimental.categories.Category;
import org.xml.sax.EntityResolver;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
/**
* Unit test for {@link GeodeEntityResolver} and
* {@link DefaultEntityResolver2}.
@@ -38,11 +38,13 @@ public class GeodeEntityResolverJUnitTest extends AbstractEntityResolverTest {
entityResolver = new GeodeEntityResolver();
}
- public EntityResolver getEntityResolver() {
+ @Override
+ protected EntityResolver getEntityResolver() {
return entityResolver;
}
- public String getSystemId() {
+ @Override
+ protected String getSystemId() {
return systemId;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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 ce4941e..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
@@ -14,18 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.cache.xmlcache;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
import org.junit.Before;
import org.junit.experimental.categories.Category;
import org.xml.sax.EntityResolver;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
/**
* Unit test for {@link PivotalEntityResolver} and
* {@link DefaultEntityResolver2}.
- *
*
* @since 8.1
*/
@@ -41,11 +40,13 @@ public class PivotalEntityResolverJUnitTest extends AbstractEntityResolverTest {
entityResolver = new PivotalEntityResolver();
}
- public EntityResolver getEntityResolver() {
+ @Override
+ protected EntityResolver getEntityResolver() {
return entityResolver;
}
- public String getSystemId() {
+ @Override
+ protected String getSystemId() {
return systemId;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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/bf258f62/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/bf258f62/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/bf258f62/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 + ": " + "\u3053\u308c\u306f\u30c6\u30b9\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u3042\u308b\u3002";
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: \u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306b 1 \u30e1\u30f3\u30d0\u30fc\u304c\u3042\u308b\u3002";
- private static final String englishMessageWithArgMissing
- = "Please ignore: This message has {0} members.";
- private static final String japaneseMessageWithArgMissing
- = "msgID " + messageIdWithArg.id + ": Please ignore: \u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306b {0} \u30e1\u30f3\u30d0\u30fc\u304c\u3042\u308b\u3002";
-
- /**
- * 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: \u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306b 1 \u30e1\u30f3\u30d0\u30fc\u304c\u3042\u308b\u3002";
+ private static final String englishMessageWithArgMissing = "Please ignore: This message has {0} members.";
+ private static final String japaneseMessageWithArgMissing = "msgID " + messageIdWithArg.id + ": Please ignore: \u3053\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306b {0} \u30e1\u30f3\u30d0\u30fc\u304c\u3042\u308b\u3002";
- @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/bf258f62/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/bf258f62/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 2fe0518..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
@@ -16,8 +16,9 @@
*/
package com.gemstone.gemfire.internal.jndi;
-import java.util.Hashtable;
+import static org.junit.Assert.*;
+import java.util.Hashtable;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.ContextNotEmptyException;
@@ -28,337 +29,290 @@ import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
-//import com.gemstone.gemfire.internal.jndi.InitialContextFactoryImpl;
-
/**
* Tests all basic methods of ContextImpl.
- *
*/
@Category(UnitTest.class)
-public class ContextJUnitTest extends TestCase {
-
- private Context initialCtx;
-
- private Context gfCtx;
-
- private Context envCtx;
+public class ContextJUnitTest {
- private Context datasourceCtx;
-
- public ContextJUnitTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- // InitialContextFactoryImpl impl = new InitialContextFactoryImpl();
- // impl.setAsInitial();
+ 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");
- // table.put(Context.URL_PKG_PREFIXES,
- // "com.gemstone.gemfire.internal.jndi");
- 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");
+ table.put(Context.INITIAL_CONTEXT_FACTORY, "com.gemstone.gemfire.internal.jndi.InitialContextFactoryImpl");
+ 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");
}
-
- protected void tearDown() throws Exception {
-
- clearContext(initialCtx);
- datasourceCtx = null;
- envCtx = null;
- gfCtx = null;
- initialCtx = null;
- //InitialContextFactoryImpl.revertSetAsInitial();
+
+ @After
+ public void tearDown() throws Exception {
+ clearContext(initialContext);
+ dataSourceContext = null;
+ envContext = null;
+ gemfireContext = null;
+ initialContext = null;
}
/**
* Removes all entries from the specified context, including subcontexts.
*
- * @param context context ot clear
+ * @param context context to clear
*/
- private void clearContext(Context context)
- throws NamingException {
-
- for (NamingEnumeration e = context.listBindings(""); e
- .hasMoreElements();) {
+ private void clearContext(Context context) throws NamingException {
+ for (NamingEnumeration e = context.listBindings(""); e.hasMoreElements();) {
Binding binding = (Binding) e.nextElement();
if (binding.getObject() instanceof Context) {
clearContext((Context) binding.getObject());
}
context.unbind(binding.getName());
}
-
}
- /*
+ /**
* Tests inability to create duplicate subcontexts.
- *
- * @throws NamingException
*/
- public void testSubcontextCreationOfDuplicates()
- throws NamingException {
-
+ @Test
+ 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) {
}
}
- /*
+ /**
* Tests inability to destroy non empty subcontexts.
- *
- * @throws NamingException
*/
- public void testSubcontextNonEmptyDestruction()
- throws NamingException {
-
+ @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) {
}
}
- /*
+ /**
* Tests ability to destroy empty subcontexts.
- *
- * @throws NamingException
*/
- public void testSubcontextDestruction()
- throws NamingException {
-
+ @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) {
}
}
- /*
- * Tests inability to invoke methods on destroyed subcontexts. @throws
- * NamingException
+ /**
+ * Tests inability to invoke methods on destroyed subcontexts.
*/
- public void testSubcontextInvokingMethodsOnDestroyedContext()
- throws NamingException {
-
+ @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) {
}
}
- /*
- * Tests ability to bind name to object. @throws NamingException
+ /**
+ * Tests ability to bind name to object.
*/
- public void testBindLookup() throws NamingException {
-
+ @Test
+ public void testBindLookup() throws Exception {
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);
}
- /*
- * Tests ability to unbind names. @throws NamingException
+ /**
+ * Tests ability to unbind names.
*/
- public void testUnbind() throws NamingException {
-
- envCtx.bind("sub31", null);
- gfCtx.bind("env/ejb/sub32", new String("UnbindObject"));
+ @Test
+ public void testUnbind() throws Exception {
+ 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) {
}
}
- /*
+ /**
* Tests ability to list bindings for a context - specified by name through
* object reference.
- *
- * @throws NamingException
*/
- public void testListBindings() throws NamingException {
-
- gfCtx.bind("env/datasource/sub41", "ListBindings1");
- envCtx.bind("sub42", "ListBindings2");
- datasourceCtx.bind("sub43", null);
+ @Test
+ public void testListBindings() throws Exception {
+ 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 {
-
+ private void verifyListBindings(Context c, String name, Object obj1, Object obj2) throws NamingException {
boolean datasourceFoundFlg = false;
boolean o2FoundFlg = false;
boolean datasourceO1FoundFlg = false;
boolean datasourceNullFoundFlg = false;
// List bindings for the specified context
- for (NamingEnumeration en = c.listBindings(name); en
- .hasMore();) {
+ 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();
- for (NamingEnumeration en1 = nextCon
- .listBindings(""); en1.hasMore();) {
+ for (NamingEnumeration en1 = nextCon.listBindings(""); en1.hasMore();) {
Binding b1 = (Binding) en1.next();
if (b1.getName().equals("sub41")) {
assertEquals(b1.getObject(), obj1);
@@ -376,12 +330,12 @@ public class ContextJUnitTest extends TestCase {
o2FoundFlg = true;
}
}
- if (!(datasourceFoundFlg && o2FoundFlg
- && datasourceO1FoundFlg && datasourceNullFoundFlg)) {
+ if (!(datasourceFoundFlg && o2FoundFlg && datasourceO1FoundFlg && datasourceNullFoundFlg)) {
fail();
}
}
-
+
+ @Test
public void testCompositeName() throws Exception {
ContextImpl c = new ContextImpl();
Object o = new Object();
@@ -389,9 +343,9 @@ public class ContextJUnitTest extends TestCase {
c.rebind("/a/b/c/", o);
assertEquals(c.lookup("a/b/c"), o);
assertEquals(c.lookup("///a/b/c///"), o);
-
}
-
+
+ @Test
public void testLookup() throws Exception {
ContextImpl ctx = new ContextImpl();
Object obj = new Object();
@@ -400,14 +354,13 @@ public class ContextJUnitTest extends TestCase {
ctx.bind("a", obj);
assertEquals(obj, ctx.lookup("a"));
-
}
- /*
+ /**
* Tests "getCompositeName" method
*/
+ @Test
public void testGetCompositeName() throws Exception {
-
ContextImpl ctx = new ContextImpl();
ctx.rebind("a/b/c/d", new Object());
@@ -418,15 +371,13 @@ public class ContextJUnitTest extends TestCase {
subCtx = (ContextImpl) ctx.lookup("a/b/c");
assertEquals("a/b/c", subCtx.getCompoundStringName());
-
}
- /*
- * Tests substitution of '.' with '/' when parsing string names. @throws
- * NamingException
+ /**
+ * Tests substitution of '.' with '/' when parsing string names.
*/
- public void testTwoSeparatorNames()
- throws NamingException {
+ @Test
+ public void testTwoSeparatorNames() throws Exception {
ContextImpl ctx = new ContextImpl();
Object obj = new Object();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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/bf258f62/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/bf258f62/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 ea2a1e9..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,22 +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/bf258f62/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 24002f9..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;
@@ -29,6 +28,7 @@ import java.io.StringWriter;
import java.util.Date;
import java.util.Random;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.LogWriter;
@@ -37,7 +37,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests the functionality of the {@link SortLogFile} program.
*
- *
* @since 3.0
*/
@Category(UnitTest.class)
@@ -48,8 +47,8 @@ public class SortLogFileJUnitTest {
* order. Then it sorts the log file and asserts that the entries
* are sorted order.
*/
- @org.junit.Test
- public void testRandomLog() throws IOException {
+ @Test
+ public void testRandomLog() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos), true);
LogWriter logger = new RandomLogWriter(pw);
@@ -105,6 +104,7 @@ public class SortLogFileJUnitTest {
* Ignores <code>date</code> and returns the timestamp for a
* random date.
*/
+ @Override
protected String formatDate(Date date) {
long time = date.getTime() + (random.nextInt(100000) * 1000);
date = new Date(time);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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 a1d5e9d..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;
@@ -44,7 +41,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests the AlertAppender.
- *
*/
@Category(UnitTest.class)
public class AlertAppenderJUnitTest {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/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/bf258f62/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/bf258f62/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 5c41ae0..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;
@@ -30,7 +27,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests for LocalizedMessage which bridges our StringId LocalizedStrings for
* Log4J2 usage.
- *
*/
@Category(UnitTest.class)
public class LocalizedMessageJUnitTest {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bf258f62/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenderJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenderJUnitTest.java
index 58abcc8..4a485d8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenderJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/LogWriterAppenderJUnitTest.java
@@ -40,7 +40,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* Tests the LogWriterAppender.
- *
*/
@Category(UnitTest.class)
public class LogWriterAppenderJUnitTest {