Search in sources :

Example 1 with FlinkILoop

use of org.apache.flink.api.scala.FlinkILoop in project flink by apache.

the class FlinkILoopTest method testConfigurationForwardingStreamEnvironment.

@Test
public void testConfigurationForwardingStreamEnvironment() {
    Configuration configuration = new Configuration();
    configuration.setString("foobar", "foobar");
    FlinkILoop flinkILoop = new FlinkILoop("localhost", 6123, configuration, Option.<String[]>empty());
    StreamExecutionEnvironment streamEnv = flinkILoop.scalaSenv().getJavaEnv();
    assertTrue(streamEnv instanceof RemoteStreamEnvironment);
    RemoteStreamEnvironment remoteStreamEnv = (RemoteStreamEnvironment) streamEnv;
    Configuration forwardedConfiguration = remoteStreamEnv.getClientConfiguration();
    assertEquals(configuration, forwardedConfiguration);
}
Also used : FlinkILoop(org.apache.flink.api.scala.FlinkILoop) Configuration(org.apache.flink.configuration.Configuration) RemoteStreamEnvironment(org.apache.flink.streaming.api.environment.RemoteStreamEnvironment) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with FlinkILoop

use of org.apache.flink.api.scala.FlinkILoop in project flink by apache.

the class FlinkILoopTest method testConfigurationForwarding.

@Test
public void testConfigurationForwarding() throws Exception {
    Configuration configuration = new Configuration();
    configuration.setString("foobar", "foobar");
    FlinkILoop flinkILoop = new FlinkILoop("localhost", 6123, configuration, Option.<String[]>empty());
    final TestPlanExecutor testPlanExecutor = new TestPlanExecutor();
    PowerMockito.mockStatic(PlanExecutor.class);
    BDDMockito.given(PlanExecutor.createRemoteExecutor(Matchers.anyString(), Matchers.anyInt(), Matchers.any(Configuration.class), Matchers.any(java.util.List.class), Matchers.any(java.util.List.class))).willAnswer(new Answer<PlanExecutor>() {

        @Override
        public PlanExecutor answer(InvocationOnMock invocation) throws Throwable {
            testPlanExecutor.setHost((String) invocation.getArguments()[0]);
            testPlanExecutor.setPort((Integer) invocation.getArguments()[1]);
            testPlanExecutor.setConfiguration((Configuration) invocation.getArguments()[2]);
            testPlanExecutor.setJars((List<String>) invocation.getArguments()[3]);
            testPlanExecutor.setGlobalClasspaths((List<String>) invocation.getArguments()[4]);
            return testPlanExecutor;
        }
    });
    Settings settings = new Settings();
    ((MutableSettings.BooleanSetting) settings.usejavacp()).value_$eq(true);
    flinkILoop.settings_$eq(settings);
    flinkILoop.createInterpreter();
    ExecutionEnvironment env = flinkILoop.scalaBenv().getJavaEnv();
    env.fromElements(1).output(new DiscardingOutputFormat<Integer>());
    env.execute("Test job");
    Configuration forwardedConfiguration = testPlanExecutor.getConfiguration();
    assertEquals(configuration, forwardedConfiguration);
}
Also used : StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) Configuration(org.apache.flink.configuration.Configuration) PlanExecutor(org.apache.flink.api.common.PlanExecutor) FlinkILoop(org.apache.flink.api.scala.FlinkILoop) InvocationOnMock(org.mockito.invocation.InvocationOnMock) List(java.util.List) MutableSettings(scala.tools.nsc.settings.MutableSettings) Settings(scala.tools.nsc.Settings) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

FlinkILoop (org.apache.flink.api.scala.FlinkILoop)2 Configuration (org.apache.flink.configuration.Configuration)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 List (java.util.List)1 PlanExecutor (org.apache.flink.api.common.PlanExecutor)1 RemoteStreamEnvironment (org.apache.flink.streaming.api.environment.RemoteStreamEnvironment)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Settings (scala.tools.nsc.Settings)1 MutableSettings (scala.tools.nsc.settings.MutableSettings)1