Example usage for org.springframework.integration.test.util TestUtils applySystemFileSeparator

List of usage examples for org.springframework.integration.test.util TestUtils applySystemFileSeparator

Introduction

In this page you can find the example usage for org.springframework.integration.test.util TestUtils applySystemFileSeparator.

Prototype

public static String applySystemFileSeparator(String s) 

Source Link

Document

Update file path by replacing any '/' with the system's file separator.

Usage

From source file:org.springframework.integration.dsl.test.IntegrationFlowTests.java

@Test
public void testFileWritingFlow() throws Exception {
    String payload = "Spring Integration";
    this.fileWritingInput.send(new GenericMessage<>(payload));
    Message<?> receive = this.fileWritingResultChannel.receive(1000);
    assertNotNull(receive);//  w  w w.j a v  a  2  s  .c o m
    assertThat(receive.getPayload(), instanceOf(java.io.File.class));
    java.io.File resultFile = (java.io.File) receive.getPayload();
    assertThat(resultFile.getAbsolutePath(),
            endsWith(TestUtils.applySystemFileSeparator("fileWritingFlow/foo.sitest")));
    String fileContent = StreamUtils.copyToString(new FileInputStream(resultFile), Charset.defaultCharset());
    assertEquals(payload, fileContent);
}

From source file:org.springframework.integration.file.FileWritingMessageHandlerTests.java

@Test
public void testFileNameHeader() throws Exception {
    Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT)
            .setHeader(FileHeaders.FILENAME, "dir1" + File.separator + "dir2/test").build();
    QueueChannel output = new QueueChannel();
    handler.setCharset(DEFAULT_ENCODING);
    handler.setOutputChannel(output);//w w w . j  av a2 s  . c  om
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
    File destFile = (File) result.getPayload();
    assertThat(destFile.getAbsolutePath(),
            containsString(TestUtils.applySystemFileSeparator("/dir1/dir2/test")));
}

From source file:org.springframework.integration.samples.filesplit.ApplicationTests.java

@SuppressWarnings("unchecked")
@Test/*www.  j av  a2 s .  c  om*/
public void testSuccess() throws Exception {
    String message = runTest(false);
    assertThat(message).contains("File successfully split and transferred");
    assertThat(message).contains(TestUtils.applySystemFileSeparator("/tmp/in/foo.txt"));
}

From source file:org.springframework.integration.samples.filesplit.ApplicationTests.java

@Test
public void testFailure() throws Exception {
    willThrow(new RuntimeException("fail test exception")).given(this.session).write(any(InputStream.class),
            eq("foo/002.txt.writing"));
    String message = runTest(true);
    assertThat(message).contains("File split and transfer failed");
    assertThat(message).contains("fail test exception");
    assertThat(message).contains(TestUtils.applySystemFileSeparator("/tmp/out/002.txt"));
}