diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java
index 673f34f08f..5ad8773131 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java
@@ -1,6 +1,6 @@
package org.springframework.integration.config.xml;
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2012 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.
@@ -15,10 +15,11 @@ package org.springframework.integration.config.xml;
* limitations under the License.
*/
-
import java.io.ByteArrayInputStream;
import java.util.Properties;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -31,83 +32,189 @@ import org.springframework.core.io.InputStreamResource;
/**
* @author Oleg Zhurakousky
+ * @author Gunnar Hillert
*
*/
public class ChainElementsFailureTests {
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
+
+ @Test
public void chainServiceActivator() throws Exception {
- this.bootStrap("service-activator");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainAggregator() throws Exception {
- this.bootStrap("aggregator");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainChain() throws Exception {
- this.bootStrap("chain");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainDelayer() throws Exception {
- this.bootStrap("delayer");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainFilter() throws Exception {
- this.bootStrap("filter");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainGateway() throws Exception {
- this.bootStrap("gateway");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainHeaderEnricher() throws Exception {
- this.bootStrap("header-enricher");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainHeaderFilter() throws Exception {
- this.bootStrap("header-filter");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainHeaderValueRouter() throws Exception {
- this.bootStrap("header-value-router");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainTransformer() throws Exception {
- this.bootStrap("transformer");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainRouter() throws Exception {
- this.bootStrap("router");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainSplitter() throws Exception {
- this.bootStrap("splitter");
- }
-
- @Test(expected=XmlBeanDefinitionStoreException.class)
- public void chainResequencer() throws Exception {
- this.bootStrap("resequencer");
+
+ try {
+ this.bootStrap("service-activator");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:service-activator'.", e.getCause().getMessage());
+ }
+
+ }
+
+ @Test
+ public void chainAggregator() throws Exception {
+
+ try {
+ this.bootStrap("aggregator");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:aggregator'.", e.getCause().getMessage());
+ }
+
+ }
+
+ @Test
+ public void chainChain() throws Exception {
+
+ try {
+ this.bootStrap("chain");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:chain'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainDelayer() throws Exception {
+
+ try {
+ this.bootStrap("delayer");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:delayer'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainFilter() throws Exception {
+
+ try {
+ this.bootStrap("filter");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:filter'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainGateway() throws Exception {
+
+ try {
+ this.bootStrap("gateway");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:gateway'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainHeaderEnricher() throws Exception {
+
+ try {
+ this.bootStrap("header-enricher");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:header-enricher'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainHeaderFilter() throws Exception {
+
+ try {
+ this.bootStrap("header-filter");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:header-filter'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainHeaderValueRouter() throws Exception {
+
+ try {
+ this.bootStrap("header-value-router");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:header-value-router'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainTransformer() throws Exception {
+
+ try {
+ this.bootStrap("transformer");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:transformer'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainRouter() throws Exception {
+
+ try {
+ this.bootStrap("router");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:router'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainSplitter() throws Exception {
+
+ try {
+ this.bootStrap("splitter");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:splitter'.", e.getCause().getMessage());
+ }
+ }
+
+ @Test
+ public void chainResequencer() throws Exception {
+
+ try {
+ this.bootStrap("resequencer");
+ fail("Expected a XmlBeanDefinitionStoreException to be thrown.");
+ }
+ catch (XmlBeanDefinitionStoreException e) {
+ assertEquals("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" +
+ " allowed to appear in element 'int:resequencer'.", e.getCause().getMessage());
+ }
}
-
private ApplicationContext bootStrap(String configProperty) throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setLocation(new ClassPathResource("org/springframework/integration/config/xml/chain-elements-config.properties"));
pfb.afterPropertiesSet();
Properties prop = pfb.getObject();
StringBuffer buffer = new StringBuffer();
- buffer.append(prop.getProperty("xmlheader")).append(prop.getProperty(configProperty)).append(prop.getProperty("xmlfooter"));
+ buffer.append(prop.getProperty("xmlheaders")).append(prop.getProperty(configProperty)).append(prop.getProperty("xmlfooter"));
ByteArrayInputStream stream = new ByteArrayInputStream(buffer.toString().getBytes());
GenericApplicationContext ac = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac);
@@ -116,7 +223,7 @@ public class ChainElementsFailureTests {
ac.refresh();
return ac;
}
-
+
public static class Sampleservice {
public String echo(String value){
return value;
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/chain-elements-config.properties b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/chain-elements-config.properties
index 7b134ea8c2..6ba79a0767 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/chain-elements-config.properties
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/chain-elements-config.properties
@@ -3,8 +3,8 @@ xmlheaders=\
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd \
+ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
xmlfooter=
service-activator=\
@@ -12,36 +12,36 @@ service-activator=\
\
\
\
-
-
+
+
aggregator=\
\
\
-
-
+
+
chain=\
\
\
\
\
-
-
+
+
delayer=\
\
\
-
-
+
+
filter=\
\
\
-
-
+
+
gateway=\
\
\
-
-
-header-enricher=\
+
+
+header-enricher=\
\
\
@@ -50,7 +50,7 @@ header-filter=\
\
\
-
+
header-value-router=\
\
\
@@ -60,17 +60,17 @@ transformer=\
\
\
-
+
router=\
\
\
-
+
splitter=\
\
\
-
+
resequencer=\
\
\