From 4f32f623f09971882db6a35a7ff375e558eab2da Mon Sep 17 00:00:00 2001 From: Chris Schaefer Date: Thu, 12 Jun 2014 03:14:34 -0400 Subject: [PATCH] BATCH-2241 & BATCH-2243 - add namespace support for remote chunking --- .../xml/BatchIntegrationNamespaceHandler.java | 7 +- .../xml/RemoteChunkingMasterParser.java | 83 ++++++ .../config/xml/RemoteChunkingSlaveParser.java | 117 ++++++++ .../main/resources/META-INF/spring.schemas | 3 +- .../xml/spring-batch-integration-1.3.xsd | 2 +- .../xml/spring-batch-integration-3.1.xsd | 244 ++++++++++++++++ .../config/xml/RemoteChunkingParserTests.java | 276 ++++++++++++++++++ ...ChunkingMasterParserMissingIdAttrTests.xml | 12 + ...rParserMissingMessageTemplateAttrTests.xml | 12 + ...sterParserMissingReplyChannelAttrTests.xml | 12 + ...unkingMasterParserMissingStepAttrTests.xml | 12 + .../xml/RemoteChunkingMasterParserTests.xml | 57 ++++ ...eChunkingSlaveParserMissingIdAttrTests.xml | 13 + ...laveParserMissingInputChannelAttrTests.xml | 13 + ...gSlaveParserMissingItemWriterAttrTests.xml | 13 + ...aveParserMissingOutputChannelAttrTests.xml | 13 + ...oteChunkingSlaveParserNoProcessorTests.xml | 21 ++ .../xml/RemoteChunkingSlaveParserTests.xml | 21 ++ 18 files changed, 926 insertions(+), 5 deletions(-) create mode 100644 spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParser.java create mode 100644 spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParser.java create mode 100644 spring-batch-integration/src/main/resources/org/springframework/batch/integration/config/xml/spring-batch-integration-3.1.xsd create mode 100644 spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserNoProcessorTests.xml create mode 100644 spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserTests.xml diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/BatchIntegrationNamespaceHandler.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/BatchIntegrationNamespaceHandler.java index eaf47fd9f..812bfb531 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/BatchIntegrationNamespaceHandler.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/BatchIntegrationNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,15 +21,16 @@ import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHa * The namespace handler for the Spring Batch Integration namespace. * * @author Gunnar Hillert + * @author Chris Schaefer * @since 1.3 - * */ public class BatchIntegrationNamespaceHandler extends AbstractIntegrationNamespaceHandler { - /* (non-Javadoc) * @see org.springframework.beans.factory.xml.NamespaceHandler#init() */ public void init() { this.registerBeanDefinitionParser("job-launching-gateway", new JobLaunchingGatewayParser()); + this.registerBeanDefinitionParser("remote-chunking-master", new RemoteChunkingMasterParser()); + this.registerBeanDefinitionParser("remote-chunking-slave", new RemoteChunkingSlaveParser()); } } diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParser.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParser.java new file mode 100644 index 000000000..dc1b23994 --- /dev/null +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParser.java @@ -0,0 +1,83 @@ +/* + * Copyright 2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.integration.config.xml; + +import org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter; +import org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.util.Assert; +import org.w3c.dom.Element; + +/** + *

+ * Parser for the remote-chunking-master namespace element. + *

+ * + * @author Chris Schaefer + * @since 3.1 + */ +public class RemoteChunkingMasterParser extends AbstractBeanDefinitionParser { + private static final String MESSAGE_TEMPLATE_ATTRIBUTE = "message-template"; + private static final String STEP_ATTRIBUTE = "step"; + private static final String REPLY_CHANNEL_ATTRIBUTE = "reply-channel"; + private static final String MESSAGING_OPERATIONS_PROPERTY = "messagingOperations"; + private static final String REPLY_CHANNEL_PROPERTY = "replyChannel"; + private static final String CHUNK_WRITER_PROPERTY = "chunkWriter"; + private static final String STEP_PROPERTY = "step"; + private static final String CHUNK_HANDLER_BEAN_NAME_PREFIX = "remoteChunkHandlerFactoryBean_"; + + @Override + public AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { + String id = element.getAttribute(ID_ATTRIBUTE); + Assert.hasText(id, "The id attribute must be specified"); + + String messageTemplate = element.getAttribute(MESSAGE_TEMPLATE_ATTRIBUTE); + Assert.hasText(messageTemplate, "The message-template attribute must be specified"); + + String step = element.getAttribute(STEP_ATTRIBUTE); + Assert.hasText(step, "The step attribute must be specified"); + + String replyChannel = element.getAttribute(REPLY_CHANNEL_ATTRIBUTE); + Assert.hasText(replyChannel, "The reply-channel attribute must be specified"); + + BeanDefinitionRegistry beanDefinitionRegistry = parserContext.getRegistry(); + + BeanDefinition chunkMessageChannelItemWriter = + BeanDefinitionBuilder + .genericBeanDefinition(ChunkMessageChannelItemWriter.class) + .addPropertyReference(MESSAGING_OPERATIONS_PROPERTY, messageTemplate) + .addPropertyReference(REPLY_CHANNEL_PROPERTY, replyChannel) + .getBeanDefinition(); + + beanDefinitionRegistry.registerBeanDefinition(id, chunkMessageChannelItemWriter); + + BeanDefinition remoteChunkHandlerFactoryBean = + BeanDefinitionBuilder + .genericBeanDefinition(RemoteChunkHandlerFactoryBean.class) + .addPropertyValue(CHUNK_WRITER_PROPERTY, chunkMessageChannelItemWriter) + .addPropertyValue(STEP_PROPERTY, step) + .getBeanDefinition(); + + beanDefinitionRegistry.registerBeanDefinition(CHUNK_HANDLER_BEAN_NAME_PREFIX + step, remoteChunkHandlerFactoryBean); + + return null; + } +} diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParser.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParser.java new file mode 100644 index 000000000..d065b5240 --- /dev/null +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParser.java @@ -0,0 +1,117 @@ +/* + * Copyright 2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.integration.config.xml; + +import org.springframework.batch.core.step.item.SimpleChunkProcessor; +import org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler; +import org.springframework.batch.item.support.PassThroughItemProcessor; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.RuntimeBeanReference; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.integration.config.ServiceActivatorFactoryBean; +import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; +import org.w3c.dom.Element; + +/** + *

+ * Parser for the remote-chunking-slave namespace element. If an + * {@link org.springframework.batch.item.ItemProcessor} is not provided, an + * {@link org.springframework.batch.item.support.PassThroughItemProcessor} will be + * configured. + *

+ * + * @author Chris Schaefer + * @since 3.1 + */ +public class RemoteChunkingSlaveParser extends AbstractBeanDefinitionParser { + private static final String INPUT_CHANNEL_ATTRIBUTE = "input-channel"; + private static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel"; + private static final String ITEM_PROCESSOR_ATTRIBUTE = "item-processor"; + private static final String ITEM_WRITER_ATTRIBUTE = "item-writer"; + private static final String ITEM_PROCESSOR_PROPERTY_NAME = "itemProcessor"; + private static final String ITEM_WRITER_PROPERTY_NAME = "itemWriter"; + private static final String CHUNK_PROCESSOR_PROPERTY_NAME = "chunkProcessor"; + private static final String CHUNK_PROCESSOR_CHUNK_HANDLER_BEAN_NAME_PREFIX = "chunkProcessorChunkHandler_"; + + @Override + protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { + String id = element.getAttribute(ID_ATTRIBUTE); + Assert.hasText(id, "The id attribute must be specified"); + + String inputChannel = element.getAttribute(INPUT_CHANNEL_ATTRIBUTE); + Assert.hasText(inputChannel, "The input-channel attribute must be specified"); + + String outputChannel = element.getAttribute(OUTPUT_CHANNEL_ATTRIBUTE); + Assert.hasText(outputChannel, "The output-channel attribute must be specified"); + + String itemProcessor = element.getAttribute(ITEM_PROCESSOR_ATTRIBUTE); + + String itemWriter = element.getAttribute(ITEM_WRITER_ATTRIBUTE); + Assert.hasText(itemWriter, "The item-writer attribute must be specified"); + + BeanDefinitionRegistry beanDefinitionRegistry = parserContext.getRegistry(); + + BeanDefinitionBuilder chunkProcessorBuilder = + BeanDefinitionBuilder + .genericBeanDefinition(SimpleChunkProcessor.class) + .addPropertyReference(ITEM_WRITER_PROPERTY_NAME, itemWriter); + + if(StringUtils.hasText(itemProcessor)) { + chunkProcessorBuilder.addPropertyReference(ITEM_PROCESSOR_PROPERTY_NAME, itemProcessor); + } else { + chunkProcessorBuilder.addPropertyValue(ITEM_PROCESSOR_PROPERTY_NAME, new PassThroughItemProcessor()); + } + + BeanDefinition chunkProcessorChunkHandler = + BeanDefinitionBuilder + .genericBeanDefinition(ChunkProcessorChunkHandler.class) + .addPropertyValue(CHUNK_PROCESSOR_PROPERTY_NAME, chunkProcessorBuilder.getBeanDefinition()) + .getBeanDefinition(); + + beanDefinitionRegistry.registerBeanDefinition(CHUNK_PROCESSOR_CHUNK_HANDLER_BEAN_NAME_PREFIX + id, chunkProcessorChunkHandler); + + new ServiceActivatorParser(id).parse(element, parserContext); + + return null; + } + + private static class ServiceActivatorParser extends AbstractConsumerEndpointParser { + private static final String TARGET_METHOD_NAME_PROPERTY_NAME = "targetMethodName"; + private static final String TARGET_OBJECT_PROPERTY_NAME = "targetObject"; + private static final String HANDLE_CHUNK_METHOD_NAME = "handleChunk"; + private static final String CHUNK_PROCESSOR_CHUNK_HANDLER_BEAN_NAME_PREFIX = "chunkProcessorChunkHandler_"; + + private String id; + + public ServiceActivatorParser(String id) { + this.id = id; + } + + @Override + protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatorFactoryBean.class); + builder.addPropertyValue(TARGET_METHOD_NAME_PROPERTY_NAME, HANDLE_CHUNK_METHOD_NAME); + builder.addPropertyValue(TARGET_OBJECT_PROPERTY_NAME, new RuntimeBeanReference(CHUNK_PROCESSOR_CHUNK_HANDLER_BEAN_NAME_PREFIX + id)); + return builder; + } + } +} diff --git a/spring-batch-integration/src/main/resources/META-INF/spring.schemas b/spring-batch-integration/src/main/resources/META-INF/spring.schemas index 5261db6ee..5f1da865f 100644 --- a/spring-batch-integration/src/main/resources/META-INF/spring.schemas +++ b/spring-batch-integration/src/main/resources/META-INF/spring.schemas @@ -1,2 +1,3 @@ http\://www.springframework.org/schema/batch-integration/spring-batch-integration-1.3.xsd=org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd -http\://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd=org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd +http\://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd=org/springframework/batch/integration/config/xml/spring-batch-integration-3.1.xsd +http\://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd=org/springframework/batch/integration/config/xml/spring-batch-integration-3.1.xsd diff --git a/spring-batch-integration/src/main/resources/org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd b/spring-batch-integration/src/main/resources/org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd index cae6ba4ec..2e5b1f1f6 100644 --- a/spring-batch-integration/src/main/resources/org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd +++ b/spring-batch-integration/src/main/resources/org/springframework/batch/integration/config/xml/spring-batch-integration-1.3.xsd @@ -1,6 +1,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java new file mode 100644 index 000000000..77e46fda2 --- /dev/null +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java @@ -0,0 +1,276 @@ +/* + * Copyright 2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.integration.config.xml; + +import org.junit.Test; +import org.springframework.batch.core.step.item.ChunkProcessor; +import org.springframework.batch.core.step.item.SimpleChunkProcessor; +import org.springframework.batch.integration.chunk.ChunkHandler; +import org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter; +import org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler; +import org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean; +import org.springframework.batch.item.ItemProcessor; +import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.item.support.PassThroughItemProcessor; +import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.config.ServiceActivatorFactoryBean; +import org.springframework.integration.test.util.TestUtils; +import org.springframework.messaging.MessageChannel; +import java.util.List; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + *

+ * Test cases for the {@link org.springframework.batch.integration.config.xml.RemoteChunkingSlaveParser} + * and {@link org.springframework.batch.integration.config.xml.RemoteChunkingMasterParser}. + *

+ * + * @author Chris Schaefer + * @since 3.1 + */ +public class RemoteChunkingParserTests { + @Test + public void testRemoteChunkingSlaveParserWithProcessorDefined() { + ApplicationContext applicationContext = + new ClassPathXmlApplicationContext("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserTests.xml"); + + ChunkHandler chunkHandler = applicationContext.getBean(ChunkProcessorChunkHandler.class); + ChunkProcessor chunkProcessor = (SimpleChunkProcessor) TestUtils.getPropertyValue(chunkHandler, "chunkProcessor"); + assertNotNull("ChunkProcessor must not be null", chunkProcessor); + + ItemWriter itemWriter = (ItemWriter) TestUtils.getPropertyValue(chunkProcessor, "itemWriter"); + assertNotNull("ChunkProcessor ItemWriter must not be null", itemWriter); + assertTrue("Got wrong instance of ItemWriter", itemWriter instanceof Writer); + + ItemProcessor itemProcessor = (ItemProcessor) TestUtils.getPropertyValue(chunkProcessor, "itemProcessor"); + assertNotNull("ChunkProcessor ItemWriter must not be null", itemProcessor); + assertTrue("Got wrong instance of ItemProcessor", itemProcessor instanceof Processor); + + FactoryBean serviceActivatorFactoryBean = applicationContext.getBean(ServiceActivatorFactoryBean.class); + assertNotNull("ServiceActivatorFactoryBean must not be null", serviceActivatorFactoryBean); + assertNotNull("Output channel must not be null", TestUtils.getPropertyValue(serviceActivatorFactoryBean, "outputChannel")); + + MessageChannel inputChannel = applicationContext.getBean("requests", MessageChannel.class); + assertNotNull("Input channel must not be null", inputChannel); + + String targetMethodName = (String) TestUtils.getPropertyValue(serviceActivatorFactoryBean, "targetMethodName"); + assertNotNull("Target method name must not be null", targetMethodName); + assertTrue("Target method name must be handleChunk, got: " + targetMethodName, "handleChunk".equals(targetMethodName)); + + ChunkHandler targetObject = (ChunkHandler) TestUtils.getPropertyValue(serviceActivatorFactoryBean, "targetObject"); + assertNotNull("Target object must not be null", targetObject); + } + + @Test + public void testRemoteChunkingSlaveParserWithProcessorNotDefined() { + ApplicationContext applicationContext = + new ClassPathXmlApplicationContext("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserNoProcessorTests.xml"); + + ChunkHandler chunkHandler = applicationContext.getBean(ChunkProcessorChunkHandler.class); + ChunkProcessor chunkProcessor = (SimpleChunkProcessor) TestUtils.getPropertyValue(chunkHandler, "chunkProcessor"); + assertNotNull("ChunkProcessor must not be null", chunkProcessor); + + ItemProcessor itemProcessor = (ItemProcessor) TestUtils.getPropertyValue(chunkProcessor, "itemProcessor"); + assertNotNull("ChunkProcessor ItemWriter must not be null", itemProcessor); + assertTrue("Got wrong instance of ItemProcessor", itemProcessor instanceof PassThroughItemProcessor); + } + + @Test + public void testRemoteChunkingMasterParser() { + ApplicationContext applicationContext = + new ClassPathXmlApplicationContext("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserTests.xml"); + + ItemWriter itemWriter = applicationContext.getBean("itemWriter", ChunkMessageChannelItemWriter.class); + assertNotNull("Messaging template must not be null", TestUtils.getPropertyValue(itemWriter, "messagingGateway")); + assertNotNull("Reply channel must not be null", TestUtils.getPropertyValue(itemWriter, "replyChannel")); + + FactoryBean remoteChunkingHandlerFactoryBean = applicationContext.getBean(RemoteChunkHandlerFactoryBean.class); + assertNotNull("Chunk writer must not be null", TestUtils.getPropertyValue(remoteChunkingHandlerFactoryBean, "chunkWriter")); + assertNotNull("Step must not be null", TestUtils.getPropertyValue(remoteChunkingHandlerFactoryBean, "step")); + } + + @Test + public void testRemoteChunkingMasterIdAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The id attribute must be specified" + " but got: " + iae.getMessage(), + "The id attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingMasterMessageTemplateAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The message-template attribute must be specified" + " but got: " + iae.getMessage(), + "The message-template attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingMasterStepAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The step attribute must be specified" + " but got: " + iae.getMessage(), + "The step attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingMasterReplyChannelAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The reply-channel attribute must be specified" + " but got: " + iae.getMessage(), + "The reply-channel attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingSlaveIdAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The id attribute must be specified" + " but got: " + iae.getMessage(), + "The id attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingSlaveInputChannelAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The input-channel attribute must be specified" + " but got: " + iae.getMessage(), + "The input-channel attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingSlaveItemWriterAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The item-writer attribute must be specified" + " but got: " + iae.getMessage(), + "The item-writer attribute must be specified".equals(iae.getMessage())); + } + } + + @Test + public void testRemoteChunkingSlaveOutputChannelAttrAssert() throws Exception { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); + applicationContext.setValidating(false); + applicationContext.setConfigLocation("/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml"); + + try { + applicationContext.refresh(); + fail(); + } catch (BeanDefinitionStoreException e) { + assertTrue("Nested exception must be of type IllegalArgumentException", e.getCause() instanceof IllegalArgumentException); + + IllegalArgumentException iae = (IllegalArgumentException) e.getCause(); + + assertTrue("Expected: " + "The output-channel attribute must be specified" + " but got: " + iae.getMessage(), + "The output-channel attribute must be specified".equals(iae.getMessage())); + } + } + + private static class Writer implements ItemWriter { + @Override + public void write(List items) throws Exception { + // + } + } + + private static class Processor implements ItemProcessor { + @Override + public String process(String item) throws Exception { + return item; + } + } +} diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml new file mode 100644 index 000000000..75d3a0b3a --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingIdAttrTests.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml new file mode 100644 index 000000000..36fbe7786 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingMessageTemplateAttrTests.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml new file mode 100644 index 000000000..d55a354b7 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingReplyChannelAttrTests.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml new file mode 100644 index 000000000..f0fc3401a --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserMissingStepAttrTests.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserTests.xml new file mode 100644 index 000000000..fbaf64421 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingMasterParserTests.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml new file mode 100644 index 000000000..09173927f --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingIdAttrTests.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml new file mode 100644 index 000000000..29480b025 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingInputChannelAttrTests.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml new file mode 100644 index 000000000..cdb38ebff --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingItemWriterAttrTests.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml new file mode 100644 index 000000000..ce7889fe7 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserMissingOutputChannelAttrTests.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserNoProcessorTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserNoProcessorTests.xml new file mode 100644 index 000000000..234018ab5 --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserNoProcessorTests.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserTests.xml b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserTests.xml new file mode 100644 index 000000000..d1174f24b --- /dev/null +++ b/spring-batch-integration/src/test/resources/org/springframework/batch/integration/config/xml/RemoteChunkingSlaveParserTests.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + +