Search in sources :

Example 71 with DataOutput

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);
}
Also used : DataOutput(java.io.DataOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 72 with DataOutput

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);
}
Also used : DataOutput(java.io.DataOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 73 with DataOutput

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())));
}
Also used : DataOutput(java.io.DataOutput) Set(java.util.Set) HashSet(java.util.HashSet) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) PersistentMemberID(org.apache.geode.internal.cache.persistence.PersistentMemberID) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 74 with DataOutput

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);
}
Also used : DataOutput(java.io.DataOutput) Test(org.junit.Test)

Example 75 with DataOutput

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);
}
Also used : DataOutput(java.io.DataOutput) Test(org.junit.Test)

Aggregations

DataOutput (java.io.DataOutput)295 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)140 IPointable (org.apache.hyracks.data.std.api.IPointable)135 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)134 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)133 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)129 IOException (java.io.IOException)127 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)126 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)125 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)124 TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)116 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)96 DataOutputStream (java.io.DataOutputStream)79 ByteArrayOutputStream (java.io.ByteArrayOutputStream)60 Test (org.junit.Test)56 InvalidDataFormatException (org.apache.asterix.runtime.exceptions.InvalidDataFormatException)48 DataInputStream (java.io.DataInputStream)40 ByteArrayInputStream (java.io.ByteArrayInputStream)39 UTF8StringPointable (org.apache.hyracks.data.std.primitive.UTF8StringPointable)35 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)33