Add @DirtiesContext to active tests
Related to https://github.com/spring-projects/spring-integration/issues/2782
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.file;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.File;
|
||||
@@ -61,23 +62,25 @@ public class AutoCreateDirectoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoCreateForInboundEnabledByDefault() throws Exception {
|
||||
public void autoCreateForInboundEnabledByDefault() {
|
||||
FileReadingMessageSource source = new FileReadingMessageSource();
|
||||
source.setDirectory(new File(INBOUND_PATH));
|
||||
source.setBeanFactory(mock(BeanFactory.class));
|
||||
source.afterPropertiesSet();
|
||||
source.start();
|
||||
assertThat(new File(INBOUND_PATH).exists()).isTrue();
|
||||
source.stop();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void autoCreateForInboundDisabled() throws Exception {
|
||||
@Test
|
||||
public void autoCreateForInboundDisabled() {
|
||||
FileReadingMessageSource source = new FileReadingMessageSource();
|
||||
source.setDirectory(new File(INBOUND_PATH));
|
||||
source.setAutoCreateDirectory(false);
|
||||
source.setBeanFactory(mock(BeanFactory.class));
|
||||
source.afterPropertiesSet();
|
||||
source.start();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(source::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -30,15 +30,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
public class AutoCreateDirectoryIntegrationTests {
|
||||
|
||||
private static final String BASE_PATH =
|
||||
|
||||
@@ -30,15 +30,16 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.integration.file.filters.CompositeFileListFilter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Gunnar Hillert
|
||||
* @author Artme Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
public class FileLockingNamespaceTests {
|
||||
|
||||
@Autowired
|
||||
@@ -56,7 +57,8 @@ public class FileLockingNamespaceTests {
|
||||
@Before
|
||||
public void extractSources() {
|
||||
nioLockingSource = (FileReadingMessageSource) new DirectFieldAccessor(nioAdapter).getPropertyValue("source");
|
||||
customLockingSource = (FileReadingMessageSource) new DirectFieldAccessor(customAdapter).getPropertyValue("source");
|
||||
customLockingSource =
|
||||
(FileReadingMessageSource) new DirectFieldAccessor(customAdapter).getPropertyValue("source");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +73,8 @@ public class FileLockingNamespaceTests {
|
||||
}
|
||||
|
||||
private Object extractFromScanner(String propertyName, FileReadingMessageSource source) {
|
||||
return new DirectFieldAccessor(new DirectFieldAccessor(source).getPropertyValue("scanner")).getPropertyValue(propertyName);
|
||||
return new DirectFieldAccessor(new DirectFieldAccessor(source).getPropertyValue("scanner"))
|
||||
.getPropertyValue(propertyName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,5 +96,7 @@ public class FileLockingNamespaceTests {
|
||||
public void unlock(File fileToUnlock) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,19 +30,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(org.springframework.test.context.junit4.SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@DirtiesContext
|
||||
public class FileLockingWithMultipleSourcesIntegrationTests {
|
||||
|
||||
private static File workdir;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupWorkDirectory() throws Exception {
|
||||
public static void setupWorkDirectory() {
|
||||
workdir = new File(new File(System.getProperty("java.io.tmpdir")),
|
||||
FileLockingWithMultipleSourcesIntegrationTests.class.getSimpleName());
|
||||
workdir.mkdir();
|
||||
|
||||
Reference in New Issue
Block a user