use of org.apache.flink.types.DeserializationException in project flink by apache.
the class OutputEmitterTest method testWrongKeyClass.
@Test
public void testWrongKeyClass() {
// Test for IntValue
@SuppressWarnings({ "unchecked", "rawtypes" }) final TypeComparator<Record> doubleComp = new RecordComparatorFactory(new int[] { 0 }, new Class[] { DoubleValue.class }).createComparator();
final ChannelSelector<SerializationDelegate<Record>> oe1 = new OutputEmitter<Record>(ShipStrategyType.PARTITION_HASH, doubleComp);
final SerializationDelegate<Record> delegate = new SerializationDelegate<Record>(new RecordSerializerFactory().getSerializer());
;
Record rec = null;
try {
PipedInputStream pipedInput = new PipedInputStream(1024 * 1024);
DataInputView in = new DataInputViewStreamWrapper(pipedInput);
DataOutputView out = new DataOutputViewStreamWrapper(new PipedOutputStream(pipedInput));
rec = new Record(1);
rec.setField(0, new IntValue());
rec.write(out);
rec = new Record();
rec.read(in);
} catch (IOException e) {
fail("Test erroneous");
}
try {
delegate.setInstance(rec);
oe1.selectChannels(delegate, 100);
} catch (DeserializationException re) {
return;
}
Assert.fail("Expected a NullKeyFieldException.");
}
Aggregations