Example usage for org.springframework.integration.channel QueueChannel QueueChannel

List of usage examples for org.springframework.integration.channel QueueChannel QueueChannel

Introduction

In this page you can find the example usage for org.springframework.integration.channel QueueChannel QueueChannel.

Prototype

public QueueChannel() 

Source Link

Document

Create a channel with "unbounded" queue capacity.

Usage

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

@Test
public void stringPayloadCopiedToNewFile() throws Exception {
    long lastModified = 1234000L;
    Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT)
            .setHeader(FileHeaders.SET_MODIFIED, lastModified).build();
    QueueChannel output = new QueueChannel();
    handler.setCharset(DEFAULT_ENCODING);
    handler.setOutputChannel(output);/*www . ja v  a 2  s. c om*/
    handler.setPreserveTimestamp(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
    assertLastModifiedIs(result, lastModified);
}

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);//from  w  ww  .j a va2  s  .  c o m
    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.file.FileWritingMessageHandlerTests.java

@Test
public void stringPayloadCopiedToNewFileWithNewLines() throws Exception {
    Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT).build();
    QueueChannel output = new QueueChannel();
    String newLine = System.getProperty("line.separator");
    handler.setCharset(DEFAULT_ENCODING);
    handler.setOutputChannel(output);//from  ww w .  j  a v  a2 s  .  c o m
    handler.setAppendNewLine(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIs(result, SAMPLE_CONTENT + newLine);
}

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

@Test
public void byteArrayPayloadCopiedToNewFile() throws Exception {
    Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING)).build();
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);/*from   w w  w  .  j  av a  2 s  .  com*/
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
}

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

@Test
public void byteArrayPayloadCopiedToNewFileWithNewLines() throws Exception {
    Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING)).build();
    QueueChannel output = new QueueChannel();
    String newLine = System.getProperty("line.separator");
    handler.setOutputChannel(output);/*from  w ww.j  av a 2 s .  c  o m*/
    handler.setAppendNewLine(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIs(result, SAMPLE_CONTENT + newLine);
}

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

@Test
public void filePayloadCopiedToNewFile() throws Exception {
    Message<?> message = MessageBuilder.withPayload(sourceFile).build();
    long lastModified = 12345000L;
    sourceFile.setLastModified(lastModified);
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);//from w w  w  .j  av  a2s .c  o m
    handler.setPreserveTimestamp(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
    assertLastModifiedIs(result, lastModified);
}

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

@Test
public void filePayloadCopiedToNewFileWithNewLines() throws Exception {
    Message<?> message = MessageBuilder.withPayload(sourceFile).build();
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);/*from   w ww.  j  a  va  2s .  c  o m*/
    handler.setAppendNewLine(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIs(result, SAMPLE_CONTENT + System.getProperty("line.separator"));
}

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

@Test
public void inputStreamPayloadCopiedToNewFile() throws Exception {
    InputStream is = new FileInputStream(sourceFile);
    Message<?> message = MessageBuilder.withPayload(is).build();
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);/*from  w  ww . j  av a  2  s.c o  m*/
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
}

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

@Test
public void inputStreamPayloadCopiedToNewFileWithNewLines() throws Exception {
    InputStream is = new FileInputStream(sourceFile);
    Message<?> message = MessageBuilder.withPayload(is).build();
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);//  w  w w  .ja  va  2s. c  o  m
    handler.setAppendNewLine(true);
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIs(result, SAMPLE_CONTENT + System.getProperty("line.separator"));
}

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

@Test
public void deleteFilesFalseByDefault() throws Exception {
    QueueChannel output = new QueueChannel();
    handler.setOutputChannel(output);//from   ww w.jav a2s .  c o  m
    Message<?> message = MessageBuilder.withPayload(sourceFile).build();
    handler.handleMessage(message);
    Message<?> result = output.receive(0);
    assertFileContentIsMatching(result);
    assertTrue(sourceFile.exists());
}