Package org.springframework.xd.module.core

Examples of org.springframework.xd.module.core.Module


    }
    return source.getComponent("output", MessageChannel.class);
  }

  protected static SubscribableChannel getSinkInputChannel(String streamName) {
    Module sink = getDeployedSink(streamName);
    // Should be a publish-subscribe-channel
    if (sink instanceof CompositeModule) {
      @SuppressWarnings("unchecked")
      List<Module> modules = TestUtils.getPropertyValue(sink, "modules", List.class);
      sink = modules.get(modules.size() - 1);
    }
    return sink.getComponent("input", SubscribableChannel.class);
  }
View Full Code Here


        .setModuleDefinition(ModuleDefinitions.dummy("testsource", ModuleType.source))
        .setGroup("foo")
        .setIndex(0)
        .build();

    Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());
    module.initialize();
    assertEquals(0, module.getProperties().size());
    plugin.preProcessModule(module);
    assertEquals(1, module.getProperties().size());
    assertEquals("foo", module.getProperties().getProperty(XD_STREAM_NAME_KEY));
  }
View Full Code Here

  }

  @Test
  public void streamChannelTests() throws InterruptedException {
    ModuleDefinition moduleDefinition = ModuleDefinitions.dummy("testing", ModuleType.processor);
    Module module = mock(Module.class);
    when(module.getDescriptor()).thenReturn(new ModuleDescriptor.Builder()
        .setGroup("foo")
        .setIndex(1)
        .setModuleDefinition(moduleDefinition)
        .build());
    when(module.getType()).thenReturn(moduleDefinition.getType());
    when(module.getName()).thenReturn(moduleDefinition.getName());
    when(module.getComponent(MessageBus.class)).thenReturn(bus);
    when(module.getComponent("input", MessageChannel.class)).thenReturn(input);
    when(module.getComponent("output", MessageChannel.class)).thenReturn(output);
    plugin.preProcessModule(module);
    plugin.postProcessModule(module);
    verify(bus).bindConsumer(eq("foo.0"), same(input), any(Properties.class));
    verify(bus).bindProducer(eq("foo.1"), same(output), any(Properties.class));
    plugin.beforeShutdown(module);
View Full Code Here

  }

  @Test
  public void testTapOnProxy() throws Exception {
    ModuleDefinition moduleDefinition = ModuleDefinitions.dummy("testing", ModuleType.processor);
    Module module = mock(Module.class);
    when(module.getDescriptor()).thenReturn(new ModuleDescriptor.Builder()
        .setGroup("foo")
        .setIndex(1)
        .setModuleDefinition(moduleDefinition)
        .build());
    when(module.getComponent(MessageBus.class)).thenReturn(bus);
    when(module.getName()).thenReturn(moduleDefinition.getName());
    DirectChannel output = new DirectChannel();
    MessageChannel proxy = (MessageChannel) new ProxyFactory(output).getProxy();
    when(module.getComponent("output", MessageChannel.class)).thenReturn(proxy);
    plugin.postProcessModule(module);
    List<?> interceptors = TestUtils.getPropertyValue(output, "interceptors.interceptors", List.class);
    assertEquals(0, interceptors.size());

    // simulate addition of a tap consumer
View Full Code Here

        "source --outputType=application/json | sink --inputType=application/x-xd-tuple");
  }

  @Test
  public void testParametersPresent() {
    Module source = getDeployedSource("test1");
    Module sink = getDeployedSink("test1");
    assertEquals("application/json", source.getProperties().get("outputType"));
    assertEquals("application/x-xd-tuple", sink.getProperties().get("inputType"));
  }
View Full Code Here

    .setModuleDefinition(ModuleDefinitions.dummy("testJob", ModuleType.job))
    .setGroup("foo")
    .setIndex(0)
    .build();

    Module module = new ResourceConfiguredModule(descriptor,
        new ModuleDeploymentProperties());

    assertEquals(0, module.getProperties().size());
    jobPlugin.preProcessModule(module);

    Properties moduleProperties = module.getProperties();

    assertEquals("foo", moduleProperties.getProperty(XD_JOB_NAME_KEY));
  }
View Full Code Here

  @Test
  public void partitionedJob() {
    String moduleGroupName = "partitionedJob";
    int moduleIndex = 0;
    Module module = Mockito.mock(Module.class);
    when(module.getType()).thenReturn(ModuleType.job);
    Properties properties = new Properties();
    when(module.getProperties()).thenReturn(properties);
    when(module.getDescriptor()).thenReturn(
        new ModuleDescriptor.Builder().setGroup(moduleGroupName).setIndex(moduleIndex).setModuleDefinition(
            ModuleDefinitions.dummy("testjob", ModuleType.job)).build());

    MessageChannel stepsOut = new DirectChannel();
    when(module.getComponent("stepExecutionRequests.output", MessageChannel.class)).thenReturn(stepsOut);
    PollableChannel stepResultsIn = new QueueChannel();
    when(module.getComponent("stepExecutionReplies.input", MessageChannel.class)).thenReturn(stepResultsIn);
    PollableChannel stepsIn = new QueueChannel();
    when(module.getComponent("stepExecutionRequests.input", MessageChannel.class)).thenReturn(stepsIn);
    MessageChannel stepResultsOut = new DirectChannel();
    when(module.getComponent("stepExecutionReplies.output", MessageChannel.class)).thenReturn(stepResultsOut);
    jobPartitionerPlugin.preProcessModule(module);
    jobPartitionerPlugin.postProcessModule(module);
    checkBusBound(messageBus);
    stepsOut.send(new GenericMessage<String>("foo"));
    Message<?> stepExecutionRequest = stepsIn.receive(10000);
View Full Code Here

  }

  @Test
  public void streamComponentsAdded() {

    Module module = Mockito.mock(Module.class);
    Mockito.when(module.getType()).thenReturn(ModuleType.job);
    Properties properties = new Properties();
    Mockito.when(module.getProperties()).thenReturn(properties);
    Mockito.when(module.getDescriptor()).thenReturn(
        new ModuleDescriptor.Builder().setGroup("job").setIndex(0).setModuleDefinition(
            ModuleDefinitions.dummy("testjob", ModuleType.job)).build());

    jobPlugin.preProcessModule(module);
    Mockito.verify(module).addSource(Matchers.any(Resource.class));
View Full Code Here

        .setModuleDefinition(ModuleDefinitions.dummy("myjob", ModuleType.job))
        .setGroup("myjob")
        .setIndex(0)
        .build();

    final Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());

    final TestMessageBus messageBus = new TestMessageBus();
    final JobPlugin plugin = new JobPlugin(messageBus);
    final DirectChannel inputChannel = new DirectChannel();

    final Module spiedModule = spy(module);

    doReturn(inputChannel).when(spiedModule).getComponent("input", MessageChannel.class);
    doReturn(null).when(spiedModule).getComponent("output", MessageChannel.class);
    doReturn(null).when(spiedModule).getComponent("stepExecutionRequests.output", MessageChannel.class);
View Full Code Here

        .setModuleDefinition(ModuleDefinitions.dummy("myjob", ModuleType.job))
        .setGroup("myjob")
        .setIndex(0)
        .build();

    final Module module = new ResourceConfiguredModule(moduleDescriptor,
        new ModuleDeploymentProperties());

    final TestMessageBus messageBus = new TestMessageBus();
    final JobEventsListenerPlugin eventsListenerPlugin = new JobEventsListenerPlugin(messageBus);
    final SubscribableChannel jobExecutionEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel stepExecutionEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel chunkEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel itemEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel skipEventsChannel = new PublishSubscribeChannel();
    final SubscribableChannel aggregatedEventsChannel = new PublishSubscribeChannel();

    final Module spiedModule = spy(module);

    doReturn(messageBus).when(spiedModule).getComponent(MessageBus.class);
    doReturn(jobExecutionEventsChannel).when(spiedModule).getComponent("xd.job.jobExecutionEvents",
        SubscribableChannel.class);
    doReturn(stepExecutionEventsChannel).when(spiedModule).getComponent("xd.job.stepExecutionEvents",
View Full Code Here

TOP

Related Classes of org.springframework.xd.module.core.Module

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.