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

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


   */
  @Test
  public void testTuplePropertyAccessor() throws Exception {
    logger.info("Creating stream with temp File 'tupletest' as sink");
    FileSink sink = newFileSink().binary(true);
    HttpSource source = newHttpSource();

    stream().create(
        generateStreamName(),
        "%s | json-to-tuple | transform --expression=payload.foo | %s",
        source, sink);

    source.ensureReady().postData("{\"foo\":\"bar\"}");

    assertThat(sink, eventually(hasContentsThat(equalTo("bar"))));
  }
View Full Code Here


   * This tests that we have Json property access out of the box.
   */
  @Test
  public void testJsonPropertyAccessor() throws Exception {
    FileSink sink = newFileSink().binary(true);
    HttpSource source = newHttpSource();

    stream().create(
        generateStreamName(),
        "%s | transform --expression=payload.foo.toString() | %s",
        source, sink);

    source.ensureReady().postData("{\"foo\":\"bar\"}");

    assertThat(sink, eventually(hasContentsThat(equalTo("bar"))));

  }
View Full Code Here

  }

  @Test
  public void testTuplePropertyAccessorProjection() throws Exception {
    FileSink sink = newFileSink().binary(true);
    HttpSource source = newHttpSource();

    stream().create(
        generateStreamName(),
        "%s | json-to-tuple | transform --expression=payload.entities.hashtags.![text].toString() | %s",
        source, sink);
    String tweet = "{\"created_at\":\"Tue Aug 27 18:17:06 +0000 2013\",\"id\":100000,\"text\":\"whocares\",\"retweet_count\":0,"
        +
        "\"entities\":{\"hashtags\":[{\"text\":\"hello\",\"indices\":[23,41]},{\"text\":\"there\",\"indices\":[45,50]}],\"symbols\":[],"
        +
        "\"urls\":[],\"user_mentions\":[]},"
        +
        "\"favorited\":false,\"retweeted\":false,\"possibly_sensitive\":false,\"filter_level\":\"medium\",\"lang\":\"bg\"}";

    source.ensureReady().postData(tweet);

    assertThat(sink, eventually(hasContentsThat(equalTo("[hello, there]"))));
  }
View Full Code Here

    this.streamDynamicPart = streamDynamicPart;
  }

  @Test
  public void benchmark() throws Exception {
    HttpSource source = newHttpSource();
    CounterSink sink = metrics().newCounterSink();
    stream().create(
        generateStreamName(),
        "%s | aggregator --store=%s --count=%d --aggregation=T(org.springframework.util.StringUtils).collectionToDelimitedString(#this.![payload],' ') --timeout=500000%s | %s ",
        source, storeName, MESSAGES_PER_GROUP,
        streamDynamicPart, sink);

    source.ensureReady();

    StopWatch stopWatch = new StopWatch(storeName);
    stopWatch.start(storeName + "-" + executionCount);
    for (int i = 0; i < MESSAGES_PER_GROUP * MESSAGE_GROUPS_PER_EXECUTION; i++) {
      source.postData("boo");
    }

    assertThat(sink, eventually(hasValue(NumberFormat.getInstance().format(MESSAGE_GROUPS_PER_EXECUTION))));

    stopWatch.stop();
View Full Code Here

*/
public class ProcessorsTests extends AbstractStreamIntegrationTest {

  @Test
  public void splitterDoesNotSplitByDefault() throws Exception {
    HttpSource httpSource = newHttpSource();
    CounterSink counterSink = metrics().newCounterSink();

    stream().create(generateStreamName(), "%s | splitter | %s", httpSource, counterSink);

    httpSource.ensureReady().postData("Hello World !");
    assertThat(counterSink, eventually(hasValue("1")));

  }
View Full Code Here

  }

  @Test
  public void splitterDoesSplit() {
    HttpSource httpSource = newHttpSource();
    CounterSink counterSink = metrics().newCounterSink();

    stream().create(generateStreamName(), "%s | splitter --expression=payload.split(' ') | %s",
        httpSource, counterSink);

    httpSource.ensureReady().postData("Hello World !");
    assertThat(counterSink, eventually(hasValue("3")));

  }
View Full Code Here

  }

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

    stream().create(
        generateStreamName(),
        "%s | aggregator --count=3 --aggregation=T(org.springframework.util.StringUtils).collectionToDelimitedString(#this.![payload],' ') | %s",
        httpSource, fileSink);

    httpSource.ensureReady().postData("Hello").postData("World").postData("!");

    assertThat(fileSink, eventually(hasContentsThat(equalTo("Hello World !"))));

  }
View Full Code Here

  }

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

    int timeout = 1000;

    stream().create(
        generateStreamName(),
        "%s | aggregator --count=100 --timeout=%d --aggregation=T(org.springframework.util.StringUtils).collectionToDelimitedString(#this.![payload],' ') | %s",
        httpSource, timeout, fileSink);

    httpSource.ensureReady().postData("Hello").postData("World").postData("!");

    // Although the reaper and the task scheduler are both configured with 'timeout',
    // this does not take into account the amount of time it may take to deploy the
    // stream in a distributed environment; therefore this assert will use the default
    // timeouts configured in the eventually/hasContentsThat methods.
View Full Code Here

  }

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

    stream().create(
        generateStreamName(),
        "%s | aggregator --count=3 --aggregation=T(org.springframework.util.StringUtils).collectionToDelimitedString(#this.![payload],' ') "
            + "--correlation=payload.length() | %s",
        httpSource, fileSink);

    httpSource.ensureReady().postData("Hello").postData("World").postData("!");
    httpSource.ensureReady().postData("I").postData("am").postData("1");
    httpSource.ensureReady().postData("tu").postData("es").postData("fifth");

    String expected = "! I 1";
    expected += "am tu es";
    expected += "Hello World fifth";
    assertThat(fileSink, eventually(hasContentsThat(equalTo(expected))));
View Full Code Here

  }

  @Test
  public void testScriptTransformProcessor() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --script='org/springframework/xd/shell/command/transform-to-lowercase.groovy' | %s",
        httpSource, fileSink);
    httpSource.ensureReady().postData("HELLO").postData("World").postData("!");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloworld!"))));
  }
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.