fixed typos and formatting
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -18,7 +34,10 @@ import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
|
||||
public class DefaultTransformerConfiguerTests {
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
public class DefaultTransformerConfigurerTests {
|
||||
|
||||
StubTransformer transformer;
|
||||
|
||||
@@ -30,18 +49,16 @@ public class DefaultTransformerConfiguerTests {
|
||||
this.transformerConfigurer = new DefaultTransformerConfigurer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSettingParametersAndOutputProperties(){
|
||||
Message<String> testMessage = MessageBuilder.withPayload("test")
|
||||
.setHeader("xslt_parameter_headerOne",1)
|
||||
.setHeader("xslt_parameter_headerTwo", "string")
|
||||
.setHeader("xslt_output_property_outOne","1")
|
||||
.setHeader("xslt_output_property_outTwo","2")
|
||||
.build();
|
||||
transformerConfigurer.configureTransfomer(testMessage, transformer);
|
||||
|
||||
.setHeader("xslt_parameter_headerOne",1)
|
||||
.setHeader("xslt_parameter_headerTwo", "string")
|
||||
.setHeader("xslt_output_property_outOne","1")
|
||||
.setHeader("xslt_output_property_outTwo","2")
|
||||
.build();
|
||||
transformerConfigurer.configureTransformer(testMessage, transformer);
|
||||
|
||||
Object paramOne = transformer.getParameter("headerOne");
|
||||
assertEquals("Wrong value for headerOne parameter",1, paramOne);
|
||||
|
||||
@@ -53,97 +70,78 @@ public class DefaultTransformerConfiguerTests {
|
||||
|
||||
String outPropertyTwo = transformer.getOutputProperty("outTwo");
|
||||
assertEquals("Wrong value for headerTwo parameter","2", outPropertyTwo);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNonStringOutputPropertyHeader(){
|
||||
public void testNonStringOutputPropertyHeader() {
|
||||
Message<String> testMessage = MessageBuilder.withPayload("test")
|
||||
.setHeader("xslt_output_property_outOne",12)
|
||||
.build();
|
||||
transformerConfigurer.configureTransfomer(testMessage, transformer);
|
||||
.setHeader("xslt_output_property_outOne",12)
|
||||
.build();
|
||||
transformerConfigurer.configureTransformer(testMessage, transformer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class StubTransformer extends Transformer{
|
||||
|
||||
Map<String,Object> paramterMap = new HashMap<String, Object>();
|
||||
Map<String,Object> parameterMap = new HashMap<String, Object>();
|
||||
|
||||
Map<String, String> outputProperties = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public void clearParameters() {
|
||||
paramterMap.clear();
|
||||
|
||||
parameterMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorListener getErrorListener() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getOutputProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputProperty(String name)
|
||||
throws IllegalArgumentException {
|
||||
public String getOutputProperty(String name) throws IllegalArgumentException {
|
||||
return outputProperties.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParameter(String name) {
|
||||
return paramterMap.get(name);
|
||||
return parameterMap.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URIResolver getURIResolver() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorListener(ErrorListener listener)
|
||||
throws IllegalArgumentException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void setErrorListener(ErrorListener listener) throws IllegalArgumentException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputProperties(Properties oformat) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputProperty(String name, String value)
|
||||
throws IllegalArgumentException {
|
||||
public void setOutputProperty(String name, String value) throws IllegalArgumentException {
|
||||
outputProperties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(String name, Object value) {
|
||||
paramterMap.put(name, value);
|
||||
parameterMap.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setURIResolver(URIResolver resolver) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(Source xmlSource, Result outputTarget)
|
||||
throws TransformerException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void transform(Source xmlSource, Result outputTarget) throws TransformerException {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
@@ -29,16 +29,21 @@ import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.xml.util.XmlTestUtil;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
|
||||
public class ResultToStringTransfomerTests {
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
public class ResultToStringTransformerTests {
|
||||
|
||||
ResultToStringTransformer transformer;
|
||||
private ResultToStringTransformer transformer;
|
||||
|
||||
private String doc = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>";
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp(){
|
||||
public void setUp() {
|
||||
transformer = new ResultToStringTransformer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDomResult() throws Exception {
|
||||
DOMResult result = XmlTestUtil.getDomResultForString(doc);
|
||||
Reference in New Issue
Block a user