use of com.adaptris.util.text.xml.InsertNode 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.text.xml.InsertNode 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.text.xml.InsertNode 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.text.xml.InsertNode 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.text.xml.InsertNode in project interlok by adaptris.
the class IgnoreOriginalXmlAggregatorTest method testSplitJoinService_WithImplicitDocumentEnoding.
@Test
public void testSplitJoinService_WithImplicitDocumentEnoding() throws Exception {
// This is a XML doc with 3 iterable elements...
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(SplitterCase.XML_MESSAGE, "ISO-8859-1");
PooledSplitJoinService service = new PooledSplitJoinService();
// The service doesn't actually matter right now.
service.setService(asCollection(new NullService()));
service.setTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
service.setSplitter(new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8));
service.setAggregator(new IgnoreOriginalXmlDocumentAggregator("<new/>", new InsertNode("/new")));
execute(service, msg);
// Should now be 6 document nodes
XPath xpath = new XPath();
assertEquals(3, xpath.selectNodeList(XmlHelper.createDocument(msg, true), "/new/document").getLength());
assertEquals("ISO-8859-1", msg.getContentEncoding());
}
Aggregations