Examples of HttpSource


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

   * This tests that options passed in the definition of a composed module are kept as first level defaults.
   */
  @Test
  public void testComposedModulesValuesInDefinition() throws IOException {
    FileSink sink = newFileSink().binary(true);
    HttpSource httpSource = newHttpSource();
    compose().newModule("filterAndTransform",
        "filter --expression=true | transform --expression=payload.replace('abc','...')");
    stream().create(generateStreamName(), "%s | filterAndTransform | %s", httpSource, sink);
    httpSource.ensureReady().postData("abcdefghi!");
    assertThat(sink, eventually(hasContentsThat(equalTo("...defghi!"))));
  }
View Full Code Here

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

   * This tests that options passed at usage time of a composed module are override definition values.
   */
  @Test
  public void testComposedModulesValuesAtUsageTime() throws IOException {
    FileSink sink = newFileSink().binary(true);
    HttpSource httpSource = newHttpSource();
    compose().newModule("filterAndTransform",
        "filter --expression=false | transform --expression=payload.replace('abc','...')");
    String options = String.format(
        "--filter%sexpression=true --transform%sexpression=payload.replace('def','...')", OPTION_SEPARATOR,
        OPTION_SEPARATOR);
    stream().create(generateStreamName(), "%s | filterAndTransform %s | %s", httpSource, options, sink);
    httpSource.ensureReady().postData("abcdefghi!");
    assertThat(sink, eventually(hasContentsThat(equalTo("abc...ghi!"))));

  }
View Full Code Here

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

  @Test
  public void testJdbcSinkWith1InsertionAndDefaultConfiguration() throws Exception {
    JdbcSink jdbcSink = newJdbcSink();

    HttpSource httpSource = newHttpSource();


    String streamName = generateStreamName().replaceAll("-", "_");
    stream().create(streamName, "%s | %s", httpSource, jdbcSink);
    httpSource.ensureReady().postData("Hi there!");

    String query = String.format("SELECT payload FROM %s", streamName);
    assertEquals(
        "Hi there!",
        jdbcSink.getJdbcTemplate().queryForObject(query, String.class));
View Full Code Here

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

  @Test
  public void testJdbcSinkWith2InsertionsAndDefaultConfiguration() throws Exception {
    JdbcSink jdbcSink = newJdbcSink();

    HttpSource httpSource = newHttpSource();


    String streamName = generateStreamName().replaceAll("-", "_");
    stream().create(streamName, "%s | %s", httpSource, jdbcSink);
    httpSource.ensureReady().postData("Hi there!");
    httpSource.postData("How are you?");

    String query = String.format("SELECT payload FROM %s", streamName);
    List<String> result = jdbcSink.getJdbcTemplate().queryForList(query, String.class);
    assertThat(result, contains("Hi there!", "How are you?"));
  }
View Full Code Here

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

  @Test
  public void testJdbcSinkWithCustomTableName() throws Exception {
    String tableName = "foobar";
    JdbcSink jdbcSink = newJdbcSink().tableName(tableName);

    HttpSource httpSource = newHttpSource();

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

    String query = String.format("SELECT payload FROM %s", tableName);
    assertEquals(
        "Hi there!",
        jdbcSink.getJdbcTemplate().queryForObject(query, String.class));
View Full Code Here

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

  @Test
  public void testJdbcSinkWithCustomColumnNames() throws Exception {
    JdbcSink jdbcSink = newJdbcSink().columns("foo,bar");

    HttpSource httpSource = newHttpSource();


    String streamName = generateStreamName().replaceAll("-", "_");
    stream().create(streamName, "%s | %s", httpSource, jdbcSink);
    String json = "{\"foo\":5, \"bar\": \"hello\"}";
    httpSource.ensureReady().postData(json);

    String query = String.format("SELECT foo, bar FROM %s", streamName);
    Result result = jdbcSink.getJdbcTemplate().queryForObject(query, new BeanPropertyRowMapper<>(Result.class));
    assertEquals("hello", result.getBar());
    assertEquals(5, result.getFoo());
View Full Code Here

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

  @Test
  public void testJdbcSinkWithCustomColumnNamesWithUnderscores() throws Exception {
    JdbcSink jdbcSink = newJdbcSink().columns("foo_bar,bar_foo,bar_baz");

    HttpSource httpSource = newHttpSource();

    String streamName = generateStreamName().replaceAll("-", "_");
    stream().create(streamName, "%s | %s", httpSource, jdbcSink);
    String json = "{\"fooBar\":5, \"barFoo\": \"hello\", \"bar_baz\": \"good_bye\"}";
    httpSource.ensureReady().postData(json);

    String query = String.format("SELECT foo_bar, bar_foo, bar_baz FROM %s", streamName);
    Map<String, Object> result = jdbcSink.getJdbcTemplate().queryForMap(query);
    assertEquals("hello", result.get("bar_foo"));
    assertEquals("5", result.get("foo_bar"));
View Full Code Here

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

public class RouterSinkTests extends AbstractStreamIntegrationTest {

  @Test
  public void testUsingExpression() {
    FileSink fileSink = newFileSink().binary(true);
    HttpSource httpSource = newHttpSource();
    String queue1 = generateQueueName();
    String queue2 = generateQueueName();

    stream().create(generateStreamName(), "%s > transform --expression=payload+'-foo' | %s", queue1, fileSink);
    stream().create(generateStreamName(), "%s > transform --expression=payload+'-bar' | %s", queue2, fileSink);
    stream().create(generateStreamName(),
        "%s | router --expression=payload.contains('a')?'" + queue1 + "':'" + queue2 + "'",
        httpSource);

    httpSource.ensureReady();
    httpSource.postData("a");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foo"))));
    httpSource.postData("b");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foob-bar"))));
  }
View Full Code Here

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

  }

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

    stream().create(generateStreamName(), "queue:testUsingScript1 > transform --expression=payload+'-foo' | %s", fileSink);
    stream().create(generateStreamName(), "queue:testUsingScript2 > transform --expression=payload+'-bar' | %s", fileSink);
    stream().create(generateStreamName(),
        "%s | router --script='org/springframework/xd/shell/command/router.groovy'", httpSource);

    httpSource.ensureReady();
    httpSource.postData("a");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foo"))));
    httpSource.postData("b");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("a-foob-bar"))));
  }
View Full Code Here

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

    assertThat(fileSink, eventually(hasContentsThat(equalTo("My body is slim!\r\n"))));
  }

  @Test
  public void testMailSink() throws Exception {
    HttpSource httpSource = newHttpSource();
    MailSink mailSink = newMailSink();

    mailSink.ensureStarted()
        .to("'\"some.one@domain.com\"'")
        .subject("payload");


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

    httpSource.ensureReady().postData("Woohoo!");
    MimeMessage result = mailSink.waitForEmail();

    Assert.assertEquals("Woohoo!\r\n", result.getContent());
    Assert.assertEquals("Woohoo!", result.getSubject());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.