INT-4096: Allow Configuration of ReadOnly Headers
JIRA: https://jira.spring.io/browse/INT-4096 * Introduce `spring.integration.readOnly.headers` Integration property * Introduce `IntegrationMessageHeaderAccessor.setReadOnlyHeaders()` and use it from the overridden `IntegrationMessageHeaderAccessor.isReadOnly()` * Add `DefaultMessageBuilderFactory.setReadOnlyHeaders()` and delegate the value to the new `MessageBuilder.readOnlyHeaders()` * Modify `spring.integration.properties` for the `contentType` as a `readOnly` header for testing * Ensure that provided logic works via an appropriate modification to the `ObjectToJsonTransformerParserTests` Increase receive timeouts in the `OutboundGatewayFunctionTests` Fix `FileInboundTransactionTests` for slow `WatchService` issue on Linux/OS X Also redo the `tmp` dir logic to the `TemporaryFolder` `@ClassRule` Fix unused `import` in the `FileInboundTransactionTests` Polishing Conflicts: spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationProperties.java spring-integration-core/src/main/resources/META-INF/spring.integration.default.properties Some polishing and documentation Localize `readOnly.headers` customization only in the `ObjectToJsonTransformerParserTests-context.xml` Otherwise ti might affect many other tests and the search for the reason of failure would be enough complicated Doc Polish
This commit is contained in:
committed by
Gary Russell
parent
450ac7f18d
commit
dbcebebf38
@@ -12,7 +12,8 @@
|
||||
<context:property-placeholder/>
|
||||
|
||||
<int-file:inbound-channel-adapter id="pseudoTx"
|
||||
channel="input" auto-startup="false" directory="${java.io.tmpdir}/si-test1"
|
||||
channel="input" auto-startup="false"
|
||||
directory="#{T (org.springframework.integration.file.FileInboundTransactionTests).tmpDir.root}/si-test1"
|
||||
use-watch-service="true">
|
||||
<int:poller fixed-rate="500">
|
||||
<int:transactional synchronization-factory="syncFactoryA"/>
|
||||
@@ -32,7 +33,7 @@
|
||||
<int:channel id="txInput" />
|
||||
|
||||
<int-file:inbound-channel-adapter id="realTx" channel="txInput" auto-startup="false"
|
||||
directory="${java.io.tmpdir}/si-test2">
|
||||
directory="#{T (org.springframework.integration.file.FileInboundTransactionTests).tmpDir.root}/si-test2">
|
||||
<int:poller fixed-rate="500">
|
||||
<int:transactional transaction-manager="txManager" synchronization-factory="syncFactoryB"/>
|
||||
</int:poller>
|
||||
|
||||
@@ -27,11 +27,12 @@ import java.io.File;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -39,6 +40,7 @@ import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
@@ -54,8 +56,12 @@ import org.springframework.transaction.support.DefaultTransactionStatus;
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext
|
||||
public class FileInboundTransactionTests {
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder tmpDir = new TemporaryFolder();
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter pseudoTx;
|
||||
|
||||
@@ -77,9 +83,6 @@ public class FileInboundTransactionTests {
|
||||
@Autowired
|
||||
private DummyTxManager transactionManager;
|
||||
|
||||
@Value("${java.io.tmpdir}")
|
||||
private String tmpDir;
|
||||
|
||||
@Test
|
||||
public void testNoTx() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
@@ -95,17 +98,16 @@ public class FileInboundTransactionTests {
|
||||
}
|
||||
});
|
||||
pseudoTx.start();
|
||||
new File(tmpDir + "/si-test1").mkdir();
|
||||
File file = new File(tmpDir + "/si-test1/foo");
|
||||
File file = new File(tmpDir.getRoot(), "si-test1/foo");
|
||||
file.createNewFile();
|
||||
Message<?> result = successChannel.receive(40000);
|
||||
Message<?> result = successChannel.receive(60000);
|
||||
assertNotNull(result);
|
||||
assertEquals(Boolean.TRUE, result.getPayload());
|
||||
assertFalse(file.delete());
|
||||
crash.set(true);
|
||||
file = new File(tmpDir + "/si-test1/bar");
|
||||
file = new File(tmpDir.getRoot(), "si-test1/bar");
|
||||
file.createNewFile();
|
||||
result = failureChannel.receive(10000);
|
||||
result = failureChannel.receive(60000);
|
||||
assertNotNull(result);
|
||||
assertTrue(file.delete());
|
||||
assertEquals("foo", result.getPayload());
|
||||
@@ -132,18 +134,17 @@ public class FileInboundTransactionTests {
|
||||
}
|
||||
});
|
||||
realTx.start();
|
||||
new File(tmpDir + "/si-test2").mkdir();
|
||||
File file = new File(tmpDir + "/si-test2/baz");
|
||||
File file = new File(tmpDir.getRoot(), "si-test2/baz");
|
||||
file.createNewFile();
|
||||
Message<?> result = successChannel.receive(40000);
|
||||
Message<?> result = successChannel.receive(60000);
|
||||
assertNotNull(result);
|
||||
assertEquals(Boolean.TRUE, result.getPayload());
|
||||
assertTrue(file.delete());
|
||||
assertTrue(transactionManager.getCommitted());
|
||||
crash.set(true);
|
||||
file = new File(tmpDir + "/si-test2/qux");
|
||||
file = new File(tmpDir.getRoot(), "si-test2/qux");
|
||||
file.createNewFile();
|
||||
result = failureChannel.receive(10000);
|
||||
result = failureChannel.receive(60000);
|
||||
assertNotNull(result);
|
||||
assertTrue(file.delete());
|
||||
assertEquals(Boolean.TRUE, result.getPayload());
|
||||
@@ -193,6 +194,7 @@ public class FileInboundTransactionTests {
|
||||
public boolean getRolledBack() {
|
||||
return rolledBack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user