use of java.io.DataOutput in project geode by apache.
the class ColocatedRegionDetailsJUnitTest method testSerializationOfEmptyColocatedRegionDetails.
@Test
public void testSerializationOfEmptyColocatedRegionDetails() throws Exception {
ColocatedRegionDetails crd = new ColocatedRegionDetails();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(baos);
crd.toData(out);
ColocatedRegionDetails crdIn = new ColocatedRegionDetails();
crdIn.fromData(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
assertEquals(crd, crdIn);
}
use of java.io.DataOutput in project geode by apache.
the class ColocatedRegionDetailsJUnitTest method testSerialization.
@Test
public void testSerialization() throws Exception {
ColocatedRegionDetails crd = new ColocatedRegionDetails("host", "member name", "parent region", "child region");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(baos);
crd.toData(out);
ColocatedRegionDetails crdIn = new ColocatedRegionDetails();
crdIn.fromData(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
assertEquals(crd, crdIn);
}
use of java.io.DataOutput in project geode by apache.
the class OfflineMembersDetailsJUnitTest method testSerialization.
@Test
public void testSerialization() throws Exception {
Set<PersistentMemberID>[] offlineMembers = new Set[5];
for (int i = 0; i < offlineMembers.length; i++) {
offlineMembers[i] = new HashSet<PersistentMemberID>();
offlineMembers[i].add(new PersistentMemberID(DiskStoreID.random(), InetAddress.getLocalHost(), "a", System.currentTimeMillis(), (short) 0));
}
OfflineMemberDetailsImpl details = new OfflineMemberDetailsImpl(offlineMembers);
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(boas);
details.toData(out);
OfflineMemberDetailsImpl details2 = new OfflineMemberDetailsImpl();
details2.fromData(new DataInputStream(new ByteArrayInputStream(boas.toByteArray())));
}
use of java.io.DataOutput in project geode by apache.
the class AbstractStoredObjectTestBase method sendAsByteArrayShouldWriteSerializedValueToDataOutput.
@Test
public void sendAsByteArrayShouldWriteSerializedValueToDataOutput() throws IOException {
Object regionEntryValue = getValue();
StoredObject storedObject = createValueAsSerializedStoredObject(regionEntryValue);
DataOutput dataOutput = mock(DataOutput.class);
storedObject.sendAsByteArray(dataOutput);
verify(dataOutput, times(1)).write(storedObject.getSerializedValue(), 0, storedObject.getSerializedValue().length);
}
use of java.io.DataOutput in project geode by apache.
the class AbstractStoredObjectTestBase method sendAsByteArrayShouldWriteDeserializedObjectToDataOutput.
@Test
public void sendAsByteArrayShouldWriteDeserializedObjectToDataOutput() throws IOException {
byte[] regionEntryValue = getValueAsByteArray();
StoredObject storedObject = createValueAsUnserializedStoredObject(regionEntryValue);
DataOutput dataOutput = mock(DataOutput.class);
storedObject.sendAsByteArray(dataOutput);
verify(dataOutput, times(1)).write(regionEntryValue, 0, regionEntryValue.length);
}
Aggregations