diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/RollbackLocalFilterTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/RollbackLocalFilterTests.java index e78f2e7318..58ab0781b6 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/RollbackLocalFilterTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/RollbackLocalFilterTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.sftp.inbound; import static org.junit.Assert.assertEquals; @@ -29,16 +30,19 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gary Russell + * @author Artem Bilan * @since 4.1.7 * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) +@DirtiesContext public class RollbackLocalFilterTests { @BeforeClass @@ -73,11 +77,12 @@ public class RollbackLocalFilterTests { } public void handle(File in) { - latch.countDown(); if (this.shouldCrash.compareAndSet(false, true)) { + latch.countDown(); throw new RuntimeException("foo"); } this.file = in; + latch.countDown(); } } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java index fda74ba923..ca93f6a06f 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java @@ -42,7 +42,6 @@ import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.BeanFactory; -import org.springframework.integration.expression.ExpressionUtils; import org.springframework.integration.file.filters.AcceptOnceFileListFilter; import org.springframework.integration.file.filters.CompositeFileListFilter; import org.springframework.integration.file.filters.FileListFilter; @@ -86,8 +85,8 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { @Test public void testCopyFileToLocalDir() throws Exception { - File localDirectoy = new File("test"); - assertFalse(localDirectoy.exists()); + File localDirectory = new File("test"); + assertFalse(localDirectory.exists()); TestSftpSessionFactory ftpSessionFactory = new TestSftpSessionFactory(); ftpSessionFactory.setUser("kermit"); @@ -114,7 +113,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { SftpInboundFileSynchronizingMessageSource ms = new SftpInboundFileSynchronizingMessageSource(synchronizer); ms.setAutoCreateLocalDirectory(true); - ms.setLocalDirectory(localDirectoy); + ms.setLocalDirectory(localDirectory); ms.setBeanFactory(mock(BeanFactory.class)); CompositeFileListFilter localFileListFilter = new CompositeFileListFilter(); localFileListFilter.addFilter(new RegexPatternFileListFilter(".*\\.test$")); @@ -138,7 +137,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { assertNull(nothing); // two times because on the third receive (above) the internal queue will be empty, so it will attempt - verify(synchronizer, times(2)).synchronizeToLocalDirectory(localDirectoy); + verify(synchronizer, times(2)).synchronizeToLocalDirectory(localDirectory); assertTrue(new File("test/a.test").exists()); assertTrue(new File("test/b.test").exists()); @@ -199,6 +198,7 @@ public class SftpInboundRemoteFileSystemSynchronizerTests { throw new RuntimeException("Failed to create mock sftp session", e); } } + } }