INT-3840: Fix RollbackLocalFilterTests

JIRA: https://jira.spring.io/browse/INT-3840

* In addition: fix some typos in the `SftpInboundRemoteFileSystemSynchronizerTests`

**Cherry-pick to 4.1.x**
This commit is contained in:
Artem Bilan
2015-09-30 19:20:44 -04:00
parent 3fe71ed77c
commit 1a0cbf0494
2 changed files with 11 additions and 6 deletions

View File

@@ -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();
}
}

View File

@@ -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<File> localFileListFilter = new CompositeFileListFilter<File>();
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);
}
}
}
}