Fix inconsistency with imports in Locker tests

https://build.spring.io/browse/INT-SI51X-93/
This commit is contained in:
Artem Bilan
2019-10-17 15:19:03 -04:00
parent d8dd56d34f
commit 9abb68eb05
2 changed files with 9 additions and 6 deletions

View File

@@ -27,6 +27,8 @@ import org.junit.rules.TemporaryFolder;
/**
* @author Emmanuel Roux
* @author Artem Bilan
*
* @since 4.3.22
*/
public class FileChannelCacheTests {
@@ -35,7 +37,7 @@ public class FileChannelCacheTests {
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void throwsExceptionWhenFileNotExists() throws IOException {
public void noLockWhenFileNotExists() throws IOException {
File testFile = new File(temp.getRoot(), "test0");
assertThat(testFile.exists()).isFalse();
assertThat(FileChannelCache.tryLockFor(testFile)).isNull();
@@ -45,7 +47,6 @@ public class FileChannelCacheTests {
@Test
public void fileLocked() throws IOException {
File testFile = temp.newFile("test1");
testFile.createNewFile();
assertThat(testFile.exists()).isTrue();
assertThat(FileChannelCache.tryLockFor(testFile)).isNotNull();
FileChannelCache.closeChannelFor(testFile);

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.file.locking;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -37,6 +38,7 @@ import org.springframework.integration.test.util.TestUtils;
* @author Iwein Fuld
* @author Gary Russell
* @author Emmanuel Roux
* @author Artem Bilan
*/
public class NioFileLockerTests {
@@ -84,16 +86,16 @@ public class NioFileLockerTests {
NioFileLocker locker = new NioFileLocker();
File testFile = new File(workdir, "test2");
testFile.createNewFile();
assertThat(locker.lock(testFile)).isTrue();
assertTrue(locker.lock(testFile));
locker.unlock(testFile);
}
@Test
public void fileNotLockedWhenNotExists() throws IOException {
public void fileNotLockedWhenNotExists() {
NioFileLocker locker = new NioFileLocker();
File testFile = new File(workdir, "test3");
assertThat(locker.lock(testFile)).isFalse();
assertThat(testFile.exists()).isFalse();
assertFalse(locker.lock(testFile));
assertFalse(testFile.exists());
}
}