use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class MergeResultSetIntoPayloadTest method testXpathStatementParamWithLowerCase.
@Test
public void testXpathStatementParamWithLowerCase() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createXmlService();
MergeResultSetIntoXmlPayload t = new MergeResultSetIntoXmlPayload(new InsertNode("/root"));
t.setColumnNameStyle(ResultSetTranslatorImp.ColumnStyle.LowerCase);
s.setResultSetTranslator(t);
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(ADAPTER_ID_KEY + " exists", msg.containsKey(ADAPTER_ID_KEY));
assertNotSame(XML_PAYLOAD_PREFIX + entry.getUniqueId() + XML_PAYLOAD_SUFFIX, msg.getContent());
assertFalse(msg.containsKey(JdbcDataQueryService.class.getCanonicalName()));
XmlUtils xu = XmlHelper.createXmlUtils(msg);
assertNotNull("/root/document", xu.getSingleNode("/root/document"));
assertNotNull("/root/Results/Row", xu.getSingleNode("/root/results/row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class MergeResultSetIntoPayloadTest method testContainsRowCount.
@Test
public void testContainsRowCount() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createMetadataService();
MergeResultSetIntoXmlPayload t = new MergeResultSetIntoXmlPayload(new InsertNode("/root"));
t.setResultCountMetadataItem(getName());
s.setResultSetTranslator(t);
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(ADAPTER_ID_KEY + " exists", msg.containsKey(ADAPTER_ID_KEY));
assertNotSame(XML_PAYLOAD_PREFIX + entry.getUniqueId() + XML_PAYLOAD_SUFFIX, msg.getContent());
assertFalse(msg.containsKey(JdbcDataQueryService.class.getCanonicalName()));
XmlUtils xu = XmlHelper.createXmlUtils(msg);
log.warn(msg.getContent());
assertNotNull("/root/document", xu.getSingleNode("/root/document"));
assertNotNull("/root/Results/Row", xu.getSingleNode("/root/Results/Row"));
assertTrue(msg.containsKey(getName()));
assertEquals("1", msg.getMetadataValue(getName()));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class MergeResultSetIntoPayloadTest method testXpathStatementParam.
@Test
public void testXpathStatementParam() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createXmlService();
s.setResultSetTranslator(new MergeResultSetIntoXmlPayload(new InsertNode("/root")));
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(ADAPTER_ID_KEY + " exists", msg.containsKey(ADAPTER_ID_KEY));
assertNotSame(XML_PAYLOAD_PREFIX + entry.getUniqueId() + XML_PAYLOAD_SUFFIX, msg.getContent());
assertFalse(msg.containsKey(JdbcDataQueryService.class.getCanonicalName()));
XmlUtils xu = XmlHelper.createXmlUtils(msg);
assertNotNull("/root/document", xu.getSingleNode("/root/document"));
assertNotNull("/root/Results/Row", xu.getSingleNode("/root/Results/Row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class MergeResultSetIntoPayloadTest method testMetadataStatementParam.
@Test
public void testMetadataStatementParam() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createMetadataService();
s.setResultSetTranslator(new MergeResultSetIntoXmlPayload(new InsertNode("/root")));
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(ADAPTER_ID_KEY + " exists", msg.containsKey(ADAPTER_ID_KEY));
assertNotSame(XML_PAYLOAD_PREFIX + entry.getUniqueId() + XML_PAYLOAD_SUFFIX, msg.getContent());
assertFalse(msg.containsKey(JdbcDataQueryService.class.getCanonicalName()));
XmlUtils xu = XmlHelper.createXmlUtils(msg);
log.warn(msg.getContent());
assertNotNull("/root/document", xu.getSingleNode("/root/document"));
assertNotNull("/root/Results/Row", xu.getSingleNode("/root/Results/Row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class XmlHelperTest method testCreateDocumentFromMessage.
@Test
public void testCreateDocumentFromMessage() throws Exception {
Document d = XmlHelper.createDocument(AdaptrisMessageFactory.getDefaultInstance().newMessage(EXAMPLE_XML));
assertNotNull(d);
XmlUtils xu = new XmlUtils();
xu.setSource(d);
assertEquals("text body", xu.getSingleTextItem("/document/content"));
assertNotNull(createDocument(AdaptrisMessageFactory.getDefaultInstance().newMessage(EXAMPLE_XML), DocumentBuilderFactoryBuilderTest.createNamespaceContext()));
assertNotNull(createDocument(AdaptrisMessageFactory.getDefaultInstance().newMessage(EXAMPLE_XML), (NamespaceContext) null));
}
Aggregations