Mainly Checkstyle Violation Fixes
* Upgrade to Checkstyle `7.1` * Relax `RequireThis` rule a bit. Right now it does the effort only in case of overlapping. See https://github.com/checkstyle/checkstyle/issues/2362 for more info * Enable some annotation rules and provide fixes for violations * Enable `tabs indents` rule. This was the biggest fix in this PR * Resolve `TODO` in the `MessagingMethodInvokerHelper` and fix tests to meet `IllegalStateException` now Remain Checkstyle version `6.16.1` and reinstate `RequireThis` rule The latest Checkstyle has a bug with local scope variables if they have the same names as property. Revert some literals splitting Fix some line length exceeding and code style
This commit is contained in:
committed by
Gary Russell
parent
22b7187784
commit
12fb590b95
@@ -120,12 +120,12 @@ public class DefaultXmlPayloadConverterTests {
|
||||
converter.convertToSource(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNodePassingDOMSource() {
|
||||
Node element = testDocument.getElementsByTagName("test").item(0);
|
||||
@Test
|
||||
public void testGetNodePassingDOMSource() {
|
||||
Node element = testDocument.getElementsByTagName("test").item(0);
|
||||
Node n = converter.convertToNode(new DOMSource(element));
|
||||
assertTrue("Wrong node returned", element == n);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertNodeToDocument() {
|
||||
|
||||
@@ -43,8 +43,8 @@ public class TestXmlApplicationContextHelper {
|
||||
+ "http://www.springframework.org/schema/integration/xml "
|
||||
+ "http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd "
|
||||
+ "http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd " +
|
||||
"http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd' >" +
|
||||
"<context:annotation-config/>";
|
||||
"http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd' >" +
|
||||
"<context:annotation-config/>";
|
||||
|
||||
private final static String footer = "</beans>";
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
public class XPathExpressionParserTests {
|
||||
|
||||
@@ -56,8 +57,8 @@ public class XPathExpressionParserTests {
|
||||
public void testStringExpressionWithNamespaceInnerBean() throws Exception {
|
||||
|
||||
StringBuilder xmlDoc = new StringBuilder("<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name'>")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc.toString());
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
@@ -68,10 +69,10 @@ public class XPathExpressionParserTests {
|
||||
public void testStringExpressionWithMultipleNamespaceInnerBean() throws Exception {
|
||||
|
||||
StringBuilder xmlDoc = new StringBuilder(
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' >")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append(" <map><entry key='ns2' value='www.example2.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' >")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append(" <map><entry key='ns2' value='www.example2.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
|
||||
try {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
@@ -114,9 +115,9 @@ public class XPathExpressionParserTests {
|
||||
@Test
|
||||
public void testNamespacedStringExpressionWithNamespaceInnerBean() throws Exception {
|
||||
StringBuilder xmlDoc = new StringBuilder(
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' ns-uri='www.example.org'>")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' ns-uri='www.example.org'>")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>");
|
||||
try {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
@@ -132,10 +133,10 @@ public class XPathExpressionParserTests {
|
||||
@Test
|
||||
public void testStringExpressionWithNamespaceInnerBeanAndWithNamespaceMapReference() throws Exception {
|
||||
StringBuilder xmlDoc = new StringBuilder(
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' namespace-map='myNamespaces'>")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>")
|
||||
.append("<util:map id='myNamespaces'><entry key='ns1' value='www.example.org' /></util:map>");
|
||||
"<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' namespace-map='myNamespaces'>")
|
||||
.append(" <map><entry key='ns1' value='www.example.org' /></map>")
|
||||
.append("</si-xml:xpath-expression>")
|
||||
.append("<util:map id='myNamespaces'><entry key='ns1' value='www.example.org' /></util:map>");
|
||||
try {
|
||||
getXPathExpression(xmlDoc.toString());
|
||||
}
|
||||
@@ -154,6 +155,4 @@ public class XPathExpressionParserTests {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ public class XPathMessageSplitterParserTests {
|
||||
public void testXPathExpressionRef() throws Exception {
|
||||
TestXmlApplicationContext ctx = TestXmlApplicationContextHelper
|
||||
.getTestAppContext(
|
||||
channelDefinitions +
|
||||
"<si-xml:xpath-expression id='xpathOne' expression='//name'/>" +
|
||||
"<si-xml:xpath-splitter id='splitter' xpath-expression-ref='xpathOne' input-channel='test-input' output-channel='test-output' />");
|
||||
channelDefinitions +
|
||||
"<si-xml:xpath-expression id='xpathOne' expression='//name'/>" +
|
||||
"<si-xml:xpath-splitter id='splitter' xpath-expression-ref='xpathOne' input-channel='test-input' output-channel='test-output' />");
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) ctx.getBean("splitter");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(consumer);
|
||||
Object handler = fieldAccessor.getPropertyValue("handler");
|
||||
|
||||
@@ -51,7 +51,7 @@ public class XmlValidatingMessageSelectorTests {
|
||||
context = new ClassPathXmlApplicationContext("XmlValidatingMessageSelectorTests-context.xml", this.getClass());
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("java.lang.IllegalArgumentException: No enum constant"));
|
||||
assertTrue(e.getMessage().contains("java.lang.IllegalArgumentException: No enum constant"));
|
||||
}
|
||||
finally {
|
||||
if (context != null) {
|
||||
|
||||
@@ -17,43 +17,44 @@
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
|
||||
import org.springframework.integration.xml.result.ResultFactory;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.springframework.integration.xml.result.ResultFactory;
|
||||
|
||||
public class CustomTestResultFactory implements ResultFactory {
|
||||
|
||||
private final String stringToReturn;
|
||||
private final String stringToReturn;
|
||||
|
||||
|
||||
public CustomTestResultFactory(String stringToReturn) {
|
||||
this.stringToReturn = stringToReturn;
|
||||
}
|
||||
public CustomTestResultFactory(String stringToReturn) {
|
||||
this.stringToReturn = stringToReturn;
|
||||
}
|
||||
|
||||
public Result createResult(Object payload) {
|
||||
return new FixedStringResult(this.stringToReturn); //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
public Result createResult(Object payload) {
|
||||
return new FixedStringResult(this.stringToReturn); //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public static class FixedStringResult extends StreamResult {
|
||||
public static class FixedStringResult extends StreamResult {
|
||||
|
||||
|
||||
private final String stringToReturn;
|
||||
private final String stringToReturn;
|
||||
|
||||
public FixedStringResult(String stringToReturn) {
|
||||
super(new StringWriter());
|
||||
this.stringToReturn = stringToReturn;
|
||||
}
|
||||
public FixedStringResult(String stringToReturn) {
|
||||
super(new StringWriter());
|
||||
this.stringToReturn = stringToReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the written XML as a string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.stringToReturn;
|
||||
}
|
||||
/**
|
||||
* Returns the written XML as a string.
|
||||
*/
|
||||
public String toString() {
|
||||
return this.stringToReturn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user