Make the outputChannel and messagingTemplate mutually exclusive

This commit changes the remote chunking and partitioning master step
builders to either accept an output channel or a messaging template
but not both.

See BATCH-2687
This commit is contained in:
Mahmoud Ben Hassine
2018-07-12 11:54:35 +02:00
parent 39676a45c4
commit d72cd67cad
5 changed files with 66 additions and 46 deletions

View File

@@ -176,13 +176,15 @@ public class RemoteChunkingMasterStepBuilderTest {
}
@Test
public void testMandatoryOutputChannel() {
public void eitherOutputChannelOrMessagingTemplateMustBeProvided() {
// given
RemoteChunkingMasterStepBuilder<String, String> builder = new RemoteChunkingMasterStepBuilder<String, String>("step")
.inputChannel(this.inputChannel);
.inputChannel(this.inputChannel)
.outputChannel(new DirectChannel())
.messagingTemplate(new MessagingTemplate());
this.expectedException.expect(IllegalArgumentException.class);
this.expectedException.expectMessage("An OutputChannel must be provided");
this.expectedException.expect(IllegalStateException.class);
this.expectedException.expectMessage("You must specify either an outputChannel or a messagingTemplate but not both.");
// when
TaskletStep step = builder.build();

View File

@@ -118,12 +118,14 @@ public class RemotePartitioningMasterStepBuilderTests {
}
@Test
public void testMandatoryOutputChannel() {
public void eitherOutputChannelOrMessagingTemplateMustBeProvided() {
// given
RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step")
.outputChannel(new DirectChannel())
.messagingTemplate(new MessagingTemplate());
this.expectedException.expect(IllegalArgumentException.class);
this.expectedException.expectMessage("An outputChannel must be provided");
this.expectedException.expect(IllegalStateException.class);
this.expectedException.expectMessage("You must specify either an outputChannel or a messagingTemplate but not both.");
// when
Step step = builder.build();