List of usage examples for org.springframework.integration.channel QueueChannel receive
@Override @Nullable public Message<?> receive(long timeout)
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 a v 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);// ww w .j av a 2 s. 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);//w w w . j a v a 2 s.co 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);/* w ww . j ava 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 . java 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);/* w w w .ja va2 s .c om*/ Message<?> message = MessageBuilder.withPayload(sourceFile).build(); handler.handleMessage(message); Message<?> result = output.receive(0); assertFileContentIsMatching(result); assertTrue(sourceFile.exists()); }
From source file:org.springframework.integration.file.FileWritingMessageHandlerTests.java
@Test public void deleteFilesTrueWithFilePayload() throws Exception { QueueChannel output = new QueueChannel(); handler.setDeleteSourceFiles(true);/* w w w .j a va 2 s .c om*/ handler.setOutputChannel(output); Message<?> message = MessageBuilder.withPayload(sourceFile).build(); handler.handleMessage(message); Message<?> result = output.receive(0); assertFileContentIsMatching(result); assertFalse(sourceFile.exists()); }
From source file:org.springframework.integration.file.FileWritingMessageHandlerTests.java
@Test public void deleteSourceFileWithStringPayloadAndFileInstanceHeader() throws Exception { QueueChannel output = new QueueChannel(); handler.setCharset(DEFAULT_ENCODING); handler.setDeleteSourceFiles(true);/* w w w.j a v a 2 s. c o m*/ handler.setOutputChannel(output); Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT) .setHeader(FileHeaders.ORIGINAL_FILE, sourceFile).build(); assertTrue(sourceFile.exists()); handler.handleMessage(message); Message<?> result = output.receive(0); assertFileContentIsMatching(result); assertFalse(sourceFile.exists()); }
From source file:org.springframework.integration.file.FileWritingMessageHandlerTests.java
@Test public void deleteSourceFileWithStringPayloadAndFilePathHeader() throws Exception { QueueChannel output = new QueueChannel(); handler.setCharset(DEFAULT_ENCODING); handler.setDeleteSourceFiles(true);//from w w w . ja v a2 s. c o m handler.setOutputChannel(output); Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT) .setHeader(FileHeaders.ORIGINAL_FILE, sourceFile.getAbsolutePath()).build(); assertTrue(sourceFile.exists()); handler.handleMessage(message); Message<?> result = output.receive(0); assertFileContentIsMatching(result); assertFalse(sourceFile.exists()); }
From source file:org.springframework.integration.file.FileWritingMessageHandlerTests.java
@Test public void deleteSourceFileWithByteArrayPayloadAndFileInstanceHeader() throws Exception { QueueChannel output = new QueueChannel(); handler.setCharset(DEFAULT_ENCODING); handler.setDeleteSourceFiles(true);/* w ww . j av a 2 s . c om*/ handler.setOutputChannel(output); Message<?> message = MessageBuilder.withPayload(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING)) .setHeader(FileHeaders.ORIGINAL_FILE, sourceFile).build(); assertTrue(sourceFile.exists()); handler.handleMessage(message); Message<?> result = output.receive(0); assertFileContentIsMatching(result); assertFalse(sourceFile.exists()); }