use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class BufferPoolTest method returnOutputBuffer.
@Test
public void returnOutputBuffer() {
BufferObjectDataOutput out = mock(BufferObjectDataOutput.class);
bufferPool.returnOutputBuffer(out);
// lets see if the item was pushed on the queue
assertEquals(1, bufferPool.outputQueue.size());
// we need to make sure clear was called
verify(out, times(1)).clear();
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class BufferPoolTest method returnOutputBuffer_whenOverflowing.
@Test
public void returnOutputBuffer_whenOverflowing() {
for (int k = 0; k < BufferPoolImpl.MAX_POOLED_ITEMS; k++) {
bufferPool.returnOutputBuffer(mock(BufferObjectDataOutput.class));
}
BufferObjectDataOutput out = mock(BufferObjectDataOutput.class);
bufferPool.returnOutputBuffer(out);
assertEquals(BufferPoolImpl.MAX_POOLED_ITEMS, bufferPool.outputQueue.size());
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class BufferPoolTest method takeOutputBuffer_whenNestedInstance.
@Test
public void takeOutputBuffer_whenNestedInstance() {
BufferObjectDataOutput found1 = bufferPool.takeOutputBuffer();
BufferObjectDataOutput found2 = bufferPool.takeOutputBuffer();
assertNotSame(found1, found2);
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class StringSerializationTest method testNullStringEncodeDecode2.
@Test
public void testNullStringEncodeDecode2() throws Exception {
BufferObjectDataOutput objectDataOutput = serializationService.createObjectDataOutput();
objectDataOutput.writeString(null);
byte[] bytes = objectDataOutput.toByteArray();
objectDataOutput.close();
BufferObjectDataInput objectDataInput = serializationService.createObjectDataInput(bytes);
String decodedStr = objectDataInput.readString();
assertNull(decodedStr);
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class PortableClassVersionTest method testDifferentClassVersionsUsingDataWriteAndRead.
// used in EE, so needs to be package private
static void testDifferentClassVersionsUsingDataWriteAndRead(InternalSerializationService serializationService, InternalSerializationService serializationService2) throws Exception {
NamedPortable portableV1 = new NamedPortable("portable-v1", 111);
Data dataV1 = serializationService.toData(portableV1);
// emulate socket write by writing data to stream
BufferObjectDataOutput out = serializationService.createObjectDataOutput(1024);
writeData(out, dataV1);
byte[] bytes = out.toByteArray();
// emulate socket read by reading data from stream
BufferObjectDataInput in = serializationService2.createObjectDataInput(bytes);
dataV1 = readData(in);
// serialize new portable version
NamedPortableV2 portableV2 = new NamedPortableV2("portable-v2", 123, 500);
Data dataV2 = serializationService2.toData(portableV2);
NamedPortable v1FromV2 = serializationService.toObject(dataV2);
assertEquals(portableV2.name, v1FromV2.name);
assertEquals(portableV2.myint, v1FromV2.myint);
NamedPortableV2 v2FromV1 = serializationService2.toObject(dataV1);
assertEquals(portableV1.name, v2FromV1.name);
assertEquals(portableV1.myint, v2FromV1.myint);
assertNull(v2FromV1.v);
}
Aggregations