Java Code Examples for org.apache.flink.api.common.typeutils.SerializerTestInstance#testAll()
The following examples show how to use
org.apache.flink.api.common.typeutils.SerializerTestInstance#testAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EitherSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testStringDoubleEither() { Either<String, Double>[] testData = new Either[] { Left("banana"), Left(""), Right(32.0), Right(Double.MIN_VALUE), Right(Double.MAX_VALUE)}; EitherTypeInfo<String, Double> eitherTypeInfo = (EitherTypeInfo<String, Double>) new EitherTypeInfo<String, Double>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO); EitherSerializer<String, Double> eitherSerializer = (EitherSerializer<String, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<String, Double>> testInstance = new EitherSerializerTestInstance<Either<String, Double>>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 2
Source File: TupleSerializerTest.java From flink with Apache License 2.0 | 6 votes |
private <T extends Tuple> void runTests(int length, T... instances) { try { TupleTypeInfo<T> tupleTypeInfo = (TupleTypeInfo<T>) TypeExtractor.getForObject(instances[0]); TypeSerializer<T> serializer = tupleTypeInfo.createSerializer(new ExecutionConfig()); Class<T> tupleClass = tupleTypeInfo.getTypeClass(); if(tupleClass == Tuple0.class) { length = 1; } SerializerTestInstance<T> test = new SerializerTestInstance<>(serializer, tupleClass, length, instances); test.testAll(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 3
Source File: AbstractGenericArraySerializerTest.java From flink with Apache License 2.0 | 6 votes |
@SafeVarargs private final <T> void runTests(Class<T> type, TypeSerializer<T> componentSerializer, T[]... instances) { try { if (type == null || componentSerializer == null || instances == null || instances.length == 0) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") Class<T[]> arrayClass = (Class<T[]>) (Class<?>) Array.newInstance(type, 0).getClass(); GenericArraySerializer<T> serializer = createSerializer(type, componentSerializer); SerializerTestInstance<T[]> test = new SerializerTestInstance<T[]>(serializer, arrayClass, -1, instances); test.testAll(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 4
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testStringDoubleEither() { Either<String, Double>[] testData = new Either[] { Left("banana"), Left(""), Right(32.0), Right(Double.MIN_VALUE), Right(Double.MAX_VALUE)}; EitherTypeInfo<String, Double> eitherTypeInfo = (EitherTypeInfo<String, Double>) new EitherTypeInfo<String, Double>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO); EitherSerializer<String, Double> eitherSerializer = (EitherSerializer<String, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<String, Double>> testInstance = new EitherSerializerTestInstance<Either<String, Double>>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 5
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testStringDoubleEither() { Either<String, Double>[] testData = new Either[] { Left("banana"), Left(""), Right(32.0), Right(Double.MIN_VALUE), Right(Double.MAX_VALUE)}; EitherTypeInfo<String, Double> eitherTypeInfo = (EitherTypeInfo<String, Double>) new EitherTypeInfo<String, Double>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO); EitherSerializer<String, Double> eitherSerializer = (EitherSerializer<String, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<String, Double>> testInstance = new EitherSerializerTestInstance<Either<String, Double>>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 6
Source File: EitherSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testEitherWithTupleValues() { @SuppressWarnings("unchecked") Either<Tuple2<LongValue, LongValue>, DoubleValue>[] testData = new Either[] { Left(new Tuple2<>(new LongValue(2L), new LongValue(9L))), new Left<>(new Tuple2<>(new LongValue(Long.MIN_VALUE), new LongValue(Long.MAX_VALUE))), new Right<>(new DoubleValue(32.0)), Right(new DoubleValue(Double.MIN_VALUE)), Right(new DoubleValue(Double.MAX_VALUE))}; EitherTypeInfo<Tuple2<LongValue, LongValue>, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( new TupleTypeInfo<Tuple2<LongValue, LongValue>>(ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.LONG_VALUE_TYPE_INFO), ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<Tuple2<LongValue, LongValue>, DoubleValue> eitherSerializer = (EitherSerializer<Tuple2<LongValue, LongValue>, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<Tuple2<LongValue, LongValue>, DoubleValue>> testInstance = new EitherSerializerTestInstance<>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 7
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testStringValueDoubleValueEither() { @SuppressWarnings("unchecked") Either<StringValue, DoubleValue>[] testData = new Either[] { Left(new StringValue("banana")), Left.of(new StringValue("apple")), new Left(new StringValue("")), Right(new DoubleValue(32.0)), Right.of(new DoubleValue(Double.MIN_VALUE)), new Right(new DoubleValue(Double.MAX_VALUE))}; EitherTypeInfo<StringValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( ValueTypeInfo.STRING_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<StringValue, DoubleValue> eitherSerializer = (EitherSerializer<StringValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<StringValue, DoubleValue>> testInstance = new EitherSerializerTestInstance<>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 8
Source File: EitherSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testStringValueDoubleValueEither() { @SuppressWarnings("unchecked") Either<StringValue, DoubleValue>[] testData = new Either[] { Left(new StringValue("banana")), Left.of(new StringValue("apple")), new Left(new StringValue("")), Right(new DoubleValue(32.0)), Right.of(new DoubleValue(Double.MIN_VALUE)), new Right(new DoubleValue(Double.MAX_VALUE))}; EitherTypeInfo<StringValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>( ValueTypeInfo.STRING_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO); EitherSerializer<StringValue, DoubleValue> eitherSerializer = (EitherSerializer<StringValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<StringValue, DoubleValue>> testInstance = new EitherSerializerTestInstance<>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 9
Source File: EitherSerializerTest.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testEitherWithTuple() { Either<Tuple2<Long, Long>, Double>[] testData = new Either[] { Either.Left(new Tuple2<>(2L, 9L)), new Left<>(new Tuple2<>(Long.MIN_VALUE, Long.MAX_VALUE)), new Right<>(32.0), Right(Double.MIN_VALUE), Right(Double.MAX_VALUE)}; EitherTypeInfo<Tuple2<Long, Long>, Double> eitherTypeInfo = (EitherTypeInfo<Tuple2<Long, Long>, Double>) new EitherTypeInfo<Tuple2<Long, Long>, Double>( new TupleTypeInfo<Tuple2<Long, Long>>(BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO), BasicTypeInfo.DOUBLE_TYPE_INFO); EitherSerializer<Tuple2<Long, Long>, Double> eitherSerializer = (EitherSerializer<Tuple2<Long, Long>, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig()); SerializerTestInstance<Either<Tuple2<Long, Long>, Double>> testInstance = new EitherSerializerTestInstance<Either<Tuple2<Long, Long>, Double>>( eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData); testInstance.testAll(); }
Example 10
Source File: AbstractGenericArraySerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SafeVarargs private final <T> void runTests(Class<T> type, TypeSerializer<T> componentSerializer, T[]... instances) { try { if (type == null || componentSerializer == null || instances == null || instances.length == 0) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") Class<T[]> arrayClass = (Class<T[]>) (Class<?>) Array.newInstance(type, 0).getClass(); GenericArraySerializer<T> serializer = createSerializer(type, componentSerializer); SerializerTestInstance<T[]> test = new SerializerTestInstance<T[]>(serializer, arrayClass, -1, instances); test.testAll(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 11
Source File: AbstractGenericArraySerializerTest.java From flink with Apache License 2.0 | 6 votes |
@SafeVarargs private final <T> void runTests(Class<T> type, TypeSerializer<T> componentSerializer, T[]... instances) { try { if (type == null || componentSerializer == null || instances == null || instances.length == 0) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") Class<T[]> arrayClass = (Class<T[]>) (Class<?>) Array.newInstance(type, 0).getClass(); GenericArraySerializer<T> serializer = createSerializer(type, componentSerializer); SerializerTestInstance<T[]> test = new SerializerTestInstance<T[]>(serializer, arrayClass, -1, instances); test.testAll(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 12
Source File: EnumSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@SafeVarargs public final <T extends Enum<T>> void testEnumSerializer(T... data) { @SuppressWarnings("unchecked") final Class<T> clazz = (Class<T>) data.getClass().getComponentType(); SerializerTestInstance<T> tester = new SerializerTestInstance<>( new EnumSerializer<T>(clazz), clazz, 4, data); tester.testAll(); }
Example 13
Source File: MultidimensionalArraySerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testPrimitiveArray() { int[][] array = new int[][]{{12,1},{48,42},{23,80},{484,849},{987,4}}; TypeInformation<int[][]> ti = TypeExtractor.getForClass(int[][].class); SerializerTestInstance<int[][]> testInstance = new SerializerTestInstance<int[][]>(ti.createSerializer(new ExecutionConfig()), int[][].class, -1, array); testInstance.testAll(); }
Example 14
Source File: AbstractGenericTypeSerializerTest.java From flink with Apache License 2.0 | 5 votes |
protected final <T> void runTests(T... instances) { if (instances == null || instances.length == 0) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) instances[0].getClass(); TypeSerializer<T> serializer = createSerializer(clazz); SerializerTestInstance<T> test = new SerializerTestInstance<T>(serializer, clazz, -1, instances); test.testAll(); }
Example 15
Source File: MultidimensionalArraySerializerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testPrimitiveArray() { int[][] array = new int[][]{{12,1},{48,42},{23,80},{484,849},{987,4}}; TypeInformation<int[][]> ti = TypeExtractor.getForClass(int[][].class); SerializerTestInstance<int[][]> testInstance = new SerializerTestInstance<int[][]>(ti.createSerializer(new ExecutionConfig()), int[][].class, -1, array); testInstance.testAll(); }
Example 16
Source File: MultidimensionalArraySerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testObjectArrays() { Integer[][] array = new Integer[][]{{0,1}, null, {null, 42}}; TypeInformation<Integer[][]> ti = TypeExtractor.getForClass(Integer[][].class); SerializerTestInstance<Integer[][]> testInstance = new SerializerTestInstance<Integer[][]>(ti.createSerializer(new ExecutionConfig()), Integer[][].class, -1, array); testInstance.testAll(); MyPojo[][] array2 = new MyPojo[][]{{new MyPojo(null, 42), new MyPojo("test2", -1)}, {null, null}, null}; TypeInformation<MyPojo[][]> ti2 = TypeExtractor.getForClass(MyPojo[][].class); SerializerTestInstance<MyPojo[][]> testInstance2 = new SerializerTestInstance<MyPojo[][]>(ti2.createSerializer(new ExecutionConfig()), MyPojo[][].class, -1, array2); testInstance2.testAll(); }
Example 17
Source File: MultidimensionalArraySerializerTest.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testGenericObjectArrays() { MyGenericPojo<String>[][] array = (MyGenericPojo<String>[][]) new MyGenericPojo[][]{ { new MyGenericPojo<String>(new String[][]{{"a", "b"},{"c", "d"}}), null} }; TypeInformation<MyGenericPojo<String>[][]> ti = TypeInformation.of(new TypeHint<MyGenericPojo<String>[][]>(){}); SerializerTestInstance testInstance = new SerializerTestInstance(ti.createSerializer(new ExecutionConfig()), MyGenericPojo[][].class, -1, (Object) array); testInstance.testAll(); }
Example 18
Source File: EnumSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@SafeVarargs public final <T extends Enum<T>> void testEnumSerializer(T... data) { @SuppressWarnings("unchecked") final Class<T> clazz = (Class<T>) data.getClass().getComponentType(); SerializerTestInstance<T> tester = new SerializerTestInstance<>( new EnumSerializer<T>(clazz), clazz, 4, data); tester.testAll(); }
Example 19
Source File: AvroSerializerEmptyArrayTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testBookSerialization() { try { Book b = new Book(123, "This is a test book", 26382648); AvroSerializer<Book> serializer = new AvroSerializer<Book>(Book.class); SerializerTestInstance<Book> test = new SerializerTestInstance<Book>(serializer, Book.class, -1, b); test.testAll(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
Example 20
Source File: MultidimensionalArraySerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testObjectArrays() { Integer[][] array = new Integer[][]{{0,1}, null, {null, 42}}; TypeInformation<Integer[][]> ti = TypeExtractor.getForClass(Integer[][].class); SerializerTestInstance<Integer[][]> testInstance = new SerializerTestInstance<Integer[][]>(ti.createSerializer(new ExecutionConfig()), Integer[][].class, -1, array); testInstance.testAll(); MyPojo[][] array2 = new MyPojo[][]{{new MyPojo(null, 42), new MyPojo("test2", -1)}, {null, null}, null}; TypeInformation<MyPojo[][]> ti2 = TypeExtractor.getForClass(MyPojo[][].class); SerializerTestInstance<MyPojo[][]> testInstance2 = new SerializerTestInstance<MyPojo[][]>(ti2.createSerializer(new ExecutionConfig()), MyPojo[][].class, -1, array2); testInstance2.testAll(); }