use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testObtainUrlWithEmptyMetadataValueInMessage.
@Test
public void testObtainUrlWithEmptyMetadataValueInMessage() throws Exception {
XmlTransformService service = new XmlTransformService();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("key", "");
try {
service.setUrl("url");
service.setMetadataKey("key");
LifecycleHelper.init(service);
assertTrue(service.obtainUrlToUse(msg).equals("url"));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testObtainUrlWithNoMetadataValue.
@Test
public void testObtainUrlWithNoMetadataValue() throws Exception {
XmlTransformService service = new XmlTransformService();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
try {
service.setUrl("url");
service.setMetadataKey("key");
service.setAllowOverride(true);
LifecycleHelper.init(service);
assertTrue(service.obtainUrlToUse(msg).equals("url"));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testIssue2641_NoOutputMessageEncoding.
@Test
public void testIssue2641_NoOutputMessageEncoding() throws Exception {
DefaultMessageFactory factory = new DefaultMessageFactory();
factory.setDefaultCharEncoding("ISO-8859-1");
AdaptrisMessage msg = MessageHelper.createMessage(factory, PROPERTIES.getProperty(KEY_ISSUE2641_INPUT));
Document srcXml = createDocument(msg.getPayload());
XPath srcXpath = new XPath();
String srcValue = srcXpath.selectSingleTextItem(srcXml, ISSUE2641_SRC_XPATH);
assertEquals("ISO-8859-1", msg.getContentEncoding());
XmlTransformService service = new XmlTransformService();
service.setUrl(PROPERTIES.getProperty(KEY_ISSUE2641_TRANSFORM_URL));
execute(service, msg);
assertEquals("ISO-8859-1", msg.getContentEncoding());
// We're using UTF-8 as the encoding; get bytes will give us the right thing.
Document destXml = createDocument(msg.getPayload());
XPath destXpath = new XPath();
String destValue = destXpath.selectSingleTextItem(destXml, ISSUE2641_DEST_XPATH);
log.debug("testIssue2641:: srcValue = [" + srcValue + "]");
log.debug("testIssue2641:: destValue = [" + destValue + "]");
// All things being equal, they should be the same.
assertEquals(srcValue, destValue);
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testObtainUrlWithNullMetadataValueInMessage.
@Test
public void testObtainUrlWithNullMetadataValueInMessage() throws Exception {
XmlTransformService service = new XmlTransformService();
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
try {
service.setUrl("url");
service.setMetadataKey("key");
LifecycleHelper.init(service);
assertTrue(service.obtainUrlToUse(msg).equals("url"));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testIssue2641.
@Test
public void testIssue2641() throws Exception {
DefaultMessageFactory factory = new DefaultMessageFactory();
factory.setDefaultCharEncoding("ISO-8859-1");
AdaptrisMessage msg = MessageHelper.createMessage(factory, PROPERTIES.getProperty(KEY_ISSUE2641_INPUT));
Document srcXml = createDocument(msg.getPayload());
XPath srcXpath = new XPath();
String srcValue = srcXpath.selectSingleTextItem(srcXml, ISSUE2641_SRC_XPATH);
assertEquals("ISO-8859-1", msg.getContentEncoding());
XmlTransformService service = new XmlTransformService();
service.setUrl(PROPERTIES.getProperty(KEY_ISSUE2641_TRANSFORM_URL));
service.setOutputMessageEncoding("UTF-8");
execute(service, msg);
assertEquals("UTF-8", msg.getContentEncoding());
Document destXml = createDocument(msg.getPayload());
XPath destXpath = new XPath();
String destValue = destXpath.selectSingleTextItem(destXml, ISSUE2641_DEST_XPATH);
log.debug("testIssue2641:: srcValue = [" + srcValue + "]");
log.debug("testIssue2641:: destValue = [" + destValue + "]");
// All things being equal, they should be the same.
assertEquals(srcValue, destValue);
}
Aggregations