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

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


    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloworld!"))));
  }

  @Test
  public void testScriptTransformProcessorWithPropertiesLocation() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --script='org/springframework/xd/shell/command/script-with-variables.groovy' " +
            "--propertiesLocation='org/springframework/xd/shell/command/script.properties'" +
            " | %s",
        httpSource, fileSink);
    httpSource.ensureReady().postData("hello");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloFOO"))));
  }
View Full Code Here


    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloFOO"))));
  }

  @Test
  public void testScriptTransformProcessorWithInlineProperties() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --script='org/springframework/xd/shell/command/script-with-variables.groovy' " +
            "--variables='foo=FOO'" +
            " | %s",
        httpSource, fileSink);
    httpSource.ensureReady().postData("hello");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloFOO"))));
  }
View Full Code Here

    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloFOO"))));
  }

  @Test
  public void testScriptInlinePropertiesOverridesLocation() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --script='org/springframework/xd/shell/command/script-with-variables.groovy' " +
            "--variables='foo=BAR' --propertiesLocation='org/springframework/xd/shell/command/script.properties'" +
            " | %s",
        httpSource, fileSink);
    httpSource.ensureReady().postData("hello");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloBAR"))));
  }
View Full Code Here

    assertThat(fileSink, eventually(hasContentsThat(equalTo("helloBAR"))));
  }

  @Test
  public void testExpressionTransformProcessor() {
    HttpSource httpSource = newHttpSource();
    FileSink fileSink = newFileSink().binary(true);
    stream().create(generateStreamName(),
        "%s | transform --expression=payload.toString().toUpperCase() | %s",
        httpSource, fileSink);
    httpSource.ensureReady().postData("hello").postData("World").postData("!");
    assertThat(fileSink, eventually(hasContentsThat(equalTo("HELLOWORLD!"))));
  }
View Full Code Here

   * used to post a simple Ascii String to the admin server.
   */
  @Test
  public void testHttpPostAsciiText() throws InterruptedException, IOException {

    final HttpSource httpSource = newHttpSource();

    final String stringToPost = "hello";
    final FileSink fileSink = newFileSink().binary(true);

    final String streamName = generateStreamName();
    final String stream = String.format("%s | %s", httpSource, fileSink);

    logger.info("Creating Stream: " + stream);
    stream().create(streamName, stream);

    logger.info("Posting String: " + stringToPost);
    httpSource.ensureReady().postData(stringToPost);

    assertThat(fileSink, eventually(hasContentsThat(equalTo(stringToPost))));

  }
View Full Code Here

   * used to post a UTF String (Japanese) to the admin server.
   */
  @Test
  public void testHttpPostUtfText() throws InterruptedException, IOException {

    final HttpSource httpSource = newHttpSource();
    final FileSink fileSink = newFileSink().binary(true);

    /** I want to go to Japan. */
    final String stringToPostInJapanese = "\u65e5\u672c\u306b\u884c\u304d\u305f\u3044\u3002";

    final String streamName = generateStreamName();
    final String stream = String.format("%s | %s", httpSource, fileSink);

    logger.info("Creating Stream: " + stream);
    stream().create(streamName, stream);

    logger.info("Posting String: " + stringToPostInJapanese);
    httpSource.ensureReady().postData(stringToPostInJapanese);


    assertThat(fileSink, eventually(hasContentsThat(equalTo(stringToPostInJapanese))));

  }
View Full Code Here

  @Test
  public void testReadingFromFile() throws Exception {
    final File tempFileIn = testFolder.newFile("utfdatain.txt");
    final FileSink fileSink = newFileSink().binary(true);

    final HttpSource source = newHttpSource();

    /* I want to go to Japan. */
    final String stringToPostInJapanese = "\u65e5\u672c\u306b\u884c\u304d\u305f\u3044\u3002";
    // Let's source from an UTF16 file.
    Charset inCharset = Charset.forName("UTF-16");
    OutputStream os = new FileOutputStream(tempFileIn);
    StreamUtils.copy(stringToPostInJapanese, inCharset, os);
    os.close();

    final String streamName = generateStreamName();
    final String stream = String.format("%s | %s", source, fileSink);

    stream().create(streamName, stream);

    source.ensureReady().useContentType(String.format("text/plain;charset=%s", inCharset)).postFromFile(tempFileIn);

    assertThat(fileSink, eventually(hasContentsThat(equalTo(stringToPostInJapanese))));

  }
View Full Code Here

  @Test
  public void testCreateNamedChannelAsSink() {
    String streamName = generateStreamName();
    String queueName = generateQueueName();
    logger.info("Creating stream with named channel " + queueName + " as sink");
    HttpSource source = newHttpSource();

    stream().create(streamName,
        "%s | transform --expression=payload.toUpperCase() > %s", source, queueName);
  }
View Full Code Here

  public void testCreateNamedChannelAsSource() throws InterruptedException {
    String streamName1 = generateStreamName();
    String streamName2 = generateStreamName();
    String queueName = generateQueueName();
    logger.info("Creating stream with named channel '" + queueName + "' as source");
    HttpSource httpSource = newHttpSource();
    CounterSink counterSink = metrics().newCounterSink();

    stream().create(streamName1, "%s | transform --expression=payload.toUpperCase() > %s",
        httpSource, queueName);
    // Create stream with named channel as source
    stream().create(streamName2, "%s > %s", queueName, counterSink);
    httpSource.ensureReady().postData("test");
    assertThat(counterSink, eventually(hasValue("1")));
  }
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.