Search in sources :

Example 31 with XmlUtils

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

Example 32 with XmlUtils

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

Example 33 with XmlUtils

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

Example 34 with XmlUtils

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

Example 35 with XmlUtils

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));
}
Also used : XmlUtils(com.adaptris.util.XmlUtils) NamespaceContext(javax.xml.namespace.NamespaceContext) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

XmlUtils (com.adaptris.util.XmlUtils)41 Test (org.junit.Test)32 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)23 Document (org.w3c.dom.Document)13 InsertNode (com.adaptris.util.text.xml.InsertNode)8 CoreException (com.adaptris.core.CoreException)7 ServiceException (com.adaptris.core.ServiceException)4 Notification (javax.management.Notification)4 NamespaceContext (javax.xml.namespace.NamespaceContext)3 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)2 ReplaceNode (com.adaptris.util.text.xml.ReplaceNode)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)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