use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class StoredProcedureProducerTest method resolveXPath.
private String resolveXPath(AdaptrisMessage message, String xpath) throws XPathExpressionException, IOException {
XmlUtils xmlUtility = new XmlUtils();
xmlUtility.setSource(message.getInputStream());
String textItem = new XPath().selectSingleTextItem(xmlUtility.getCurrentDoc(), xpath);
if (isEmpty(textItem)) {
return null;
} else {
return textItem;
}
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlNotificationSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
String myName = testName.getMethodName();
Notification n = new Notification(myName, myName, 1, myName);
n.setUserData(new Object());
XmlNotificationSerializer serializer = new XmlNotificationSerializer();
AdaptrisMessage msg = serializer.serialize(n, AdaptrisMessageFactory.getDefaultInstance().newMessage());
XmlUtils utils = XmlHelper.createXmlUtils(msg, null, null);
assertNotNull(msg.getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
assertEquals(myName, utils.getSingleTextItem("/Notification/Message"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Type"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Source"));
assertEquals("1", utils.getSingleTextItem("/Notification/SequenceNumber"));
assertNotNull(utils.getSingleTextItem("/Notification/Timestamp"));
assertEquals("UTF-8", msg.getContentEncoding());
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlNotificationSerializerTest method testSerialize_NoUserData.
@Test
public void testSerialize_NoUserData() throws Exception {
String myName = testName.getMethodName();
Notification n = new Notification(myName, myName, 1, myName);
XmlNotificationSerializer serializer = new XmlNotificationSerializer();
AdaptrisMessage msg = serializer.serialize(n, AdaptrisMessageFactory.getDefaultInstance().newMessage());
XmlUtils utils = XmlHelper.createXmlUtils(msg, null, null);
assertNull(msg.getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
assertEquals(myName, utils.getSingleTextItem("/Notification/Message"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Type"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Source"));
assertEquals("1", utils.getSingleTextItem("/Notification/SequenceNumber"));
assertNotNull(utils.getSingleTextItem("/Notification/Timestamp"));
assertEquals("UTF-8", msg.getContentEncoding());
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlNotificationSerializerTest method testSerialize_WithContentEncoding.
@Test
public void testSerialize_WithContentEncoding() throws Exception {
String myName = testName.getMethodName();
Notification n = new Notification(myName, myName, 1, myName);
n.setUserData(new Object());
XmlNotificationSerializer serializer = new XmlNotificationSerializer();
serializer.setOutputMessageEncoding("ISO-8859-1");
AdaptrisMessage msg = serializer.serialize(n, AdaptrisMessageFactory.getDefaultInstance().newMessage());
XmlUtils utils = XmlHelper.createXmlUtils(msg, null, null);
assertNotNull(msg.getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
assertEquals(myName, utils.getSingleTextItem("/Notification/Message"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Type"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Source"));
assertEquals("1", utils.getSingleTextItem("/Notification/SequenceNumber"));
assertNotNull(utils.getSingleTextItem("/Notification/Timestamp"));
assertEquals("ISO-8859-1", msg.getContentEncoding());
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlNotificationSerializerTest method testSerialize_WithContentEncoding_FromMessage.
@Test
public void testSerialize_WithContentEncoding_FromMessage() throws Exception {
String myName = testName.getMethodName();
Notification n = new Notification(myName, myName, 1, myName);
n.setUserData(new Object());
XmlNotificationSerializer serializer = new XmlNotificationSerializer();
AdaptrisMessageFactory factory = new DefaultMessageFactory();
factory.setDefaultCharEncoding("ISO-8859-1");
AdaptrisMessage msg = serializer.serialize(n, factory.newMessage());
XmlUtils utils = XmlHelper.createXmlUtils(msg, null, null);
assertNotNull(msg.getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
assertEquals(myName, utils.getSingleTextItem("/Notification/Message"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Type"));
assertEquals(myName, utils.getSingleTextItem("/Notification/Source"));
assertEquals("1", utils.getSingleTextItem("/Notification/SequenceNumber"));
assertNotNull(utils.getSingleTextItem("/Notification/Timestamp"));
assertEquals("ISO-8859-1", msg.getContentEncoding());
}
Aggregations