Search in sources :

Example 11 with InsertNode

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"));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 12 with InsertNode

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()));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 13 with InsertNode

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"));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 14 with InsertNode

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"));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 15 with InsertNode

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());
}
Also used : PooledSplitJoinService(com.adaptris.core.services.splitter.PooledSplitJoinService) XPath(com.adaptris.util.text.xml.XPath) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) XpathMessageSplitter(com.adaptris.core.services.splitter.XpathMessageSplitter) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Aggregations

InsertNode (com.adaptris.util.text.xml.InsertNode)20 Test (org.junit.Test)19 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)18 XmlUtils (com.adaptris.util.XmlUtils)8 XPath (com.adaptris.util.text.xml.XPath)6 CoreException (com.adaptris.core.CoreException)5 NullService (com.adaptris.core.NullService)5 PooledSplitJoinService (com.adaptris.core.services.splitter.PooledSplitJoinService)5 XpathMessageSplitter (com.adaptris.core.services.splitter.XpathMessageSplitter)5 TimeInterval (com.adaptris.util.TimeInterval)5 ServiceException (com.adaptris.core.ServiceException)2 EvenOddCondition (com.adaptris.core.services.aggregator.MessageAggregatorTest.EvenOddCondition)2 DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)2 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)1 Service (com.adaptris.core.Service)1 ServiceImp (com.adaptris.core.ServiceImp)1 ServiceList (com.adaptris.core.ServiceList)1 StandaloneProducer (com.adaptris.core.StandaloneProducer)1 StandardProcessingExceptionHandler (com.adaptris.core.StandardProcessingExceptionHandler)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1