use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class AggregatorListTest method testAggregatedList.
@Test
public void testAggregatedList() {
int numBuffers = 16;
int size = 1000;
List<Object> tuples = new ArrayList<>();
for (int j = 0; j < 10; j++) {
List<Object> data = new ArrayList<>();
for (int i = 0; i < 4; i++) {
data.add("I " + i);
}
Tuple tuple = new Tuple(1, data);
tuples.add(tuple);
}
try {
InMessage inMessage = keyedListValueCase(numBuffers, size, tuples, MessageTypes.OBJECT, MessageTypes.INTEGER);
Assert.fail();
} catch (ClassCastException e) {
Assert.assertTrue(true);
}
List<Object> aTuples = new AggregatedObjects<>();
for (int j = 0; j < 10; j++) {
List<Object> data = new ArrayList<>();
for (int i = 0; i < 4; i++) {
data.add("I " + i);
}
Tuple tuple = new Tuple(1, data);
aTuples.add(tuple);
}
try {
InMessage inMessage = keyedListValueCase(numBuffers, size, aTuples, MessageTypes.OBJECT, MessageTypes.INTEGER);
Assert.assertTrue(true);
} catch (ClassCastException e) {
Assert.fail();
}
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeShortMessage.
@Test
public void testBuildLargeShortMessage() {
int numBuffers = 10;
int size = 1000;
MessageType type = MessageTypes.SHORT_ARRAY;
Object data = createData(800, type);
InMessage inMessage = singleValueCase(numBuffers, size, type, data);
Assert.assertArrayEquals((short[]) inMessage.getDeserializedData(), (short[]) data);
}
use of edu.iu.dsc.tws.comms.dfw.InMessage in project twister2 by DSC-SPIDAL.
the class DataSerializerTest method testBuildLargeListIntMessage.
@SuppressWarnings("Unchecked")
@Test
public void testBuildLargeListIntMessage() {
int numBuffers = 16;
int size = 1000;
List<Object> data = new AggregatedObjects<>();
for (int i = 0; i < 4; i++) {
Object o = createData(800, MessageTypes.INTEGER_ARRAY);
data.add(o);
}
InMessage inMessage = listValueCase(numBuffers, size, data, MessageTypes.INTEGER_ARRAY);
List<Object> result = (List<Object>) inMessage.getDeserializedData();
for (int i = 0; i < result.size(); i++) {
Object exp = result.get(i);
Object d = data.get(i);
Assert.assertArrayEquals((int[]) exp, (int[]) d);
}
}
Aggregations