Search in sources :

Example 1 with MetadataElement

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

the class StandardResponseProducerTest method testResponse_MetadataContentType.

@Test
public void testResponse_MetadataContentType() throws Exception {
    StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
    responder.setContentTypeProvider(new MetadataContentTypeProvider("MyContentType"));
    AddMetadataService addMetadata = new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement("MyContentType", "text/xml") }));
    HttpConnection httpConnection = createConnection();
    Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), new ServiceList(new Service[] { addMetadata, new StandaloneProducer(responder) })));
    StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
    AdaptrisMessage msg = createMessage();
    try {
        c.requestStart();
        start(requestor);
        requestor.doService(msg);
        assertEquals(TEXT, msg.getContent());
        assertTrue(msg.containsKey("Content-Type"));
        assertTrue(msg.getMetadataValue("Content-Type").startsWith("text/xml"));
    } finally {
        c.requestClose();
        stop(requestor);
        PortManager.release(httpConnection.getPort());
    }
}
Also used : MetadataContentTypeProvider(com.adaptris.core.http.MetadataContentTypeProvider) StandaloneRequestor(com.adaptris.core.StandaloneRequestor) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 2 with MetadataElement

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

the class MessageMetricsStatisticsByMetadataTest method createMessageForInjection.

@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
    SerializableAdaptrisMessage msg = null;
    if (!isEmpty(payload)) {
        msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
    } else {
        msg = new SerializableAdaptrisMessage(GUID.getUUID());
    }
    msg.addMetadata(new MetadataElement("messageType", "Order"));
    return msg;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 3 with MetadataElement

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

the class MetadataTotalsMBeanTest method createMessageForInjection.

@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
    SerializableAdaptrisMessage msg = null;
    if (!isEmpty(payload)) {
        msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
    } else {
        msg = new SerializableAdaptrisMessage(GUID.getUUID());
    }
    msg.addMetadata(new MetadataElement(METADATA_KEY1, STATS_KEY));
    return msg;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 4 with MetadataElement

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

the class MetadataCountMBeanTest method createMessageForInjection.

@Override
protected SerializableAdaptrisMessage createMessageForInjection(String payload) {
    SerializableAdaptrisMessage msg = null;
    if (!isEmpty(payload)) {
        msg = new SerializableAdaptrisMessage(GUID.getUUID(), payload);
    } else {
        msg = new SerializableAdaptrisMessage(GUID.getUUID());
    }
    msg.addMetadata(new MetadataElement(COUNTER_1, "10"));
    msg.addMetadata(new MetadataElement(COUNTER_2, "10"));
    return msg;
}
Also used : SerializableAdaptrisMessage(com.adaptris.core.SerializableAdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement)

Example 5 with MetadataElement

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

the class MetadataConverterCase method testSetProperty.

@Test
public void testSetProperty() throws Exception {
    MetadataConverter mc = createConverter();
    Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
    MetadataCollection metadataCollection = new MetadataCollection();
    metadataCollection.add(new MetadataElement(HEADER, getStringValue()));
    Message jmsMsg = session.createMessage();
    mc.moveMetadata(metadataCollection, jmsMsg);
    assertEquals(getStringValue(), jmsMsg.getStringProperty(HEADER));
    assertValue(jmsMsg);
}
Also used : Message(javax.jms.Message) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

MetadataElement (com.adaptris.core.MetadataElement)151 Test (org.junit.Test)101 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)94 XPath (com.adaptris.util.text.xml.XPath)23 Document (org.w3c.dom.Document)19 MetadataCollection (com.adaptris.core.MetadataCollection)18 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)18 ServiceException (com.adaptris.core.ServiceException)17 ServiceList (com.adaptris.core.ServiceList)14 Cache (com.adaptris.core.cache.Cache)14 MetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator)12 ArrayList (java.util.ArrayList)11 CoreException (com.adaptris.core.CoreException)10 Service (com.adaptris.core.Service)10 HashSet (java.util.HashSet)9 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)8 StandaloneProducer (com.adaptris.core.StandaloneProducer)7 StaticCacheValueTranslator (com.adaptris.core.services.cache.translators.StaticCacheValueTranslator)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 Session (javax.jms.Session)6