checkstyle WhiteAround
WhiteAroundCheck script
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -92,31 +92,31 @@ public class DefaultXmlPayloadConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetSourcePassingDocument() throws Exception{
|
||||
public void testGetSourcePassingDocument() throws Exception {
|
||||
Source source = converter.convertToSource(testDocument);
|
||||
assertEquals(DOMSource.class, source.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSourcePassingString() throws Exception{
|
||||
public void testGetSourcePassingString() throws Exception {
|
||||
Source source = converter.convertToSource(testDocumentAsString);
|
||||
assertEquals(StringSource.class, source.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSourcePassingSource() throws Exception{
|
||||
public void testGetSourcePassingSource() throws Exception {
|
||||
SAXSource passedInSource = new SAXSource();
|
||||
Source source = converter.convertToSource(passedInSource);
|
||||
assertEquals(source, passedInSource);
|
||||
}
|
||||
|
||||
@Test(expected=MessagingException.class)
|
||||
public void testInvalidPayload(){
|
||||
@Test(expected = MessagingException.class)
|
||||
public void testInvalidPayload() {
|
||||
converter.convertToSource(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNodePassingDOMSource(){
|
||||
public void testGetNodePassingDOMSource() {
|
||||
Node element = testDocument.getElementsByTagName("test").item(0);
|
||||
Node n = converter.convertToNode(new DOMSource(element));
|
||||
assertTrue("Wrong node returned", element == n);
|
||||
@@ -133,7 +133,7 @@ public class DefaultXmlPayloadConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertSourceToDocument() throws Exception{
|
||||
public void testConvertSourceToDocument() throws Exception {
|
||||
Node element = testDocument.getElementsByTagName("test").item(0);
|
||||
DOMSource domSource = new DOMSource(element);
|
||||
Document doc = converter.convertToDocument(element);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MarshallingTransformerParserTests {
|
||||
input.send(message);
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof String);
|
||||
String resultPayload = (String)result.getPayload();
|
||||
String resultPayload = (String) result.getPayload();
|
||||
assertEquals("Wrong payload", "testReturn", resultPayload);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -23,7 +23,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
public class StubDocumentBuilderFactory extends DocumentBuilderFactory{
|
||||
public class StubDocumentBuilderFactory extends DocumentBuilderFactory {
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) throws IllegalArgumentException {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StubResultTransformer implements ResultTransformer {
|
||||
|
||||
Object toReturn;
|
||||
|
||||
public StubResultTransformer(Object toReturn){
|
||||
public StubResultTransformer(Object toReturn) {
|
||||
this.toReturn = toReturn;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext {
|
||||
|
||||
private final Resource[] resources;
|
||||
|
||||
public TestXmlApplicationContext(String ... xmlStrings){
|
||||
public TestXmlApplicationContext(String ... xmlStrings) {
|
||||
resources = new Resource[xmlStrings.length];
|
||||
for (int i = 0 ; i < xmlStrings.length; i++) {
|
||||
resources[i] = new TestResource(xmlStrings[i]);
|
||||
@@ -41,11 +41,11 @@ public class TestXmlApplicationContext extends AbstractXmlApplicationContext {
|
||||
return resources;
|
||||
}
|
||||
|
||||
private static class TestResource extends AbstractResource{
|
||||
private static class TestResource extends AbstractResource {
|
||||
|
||||
String xmlString;
|
||||
|
||||
TestResource(String xmlString){
|
||||
TestResource(String xmlString) {
|
||||
this.xmlString = xmlString;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,15 +32,15 @@ public class XPathExpressionParserTests {
|
||||
public void testSimpleStringExpression() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/name' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNamespacedStringExpression() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' ns-uri='www.example.org' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,8 +48,8 @@ public class XPathExpressionParserTests {
|
||||
StringBuffer xmlDoc = new StringBuffer("<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' namespace-map='myNamespaces' />");
|
||||
xmlDoc.append("<util:map id='myNamespaces'><entry key='ns1' value='www.example.org' /></util:map>");
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc.toString());
|
||||
assertEquals("outputOne",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,8 +60,8 @@ public class XPathExpressionParserTests {
|
||||
.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>")));
|
||||
assertEquals("",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,12 +85,12 @@ public class XPathExpressionParserTests {
|
||||
|
||||
}
|
||||
|
||||
@Test(expected=BeanDefinitionStoreException.class)
|
||||
@Test(expected = BeanDefinitionStoreException.class)
|
||||
public void testNamespacePrefixButNoUri() throws Exception {
|
||||
String xmlDoc = "<si-xml:xpath-expression id='xpathExpression' expression='/ns1:name' ns-prefix='ns1' />";
|
||||
XPathExpression xPathExpression = getXPathExpression(xmlDoc);
|
||||
assertEquals("outputOne",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("",xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
assertEquals("outputOne", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>")));
|
||||
assertEquals("", xPathExpression.evaluateAsString(XmlTestUtil.getDocumentForString("<name>outputOne</name>")));
|
||||
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class XPathExpressionParserTests {
|
||||
|
||||
}
|
||||
|
||||
public XPathExpression getXPathExpression(String contextXml){
|
||||
public XPathExpression getXPathExpression(String contextXml) {
|
||||
TestXmlApplicationContext ctx = TestXmlApplicationContextHelper.getTestAppContext(contextXml);
|
||||
return (XPathExpression) ctx.getBean("xpathExpression");
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class XPathRouterParserTests {
|
||||
|
||||
ConfigurableApplicationContext appContext;
|
||||
|
||||
public EventDrivenConsumer buildContext(String routerDef){
|
||||
public EventDrivenConsumer buildContext(String routerDef) {
|
||||
appContext = TestXmlApplicationContextHelper.getTestAppContext( channelConfig + routerDef);
|
||||
appContext.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.getBean("router");
|
||||
@@ -86,8 +86,8 @@ public class XPathRouterParserTests {
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown(){
|
||||
if(appContext != null){
|
||||
public void tearDown() {
|
||||
if (appContext != null) {
|
||||
appContext.close();
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class XPathRouterParserTests {
|
||||
Object defaultOutputChannelValue = accessor.getPropertyValue("defaultOutputChannel");
|
||||
assertEquals("Default output channel not correctly set ", defaultOutput, defaultOutputChannelValue);
|
||||
inputChannel.send(MessageBuilder.withPayload("<unrelated/>").build());
|
||||
assertEquals("Wrong count of messages on default output channel",1, defaultOutput.getQueueSize());
|
||||
assertEquals("Wrong count of messages on default output channel", 1, defaultOutput.getQueueSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -113,8 +113,8 @@ public class XPathRouterTests {
|
||||
XPathRouter router = new XPathRouter("./three/text()");
|
||||
Document testDocument = XmlTestUtil.getDocumentForString("<one><two><three>bob</three><three>dave</three></two></one>");
|
||||
Object[] channelNames = router.getChannelKeys(new GenericMessage<Node>(testDocument.getElementsByTagName("two").item(0))).toArray();
|
||||
assertEquals("bob",channelNames[0]);
|
||||
assertEquals("dave",channelNames[1]);
|
||||
assertEquals("bob", channelNames[0]);
|
||||
assertEquals("dave", channelNames[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -42,19 +42,19 @@ public class StringValueTestXPathMessageSelectorTests {
|
||||
|
||||
@Test
|
||||
public void testMatchWithSimpleStringAndNamespace() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two","ns1","www.example.org", "red");
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>red</ns1:two></ns1:one>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaseSensitiveByDefault() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two","ns1","www.example.org", "red");
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotCaseSensitive() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two","ns1","www.example.org", "red");
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two", "ns1", "www.example.org", "red");
|
||||
selector.setCaseSensitive(false);
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -33,19 +33,19 @@ import org.springframework.integration.xml.selector.XmlValidatingMessageSelector
|
||||
public class XmlValidatingMessageSelectorTests {
|
||||
|
||||
@Test
|
||||
public void validateCreationWithSchemaAndDefaultSchemaType() throws Exception{
|
||||
public void validateCreationWithSchemaAndDefaultSchemaType() throws Exception {
|
||||
Resource resource = new ByteArrayResource("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'/>".getBytes());
|
||||
new XmlValidatingMessageSelector(resource, (SchemaType) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateCreationWithSchemaAndProvidedSchemaType() throws Exception{
|
||||
public void validateCreationWithSchemaAndProvidedSchemaType() throws Exception {
|
||||
Resource resource = new ByteArrayResource("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'/>".getBytes());
|
||||
new XmlValidatingMessageSelector(resource, SchemaType.XML_SCHEMA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateFailureInvalidSchemaLanguage() throws Exception{
|
||||
public void validateFailureInvalidSchemaLanguage() throws Exception {
|
||||
ConfigurableApplicationContext context = null;
|
||||
try {
|
||||
context = new ClassPathXmlApplicationContext("XmlValidatingMessageSelectorTests-context.xml", this.getClass());
|
||||
@@ -54,14 +54,14 @@ public class XmlValidatingMessageSelectorTests {
|
||||
assertTrue(e.getMessage().contains("java.lang.IllegalArgumentException: No enum constant"));
|
||||
}
|
||||
finally {
|
||||
if(context != null) {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void validateFailureWhenNoSchemaResourceProvided() throws Exception{
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void validateFailureWhenNoSchemaResourceProvided() throws Exception {
|
||||
new XmlValidatingMessageSelector(null, (SchemaType) null);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,39 +33,39 @@ public class StringSourceTests {
|
||||
StringSourceFactory sourceFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception{
|
||||
public void setUp() throws Exception {
|
||||
sourceFactory = new StringSourceFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDocument() throws Exception{
|
||||
public void testWithDocument() throws Exception {
|
||||
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";
|
||||
Document doc = XmlTestUtil.getDocumentForString(docString);
|
||||
StringSource source = (StringSource)sourceFactory.createSource(doc);
|
||||
StringSource source = (StringSource) sourceFactory.createSource(doc);
|
||||
BufferedReader reader = new BufferedReader(source.getReader());
|
||||
String docAsString =reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource","<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
String docAsString = reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithString() throws Exception{
|
||||
public void testWithString() throws Exception {
|
||||
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";
|
||||
StringSource source = (StringSource)sourceFactory.createSource(docString);
|
||||
StringSource source = (StringSource) sourceFactory.createSource(docString);
|
||||
BufferedReader reader = new BufferedReader(source.getReader());
|
||||
String docAsString =reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource","<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
String docAsString = reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=MessagingException.class)
|
||||
public void testWithUnsupportedPayload() throws Exception{
|
||||
@Test(expected = MessagingException.class)
|
||||
public void testWithUnsupportedPayload() throws Exception {
|
||||
String docString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>";
|
||||
StringBuffer buffer = new StringBuffer(docString);
|
||||
StringSource source = (StringSource)sourceFactory.createSource(buffer);
|
||||
StringSource source = (StringSource) sourceFactory.createSource(buffer);
|
||||
BufferedReader reader = new BufferedReader(source.getReader());
|
||||
String docAsString =reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource","<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
String docAsString = reader.readLine();
|
||||
assertXMLEqual("Wrong content in StringSource", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><item>one</item>", docAsString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -45,7 +45,7 @@ public class XPathMessageSplitterTests {
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp(){
|
||||
public void setUp() {
|
||||
String splittingXPath = "/orders/order";
|
||||
splitter = new XPathMessageSplitter(splittingXPath);
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
@@ -80,8 +80,8 @@ public class XPathMessageSplitterTests {
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
for (Message<?> message : docMessages) {
|
||||
assertTrue("unexpected payload type" + message.getPayload().getClass().getName(), message.getPayload() instanceof Document);
|
||||
Document docPayload = (Document)message.getPayload();
|
||||
assertEquals("Wrong root element name" ,"order", docPayload.getDocumentElement().getLocalName());
|
||||
Document docPayload = (Document) message.getPayload();
|
||||
assertEquals("Wrong root element name" , "order", docPayload.getDocumentElement().getLocalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -64,7 +64,7 @@ public class ResultToStringTransformerTests {
|
||||
String formattedDoc = "<order><orderItem>test</orderItem></order>";
|
||||
DOMResult domResult = XmlTestUtil.getDomResultForString(doc);
|
||||
Properties outputProperties = new Properties();
|
||||
outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
|
||||
outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
transformer.setOutputProperties(outputProperties);
|
||||
Object transformed = transformer.transformResult(domResult);
|
||||
assertTrue("Wrong transformed type expected String", transformed instanceof String);
|
||||
|
||||
@@ -128,8 +128,8 @@ public class XsltTransformerTests {
|
||||
input.send(message);
|
||||
Message<?> resultMessage = output.receive();
|
||||
assertEquals("Wrong payload type", String.class, resultMessage.getPayload().getClass());
|
||||
String stringPayload = (String)resultMessage.getPayload();
|
||||
assertEquals("Wrong content of payload", "hello world text",stringPayload.trim());
|
||||
String stringPayload = (String) resultMessage.getPayload();
|
||||
assertEquals("Wrong content of payload", "hello world text", stringPayload.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -20,10 +20,10 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
@XmlType @XmlRootElement(name="person")
|
||||
@XmlType @XmlRootElement(name = "person")
|
||||
public class JaxbAnnotatedPerson {
|
||||
|
||||
@XmlElement(name="firstname")
|
||||
@XmlElement(name = "firstname")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -57,27 +57,27 @@ public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContext
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testMarshalling() throws Exception{
|
||||
public void testMarshalling() throws Exception {
|
||||
JaxbAnnotatedPerson person = new JaxbAnnotatedPerson();
|
||||
person.setFirstName("john");
|
||||
marshallIn.send(new GenericMessage<Object>(person));
|
||||
GenericMessage<Result> res = (GenericMessage<Result>) marshalledOut.receive(2000);
|
||||
assertNotNull("No response recevied" ,res);
|
||||
assertNotNull("No response recevied" , res);
|
||||
assertTrue("payload was not a DOMResult" , res.getPayload() instanceof DOMResult);
|
||||
Document doc = (Document)((DOMResult)res.getPayload()).getNode();
|
||||
assertEquals("Wrong name for root element ", "person",doc.getDocumentElement().getLocalName());
|
||||
Document doc = (Document) ((DOMResult) res.getPayload()).getNode();
|
||||
assertEquals("Wrong name for root element ", "person", doc.getDocumentElement().getLocalName());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testUnmarshalling() throws Exception{
|
||||
public void testUnmarshalling() throws Exception {
|
||||
StringSource source = new StringSource("<person><firstname>bob</firstname></person>");
|
||||
unmarshallIn.send(new GenericMessage<Source>(source));
|
||||
GenericMessage<Object> res = (GenericMessage<Object>) unmarshallOut.receive(2000);
|
||||
assertNotNull("No response", res);
|
||||
assertTrue("Not a Person ", res.getPayload() instanceof JaxbAnnotatedPerson);
|
||||
JaxbAnnotatedPerson person = (JaxbAnnotatedPerson)res.getPayload();
|
||||
JaxbAnnotatedPerson person = (JaxbAnnotatedPerson) res.getPayload();
|
||||
assertEquals("Worng firstname", "bob", person.getFirstName());
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class XmlTestUtil {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String docToString(Document doc) throws Exception{
|
||||
public static String docToString(Document doc) throws Exception {
|
||||
DOMSource source = new DOMSource(doc);
|
||||
StringResult stringResult = new StringResult();
|
||||
transform(source, stringResult);
|
||||
|
||||
Reference in New Issue
Block a user