From 24fa72aab2f9652c0a48b2eca4220c832df2333b Mon Sep 17 00:00:00 2001 From: Iwein Fuld Date: Sun, 17 Oct 2010 14:55:44 +0200 Subject: [PATCH] QUALITY: avoided file initialization @Before in favor of @Rule overriding (to avoid temporary files remaining in the source path) --- .../file/FileWritingMessageHandlerTests.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/FileWritingMessageHandlerTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/FileWritingMessageHandlerTests.java index c90c945ba7..dcdca5b78d 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/FileWritingMessageHandlerTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/FileWritingMessageHandlerTests.java @@ -54,6 +54,9 @@ public class FileWritingMessageHandlerTests { super.create(); outputDirectory = temp.newFolder("outputDirectory"); handler = new FileWritingMessageHandler(outputDirectory); + sourceFile = temp.newFile("sourceFile"); + FileCopyUtils.copy(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING), + new FileOutputStream(sourceFile, false)); } }; @@ -63,12 +66,7 @@ public class FileWritingMessageHandlerTests { @Before public void setup() throws Exception { - sourceFile = File.createTempFile("tempSourceFileForTests", ".txt"); - sourceFile.deleteOnExit(); - FileCopyUtils.copy(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING), - new FileOutputStream(sourceFile, false)); - outputDirectory = temp.newFolder("outputDirectory"); - handler = new FileWritingMessageHandler(outputDirectory); + //don't tamper with temp files here, Rule is applied later } @Test(expected = MessageHandlingException.class)