Package org.springframework.xd.shell.command.fixtures

Examples of org.springframework.xd.shell.command.fixtures.HttpSource


    rabbitAdmin.afterPropertiesSet();
  }

  @Test
  public void testDefaultOptions() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);

    String streamName = generateStreamName();
    Queue queue = new Queue(streamName);
    rabbitAdmin.declareQueue(queue);
    queues.add(streamName);


    stream().create(streamName, "%s | rabbit", httpSource);
    stream().create(generateStreamName(), "rabbit --queues=%s | %s", streamName, fileSink);

    httpSource.ensureReady().postData("hello rabbit");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("hello rabbit"))));
  }
View Full Code Here


  }

  @Test
  public void testTcpSink() throws Exception {
    TcpSink tcpSink = newTcpSink().start();
    HttpSource httpSource = newHttpSource();

    stream().create(generateStreamName(), "%s | %s", httpSource, tcpSink);
    httpSource.ensureReady().postData("Hi there!");

    // The following CRLF is b/c of the default tcp serializer
    // NOT because of FileSink
    assertThat(tcpSink, eventually(tcpSinkReceived("Hi there!\r\n")));
  }
View Full Code Here

  @Test
  public void testNamedChannelWithNoConsumerShouldBuffer() {
    String streamName = generateStreamName();
    logger.info("Create " + streamName + " stream");
    HttpSource source = newHttpSource();
    stream().create(streamName, "%s > %s", source, generateQueueName());
    source.postData("blahblah");
  }
View Full Code Here

    source.postData("blahblah");
  }

  @Test
  public void testNamedChannelsLinkingSourceAndSink() {
    HttpSource source = newHttpSource();
    String queue = generateQueueName();
    stream().create(generateStreamName(), "%s > %s", source, queue);
    stream().create(generateStreamName(), "%s > transform --expression=payload.toUpperCase() | log", queue);
    source.postData("blahblah");
  }
View Full Code Here

   * Test a stream that is simply one processor module connecting two named channels.
   */
  @Test
  public void testProcessorLinkingChannels() throws Exception {
    FileSink sink = newFileSink().binary(true);
    HttpSource source = newHttpSource(9314);

    String streamName0 = generateStreamName();
    String streamName1 = generateStreamName();
    String streamName2 = generateStreamName();

    String queue1 = generateQueueName();
    String queue2 = generateQueueName();

    stream().create(streamName0, "%s > %s", source, queue1);
    stream().create(streamName1, "%s > transform --expression=payload.toUpperCase() > %s", queue1, queue2);
    stream().create(streamName2, "%s > %s", queue2, sink);

    source.postData("blahblah");

    assertThat(String.format("Assert failed for streams %s, %s, %s", streamName0, streamName1, streamName2),
        sink, eventually(hasContentsThat(equalTo("BLAHBLAH"))));
  }
View Full Code Here

  }

  @Test
  public void testTappingModulesVariations() throws IOException {
    // Note: this test is using a regular sink, not a named channel sink
    HttpSource httpSource = newHttpSource();

    FileSink sink = newFileSink().binary(true);
    FileSink tapsink3 = newFileSink().binary(true);
    FileSink tapsink5 = newFileSink().binary(true);
    FileSink tapsink6 = newFileSink().binary(true);

    String streamName = generateStreamName();
    stream().create(streamName, "%s | transform --expression=payload.toUpperCase() | %s", httpSource, sink);
    stream().create(generateStreamName(), "%s > transform --expression=payload.replaceAll('A','.') | %s",
        getTapName(streamName), tapsink3);
    stream().create(generateStreamName(),
        "%s.transform > transform --expression=payload.replaceAll('A','.') | %s", getTapName(streamName),
        tapsink5);
    stream().create(generateStreamName(),
        "%s.0 > transform --expression=payload.replaceAll('A','.') | %s", getTapName(streamName), tapsink6);
    // use the tap channel as a sink. Not very useful currently but will be once we allow users to create pub/sub
    // channels
    // stream().create(getRandomStreamName(), "%s > %s.transform",
    // httpSource2, getTapName(streamName));

    httpSource.ensureReady().postData("Dracarys!");

    assertThat(sink, eventually(hasContentsThat(equalTo("DRACARYS!"))));

    assertThat(tapsink3, eventually(hasContentsThat(equalTo("Dracarys!"))));
View Full Code Here

  }

  @Test
  public void testTappingModulesVariationsWithSinkChannel_XD629() throws IOException {
    HttpSource source = newHttpSource();

    FileSink sink = newFileSink().binary(true);
    FileSink tapsink3 = newFileSink().binary(true);
    FileSink tapsink5 = newFileSink().binary(true);

    String streamName = generateStreamName();
    String queue = generateQueueName();
    stream().create(streamName,
        "%s | transform --expression=payload.toUpperCase() | filter --expression=true > %s", source, queue);
    stream().create(generateStreamName(), "%s > %s", queue, sink);

    stream().create(generateStreamName(),
        "%s > transform --expression=payload.replaceAll('r','.') | %s", getTapName(streamName), tapsink3);

    stream().create(generateStreamName(),
        "%s.filter > transform --expression=payload.replaceAll('A','.') | %s", getTapName(streamName), tapsink5);

    source.ensureReady().postData("Dracarys!");

    assertThat(sink, eventually(hasContentsThat(equalTo("DRACARYS!"))));

    assertThat(tapsink3, eventually(hasContentsThat(equalTo("D.aca.ys!"))));
View Full Code Here

  @Test
  public void testUsingLabels() throws IOException {
    FileSink sink1 = newFileSink().binary(true);
    FileSink sink2 = newFileSink().binary(true);

    HttpSource source = newHttpSource();

    String streamName = generateStreamName();
    stream().create(streamName, "%s | flibble: transform --expression=payload.toUpperCase() | %s", source, sink1);
    stream().create(generateStreamName(),
        "%s.flibble > transform --expression=payload.replaceAll('a','.') | %s", getTapName(streamName), sink2);

    source.ensureReady().postData("Dracarys!");

    assertThat(sink1, eventually(hasContentsThat(equalTo("DRACARYS!"))));

    assertThat(sink2, eventually(hasContentsThat(equalTo("DRACARYS!"))));
  }
View Full Code Here

    assertThat(sink2, eventually(hasContentsThat(equalTo("DRACARYS!"))));
  }

  @Test
  public void testNamedChannels() throws Exception {
    HttpSource source1 = newHttpSource();
    HttpSource source2 = newHttpSource();
    HttpSource source3 = newHttpSource();
    FileSink sink = newFileSink().binary(true);

    String streamName0 = generateStreamName();
    String streamName1 = generateStreamName();
    String streamName2 = generateStreamName();

    String queue = generateQueueName();

    stream().create(streamName0, "%s > %s", source1, queue);
    stream().create(streamName1, "%s > %s", source2, queue);
    stream().create(streamName2, "%s > %s", queue, sink);

    source1.ensureReady().postData("Dracarys!");
    source2.ensureReady().postData("testing");

    assertThat(String.format("Assert failed for streams %s, %s, %s", streamName0, streamName1, streamName2),
        sink, eventually(hasContentsThat(equalTo("Dracarys!testing"))));

    stream().destroyStream(streamName1);

    source1.ensureReady().postData("stillup");
    assertThat(sink, eventually(hasContentsThat(equalTo("Dracarys!testingstillup"))));

    stream().create(generateStreamName(), "%s > %s", source3, queue);
    source3.ensureReady().postData("newstream");
    assertThat(sink, eventually(hasContentsThat(equalTo("Dracarys!testingstillupnewstream"))));
  }
View Full Code Here

    assertThat(sink, eventually(hasContentsThat(equalTo("Dracarys!testingstillupnewstream"))));
  }

  @Test
  public void testJsonPath() throws IOException {
    HttpSource source = newHttpSource();
    FileSink sink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --expression='#jsonPath(payload, \"$.foo.bar\")' | %s",
        source, sink);
    source.ensureReady().postData("{\"foo\":{\"bar\":\"123\"}}");
    assertThat(sink, eventually(hasContentsThat(equalTo("123"))));
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.shell.command.fixtures.HttpSource

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.