@Test public void testSettingUnknownRunner() { String[] args = new String[] {"--runner=UnknownRunner"}; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Unknown 'runner' specified 'UnknownRunner', supported " + "pipeline runners"); Set<String> registeredRunners = PipelineOptionsFactory.getRegisteredRunners().keySet(); assertThat(registeredRunners, hasItem(REGISTERED_RUNNER.getSimpleName().toLowerCase())); expectedException.expectMessage( PipelineOptionsFactory.CACHE.get().getSupportedRunners().toString()); PipelineOptionsFactory.fromArgs(args).create(); }
@Test public void testFullName() { String[] args = new String[] {String.format("--runner=%s", FlinkRunner.class.getName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), FlinkRunner.class); }
@Test public void testClassName() { String[] args = new String[] {String.format("--runner=%s", ApexRunner.class.getSimpleName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), ApexRunner.class); } }
@Test public void testFullName() { String[] args = new String[] {String.format("--runner=%s", GearpumpRunner.class.getName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), GearpumpRunner.class); }
@Test public void testClassName() { String[] args = new String[] {String.format("--runner=%s", FlinkRunner.class.getSimpleName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), FlinkRunner.class); } }
@Test public void testClassName() { String[] args = new String[] {String.format("--runner=%s", FlinkRunner.class.getSimpleName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), FlinkRunner.class); }
@Test public void testUsingArgumentWithUnknownPropertyIsNotAllowed() { String[] args = new String[] {"--unknownProperty=value"}; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("missing a property named 'unknownProperty'"); PipelineOptionsFactory.fromArgs(args).create(); }
@Test public void testSettingRunnerCanonicalClassNameNotInSupportedExists() { String[] args = new String[] {String.format("--runner=%s", ExampleTestRunner.class.getName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), ExampleTestRunner.class); }
@Test public void testSettingRunnerFullName() { String[] args = new String[] {String.format("--runner=%s", CrashingRunner.class.getName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), CrashingRunner.class); }
@Test public void testSetASingularAttributeUsingAListIsIgnoredWithoutStrictParsing() { String[] args = new String[] {"--diskSizeGb=100", "--diskSizeGb=200"}; PipelineOptionsFactory.fromArgs(args).withoutStrictParsing().create(); expectedLogs.verifyWarn("Strict parsing is disabled, ignoring option"); }
@Test public void testPropertyIsSetOnRegisteredPipelineOptionNotPartOfOriginalInterface() { PipelineOptions options = PipelineOptionsFactory.fromArgs("--streaming").create(); assertTrue(options.as(StreamingOptions.class).isStreaming()); }
@Test public void testSettingRunnerCanonicalClassNameNotInSupportedNotPipelineRunner() { String[] args = new String[] {"--runner=java.lang.String"}; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("does not implement PipelineRunner"); expectedException.expectMessage("java.lang.String"); PipelineOptionsFactory.fromArgs(args).create(); }
@Test public void testFullName() { String[] args = new String[] {String.format("--runner=%s", ApexRunner.class.getName())}; PipelineOptions opts = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(opts.getRunner(), ApexRunner.class); }
@Test public void testUsingArgumentWithInvalidNameIsNotAllowed() { String[] args = new String[] {"--=100"}; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Argument '--=100' starts with '--='"); PipelineOptionsFactory.fromArgs(args).create(); }
@Test public void testUsingArgumentStartingWithIllegalCharacterIsIgnoredWithoutStrictParsing() { String[] args = new String[] {" --diskSizeGb=100"}; PipelineOptionsFactory.fromArgs(args).withoutStrictParsing().create(); expectedLogs.verifyWarn("Strict parsing is disabled, ignoring option"); }
@Test public void testUsingArgumentWithUnknownPropertyIsIgnoredWithoutStrictParsing() { String[] args = new String[] {"--unknownProperty=value"}; PipelineOptionsFactory.fromArgs(args).withoutStrictParsing().create(); expectedLogs.verifyWarn("missing a property named 'unknownProperty'"); }
@Test public void testSettingRunner() { String[] args = new String[] {"--runner=" + RegisteredTestRunner.class.getSimpleName()}; PipelineOptions options = PipelineOptionsFactory.fromArgs(args).create(); assertEquals(RegisteredTestRunner.class, options.getRunner()); }
@Test public void testWhenRequiredOptionIsNeverSetOnSuperInterfaceCli() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( "Missing required value for " + "[--object, \"Fake Description\"]."); PipelineOptions options = PipelineOptionsFactory.fromArgs(new String[] {}).create(); PipelineOptionsValidator.validateCli(Required.class, options); }
@Test public void testUsingArgumentWithInvalidNameIsIgnoredWithoutStrictParsing() { String[] args = new String[] {"--=100"}; PipelineOptionsFactory.fromArgs(args).withoutStrictParsing().create(); expectedLogs.verifyWarn("Strict parsing is disabled, ignoring option"); }
@Test public void testUsingArgumentStartingWithIllegalCharacterIsNotAllowed() { String[] args = new String[] {" --diskSizeGb=100"}; expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Argument ' --diskSizeGb=100' does not begin with '--'"); PipelineOptionsFactory.fromArgs(args).create(); }