From 83eba0bb4aa7be236f722c56e91d7ee26d46bc49 Mon Sep 17 00:00:00 2001 From: Iwein Fuld Date: Sat, 19 Sep 2009 17:27:38 +0000 Subject: [PATCH] initializing directory BeforeClass instead of Before --- ...ngWithMultipleSourcesIntegrationTests.java | 19 ++++++--------- .../locking/LockFileFileListFilterTests.java | 24 ++++++++++--------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/FileLockingWithMultipleSourcesIntegrationTests.java b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/FileLockingWithMultipleSourcesIntegrationTests.java index eb966070ce..f9e4c2ed19 100644 --- a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/FileLockingWithMultipleSourcesIntegrationTests.java +++ b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/FileLockingWithMultipleSourcesIntegrationTests.java @@ -15,22 +15,17 @@ */ package org.springframework.integration.file.locking; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.integration.file.FileReadingMessageSource; -import org.springframework.integration.test.matcher.PayloadMatcher; import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload; -import org.junit.runner.RunWith; -import org.junit.Test; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.Assert; -import org.junit.matchers.JUnitMatchers; -import static org.junit.Assert.assertThat; -import org.hamcrest.CoreMatchers; -import static org.hamcrest.CoreMatchers.nullValue; +import org.springframework.test.context.ContextConfiguration; import java.io.File; import java.io.IOException; diff --git a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/LockFileFileListFilterTests.java b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/LockFileFileListFilterTests.java index 4ecf9af152..febcc1ed19 100644 --- a/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/LockFileFileListFilterTests.java +++ b/org.springframework.integration.file/src/test/java/org/springframework/integration/file/locking/LockFileFileListFilterTests.java @@ -19,6 +19,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import org.junit.Before; import org.junit.Test; +import org.junit.BeforeClass; import java.io.File; import java.io.IOException; @@ -30,13 +31,21 @@ import java.util.List; */ public class LockFileFileListFilterTests { - private File workdir = new File(new File(System.getProperty("java.io.tmpdir")), this.getClass().getSimpleName());; + private static File workdir = new File(new File(System.getProperty("java.io.tmpdir")), LockFileFileListFilterTests.class.getSimpleName()); + + @BeforeClass + public static void setupWorkDir() { + workdir.mkdir(); + } + private FileLocker locker = new LockFileFileLocker(workdir); @Before - public void setupWorkDir() { - workdir.mkdir(); - cleanDirectory(workdir); + public void cleanDirectory() { + File[] files = workdir.listFiles(); + for (File file : files) { + file.delete(); + } } @Test @@ -60,11 +69,4 @@ public class LockFileFileListFilterTests { assertThat(filter2.filterFiles(workdir.listFiles()), is((List)new ArrayList())); } - private void cleanDirectory(File workdir) { - File[] files = workdir.listFiles(); - for (File file : files) { - file.delete(); - } - } - }