Refine search
@Test public void testDuplicateSerializerWithRegisteredSerializerClass() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer(WrappedString.class, TestSerializer.class); runDuplicateSerializerTest(executionConfig); }
@Test public void testFailIsDefaultConfig() { ExecutionConfig newExecutionConfig = new ExecutionConfig(); Assert.assertTrue(newExecutionConfig.isFailTaskOnCheckpointError()); }
@Test public void testDuplicateSerializerWithDefaultSerializerClass() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.addDefaultKryoSerializer(WrappedString.class, TestSerializer.class); runDuplicateSerializerTest(executionConfig); }
@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(); }
@Test public void testSerializability() { try { TypeInformation<MyPOJO> info = TypeExtractor.getForClass(MyPOJO.class); TypeInformationSerializationSchema<MyPOJO> schema = new TypeInformationSerializationSchema<MyPOJO>(info, new ExecutionConfig()); // this needs to succeed CommonTestUtils.createCopySerializable(schema); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void validateReferenceMappingEnabled() { KryoSerializer<String> serializer = new KryoSerializer<>(String.class, new ExecutionConfig()); Kryo kryo = serializer.getKryo(); assertTrue(kryo.getReferences()); } }
@Test(expected = IllegalArgumentException.class) public void testThatExceptionIsThrownForOuterJoinTypeNull() throws Exception { final List<String> leftInput = Arrays.asList("foo", "bar", "foobar"); final List<String> rightInput = Arrays.asList("bar", "foobar", "foo"); baseOperator.setOuterJoinType(null); ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.disableObjectReuse(); baseOperator.executeOnCollections(leftInput, rightInput, runtimeContext, executionConfig); }
@Test public void testStringArray() { String[][] array = new String[][]{{null,"b"},{"c","d"},{"e","f"},{"g","h"},null}; TypeInformation<String[][]> ti = TypeExtractor.getForClass(String[][].class); SerializerTestInstance<String[][]> testInstance = new SerializerTestInstance<String[][]>(ti.createSerializer(new ExecutionConfig()), String[][].class, -1, array); testInstance.testAll(); }
@Test public void testDoubleTypeRegistration() { ExecutionConfig config = new ExecutionConfig(); List<Class<?>> types = Arrays.<Class<?>>asList(Double.class, Integer.class, Double.class); List<Class<?>> expectedTypes = Arrays.<Class<?>>asList(Double.class, Integer.class); for (Class<?> tpe: types) { config.registerKryoType(tpe); } int counter = 0; for (Class<?> tpe: config.getRegisteredKryoTypes()){ assertEquals(tpe, expectedTypes.get(counter++)); } assertEquals(expectedTypes.size(), counter); }
@Test public void testMigrationStrategyForRemovedAvroDependency() throws Exception { KryoSerializer<TestClass> kryoSerializerForA = new KryoSerializer<>(TestClass.class, new ExecutionConfig()); // read configuration again from bytes TypeSerializerSnapshot kryoSerializerConfigSnapshot; try (InputStream in = getClass().getResourceAsStream("/kryo-serializer-flink1.3-snapshot")) { kryoSerializerConfigSnapshot = TypeSerializerSnapshotSerializationUtil.readSerializerSnapshot( new DataInputViewStreamWrapper(in), Thread.currentThread().getContextClassLoader(), kryoSerializerForA); } @SuppressWarnings("unchecked") TypeSerializerSchemaCompatibility<TestClass> compatResult = kryoSerializerConfigSnapshot.resolveSchemaCompatibility(kryoSerializerForA); assertTrue(compatResult.isCompatibleAsIs()); }
@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(); }
@Test public void testStrings() { try { String[] data = { "Oh", "boy", "what", "a", "show", "!"}; FromElementsFunction<String> source = new FromElementsFunction<String>( BasicTypeInfo.STRING_TYPE_INFO.createSerializer(new ExecutionConfig()), data); List<String> result = new ArrayList<String>(); source.run(new ListSourceContext<String>(result)); assertEquals(Arrays.asList(data), result); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testAvroByDefault() { final TypeSerializer<User> serializer = new AvroTypeInfo<>(User.class).createSerializer(new ExecutionConfig()); assertTrue(serializer instanceof AvroSerializer); } }
@Test public void testDuplicateSerializerWithRegisteredSerializerInstance() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.registerTypeWithKryoSerializer(WrappedString.class, new TestSerializer()); runDuplicateSerializerTest(executionConfig); }
@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(); }
@Test public void testDuplicateSerializerWithDefaultSerializerInstance() { ExecutionConfig executionConfig = new ExecutionConfig(); executionConfig.addDefaultKryoSerializer(WrappedString.class, new TestSerializer()); runDuplicateSerializerTest(executionConfig); }
/** * FLINK-6775, tests that the returned serializer is duplicated. * This allows to share the state descriptor across threads. */ @Test public void testSerializerDuplication() throws Exception { // we need a serializer that actually duplicates for testing (a stateful one) // we use Kryo here, because it meets these conditions TypeSerializer<String> statefulSerializer = new KryoSerializer<>(String.class, new ExecutionConfig()); TestStateDescriptor<String> descr = new TestStateDescriptor<>("foobar", statefulSerializer); TypeSerializer<String> serializerA = descr.getSerializer(); TypeSerializer<String> serializerB = descr.getSerializer(); // check that the retrieved serializers are not the same assertNotSame(serializerA, serializerB); }
@Test public void testProperties() { SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class); when(extractor.extract(any())).thenReturn(5000L); DynamicEventTimeSessionWindows assigner = DynamicEventTimeSessionWindows.withDynamicGap(extractor); assertTrue(assigner.isEventTime()); assertEquals(new TimeWindow.Serializer(), assigner.getWindowSerializer(new ExecutionConfig())); assertThat(assigner.getDefaultTrigger(mock(StreamExecutionEnvironment.class)), instanceOf(EventTimeTrigger.class)); } }
@Test public void testProperties() { SessionWindowTimeGapExtractor extractor = mock(SessionWindowTimeGapExtractor.class); when(extractor.extract(any())).thenReturn(5000L); DynamicProcessingTimeSessionWindows assigner = DynamicProcessingTimeSessionWindows.withDynamicGap(extractor); assertFalse(assigner.isEventTime()); assertEquals(new TimeWindow.Serializer(), assigner.getWindowSerializer(new ExecutionConfig())); assertThat(assigner.getDefaultTrigger(mock(StreamExecutionEnvironment.class)), instanceOf(ProcessingTimeTrigger.class)); } }
@Test public void testCheckRuntimeContextAccess() { final SerializedOutputFormat<Value> inputFormat = new SerializedOutputFormat<Value>(); final TaskInfo taskInfo = new TaskInfo("test name", 3, 1, 3, 0); inputFormat.setRuntimeContext(new RuntimeUDFContext( taskInfo, getClass().getClassLoader(), new ExecutionConfig(), new HashMap<String, Future<Path>>(), new HashMap<String, Accumulator<?, ?>>(), new UnregisteredMetricsGroup())); assertEquals(inputFormat.getRuntimeContext().getIndexOfThisSubtask(), 1); assertEquals(inputFormat.getRuntimeContext().getNumberOfParallelSubtasks(),3); }