use of java.io.DataInput in project geode by apache.
the class StartupMessageDataJUnitTest method testToDataWithNullHostedLocators.
@Test
public void testToDataWithNullHostedLocators() throws Exception {
Collection<String> hostedLocators = null;
StartupMessageData data = new StartupMessageData();
data.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
data.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
Properties props = (Properties) DataSerializer.readObject(in);
assertNull(props);
}
use of java.io.DataInput in project geode by apache.
the class StartupMessageDataJUnitTest method testNullHostedLocator.
@Test
public void testNullHostedLocator() throws Exception {
String locatorString = null;
DataInput in = getDataInputWithOneHostedLocator(locatorString);
StartupMessageData dataToRead = new StartupMessageData();
dataToRead.readFrom(in);
Collection<String> readHostedLocators = dataToRead.readHostedLocators();
assertNull(readHostedLocators);
}
use of java.io.DataInput in project geode by apache.
the class StartupMessageDataJUnitTest method testOneHostedLocator.
@Test
public void testOneHostedLocator() throws Exception {
String locatorString = createOneLocatorString();
DataInput in = getDataInputWithOneHostedLocator(locatorString);
StartupMessageData dataToRead = new StartupMessageData();
dataToRead.readFrom(in);
Collection<String> readHostedLocators = dataToRead.readHostedLocators();
assertNotNull(readHostedLocators);
assertEquals(1, readHostedLocators.size());
assertEquals(locatorString, readHostedLocators.iterator().next());
}
use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testHashtableObject.
/**
* Tests data serializing an {@link Hashtable} using {@link DataSerializer#writeObject}.
*/
@Test
public void testHashtableObject() throws Exception {
Random random = getRandom();
Hashtable map = new Hashtable();
int size = random.nextInt(50);
for (int i = 0; i < size; i++) {
Object key = new Long(random.nextLong());
Object value = String.valueOf(random.nextLong());
map.put(key, value);
}
DataOutputStream out = getDataOutput();
DataSerializer.writeObject(map, out);
out.flush();
DataInput in = getDataInput();
Hashtable map2 = (Hashtable) DataSerializer.readObject(in);
assertEquals(map, map2);
}
use of java.io.DataInput in project geode by apache.
the class RemoteRemoveAllMessageTest method shouldBeMockable.
@Test
public void shouldBeMockable() throws Exception {
RemoteRemoveAllMessage mockRemoteRemoveAllMessage = mock(RemoteRemoveAllMessage.class);
DataInput mockDataInput = mock(DataInput.class);
mockRemoteRemoveAllMessage.fromData(mockDataInput);
verify(mockRemoteRemoveAllMessage, times(1)).fromData(mockDataInput);
}
Aggregations