use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class MergeResultSetIntoPayloadTest method testXpathStatementParam_NodeDoesNotExist.
@Test
public void testXpathStatementParam_NodeDoesNotExist() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(10);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createXmlService();
// /root/NonExistentNode, doesn't actually exist at this point.
s.setResultSetTranslator(new MergeResultSetIntoXmlPayload(new InsertNode("/root/NonExistentNode")));
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 doesn't exist", xu.getSingleNode("/root/document"));
assertNotNull("/root/NonExistentNode/Results/Row doesn't exist", xu.getSingleNode("/root/NonExistentNode/Results/Row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class SplittingXmlPayloadTranslatorTest 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();
SplittingXmlPayloadTranslator t = createPayloadTranslator();
t.setColumnNameStyle(ResultSetTranslatorImp.ColumnStyle.LowerCase);
s.setResultSetTranslator(t);
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(msg.headersContainsKey(ADAPTER_ID_KEY));
assertFalse(msg.headersContainsKey(JdbcDataQueryService.class.getCanonicalName()));
AdaptrisMessage outputMessage = producer.getMessages().get(0);
XmlUtils xu = XmlHelper.createXmlUtils(outputMessage);
log.warn(msg.getContent());
assertNull("Xpath /Results/OriginalMessage", xu.getSingleNode("/results/originalmessage"));
assertNotNull("/Results/Row", xu.getSingleNode("/results/row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class SplittingXmlPayloadTranslatorTest 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(createPayloadTranslator());
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(msg.headersContainsKey(ADAPTER_ID_KEY));
assertFalse(msg.headersContainsKey(JdbcDataQueryService.class.getCanonicalName()));
AdaptrisMessage outputMessage = producer.getMessages().get(0);
XmlUtils xu = XmlHelper.createXmlUtils(outputMessage);
assertNull("Xpath /Results/OriginalMessage", xu.getSingleNode("/Results/OriginalMessage"));
assertNotNull("/Results/Row missing.", xu.getSingleNode("/Results/Row"));
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class SplittingXmlPayloadTranslatorTest method testMultipleResultMessages_CopyMetadata.
@Test
public void testMultipleResultMessages_CopyMetadata() throws Exception {
createDatabase();
List<AdapterTypeVersion> dbItems = generate(11);
AdapterTypeVersion entry = dbItems.get(0);
populateDatabase(dbItems, false);
JdbcDataQueryService s = createMultiService();
SplittingXmlPayloadTranslator translator = createPayloadTranslator().withMaxRowsPerMessage(2).withCopyMetadata(true).withMessageFactory(new DefaultMessageFactory());
s.setResultSetTranslator(translator);
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(msg.headersContainsKey(ADAPTER_ID_KEY));
assertFalse(msg.headersContainsKey(JdbcDataQueryService.class.getCanonicalName()));
List<AdaptrisMessage> outputMessages = producer.getMessages();
assertEquals(6, outputMessages.size());
int count = 0;
for (AdaptrisMessage outputMessage : outputMessages) {
XmlUtils xu = XmlHelper.createXmlUtils(outputMessage);
assertNull("Xpath /Results/OriginalMessage", xu.getSingleNode("/Results/OriginalMessage"));
assertEquals("/Results/Row", count < 5 ? 2 : 1, xu.getNodeList("/Results/Row").getLength());
assertTrue(outputMessage.headersContainsKey(ADAPTER_ID_KEY));
count++;
}
}
use of com.adaptris.util.XmlUtils in project interlok by adaptris.
the class SplittingXmlPayloadTranslatorTest 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(createPayloadTranslator());
AdaptrisMessage msg = createMessage(entry);
execute(s, msg);
assertTrue(msg.headersContainsKey(ADAPTER_ID_KEY));
assertFalse(msg.headersContainsKey(JdbcDataQueryService.class.getCanonicalName()));
AdaptrisMessage outputMessage = producer.getMessages().get(0);
XmlUtils xu = XmlHelper.createXmlUtils(outputMessage);
assertNull("Xpath /Results/OriginalMessage", xu.getSingleNode("/Results/OriginalMessage"));
assertNotNull("/Results/Row", xu.getSingleNode("/Results/Row"));
}
Aggregations