Search in sources :

Example 81 with AdaptrisMessage

use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.

the class StoredProcedureProducerTest method testMultiResultSetXmlTranslator.

@Test
public void testMultiResultSetXmlTranslator() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("many_resultsets"));
        XmlPayloadTranslator xmlPayloadTranslator = new XmlPayloadTranslator();
        xmlPayloadTranslator.setPreserveOriginalMessage(true);
        spp.setResultSetTranslator(xmlPayloadTranslator);
        AdaptrisMessage message = createMessage();
        assertEquals(0, message.getMetadata().size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals("Robbie Fowler", resolveXPath(message, "/Results/Row[1]/player"));
            assertEquals("Michael Owen", resolveXPath(message, "/Results/Row[2]/player"));
            assertEquals("Stan Collymore", resolveXPath(message, "/Results/Row[3]/player"));
            assertEquals("Emile Heskey", resolveXPath(message, "/Results/Row[5]/player"));
            assertEquals("Djibril Cisse", resolveXPath(message, "/Results/Row[6]/player"));
            assertEquals("Emile Heskey", resolveXPath(message, "/Results/Row[7]/player"));
            assertEquals("Xabi Alonso", resolveXPath(message, "/Results/Row[8]/player"));
            assertEquals("El-Hadji Diouf", resolveXPath(message, "/Results/Row[9]/player"));
            assertEquals("Stan Collymore", resolveXPath(message, "/Results/Row[10]/player"));
            assertNull(resolveXPath(message, "/Results/Row[11]/player"));
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) XmlPayloadTranslator(com.adaptris.core.services.jdbc.XmlPayloadTranslator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 82 with AdaptrisMessage

use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.

the class StoredProcedureProducerTest method testOneConstantParamInOut.

@Test
public void testOneConstantParamInOut() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_inout"));
        JdbcConstantParameter inParameter = new JdbcConstantParameter();
        inParameter.setName("xSomeAmount");
        inParameter.setType(ParameterValueType.VARCHAR);
        inParameter.setConstant("100");
        InOutParameters inOutParameters = new InOutParameters();
        inOutParameters.add(inParameter);
        spp.setInOutParameters(inOutParameters);
        StandaloneProducer producer = configureForTests(spp, true);
        AdaptrisMessage message = createMessage();
        try {
            start(producer);
            producer.doService(message);
            fail("Cannot use a constant for InOut parameters");
        } catch (ServiceException ex) {
        // pass, expected
        } finally {
            stop(producer);
        }
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 83 with AdaptrisMessage

use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.

the class StoredProcedureProducerTest method testOneObjectMetadataParamOut.

@Test
public void testOneObjectMetadataParamOut() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_out"));
        JdbcObjectMetadataParameter outParameter = new JdbcObjectMetadataParameter();
        outParameter.setMetadataKey("transferCount");
        outParameter.setName("transferCount");
        outParameter.setType(ParameterValueType.INTEGER);
        OutParameters outParameters = new OutParameters();
        outParameters.add(outParameter);
        spp.setOutParameters(outParameters);
        AdaptrisMessage message = createMessage();
        Map<Object, Object> objectMetadata = message.getObjectHeaders();
        assertEquals(0, objectMetadata.size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            objectMetadata = message.getObjectHeaders();
            assertEquals(1, objectMetadata.size());
            assertTrue("31".equals(objectMetadata.get("transferCount").toString()));
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 84 with AdaptrisMessage

use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.

the class StoredProcedureProducerTest method testOneMetadataParamInOut.

@Test
public void testOneMetadataParamInOut() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_inout"));
        JdbcMetadataParameter inParameter = new JdbcMetadataParameter();
        inParameter.setMetadataKey("xSomeAmount");
        inParameter.setName("xSomeAmount");
        inParameter.setType(ParameterValueType.INTEGER);
        AdaptrisMessage message = createMessage();
        message.addMetadata("xSomeAmount", "100");
        InOutParameters inOutParameters = new InOutParameters();
        inOutParameters.add(inParameter);
        spp.setInOutParameters(inOutParameters);
        assertEquals(1, message.getMetadata().size());
        assertEquals("100", message.getMetadataValue("xSomeAmount"));
        ExampleServiceCase.execute(configureForTests(spp, true), message);
        assertEquals(1, message.getMetadata().size());
        assertEquals("105", message.getMetadataValue("xSomeAmount"));
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 85 with AdaptrisMessage

use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.

the class StoredProcedureProducerTest method testBytePayloadParamIn.

@Test
public void testBytePayloadParamIn() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_in"));
        JdbcBytePayloadParameter inParameter = new JdbcBytePayloadParameter();
        inParameter.setName("xType");
        inParameter.setType(ParameterValueType.VARCHAR);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Sold");
        InParameters inParameters = new InParameters();
        inParameters.add(inParameter);
        spp.setInParameters(inParameters);
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(msg);
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1495 Test (org.junit.Test)1362 ServiceException (com.adaptris.core.ServiceException)171 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)158 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)156 StandaloneProducer (com.adaptris.core.StandaloneProducer)125 Channel (com.adaptris.core.Channel)122 MetadataElement (com.adaptris.core.MetadataElement)94 File (java.io.File)89 TimeInterval (com.adaptris.util.TimeInterval)77 CoreException (com.adaptris.core.CoreException)67 Session (javax.jms.Session)62 StandardWorkflow (com.adaptris.core.StandardWorkflow)57 GuidGenerator (com.adaptris.util.GuidGenerator)56 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)50 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)49 Message (javax.jms.Message)47 XPath (com.adaptris.util.text.xml.XPath)45 ServiceList (com.adaptris.core.ServiceList)43 Document (org.w3c.dom.Document)40