INT-1389 removed all dependencies on StringMessage from unit tests in spring-integration-xml
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -24,7 +24,6 @@ import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
@@ -72,7 +71,7 @@ public class XPathMultiChannelRouterTests {
|
||||
public void nonNodePayload() throws Exception {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
|
||||
XPathMultiChannelRouter router = new XPathMultiChannelRouter(expression);
|
||||
router.getChannelIndicatorList(new StringMessage("test"));
|
||||
router.getChannelIndicatorList(new GenericMessage<String>("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -19,14 +19,14 @@ package org.springframework.integration.xml.router;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
@@ -54,7 +54,7 @@ public class XPathSingleChannelRouterTests {
|
||||
public void testNonNodePayload() throws Exception {
|
||||
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
|
||||
XPathSingleChannelRouter router = new XPathSingleChannelRouter(expression);
|
||||
router.getChannelIndicatorList(new StringMessage("test"));
|
||||
router.getChannelIndicatorList(new GenericMessage<String>("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -13,65 +13,63 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.xml.selector;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jonas Partner
|
||||
*
|
||||
*/
|
||||
public class BooleanTestXpathMessageSelectorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithSimpleString(){
|
||||
public void testWithSimpleString() {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/one/two)");
|
||||
assertTrue(selector.accept(new StringMessage("<one><two/></one>")) ) ;
|
||||
assertFalse(selector.accept(new StringMessage("<one><three/></one>")) ) ;
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two/></one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><three/></one>")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithDocument() throws Exception{
|
||||
public void testWithDocument() throws Exception {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/one/two)");
|
||||
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<one><two/></one>"))) ) ;
|
||||
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<one><three/></one>"))) ) ;
|
||||
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<one><two/></one>"))));
|
||||
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil
|
||||
.getDocumentForString("<one><three/></one>"))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithNamespace(){
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/ns1:one/ns1:two)","ns1", "www.example.org");
|
||||
assertTrue(selector.accept(new StringMessage("<ns1:one xmlns:ns1='www.example.org'><ns1:two/></ns1:one>")) ) ;
|
||||
assertFalse(selector.accept(new StringMessage("<ns2:one xmlns:ns2='www.example2.org'><ns1:two xmlns:ns1='www.example.org' /></ns2:one>")) ) ;
|
||||
public void testWithNamespace() {
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector("boolean(/ns1:one/ns1:two)", "ns1", "www.example.org");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<ns1:one xmlns:ns1='www.example.org'><ns1:two/></ns1:one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<ns2:one xmlns:ns2='www.example2.org'><ns1:two xmlns:ns1='www.example.org' /></ns2:one>")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStringWithXPathExpressionProvided(){
|
||||
public void testStringWithXPathExpressionProvided() {
|
||||
XPathExpression xpathExpression = XPathExpressionFactory.createXPathExpression("boolean(/one/two)");
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(xpathExpression);
|
||||
assertTrue(selector.accept(new StringMessage("<one><two/></one>")) ) ;
|
||||
assertFalse(selector.accept(new StringMessage("<one><three/></one>")) ) ;
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two/></one>")));
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><three/></one>")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNodeWithXPathExpressionAsString() throws Exception{
|
||||
public void testNodeWithXPathExpressionAsString() throws Exception {
|
||||
XPathExpression xpathExpression = XPathExpressionFactory.createXPathExpression("boolean(./three)");
|
||||
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(xpathExpression);
|
||||
Document testDocument = XmlTestUtil.getDocumentForString("<one><two><three/></two></one>");
|
||||
|
||||
assertTrue(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("two").item(0))));
|
||||
assertFalse(selector.accept(new GenericMessage<Node>(testDocument.getElementsByTagName("three").item(0))));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -13,54 +13,50 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.xml.selector;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jonas Partner
|
||||
*
|
||||
*/
|
||||
public class StringValueTestXPathMessageSelectorTests {
|
||||
|
||||
@Test
|
||||
public void testMatchWithSimpleString() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two",
|
||||
"red");
|
||||
assertTrue(selector.accept(new StringMessage("<one><two>red</two></one>")));
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two", "red");
|
||||
assertTrue(selector.accept(new GenericMessage<String>("<one><two>red</two></one>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoMatchWithSimpleString() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two",
|
||||
"red");
|
||||
assertFalse(selector.accept(new StringMessage("<one><two>yellow</two></one>")));
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/one/two", "red");
|
||||
assertFalse(selector.accept(new GenericMessage<String>("<one><two>yellow</two></one>")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMatchWithSimpleStringAndNamespace() {
|
||||
StringValueTestXPathMessageSelector selector = new StringValueTestXPathMessageSelector("/ns1:one/ns1:two","ns1","www.example.org",
|
||||
"red");
|
||||
assertTrue(selector.accept(new StringMessage("<ns1:one xmlns:ns1='www.example.org'><ns1:two>red</ns1:two></ns1:one>")));
|
||||
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");
|
||||
assertFalse(selector.accept(new StringMessage("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
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 StringMessage("<ns1:one xmlns:ns1='www.example.org'><ns1:two>RED</ns1:two></ns1:one>")));
|
||||
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-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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 javax.xml.transform.dom.DOMResult;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.xml.result.StringResultFactory;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.oxm.XmlMappingException;
|
||||
@@ -45,7 +45,7 @@ public class MarshallingTransformerTests {
|
||||
TestMarshaller marshaller = new TestMarshaller();
|
||||
MarshallingTransformer transformer = new MarshallingTransformer(marshaller);
|
||||
transformer.setResultFactory(new StringResultFactory());
|
||||
Message<?> resultMessage = transformer.transform(new StringMessage("world"));
|
||||
Message<?> resultMessage = transformer.transform(new GenericMessage<String>("world"));
|
||||
Object resultPayload = resultMessage.getPayload();
|
||||
assertEquals(StringResult.class, resultPayload.getClass());
|
||||
assertEquals("hello world", resultPayload.toString());
|
||||
@@ -56,7 +56,7 @@ public class MarshallingTransformerTests {
|
||||
public void testDefaultResultFactory() throws Exception {
|
||||
TestMarshaller marshaller = new TestMarshaller();
|
||||
MarshallingTransformer transformer = new MarshallingTransformer(marshaller);
|
||||
Message<?> resultMessage = transformer.transform(new StringMessage("world"));
|
||||
Message<?> resultMessage = transformer.transform(new GenericMessage<String>("world"));
|
||||
Object resultPayload = resultMessage.getPayload();
|
||||
assertEquals(DOMResult.class, resultPayload.getClass());
|
||||
assertEquals("world", marshaller.payloads.get(0));
|
||||
@@ -67,7 +67,7 @@ public class MarshallingTransformerTests {
|
||||
TestMarshaller marshaller = new TestMarshaller();
|
||||
MarshallingTransformer transformer = new MarshallingTransformer(marshaller);
|
||||
transformer.setExtractPayload(false);
|
||||
Message<?> message = new StringMessage("test");
|
||||
Message<?> message = new GenericMessage<String>("test");
|
||||
transformer.transform(message);
|
||||
assertEquals(0, marshaller.payloads.size());
|
||||
assertEquals(1, marshaller.messages.size());
|
||||
@@ -81,12 +81,10 @@ public class MarshallingTransformerTests {
|
||||
|
||||
private final List<Object> payloads = new ArrayList<Object>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean supports(Class clazz) {
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void marshal(Object source, Result result) throws XmlMappingException, IOException {
|
||||
if (source instanceof Message) {
|
||||
this.messages.add((Message<?>) source);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -26,8 +26,8 @@ import javax.xml.transform.Source;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.GenericMessage;
|
||||
import org.springframework.integration.core.MessageBuilder;
|
||||
import org.springframework.integration.core.StringMessage;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.oxm.XmlMappingException;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
@@ -52,8 +52,8 @@ public class UnmarshallingTransformerTests {
|
||||
Unmarshaller unmarshaller = new TestUnmarshaller(true);
|
||||
UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
|
||||
Object transformed = transformer.transformPayload(new StringSource("foo"));
|
||||
assertEquals(StringMessage.class, transformed.getClass());
|
||||
assertEquals("message: foo", ((StringMessage) transformed).getPayload());
|
||||
assertEquals(GenericMessage.class, transformed.getClass());
|
||||
assertEquals("message: foo", ((Message<?>) transformed).getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,15 +79,14 @@ public class UnmarshallingTransformerTests {
|
||||
char[] chars = new char[8];
|
||||
((StringSource) source).getReader().read(chars);
|
||||
if (returnMessage) {
|
||||
return new StringMessage("message: " + new String(chars).trim());
|
||||
return new GenericMessage<String>("message: " + new String(chars).trim());
|
||||
}
|
||||
return "hello " + new String(chars).trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean supports(Class clazz) {
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user