Merge pull request #575 from ghillert/INT-2392

* INT-2392:
  INT-2392 - ChainElementsFailureTests reads wrong 'xmlheader' property For reference: https://jira.springsource.org/browse/INT-2392
This commit is contained in:
Oleg Zhurakousky
2012-08-10 07:48:57 -04:00
2 changed files with 194 additions and 87 deletions

View File

@@ -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;

View File

@@ -3,8 +3,8 @@ xmlheaders=\
<beans xmlns="http://www.springframework.org/schema/beans" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xmlns:int="http://www.springframework.org/schema/integration" \
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd \
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
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= </beans>
service-activator=\
@@ -12,36 +12,36 @@ service-activator=\
<int:service-activator input-channel="fail"> \
<bean class="org.springframework.integration.config.xml.ChainElementsFailureTests$Sampleservice"/> \
</int:service-activator> \
</int:chain>
</int:chain>
aggregator=\
<int:chain input-channel="input"> \
<int:aggregator input-channel="fail"/> \
</int:chain>
</int:chain>
chain=\
<int:chain input-channel="input"> \
<int:chain input-channel="fail"> \
<int:aggregator/> \
</int:chain> \
</int:chain>
</int:chain>
delayer=\
<int:chain input-channel="input"> \
<int:delayer default-delay="1000" input-channel="fail"/> \
</int:chain>
</int:chain>
filter=\
<int:chain input-channel="input"> \
<int:filter input-channel="fail"/> \
</int:chain>
</int:chain>
gateway=\
<int:chain input-channel="input"> \
<int:gateway input-channel="fail"/> \
</int:chain>
header-enricher=\
</int:chain>
header-enricher=\
<int:chain input-channel="input"> \
<int:header-enricher input-channel="fail"/> \
</int:chain>
@@ -50,7 +50,7 @@ header-filter=\
<int:chain input-channel="input"> \
<int:header-filter input-channel="fail"/> \
</int:chain>
header-value-router=\
<int:chain input-channel="input"> \
<int:header-value-router input-channel="fail"/> \
@@ -60,17 +60,17 @@ transformer=\
<int:chain input-channel="input"> \
<int:transformer input-channel="fail"/> \
</int:chain>
router=\
<int:chain input-channel="input"> \
<int:router input-channel="fail"/> \
</int:chain>
splitter=\
<int:chain input-channel="input"> \
<int:splitter input-channel="fail"/> \
</int:chain>
resequencer=\
<int:chain input-channel="input"> \
<int:resequencer input-channel="fail"/> \