Unable ImportOrder Checkstyle rule for tests
* Fix wrong import order in tests * Polishing for not closed application contexts * Use diamonds * Use proper assertion operators * Remove redundant classes * Improve performance in JPA tests * Fix typos
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
@@ -37,15 +37,16 @@ import org.springframework.core.io.InputStreamResource;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
public class ChainElementsTests {
|
||||
|
||||
@Test
|
||||
public void chainOutboundGateway() throws Exception {
|
||||
|
||||
try {
|
||||
this.bootStrap("file-oubound-gateway");
|
||||
try {
|
||||
bootStrap("file-outbound-gateway");
|
||||
fail("Expected a BeanDefinitionParsingException to be thrown.");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
@@ -57,30 +58,30 @@ public class ChainElementsTests {
|
||||
assertTrue("Error message did not start with '" + expectedMessage +
|
||||
"' but instead returned: '" + actualMessage + "'", actualMessage.startsWith(expectedMessage));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chainOutboundGatewayWithInputChannel() throws Exception {
|
||||
|
||||
try {
|
||||
this.bootStrap("file-oubound-gateway-input-channel");
|
||||
try {
|
||||
bootStrap("file-outbound-gateway-input-channel");
|
||||
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-file:outbound-gateway'.", e.getCause().getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ApplicationContext bootStrap(String configProperty) throws Exception {
|
||||
private ConfigurableApplicationContext bootStrap(String configProperty) throws Exception {
|
||||
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
|
||||
pfb.setLocation(new ClassPathResource("org/springframework/integration/file/config/chain-elements-config.properties"));
|
||||
pfb.setLocation(new ClassPathResource(
|
||||
"org/springframework/integration/file/config/chain-elements-config.properties"));
|
||||
pfb.afterPropertiesSet();
|
||||
Properties prop = pfb.getObject();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(prop.getProperty("xmlheaders")).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();
|
||||
|
||||
@@ -9,9 +9,9 @@ xmlheaders=\
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
xmlfooter= </beans>
|
||||
|
||||
file-oubound-gateway=<int:chain input-channel="fileOutboundGatewayInsideChain" output-channel="nullChannel">\
|
||||
file-outbound-gateway=<int:chain input-channel="fileOutboundGatewayInsideChain" output-channel="nullChannel">\
|
||||
<int-file:outbound-gateway id="myFileOutboundGateway" request-channel="request" directory="${java.io.tmpdir}/anyDir" delete-source-files="true"/>\
|
||||
</int:chain>
|
||||
file-oubound-gateway-input-channel=<int:chain input-channel="fileOutboundGatewayInsideChain" output-channel="nullChannel">\
|
||||
file-outbound-gateway-input-channel=<int:chain input-channel="fileOutboundGatewayInsideChain" output-channel="nullChannel">\
|
||||
<int-file:outbound-gateway id="myFileOutboundGateway" input-channel="request" directory="${java.io.tmpdir}/anyDir" delete-source-files="true"/>\
|
||||
</int:chain>
|
||||
|
||||
Reference in New Issue
Block a user