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/27 01:17:15 UTC
[03/16] incubator-geode git commit: Updating and fixing tests
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyStoredObjectJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyStoredObjectJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyStoredObjectJUnitTest.java
index 94559d6..56a93db 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyStoredObjectJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/TinyStoredObjectJUnitTest.java
@@ -14,340 +14,334 @@
* 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.mockito.Mockito.*;
+
+import java.nio.ByteBuffer;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import com.gemstone.gemfire.compression.Compressor;
import com.gemstone.gemfire.internal.cache.BytesAndBitsForCompactor;
import com.gemstone.gemfire.internal.cache.CachePerfStats;
import com.gemstone.gemfire.internal.cache.EntryEventImpl;
import com.gemstone.gemfire.internal.cache.RegionEntryContext;
-import com.gemstone.gemfire.internal.offheap.TinyStoredObject;
-
-import com.gemstone.gemfire.internal.offheap.OffHeapRegionEntryHelper;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mock;
-
-import java.nio.ByteBuffer;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.*;
@Category(UnitTest.class)
public class TinyStoredObjectJUnitTest extends AbstractStoredObjectTestBase {
- @Override
- public Object getValue() {
- return Integer.valueOf(123456789);
+ @Override
+ public Object getValue() {
+ return Integer.valueOf(123456789);
+ }
+
+ @Override
+ public byte[] getValueAsByteArray() {
+ return convertValueToByteArray(getValue());
+ }
+
+ private byte[] convertValueToByteArray(Object value) {
+ return ByteBuffer.allocate(Integer.SIZE / Byte.SIZE).putInt((Integer) value).array();
+ }
+
+ @Override
+ public Object convertByteArrayToObject(byte[] valueInByteArray) {
+ return ByteBuffer.wrap(valueInByteArray).getInt();
+ }
+
+ @Override
+ public Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray) {
+ return EntryEventImpl.deserialize(valueInSerializedByteArray);
+ }
+
+ @Override
+ public TinyStoredObject createValueAsUnserializedStoredObject(Object value) {
+ byte[] valueInByteArray;
+ if (value instanceof Integer) {
+ valueInByteArray = convertValueToByteArray(value);
+ } else {
+ valueInByteArray = (byte[]) value;
}
+ //encode a non-serialized entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInByteArray, false, false);
+ return new TinyStoredObject(encodedAddress);
+ }
+
+ @Override
+ public TinyStoredObject createValueAsSerializedStoredObject(Object value) {
+ byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
+ //encode a serialized entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, false);
+ return new TinyStoredObject(encodedAddress);
+ }
+
+ public TinyStoredObject createValueAsCompressedStoredObject(Object value) {
+ byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
+ //encode a serialized, compressed entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, true);
+ return new TinyStoredObject(encodedAddress);
+ }
+
+ public TinyStoredObject createValueAsUncompressedStoredObject(Object value) {
+ byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
+ //encode a serialized, uncompressed entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, false);
+ return new TinyStoredObject(encodedAddress);
+ }
+
+ @Test
+ public void shouldReturnCorrectEncodingAddress() {
+
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ assertNotNull(address1);
+ assertEquals("Encoding address should be:", 10001, address1.getAddress());
+
+ TinyStoredObject address2 = new TinyStoredObject(10002L);
+ assertNotNull(address2);
+ assertEquals("Returning always 10001 expected 10002", 10002, address2.getAddress());
+ }
- @Override
- public byte[] getValueAsByteArray() {
- return convertValueToByteArray(getValue());
- }
+ @Test
+ public void twoAddressesShouldBeEqualIfEncodingAddressIsSame() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ TinyStoredObject address2 = new TinyStoredObject(10001L);
+
+ assertEquals("Two addresses are equal if encoding address is same", true, address1.equals(address2));
+ }
- private byte[] convertValueToByteArray(Object value) {
- return ByteBuffer.allocate(Integer.SIZE / Byte.SIZE).putInt((Integer) value).array();
- }
+ @Test
+ public void twoAddressesShouldNotBeEqualIfEncodingAddressIsNotSame() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ TinyStoredObject address2 = new TinyStoredObject(10002L);
+
+ assertEquals("Two addresses are not equal if encoding address is not same", false, address1.equals(address2));
+ }
- @Override
- public Object convertByteArrayToObject(byte[] valueInByteArray) {
- return ByteBuffer.wrap(valueInByteArray).getInt();
- }
+ @Test
+ public void twoAddressesAreNotEqualIfTheyAreNotTypeDataAsAddress() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ Long address2 = new Long(10002L);
+
+ assertEquals("Two addresses are not equal if encoding address is not same", false, address1.equals(address2));
+ }
- @Override
- public Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray) {
- return EntryEventImpl.deserialize(valueInSerializedByteArray);
- }
+ @Test
+ public void addressHashCodeShouldBe() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ assertEquals("", 10001, address1.hashCode());
+ }
- @Override
- public TinyStoredObject createValueAsUnserializedStoredObject(Object value) {
- byte[] valueInByteArray;
- if(value instanceof Integer) {
- valueInByteArray = convertValueToByteArray(value);
- } else {
- valueInByteArray = (byte[]) value;
- }
- //encode a non-serialized entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInByteArray, false, false);
- return new TinyStoredObject(encodedAddress);
- }
+ @Test
+ public void getSizeInBytesAlwaysReturnsZero() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ TinyStoredObject address2 = new TinyStoredObject(10002L);
- @Override
- public TinyStoredObject createValueAsSerializedStoredObject(Object value) {
- byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
- //encode a serialized entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, false);
- return new TinyStoredObject(encodedAddress);
- }
+ assertEquals("getSizeInBytes", 0, address1.getSizeInBytes());
+ assertEquals("getSizeInBytes", 0, address2.getSizeInBytes());
+ }
- public TinyStoredObject createValueAsCompressedStoredObject(Object value) {
- byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
- //encode a serialized, compressed entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, true);
- return new TinyStoredObject(encodedAddress);
- }
+ @Test
+ public void getValueSizeInBytesAlwaysReturnsZero() {
+ TinyStoredObject address1 = new TinyStoredObject(10001L);
+ TinyStoredObject address2 = new TinyStoredObject(10002L);
- public TinyStoredObject createValueAsUncompressedStoredObject(Object value) {
- byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
- //encode a serialized, uncompressed entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(valueInSerializedByteArray, true, false);
- return new TinyStoredObject(encodedAddress);
- }
+ assertEquals("getSizeInBytes", 0, address1.getValueSizeInBytes());
+ assertEquals("getSizeInBytes", 0, address2.getValueSizeInBytes());
+ }
- @Test
- public void shouldReturnCorrectEncodingAddress() {
+ @Test
+ public void isCompressedShouldReturnTrueIfCompressed() {
+ Object regionEntryValue = getValue();
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- assertNotNull(address1);
- assertEquals("Encoding address should be:", 10001, address1.getAddress());
+ TinyStoredObject offheapAddress = createValueAsCompressedStoredObject(regionEntryValue);
- TinyStoredObject address2 = new TinyStoredObject(10002L);
- assertNotNull(address2);
- assertEquals("Returning always 10001 expected 10002", 10002, address2.getAddress());
- }
+ assertEquals("Should return true as it is compressed", true, offheapAddress.isCompressed());
+ }
- @Test
- public void twoAddressesShouldBeEqualIfEncodingAddressIsSame() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- TinyStoredObject address2 = new TinyStoredObject(10001L);
+ @Test
+ public void isCompressedShouldReturnFalseIfNotCompressed() {
+ Object regionEntryValue = getValue();
- assertEquals("Two addresses are equal if encoding address is same", true, address1.equals(address2));
- }
+ TinyStoredObject offheapAddress = createValueAsUncompressedStoredObject(regionEntryValue);
- @Test
- public void twoAddressesShouldNotBeEqualIfEncodingAddressIsNotSame() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- TinyStoredObject address2 = new TinyStoredObject(10002L);
+ assertEquals("Should return false as it is compressed", false, offheapAddress.isCompressed());
+ }
- assertEquals("Two addresses are not equal if encoding address is not same", false, address1.equals(address2));
- }
+ @Test
+ public void isSerializedShouldReturnTrueIfSeriazlied() {
+ Object regionEntryValue = getValue();
- @Test
- public void twoAddressesAreNotEqualIfTheyAreNotTypeDataAsAddress() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- Long address2 = new Long(10002L);
+ TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
- assertEquals("Two addresses are not equal if encoding address is not same", false, address1.equals(address2));
- }
+ assertEquals("Should return true as it is serialized", true, offheapAddress.isSerialized());
+ }
- @Test
- public void addressHashCodeShouldBe() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- assertEquals("", 10001, address1.hashCode());
- }
+ @Test
+ public void isSerializedShouldReturnFalseIfNotSeriazlied() {
+ Object regionEntryValue = getValue();
- @Test
- public void getSizeInBytesAlwaysReturnsZero() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- TinyStoredObject address2 = new TinyStoredObject(10002L);
+ TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValue);
- assertEquals("getSizeInBytes", 0, address1.getSizeInBytes());
- assertEquals("getSizeInBytes", 0, address2.getSizeInBytes());
- }
+ assertEquals("Should return false as it is serialized", false, offheapAddress.isSerialized());
+ }
- @Test
- public void getValueSizeInBytesAlwaysReturnsZero() {
- TinyStoredObject address1 = new TinyStoredObject(10001L);
- TinyStoredObject address2 = new TinyStoredObject(10002L);
+ @Test
+ public void getDecompressedBytesShouldReturnDecompressedBytesIfCompressed() {
+ Object regionEntryValue = getValue();
+ byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
- assertEquals("getSizeInBytes", 0, address1.getValueSizeInBytes());
- assertEquals("getSizeInBytes", 0, address2.getValueSizeInBytes());
- }
-
- @Test
- public void isCompressedShouldReturnTrueIfCompressed() {
- Object regionEntryValue = getValue();
-
- TinyStoredObject offheapAddress = createValueAsCompressedStoredObject(regionEntryValue);
-
- assertEquals("Should return true as it is compressed", true, offheapAddress.isCompressed());
- }
-
- @Test
- public void isCompressedShouldReturnFalseIfNotCompressed() {
- Object regionEntryValue = getValue();
-
- TinyStoredObject offheapAddress = createValueAsUncompressedStoredObject(regionEntryValue);
-
- assertEquals("Should return false as it is compressed", false, offheapAddress.isCompressed());
- }
-
- @Test
- public void isSerializedShouldReturnTrueIfSeriazlied() {
- Object regionEntryValue = getValue();
-
- TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
-
- assertEquals("Should return true as it is serialized", true, offheapAddress.isSerialized());
- }
-
- @Test
- public void isSerializedShouldReturnFalseIfNotSeriazlied() {
- Object regionEntryValue = getValue();
+ //encode a non-serialized and compressed entry value to address - last argument is to let that it is compressed
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(regionEntryValueAsBytes, false, true);
+ TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
- TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValue);
+ RegionEntryContext regionContext = mock(RegionEntryContext.class);
+ CachePerfStats cacheStats = mock(CachePerfStats.class);
+ Compressor compressor = mock(Compressor.class);
- assertEquals("Should return false as it is serialized", false, offheapAddress.isSerialized());
- }
-
- @Test
- public void getDecompressedBytesShouldReturnDecompressedBytesIfCompressed() {
- Object regionEntryValue = getValue();
- byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+ long startTime = 10000L;
- //encode a non-serialized and compressed entry value to address - last argument is to let that it is compressed
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(regionEntryValueAsBytes, false, true);
- TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
+ //mock required things
+ when(regionContext.getCompressor()).thenReturn(compressor);
+ when(compressor.decompress(regionEntryValueAsBytes)).thenReturn(regionEntryValueAsBytes);
+ when(regionContext.getCachePerfStats()).thenReturn(cacheStats);
+ when(cacheStats.startDecompression()).thenReturn(startTime);
- RegionEntryContext regionContext = mock(RegionEntryContext.class);
- CachePerfStats cacheStats = mock(CachePerfStats.class);
- Compressor compressor = mock(Compressor.class);
+ //invoke the thing
+ byte[] bytes = offheapAddress.getDecompressedBytes(regionContext);
- long startTime = 10000L;
+ //verify the thing happened
+ verify(cacheStats, atLeastOnce()).startDecompression();
+ verify(compressor, times(1)).decompress(regionEntryValueAsBytes);
+ verify(cacheStats, atLeastOnce()).endDecompression(startTime);
- //mock required things
- when(regionContext.getCompressor()).thenReturn(compressor);
- when(compressor.decompress(regionEntryValueAsBytes)).thenReturn(regionEntryValueAsBytes);
- when(regionContext.getCachePerfStats()).thenReturn(cacheStats);
- when(cacheStats.startDecompression()).thenReturn(startTime);
+ assertArrayEquals(regionEntryValueAsBytes, bytes);
+ }
- //invoke the thing
- byte[] bytes = offheapAddress.getDecompressedBytes(regionContext);
+ @Test
+ public void getDecompressedBytesShouldNotTryToDecompressIfNotCompressed() {
+ Object regionEntryValue = getValue();
- //verify the thing happened
- verify(cacheStats, atLeastOnce()).startDecompression();
- verify(compressor, times(1)).decompress(regionEntryValueAsBytes);
- verify(cacheStats, atLeastOnce()).endDecompression(startTime);
-
- assertArrayEquals(regionEntryValueAsBytes, bytes);
- }
+ TinyStoredObject offheapAddress = createValueAsUncompressedStoredObject(regionEntryValue);
- @Test
- public void getDecompressedBytesShouldNotTryToDecompressIfNotCompressed() {
- Object regionEntryValue = getValue();
+ //mock the thing
+ RegionEntryContext regionContext = mock(RegionEntryContext.class);
+ Compressor compressor = mock(Compressor.class);
+ when(regionContext.getCompressor()).thenReturn(compressor);
- TinyStoredObject offheapAddress = createValueAsUncompressedStoredObject(regionEntryValue);
+ //invoke the thing
+ byte[] actualValueInBytes = offheapAddress.getDecompressedBytes(regionContext);
- //mock the thing
- RegionEntryContext regionContext = mock(RegionEntryContext.class);
- Compressor compressor = mock(Compressor.class);
- when(regionContext.getCompressor()).thenReturn(compressor);
+ //createValueAsUncompressedStoredObject does uses a serialized value - so convert it to object
+ Object actualRegionValue = convertSerializedByteArrayToObject(actualValueInBytes);
- //invoke the thing
- byte[] actualValueInBytes = offheapAddress.getDecompressedBytes(regionContext);
-
- //createValueAsUncompressedStoredObject does uses a serialized value - so convert it to object
- Object actualRegionValue = convertSerializedByteArrayToObject(actualValueInBytes);
-
- //verify the thing happened
- verify(regionContext, never()).getCompressor();
- assertEquals(regionEntryValue, actualRegionValue);
- }
+ //verify the thing happened
+ verify(regionContext, never()).getCompressor();
+ assertEquals(regionEntryValue, actualRegionValue);
+ }
- @Test
- public void getRawBytesShouldReturnAByteArray() {
- byte[] regionEntryValueAsBytes = getValueAsByteArray();
+ @Test
+ public void getRawBytesShouldReturnAByteArray() {
+ byte[] regionEntryValueAsBytes = getValueAsByteArray();
- TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValueAsBytes);
- byte[] actual = offheapAddress.getRawBytes();
+ TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValueAsBytes);
+ byte[] actual = offheapAddress.getRawBytes();
- assertArrayEquals(regionEntryValueAsBytes, actual);
- }
+ assertArrayEquals(regionEntryValueAsBytes, actual);
+ }
- @Test
- public void getSerializedValueShouldReturnASerializedByteArray() {
- Object regionEntryValue = getValue();
+ @Test
+ public void getSerializedValueShouldReturnASerializedByteArray() {
+ Object regionEntryValue = getValue();
- TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
+ TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
- byte[] actualSerializedValue = offheapAddress.getSerializedValue();
+ byte[] actualSerializedValue = offheapAddress.getSerializedValue();
- Object actualRegionEntryValue = convertSerializedByteArrayToObject(actualSerializedValue);
+ Object actualRegionEntryValue = convertSerializedByteArrayToObject(actualSerializedValue);
- assertEquals(regionEntryValue, actualRegionEntryValue);
- }
+ assertEquals(regionEntryValue, actualRegionEntryValue);
+ }
- @Test
- public void getDeserializedObjectShouldReturnADeserializedObject() {
- Object regionEntryValue = getValue();
+ @Test
+ public void getDeserializedObjectShouldReturnADeserializedObject() {
+ Object regionEntryValue = getValue();
- TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
+ TinyStoredObject offheapAddress = createValueAsSerializedStoredObject(regionEntryValue);
- Integer actualRegionEntryValue = (Integer) offheapAddress.getDeserializedValue(null, null);
+ Integer actualRegionEntryValue = (Integer) offheapAddress.getDeserializedValue(null, null);
- assertEquals(regionEntryValue, actualRegionEntryValue);
- }
+ assertEquals(regionEntryValue, actualRegionEntryValue);
+ }
- @Test
- public void getDeserializedObjectShouldReturnAByteArrayAsIsIfNotSerialized() {
- byte[] regionEntryValueAsBytes = getValueAsByteArray();
+ @Test
+ public void getDeserializedObjectShouldReturnAByteArrayAsIsIfNotSerialized() {
+ byte[] regionEntryValueAsBytes = getValueAsByteArray();
- TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValueAsBytes);
+ TinyStoredObject offheapAddress = createValueAsUnserializedStoredObject(regionEntryValueAsBytes);
- byte[] deserializeValue = (byte[]) offheapAddress.getDeserializedValue(null, null);
+ byte[] deserializeValue = (byte[]) offheapAddress.getDeserializedValue(null, null);
- assertArrayEquals(regionEntryValueAsBytes, deserializeValue);
- }
+ assertArrayEquals(regionEntryValueAsBytes, deserializeValue);
+ }
- @Test
- public void fillSerializedValueShouldFillWrapperWithSerializedValueIfValueIsSerialized() {
- Object regionEntryValue = getValue();
- byte[] serializedRegionEntryValue = EntryEventImpl.serialize(regionEntryValue);
+ @Test
+ public void fillSerializedValueShouldFillWrapperWithSerializedValueIfValueIsSerialized() {
+ Object regionEntryValue = getValue();
+ byte[] serializedRegionEntryValue = EntryEventImpl.serialize(regionEntryValue);
- //encode a serialized entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(serializedRegionEntryValue, true, false);
+ //encode a serialized entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(serializedRegionEntryValue, true, false);
- TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
+ TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
- //mock the things
- BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
+ //mock the things
+ BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
- byte userBits = 1;
- offheapAddress.fillSerializedValue(wrapper, userBits);
+ byte userBits = 1;
+ offheapAddress.fillSerializedValue(wrapper, userBits);
- verify(wrapper, times(1)).setData(serializedRegionEntryValue, userBits, serializedRegionEntryValue.length, true);
- }
+ verify(wrapper, times(1)).setData(serializedRegionEntryValue, userBits, serializedRegionEntryValue.length, true);
+ }
- @Test
- public void fillSerializedValueShouldFillWrapperWithDeserializedValueIfValueIsNotSerialized() {
- Object regionEntryValue = getValue();
- byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+ @Test
+ public void fillSerializedValueShouldFillWrapperWithDeserializedValueIfValueIsNotSerialized() {
+ Object regionEntryValue = getValue();
+ byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
- //encode a un serialized entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(regionEntryValueAsBytes, false, false);
+ //encode a un serialized entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(regionEntryValueAsBytes, false, false);
- TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
+ TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
- //mock the things
- BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
+ //mock the things
+ BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
- byte userBits = 1;
- offheapAddress.fillSerializedValue(wrapper, userBits);
+ byte userBits = 1;
+ offheapAddress.fillSerializedValue(wrapper, userBits);
- verify(wrapper, times(1)).setData(regionEntryValueAsBytes, userBits, regionEntryValueAsBytes.length, true);
- }
+ verify(wrapper, times(1)).setData(regionEntryValueAsBytes, userBits, regionEntryValueAsBytes.length, true);
+ }
- @Test
- public void getStringFormShouldCatchExceptionAndReturnErrorMessageAsString() {
- Object regionEntryValueAsBytes = getValue();
+ @Test
+ public void getStringFormShouldCatchExceptionAndReturnErrorMessageAsString() {
+ Object regionEntryValueAsBytes = getValue();
- byte[] serializedValue = EntryEventImpl.serialize(regionEntryValueAsBytes);
+ byte[] serializedValue = EntryEventImpl.serialize(regionEntryValueAsBytes);
- //store -127 (DSCODE.ILLEGAL) - in order the deserialize to throw exception
- serializedValue[0] = -127;
+ //store -127 (DSCODE.ILLEGAL) - in order the deserialize to throw exception
+ serializedValue[0] = -127;
- //encode a un serialized entry value to address
- long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(serializedValue, true, false);
+ //encode a un serialized entry value to address
+ long encodedAddress = OffHeapRegionEntryHelper.encodeDataAsAddress(serializedValue, true, false);
- TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
+ TinyStoredObject offheapAddress = new TinyStoredObject(encodedAddress);
- String errorMessage = offheapAddress.getStringForm();
+ String errorMessage = offheapAddress.getStringForm();
- assertEquals(true, errorMessage.contains("Could not convert object to string because "));
- }
+ assertEquals(true, errorMessage.contains("Could not convert object to string because "));
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherJUnitTest.java
index 78dc6bb..3ff9936 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/LocalProcessLauncherJUnitTest.java
@@ -24,26 +24,36 @@ import java.io.FileReader;
import java.io.FileWriter;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
import com.gemstone.gemfire.internal.OSProcess;
-import com.gemstone.gemfire.internal.process.LocalProcessLauncher;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
/**
* Unit tests for ProcessLauncher.
*
* @since 7.0
*/
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
public class LocalProcessLauncherJUnitTest {
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public TestName testName = new TestName();
+
+ private File pidFile;
+
@Before
- public void createDirectory() throws Exception {
- new File(getClass().getSimpleName()).mkdir();
+ public void setUp() throws Exception {
+ this.pidFile = new File(this.temporaryFolder.getRoot(), testName.getMethodName() + ".pid");
}
-
+
@Test
public void testPidAccuracy() throws PidUnavailableException {
int pid = ProcessUtils.identifyPid();
@@ -58,8 +68,6 @@ public class LocalProcessLauncherJUnitTest {
@Test
public void testPidFileIsCreated() throws Exception {
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testPidFileIsCreated.pid");
assertFalse(pidFile.exists());
new LocalProcessLauncher(pidFile, false);
assertTrue(pidFile.exists());
@@ -67,8 +75,6 @@ public class LocalProcessLauncherJUnitTest {
@Test
public void testPidFileContainsPid() throws Exception {
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testPidFileContainsPid.pid");
final LocalProcessLauncher launcher = new LocalProcessLauncher(pidFile, false);
assertNotNull(launcher);
assertTrue(pidFile.exists());
@@ -85,8 +91,6 @@ public class LocalProcessLauncherJUnitTest {
@Test
public void testPidFileIsCleanedUp() throws Exception {
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testPidFileIsCleanedUp.pid");
final LocalProcessLauncher launcher = new LocalProcessLauncher(pidFile, false);
assertTrue(pidFile.exists());
launcher.close(); // TODO: launch an external JVM and then close it nicely
@@ -95,8 +99,6 @@ public class LocalProcessLauncherJUnitTest {
@Test
public void testExistingPidFileThrows() throws Exception {
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testExistingPidFileThrows.pid");
assertTrue(pidFile.createNewFile());
assertTrue(pidFile.exists());
@@ -115,8 +117,6 @@ public class LocalProcessLauncherJUnitTest {
@Test
public void testStalePidFileIsReplaced() throws Exception {
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testStalePidFileIsReplaced.pid");
assertTrue(pidFile.createNewFile());
assertTrue(pidFile.exists());
@@ -143,9 +143,7 @@ public class LocalProcessLauncherJUnitTest {
public void testForceReplacesExistingPidFile() throws Exception {
assertTrue("testForceReplacesExistingPidFile is broken if PID == Integer.MAX_VALUE",
ProcessUtils.identifyPid() != Integer.MAX_VALUE);
-
- final File pidFile = new File(getClass().getSimpleName()
- + File.separator + "testForceReplacesExistingPidFile.pid");
+
assertTrue(pidFile.createNewFile());
assertTrue(pidFile.exists());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
index e74365e..bd9bf62 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
@@ -41,7 +41,7 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import com.gemstone.gemfire.internal.util.StopWatch;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
import com.gemstone.gemfire.test.junit.rules.ExpectedTimeoutRule;
/**
@@ -49,7 +49,7 @@ import com.gemstone.gemfire.test.junit.rules.ExpectedTimeoutRule;
*
* @since 8.2
*/
-@Category(UnitTest.class)
+@Category(IntegrationTest.class)
public class PidFileJUnitTest {
@Rule
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectSizerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectSizerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectSizerJUnitTest.java
index 91af22c..0852c9d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectSizerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectSizerJUnitTest.java
@@ -16,26 +16,19 @@
*/
package com.gemstone.gemfire.internal.size;
+import static com.gemstone.gemfire.internal.size.SizeTestUtil.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-import static com.gemstone.gemfire.internal.size.SizeTestUtil.*;
-
@Category(UnitTest.class)
-public class ObjectSizerJUnitTest extends TestCase {
-
-
- public ObjectSizerJUnitTest() {
- super();
- }
-
- public ObjectSizerJUnitTest(String name) {
- super(name);
- }
+public class ObjectSizerJUnitTest {
- public void test() throws IllegalArgumentException, IllegalAccessException {
+ @Test
+ public void test() throws Exception {
assertEquals(roundup(OBJECT_SIZE), ObjectGraphSizer.size(new Object()));
assertEquals(roundup(OBJECT_SIZE + 4), ObjectGraphSizer.size(new TestObject1()));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectTraverserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectTraverserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectTraverserJUnitTest.java
index bd0bf9d..87ca34f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectTraverserJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ObjectTraverserJUnitTest.java
@@ -16,24 +16,25 @@
*/
package com.gemstone.gemfire.internal.size;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
+import org.junit.Ignore;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
-public class ObjectTraverserJUnitTest extends TestCase {
-
- public void testBasic() throws IllegalArgumentException, IllegalAccessException {
-
+public class ObjectTraverserJUnitTest {
+
+ @Test
+ public void testBasic() throws Exception {
Set testData = new HashSet();
Object one = new Object();
testData.add(one);
@@ -46,36 +47,35 @@ public class ObjectTraverserJUnitTest extends TestCase {
TestVisitor visitor = new TestVisitor();
ObjectTraverser.breadthFirstSearch(testData, visitor, false);
- Assert.assertNotNull(visitor.visited.remove(testData));
- Assert.assertNotNull(visitor.visited.remove(one));
- Assert.assertNotNull(visitor.visited.remove(two));
- Assert.assertNotNull(visitor.visited.remove(three));
+ assertNotNull(visitor.visited.remove(testData));
+ assertNotNull(visitor.visited.remove(one));
+ assertNotNull(visitor.visited.remove(two));
+ assertNotNull(visitor.visited.remove(three));
}
-
- public void testStatics() throws IllegalArgumentException, IllegalAccessException {
-
+
+ @Test
+ public void testStatics() throws Exception {
final Object staticObject = new Object();
TestObject1.test2 = staticObject;
TestObject1 test1 = new TestObject1();
TestVisitor visitor = new TestVisitor();
ObjectTraverser.breadthFirstSearch(test1, visitor, false);
- Assert.assertNull(visitor.visited.get(staticObject));
+ assertNull(visitor.visited.get(staticObject));
visitor = new TestVisitor();
ObjectTraverser.breadthFirstSearch(test1, visitor, true);
- Assert.assertNotNull(visitor.visited.get(staticObject));
+ assertNotNull(visitor.visited.get(staticObject));
}
-
- public void testStop() throws IllegalArgumentException, IllegalAccessException {
+
+ @Test
+ public void testStop() throws Exception {
Set set1 = new HashSet();
final Set set2 = new HashSet();
Object object3 = new Object();
set1.add(set2);
set2.add(object3);
-
-
TestVisitor visitor = new TestVisitor();
visitor = new TestVisitor() {
public boolean visit(Object parent, Object object) {
@@ -86,14 +86,15 @@ public class ObjectTraverserJUnitTest extends TestCase {
ObjectTraverser.breadthFirstSearch(set1, visitor, true);
- Assert.assertNotNull(visitor.visited.get(set1));
- Assert.assertNotNull(visitor.visited.get(set2));
- Assert.assertNull(visitor.visited.get(object3));
+ assertNotNull(visitor.visited.get(set1));
+ assertNotNull(visitor.visited.get(set2));
+ assertNull(visitor.visited.get(object3));
}
/** This test is commented out because it needs to be verified manually */
- public void z_testHistogram() throws IllegalArgumentException, IllegalAccessException {
-
+ @Ignore("commented out because it needs to be verified manually")
+ @Test
+ public void testHistogram() throws Exception {
Set set1 = new HashSet();
final Set set2 = new HashSet();
Object object3 = new Object();
@@ -110,7 +111,7 @@ public class ObjectTraverserJUnitTest extends TestCase {
public Map visited = new IdentityHashMap();
public boolean visit(Object parent, Object object) {
- Assert.assertNull(visited.put(object, VALUE));
+ assertNull(visited.put(object, VALUE));
return true;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ReflectionObjectSizerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ReflectionObjectSizerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ReflectionObjectSizerJUnitTest.java
index 4489433..7618e36 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ReflectionObjectSizerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/ReflectionObjectSizerJUnitTest.java
@@ -17,29 +17,26 @@
package com.gemstone.gemfire.internal.size;
import static org.junit.Assert.*;
-
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import io.codearte.catchexception.shade.mockito.Mockito;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class ReflectionObjectSizerJUnitTest {
@Test
public void skipsSizingDistributedSystem() {
-
- Object referenceObject = Mockito.mock(InternalDistributedSystem.class);
+ Object referenceObject = mock(InternalDistributedSystem.class);
checkSizeDoesNotChange(referenceObject);
}
@Test
public void skipsSizingClassLoader() {
-
checkSizeDoesNotChange(Thread.currentThread().getContextClassLoader());
}
@@ -59,7 +56,7 @@ public class ReflectionObjectSizerJUnitTest {
assertNotEquals(sizeWithoutReference, sizer.sizeof(stringReference));
}
- public class TestObject {
+ private static class TestObject {
public TestObject(final Object reference) {
this.reference = reference;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/size/SizeClassOnceObjectSizerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/SizeClassOnceObjectSizerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/SizeClassOnceObjectSizerJUnitTest.java
index 8f41b21..5f7bb1b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/SizeClassOnceObjectSizerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/SizeClassOnceObjectSizerJUnitTest.java
@@ -16,20 +16,19 @@
*/
package com.gemstone.gemfire.internal.size;
-import org.junit.experimental.categories.Category;
-
-import junit.framework.TestCase;
import static com.gemstone.gemfire.internal.size.SizeTestUtil.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.util.ObjectSizer;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-/**
- *
- */
@Category(UnitTest.class)
-public class SizeClassOnceObjectSizerJUnitTest extends TestCase{
-
+public class SizeClassOnceObjectSizerJUnitTest {
+
+ @Test
public void test() {
byte[] b1 = new byte[5];
byte[] b2 = new byte[15];
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/size/WellKnownClassSizerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/WellKnownClassSizerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/WellKnownClassSizerJUnitTest.java
index 76655fb..e25ae4c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/size/WellKnownClassSizerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/size/WellKnownClassSizerJUnitTest.java
@@ -16,20 +16,19 @@
*/
package com.gemstone.gemfire.internal.size;
+import static com.gemstone.gemfire.internal.size.SizeTestUtil.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.cache.util.ObjectSizer;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-import static com.gemstone.gemfire.internal.size.SizeTestUtil.*;
-
-/**
- *
- */
@Category(UnitTest.class)
-public class WellKnownClassSizerJUnitTest extends TestCase {
-
+public class WellKnownClassSizerJUnitTest {
+
+ @Test
public void testByteArrays() {
byte[] test1 = new byte[5];
byte[] test2 = new byte[8];
@@ -41,7 +40,8 @@ public class WellKnownClassSizerJUnitTest extends TestCase {
assertEquals(0, WellKnownClassSizer.sizeof(new Object()));
}
-
+
+ @Test
public void testStrings() {
String test1 = "123";
String test2 = "012345678";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java
index dcf9420..040fc85 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/SampleCollectorJUnitTest.java
@@ -16,22 +16,18 @@
*/
package com.gemstone.gemfire.internal.statistics;
-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.fail;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.io.File;
import java.util.List;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
import com.gemstone.gemfire.StatisticDescriptor;
import com.gemstone.gemfire.Statistics;
@@ -51,40 +47,24 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class SampleCollectorJUnitTest {
- private static final String dir = "SampleCollectorJUnitTest";
-
- private Mockery mockContext;
- private TestStatisticsManager manager;
+ private TestStatisticsManager manager;
private SampleCollector sampleCollector;
@Before
public void setUp() throws Exception {
- new File(dir).mkdir();
- this.mockContext = new Mockery() {{
- setImposteriser(ClassImposteriser.INSTANCE);
- }};
final long startTime = System.currentTimeMillis();
- this.manager = new TestStatisticsManager(1, "SampleCollectorJUnitTest", startTime);
-
- final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = this.mockContext.mock(StatArchiveHandlerConfig.class, "SampleCollectorJUnitTest$StatArchiveHandlerConfig");
- this.mockContext.checking(new Expectations() {{
- allowing(mockStatArchiveHandlerConfig).getArchiveFileName();
- will(returnValue(new File("")));
- allowing(mockStatArchiveHandlerConfig).getArchiveFileSizeLimit();
- will(returnValue(0));
- allowing(mockStatArchiveHandlerConfig).getArchiveDiskSpaceLimit();
- will(returnValue(0));
- allowing(mockStatArchiveHandlerConfig).getSystemId();
- will(returnValue(1));
- allowing(mockStatArchiveHandlerConfig).getSystemStartTime();
- will(returnValue(startTime));
- allowing(mockStatArchiveHandlerConfig).getSystemDirectoryPath();
- will(returnValue(""));
- allowing(mockStatArchiveHandlerConfig).getProductDescription();
- will(returnValue("SampleCollectorJUnitTest"));
- }});
+ this.manager = new TestStatisticsManager(1, getClass().getSimpleName(), startTime);
+
+ final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = mock(StatArchiveHandlerConfig.class, getClass().getSimpleName() + "$" + StatArchiveHandlerConfig.class.getSimpleName());
+ when(mockStatArchiveHandlerConfig.getArchiveFileName()).thenReturn(new File(""));
+ when(mockStatArchiveHandlerConfig.getArchiveFileSizeLimit()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getArchiveDiskSpaceLimit()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getSystemId()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getSystemStartTime()).thenReturn(startTime);
+ when(mockStatArchiveHandlerConfig.getSystemDirectoryPath()).thenReturn("");
+ when(mockStatArchiveHandlerConfig.getProductDescription()).thenReturn(getClass().getSimpleName());
- StatisticsSampler sampler = new TestStatisticsSampler(manager);
+ final StatisticsSampler sampler = new TestStatisticsSampler(manager);
this.sampleCollector = new SampleCollector(sampler);
this.sampleCollector.initialize(mockStatArchiveHandlerConfig, NanoTimer.getTime());
}
@@ -95,8 +75,6 @@ public class SampleCollectorJUnitTest {
this.sampleCollector.close();
this.sampleCollector = null;
}
- this.mockContext.assertIsSatisfied();
- this.mockContext = null;
this.manager = null;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java
index 6c88fd4..0266e86 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatMonitorHandlerJUnitTest.java
@@ -27,29 +27,19 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import com.gemstone.gemfire.i18n.LogWriterI18n;
import com.gemstone.gemfire.internal.NanoTimer;
-import com.gemstone.gemfire.internal.logging.LogWriterImpl;
-import com.gemstone.gemfire.internal.logging.PureLogWriter;
import com.gemstone.gemfire.internal.statistics.StatMonitorHandler.StatMonitorNotifier;
import com.gemstone.gemfire.internal.util.StopWatch;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
- * Unit test for the StatMonitorHandler and its inner classes.
+ * Unit tests for the StatMonitorHandler and its inner classes.
*
* @since 7.0
*/
@Category(UnitTest.class)
public class StatMonitorHandlerJUnitTest {
- private LogWriterI18n log = null;
-
- @Before
- public void setUp() throws Exception {
- this.log = new PureLogWriter(LogWriterImpl.levelNameToCode("config"));
- }
-
@Test
public void testAddNewMonitor() throws Exception {
StatMonitorHandler handler = new StatMonitorHandler();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java
index f8cf043..4f4e6bd 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/statistics/StatisticsMonitorJUnitTest.java
@@ -17,68 +17,43 @@
package com.gemstone.gemfire.internal.statistics;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.io.File;
import java.util.List;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.internal.NanoTimer;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.logging.LogWriterImpl;
-import com.gemstone.gemfire.internal.logging.PureLogWriter;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
- * Unit and integration tests for the StatisticsMonitor.
+ * Unit tests for the StatisticsMonitor class.
*
* @since 7.0
*/
@Category(UnitTest.class)
public class StatisticsMonitorJUnitTest {
- private Mockery mockContext;
- private InternalLogWriter log;
- private TestStatisticsManager manager;
+ private TestStatisticsManager manager;
private SampleCollector sampleCollector;
@Before
public void setUp() throws Exception {
- this.mockContext = new Mockery() {{
- setImposteriser(ClassImposteriser.INSTANCE);
- }};
-
- this.log = new PureLogWriter(LogWriterImpl.levelNameToCode("config"));
-
final long startTime = System.currentTimeMillis();
- this.manager = new TestStatisticsManager(
- 1,
- "StatisticsMonitorJUnitTest",
- startTime);
+ this.manager = new TestStatisticsManager(1, getClass().getSimpleName(), startTime);
- final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = this.mockContext.mock(StatArchiveHandlerConfig.class, "StatisticsMonitorJUnitTest$StatArchiveHandlerConfig");
- this.mockContext.checking(new Expectations() {{
- allowing(mockStatArchiveHandlerConfig).getArchiveFileName();
- will(returnValue(new File("")));
- allowing(mockStatArchiveHandlerConfig).getArchiveFileSizeLimit();
- will(returnValue(0));
- allowing(mockStatArchiveHandlerConfig).getArchiveDiskSpaceLimit();
- will(returnValue(0));
- allowing(mockStatArchiveHandlerConfig).getSystemId();
- will(returnValue(1));
- allowing(mockStatArchiveHandlerConfig).getSystemStartTime();
- will(returnValue(startTime));
- allowing(mockStatArchiveHandlerConfig).getSystemDirectoryPath();
- will(returnValue(""));
- allowing(mockStatArchiveHandlerConfig).getProductDescription();
- will(returnValue("StatisticsMonitorJUnitTest"));
- }});
+ final StatArchiveHandlerConfig mockStatArchiveHandlerConfig = mock(StatArchiveHandlerConfig.class, getClass().getSimpleName() + "$" + StatArchiveHandlerConfig.class.getSimpleName());
+ when(mockStatArchiveHandlerConfig.getArchiveFileName()).thenReturn(new File(""));
+ when(mockStatArchiveHandlerConfig.getArchiveFileSizeLimit()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getArchiveDiskSpaceLimit()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getSystemId()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getSystemStartTime()).thenReturn(0L);
+ when(mockStatArchiveHandlerConfig.getSystemDirectoryPath()).thenReturn("");
+ when(mockStatArchiveHandlerConfig.getProductDescription()).thenReturn(getClass().getSimpleName());
StatisticsSampler sampler = new TestStatisticsSampler(manager);
this.sampleCollector = new SampleCollector(sampler);
@@ -91,8 +66,6 @@ public class StatisticsMonitorJUnitTest {
this.sampleCollector.close();
this.sampleCollector = null;
}
- this.mockContext.assertIsSatisfied();
- this.mockContext = null;
this.manager = null;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/ArrayUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/ArrayUtilsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/ArrayUtilsJUnitTest.java
index 0a78a19..dde21ca 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/ArrayUtilsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/ArrayUtilsJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.util;
import static org.junit.Assert.*;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BytesJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BytesJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BytesJUnitTest.java
index e5a7f4d..997548c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BytesJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/BytesJUnitTest.java
@@ -16,18 +16,21 @@
*/
package com.gemstone.gemfire.internal.util;
+import static org.junit.Assert.*;
+
import java.nio.ByteBuffer;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
-public class BytesJUnitTest extends TestCase {
+public class BytesJUnitTest {
+
private ByteBuffer buf = ByteBuffer.allocate(8);
-
+
+ @Test
public void testShort() {
short[] val = { 666, -1, Short.MIN_VALUE, 0, 12, Short.MAX_VALUE };
for (int i = 0; i < val.length; i++) {
@@ -37,7 +40,8 @@ public class BytesJUnitTest extends TestCase {
buf.rewind();
}
}
-
+
+ @Test
public void testChar() {
char[] val = { 'a', 'b', 'c' };
for (int i = 0; i < val.length; i++) {
@@ -47,7 +51,8 @@ public class BytesJUnitTest extends TestCase {
buf.rewind();
}
}
-
+
+ @Test
public void testUnsignedShort() {
int[] val = { 0, 1, Short.MAX_VALUE + 1, 2 * Short.MAX_VALUE };
for (int i = 0; i < val.length; i++) {
@@ -57,7 +62,8 @@ public class BytesJUnitTest extends TestCase {
buf.rewind();
}
}
-
+
+ @Test
public void testInt() {
int[] val = { 666, -1, Integer.MIN_VALUE, 0, 1, Integer.MAX_VALUE };
for (int i = 0; i < val.length; i++) {
@@ -71,7 +77,8 @@ public class BytesJUnitTest extends TestCase {
assertEquals(val[i], Bytes.toInt(bytes[0], bytes[1], bytes[2], bytes[3]));
}
}
-
+
+ @Test
public void testLong() {
long[] val = { 666, -1, Long.MIN_VALUE, 0, 1, Long.MAX_VALUE };
for (int i = 0; i < val.length; i++) {
@@ -82,8 +89,8 @@ public class BytesJUnitTest extends TestCase {
buf.rewind();
}
}
-
-
+
+ @Test
public void testVarint() {
ByteBuffer buf = ByteBuffer.allocate(5);
checkVarint(0, buf);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/CollectionUtilsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/CollectionUtilsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/CollectionUtilsJUnitTest.java
index 0748055..242d2f2 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/CollectionUtilsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/CollectionUtilsJUnitTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.internal.util;
import static org.junit.Assert.*;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/DelayedActionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/DelayedActionJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/DelayedActionJUnitTest.java
index c6aa1a3..3a2d660 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/DelayedActionJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/DelayedActionJUnitTest.java
@@ -16,19 +16,22 @@
*/
package com.gemstone.gemfire.internal.util;
+import static org.junit.Assert.*;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
@Category(UnitTest.class)
-public class DelayedActionJUnitTest extends TestCase {
+public class DelayedActionJUnitTest {
+
+ @Test
public void testDelay() throws InterruptedException {
final AtomicBoolean hit = new AtomicBoolean(false);
final CountDownLatch complete = new CountDownLatch(1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CompactConcurrentHashSetJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CompactConcurrentHashSetJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CompactConcurrentHashSetJUnitTest.java
index 216a85c..7c63dd4 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CompactConcurrentHashSetJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/CompactConcurrentHashSetJUnitTest.java
@@ -16,8 +16,7 @@
*/
package com.gemstone.gemfire.internal.util.concurrent;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.util.HashSet;
import java.util.Iterator;
@@ -32,9 +31,10 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class CompactConcurrentHashSetJUnitTest {
- static int RANGE = 100000;
- static int SET_SIZE = 1000;
- Random ran = new Random();
+
+ private static final int RANGE = 100000;
+
+ private Random random = new Random();
@Test
public void testEquals() {
@@ -42,7 +42,7 @@ public class CompactConcurrentHashSetJUnitTest {
s1 = new CompactConcurrentHashSet2();
s2 = new HashSet();
for (int i=0; i<10000; i++) {
- int nexti = ran.nextInt(RANGE);
+ int nexti = random.nextInt(RANGE);
s1.add(nexti);
s2.add(nexti);
assertTrue("expected s1 and s2 to be equal", s1.equals(s2));
@@ -60,7 +60,7 @@ public class CompactConcurrentHashSetJUnitTest {
Set<Integer> s1;
s1 = new CompactConcurrentHashSet2<Integer>();
for (int i=0; i<10000; i++) {
- int nexti = ran.nextInt(RANGE);
+ int nexti = random.nextInt(RANGE);
s1.add(nexti);
}
for (Iterator<Integer> it=s1.iterator(); it.hasNext(); ) {
@@ -80,7 +80,7 @@ public class CompactConcurrentHashSetJUnitTest {
s1 = new CompactConcurrentHashSet2<Integer>();
s2 = new HashSet<Integer>();
for (int i=0; i<10000; i++) {
- int nexti = ran.nextInt(RANGE);
+ int nexti = random.nextInt(RANGE);
s1.add(nexti);
s2.add(nexti);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ReentrantSemaphoreJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ReentrantSemaphoreJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ReentrantSemaphoreJUnitTest.java
index d24d067..f655754 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ReentrantSemaphoreJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/ReentrantSemaphoreJUnitTest.java
@@ -16,22 +16,21 @@
*/
package com.gemstone.gemfire.internal.util.concurrent;
+import static org.junit.Assert.*;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
-/**
- *
- */
@Category(UnitTest.class)
-public class ReentrantSemaphoreJUnitTest extends TestCase {
-
+public class ReentrantSemaphoreJUnitTest {
+
+ @Test
public void test() throws Throwable {
final ReentrantSemaphore sem = new ReentrantSemaphore(2);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/SemaphoreReadWriteLockJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/SemaphoreReadWriteLockJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/SemaphoreReadWriteLockJUnitTest.java
index bc598e6..6bd7999 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/SemaphoreReadWriteLockJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/util/concurrent/SemaphoreReadWriteLockJUnitTest.java
@@ -16,24 +16,23 @@
*/
package com.gemstone.gemfire.internal.util.concurrent;
+import static org.junit.Assert.*;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
-/**
- *
- */
@Category(UnitTest.class)
-public class SemaphoreReadWriteLockJUnitTest extends TestCase {
+public class SemaphoreReadWriteLockJUnitTest {
- public void testReaderWaitsForWriter() throws InterruptedException {
+ @Test
+ public void testReaderWaitsForWriter() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
@@ -56,7 +55,8 @@ public class SemaphoreReadWriteLockJUnitTest extends TestCase {
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
- public void testWriterWaitsForReader() throws InterruptedException {
+ @Test
+ public void testWriterWaitsForReader() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
@@ -79,7 +79,8 @@ public class SemaphoreReadWriteLockJUnitTest extends TestCase {
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
- public void testReadersNotBlockedByReaders() throws InterruptedException {
+ @Test
+ public void testReadersNotBlockedByReaders() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
@@ -99,7 +100,8 @@ public class SemaphoreReadWriteLockJUnitTest extends TestCase {
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
- public void testWritersBlockedByWriters() throws InterruptedException {
+ @Test
+ public void testWritersBlockedByWriters() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
@@ -122,7 +124,8 @@ public class SemaphoreReadWriteLockJUnitTest extends TestCase {
assertTrue(latch.await(10, TimeUnit.SECONDS));
}
- public void testTrylock() throws InterruptedException {
+ @Test
+ public void testTrylock() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
@@ -146,7 +149,8 @@ public class SemaphoreReadWriteLockJUnitTest extends TestCase {
assertFalse(failed.get());
}
- public void testLockAndReleasebyDifferentThreads() throws InterruptedException {
+ @Test
+ public void testLockAndReleasebyDifferentThreads() throws Exception {
SemaphoreReadWriteLock rwl = new SemaphoreReadWriteLock();
final Lock rl = rwl.readLock();
final Lock wl = rwl.writeLock();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/UniversalMembershipListenerAdapterDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/UniversalMembershipListenerAdapterDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/UniversalMembershipListenerAdapterDUnitTest.java
index be73adc..c96c1c8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/UniversalMembershipListenerAdapterDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/UniversalMembershipListenerAdapterDUnitTest.java
@@ -448,7 +448,7 @@ public class UniversalMembershipListenerAdapterDUnitTest extends ClientServerTes
assertTrue(firedBridge[JOINED]);
assertEquals(clientMember, memberBridge[JOINED]);
//as of 6.1 the id can change when a bridge is created or a connection pool is created
- //assertEquals(clientMemberId, memberIdBridge[JOINED]);
+ //assertIndexDetailsEquals(clientMemberId, memberIdBridge[JOINED]);
assertTrue(isClientBridge[JOINED]);
assertFalse(firedBridge[LEFT]);
assertNull(memberBridge[LEFT]);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/GatewayReceiverStatsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/GatewayReceiverStatsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/GatewayReceiverStatsJUnitTest.java
index f007800..e188df4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/GatewayReceiverStatsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/GatewayReceiverStatsJUnitTest.java
@@ -88,8 +88,8 @@ public class GatewayReceiverStatsJUnitTest extends MBeanStatsTestCase {
bridge.stopMonitor();
- // TODO:FAIL: assertEquals(0, getCurrentClients());
- // TODO:FAIL: assertEquals(0, getConnectionThreads());
+ // TODO:FAIL: assertIndexDetailsEquals(0, getCurrentClients());
+ // TODO:FAIL: assertIndexDetailsEquals(0, getConnectionThreads());
}
@Test
@@ -112,8 +112,8 @@ public class GatewayReceiverStatsJUnitTest extends MBeanStatsTestCase {
assertEquals(1, getOutoforderBatchesReceived());
bridge.stopMonitor();
- // TODO:FAIL: assertEquals(0, getOutoforderBatchesReceived());
- // TODO:FAIL: assertEquals(0, getDuplicateBatchesReceived());
+ // TODO:FAIL: assertIndexDetailsEquals(0, getOutoforderBatchesReceived());
+ // TODO:FAIL: assertIndexDetailsEquals(0, getDuplicateBatchesReceived());
}
private float getCreateRequestsRate() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/RegionStatsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/RegionStatsJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/RegionStatsJUnitTest.java
index 6650fb2..f9b5489 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/RegionStatsJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/RegionStatsJUnitTest.java
@@ -78,7 +78,7 @@ public class RegionStatsJUnitTest extends MBeanStatsTestCase{
assertEquals(1, getNumBucketsWithoutRedundancy());
assertEquals(2, getActualRedundancy());
//assertTrue(getAvgBucketSize() > 0);
- //assertEquals(3, getConfiguredRedundancy());
+ //assertIndexDetailsEquals(3, getConfiguredRedundancy());
assertEquals(1, getDataStoreEntryCount());
assertEquals(10, getPrimaryBucketCount());
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/StatsRateJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/StatsRateJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/StatsRateJUnitTest.java
index bdccba5..9869a8e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/StatsRateJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/bean/stats/StatsRateJUnitTest.java
@@ -14,9 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.gemstone.gemfire.management.bean.stats;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.Statistics;
@@ -25,14 +28,8 @@ import com.gemstone.gemfire.management.internal.beans.stats.StatType;
import com.gemstone.gemfire.management.internal.beans.stats.StatsRate;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-
-/**
- *
- *
- */
@Category(UnitTest.class)
-public class StatsRateJUnitTest extends TestCase {
+public class StatsRateJUnitTest {
private Long SINGLE_STATS_LONG_COUNTER = null;
@@ -48,10 +45,7 @@ public class StatsRateJUnitTest extends TestCase {
private TestMBeanStatsMonitor statsMonitor = new TestMBeanStatsMonitor("TestStatsMonitor");
- public StatsRateJUnitTest(String name) {
- super(name);
- }
-
+ @Before
public void setUp() throws Exception {
SINGLE_STATS_LONG_COUNTER = 0L;
SINGLE_STATS_INT_COUNTER = 0;
@@ -61,10 +55,10 @@ public class StatsRateJUnitTest extends TestCase {
MULTI_STATS_INT_COUNTER_2 = 0;
}
+ @Test
public void testSingleStatLongRate() throws Exception {
StatsRate singleStatsRate = new StatsRate("SINGLE_STATS_LONG_COUNTER", StatType.LONG_TYPE, statsMonitor);
-
SINGLE_STATS_LONG_COUNTER = 5000L;
float actualRate = singleStatsRate.getRate();
@@ -74,13 +68,13 @@ public class StatsRateJUnitTest extends TestCase {
float expectedRate = 5000;
- assertEquals(expectedRate, actualRate);
+ assertEquals(expectedRate, actualRate, 0);
}
+ @Test
public void testSingleStatIntRate() throws Exception {
StatsRate singleStatsRate = new StatsRate("SINGLE_STATS_INT_COUNTER", StatType.INT_TYPE, statsMonitor);
-
SINGLE_STATS_INT_COUNTER = 5000;
float actualRate = singleStatsRate.getRate();
@@ -91,9 +85,10 @@ public class StatsRateJUnitTest extends TestCase {
float expectedRate = 5000;
- assertEquals(expectedRate, actualRate);
+ assertEquals(expectedRate, actualRate, 0);
}
+ @Test
public void testMultiStatLongRate() throws Exception {
String[] counters = new String[] { "MULTI_STATS_LONG_COUNTER_1", "MULTI_STATS_LONG_COUNTER_2" };
StatsRate multiStatsRate = new StatsRate(counters, StatType.LONG_TYPE, statsMonitor);
@@ -109,15 +104,14 @@ public class StatsRateJUnitTest extends TestCase {
float expectedRate = 9000;
- assertEquals(expectedRate, actualRate);
-
+ assertEquals(expectedRate, actualRate, 0);
}
+ @Test
public void testMultiStatIntRate() throws Exception {
String[] counters = new String[] { "MULTI_STATS_INT_COUNTER_1", "MULTI_STATS_INT_COUNTER_2" };
StatsRate multiStatsRate = new StatsRate(counters, StatType.INT_TYPE, statsMonitor);
-
MULTI_STATS_INT_COUNTER_1 = 5000;
MULTI_STATS_INT_COUNTER_2 = 4000;
float actualRate = multiStatsRate.getRate();
@@ -125,27 +119,21 @@ public class StatsRateJUnitTest extends TestCase {
MULTI_STATS_INT_COUNTER_1 = 10000;
MULTI_STATS_INT_COUNTER_2 = 8000;
-
actualRate = multiStatsRate.getRate();
float expectedRate = 9000;
- assertEquals(expectedRate, actualRate);
-
+ assertEquals(expectedRate, actualRate, 0);
}
- private class TestMBeanStatsMonitor extends MBeanStatsMonitor{
-
-
+ private class TestMBeanStatsMonitor extends MBeanStatsMonitor {
+
public TestMBeanStatsMonitor(String name) {
super(name);
- // TODO Auto-generated constructor stub
}
@Override
public void addStatisticsToMonitor(Statistics stats) {
- // TODO Auto-generated method stub
-
}
@Override
@@ -174,17 +162,11 @@ public class StatsRateJUnitTest extends TestCase {
@Override
public void removeStatisticsFromMonitor(Statistics stats) {
- // TODO Auto-generated method stub
-
}
@Override
public void stopListener() {
- // TODO Auto-generated method stub
-
}
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/internal/JettyHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/JettyHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/JettyHelperJUnitTest.java
index b7580ca..43c3d6e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/JettyHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/JettyHelperJUnitTest.java
@@ -20,10 +20,6 @@ import static org.junit.Assert.*;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
-import org.jmock.Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -33,7 +29,8 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
* The JettyHelperJUnitTest class is a test suite of test cases testing the
* contract and functionality of the JettyHelper
* class.
- * <p/>
+ * <p>
+ *
* @see com.gemstone.gemfire.management.internal.JettyHelper
* @see org.jmock.Mockery
* @see org.junit.Assert
@@ -42,20 +39,6 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class JettyHelperJUnitTest {
- private Mockery mockContext;
-
- @Before
- public void setUp() {
- mockContext = new Mockery();
- mockContext.setImposteriser(ClassImposteriser.INSTANCE);
- }
-
- @After
- public void tearDown() {
- mockContext.assertIsSatisfied();
- mockContext = null;
- }
-
@Test
public void testSetPortNoBindAddress() throws Exception {
@@ -63,7 +46,7 @@ public class JettyHelperJUnitTest {
assertNotNull(jetty);
assertNotNull(jetty.getConnectors()[0]);
- assertEquals(8090, ((ServerConnector)jetty.getConnectors()[0]).getPort());
+ assertEquals(8090, ((ServerConnector) jetty.getConnectors()[0]).getPort());
}
@Test
@@ -73,7 +56,7 @@ public class JettyHelperJUnitTest {
assertNotNull(jetty);
assertNotNull(jetty.getConnectors()[0]);
- assertEquals(10480, ((ServerConnector)jetty.getConnectors()[0]).getPort());
+ assertEquals(10480, ((ServerConnector) jetty.getConnectors()[0]).getPort());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
index 84b39d4..81d6b18 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/beans/DistributedSystemBridgeJUnitTest.java
@@ -68,7 +68,7 @@ public class DistributedSystemBridgeJUnitTest {
}
@Test
- public void testSucessfulBackup() throws Exception {
+ public void testSuccessfulBackup() throws Exception {
DM dm = cache.getDistributionManager();
DistributedSystemBridge bridge = new DistributedSystemBridge(null);
@@ -97,7 +97,6 @@ public class DistributedSystemBridgeJUnitTest {
bridge.backupAllMembers("/tmp", null);
fail("Should have failed with an exception");
} catch(RuntimeException expected) {
-
}
verify(dm).putOutgoing(isA(FinishBackupRequest.class));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CliUtilDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CliUtilDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CliUtilDUnitTest.java
index 1cfc94c..cea95c1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CliUtilDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CliUtilDUnitTest.java
@@ -388,7 +388,7 @@ public class CliUtilDUnitTest extends CacheTestCase {
/* "FIXME - Abhishek" This is failing because last param is not considered in method
set = CliUtil.getRegionAssociatedMembers(region1, cache, false);
assertNotNull(set);
- assertEquals(1, set.size());*/
+ assertIndexDetailsEquals(1, set.size());*/
set = CliUtil.getRegionAssociatedMembers(region_group1, cache, true);
assertNotNull(set);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java
index aac9528..d73597e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandManagerJUnitTest.java
@@ -50,10 +50,10 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
/**
* CommandManagerTest - Includes tests to check the CommandManager functions
- *
*/
@Category(UnitTest.class)
public class CommandManagerJUnitTest {
+
private static final String COMMAND1_NAME = "command1";
private static final String COMMAND1_NAME_ALIAS = "command1_alias";
private static final String COMMAND2_NAME = "c2";
@@ -223,9 +223,9 @@ public class CommandManagerJUnitTest {
assertTrue("Should not find unlisted plugin.", !commandManager.getCommands().containsKey("mock plugin command unlisted"));
}
-
// class that represents dummy commands
- static public class Commands implements CommandMarker {
+ public static class Commands implements CommandMarker {
+
@CliCommand(value = { COMMAND1_NAME, COMMAND1_NAME_ALIAS }, help = COMMAND1_HELP)
@CliMetaData(shellOnly = true, relatedTopic = { "relatedTopicOfCommand1" })
public static String command1(
@@ -273,11 +273,12 @@ public class CommandManagerJUnitTest {
@CliAvailabilityIndicator({ COMMAND1_NAME })
public boolean isAvailable() {
return true; // always available on server
-
}
-
}
+ /**
+ * Used by testCommandManagerLoadPluginCommands
+ */
static class SimpleConverter implements Converter<String> {
public boolean supports(Class<?> type, String optionContext) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ef0a6243/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandSeparatorEscapeJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandSeparatorEscapeJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandSeparatorEscapeJUnitTest.java
index 8057a1e..735a209 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandSeparatorEscapeJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/CommandSeparatorEscapeJUnitTest.java
@@ -16,21 +16,18 @@
*/
package com.gemstone.gemfire.management.internal.cli;
+import static com.gemstone.gemfire.management.internal.cli.shell.MultiCommandHelper.*;
+import static org.junit.Assert.*;
+
import java.util.List;
+import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import junit.framework.TestCase;
-import static com.gemstone.gemfire.management.internal.cli.shell.MultiCommandHelper.getMultipleCommands;
-
-/**
- *
- *
- */
@Category(UnitTest.class)
-public class CommandSeparatorEscapeJUnitTest extends TestCase{
+public class CommandSeparatorEscapeJUnitTest {
//testcases : single command
//testcases : multiple commands with cmdSeparator
@@ -38,8 +35,9 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
//testcases : multiplecommand with comma-value : first value
//testcases : multiplecommand with comma-value : last value
//testcases : multiplecommand with comma-value : middle value
-
- public void testEmptyCommand(){
+
+ @Test
+ public void testEmptyCommand() {
String input = ";";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -48,8 +46,9 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
}*/
assertEquals(0,split.size());
}
-
- public void testSingleCommand(){
+
+ @Test
+ public void testSingleCommand() {
String input = "stop server";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -59,8 +58,9 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals(1,split.size());
assertEquals("stop server", split.get(0));
}
-
- public void testMultiCommand(){
+
+ @Test
+ public void testMultiCommand() {
String input = "stop server1 --option1=value1; stop server2;stop server3 ";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -72,8 +72,9 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals(" stop server2", split.get(1));
assertEquals("stop server3 ", split.get(2));
}
-
- public void testMultiCommandWithCmdSep(){
+
+ @Test
+ public void testMultiCommandWithCmdSep() {
String input = "put --region=/region1 --key='key1\\;part' --value='value1\\;part2';put --region=/region1 --key='key2\\;part' --value='value2\\;part2'";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -85,7 +86,8 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals("put --region=/region1 --key='key2;part' --value='value2;part2'", split.get(1));
}
- public void testSingleCommandWithComma(){
+ @Test
+ public void testSingleCommandWithComma() {
String input = "put --region=/region1 --key='key\\;part' --value='value\\;part2'";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -96,7 +98,8 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals("put --region=/region1 --key='key;part' --value='value;part2'", split.get(0));
}
- public void testMultiCmdCommaValueFirst(){
+ @Test
+ public void testMultiCmdCommaValueFirst() {
String input = "put --region=/region1 --key='key\\;part' --value='value\\;part2';stop server";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -107,8 +110,9 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals("put --region=/region1 --key='key;part' --value='value;part2'", split.get(0));
assertEquals("stop server", split.get(1));
}
-
- public void testMultiCmdCommaValueLast(){
+
+ @Test
+ public void testMultiCmdCommaValueLast() {
String input = "stop server;put --region=/region1 --key='key\\;part' --value='value\\;part2'";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);
@@ -120,7 +124,8 @@ public class CommandSeparatorEscapeJUnitTest extends TestCase{
assertEquals("put --region=/region1 --key='key;part' --value='value;part2'", split.get(1));
}
- public void testMultiCmdCommaValueMiddle(){
+ @Test
+ public void testMultiCmdCommaValueMiddle() {
String input = "stop server1;put --region=/region1 --key='key\\;part' --value='value\\;part2';stop server2;stop server3";
//System.out.println("I >> " + input);
List<String> split = getMultipleCommands(input);