Search in sources :

Example 6 with StandardHttpProducer

use of com.adaptris.core.http.client.net.StandardHttpProducer in project interlok by adaptris.

the class EmbeddedHttpConsumerTest method createProducer.

protected StandardHttpProducer createProducer() {
    StandardHttpProducer p = new StandardHttpProducer();
    p.setContentTypeProvider(new MetadataContentTypeProvider("content.type"));
    p.setUrl("dummy_url");
    p.setIgnoreServerResponseCode(true);
    p.registerConnection(new NullConnection());
    return p;
}
Also used : StandardHttpProducer(com.adaptris.core.http.client.net.StandardHttpProducer) MetadataContentTypeProvider(com.adaptris.core.http.MetadataContentTypeProvider) NullConnection(com.adaptris.core.NullConnection)

Example 7 with StandardHttpProducer

use of com.adaptris.core.http.client.net.StandardHttpProducer in project interlok by adaptris.

the class RetryFromJettyTest method testReport_Broken.

@Test
public void testReport_Broken() throws Exception {
    RetryFromJetty retrier = create();
    try {
        retrier.setRetryStore(new BrokenRetryStore());
        start(retrier);
        String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_REPORTING_ENDPOINT);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        StandardHttpProducer http = buildProducer(url);
        http.setIgnoreServerResponseCode(true);
        http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethodProvider.RequestMethod.GET));
        ExampleServiceCase.execute(new StandaloneRequestor(http), msg);
        assertEquals(RetryFromJetty.HTTP_ERROR, msg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
    } finally {
        stop(retrier);
    }
}
Also used : StandardHttpProducer(com.adaptris.core.http.client.net.StandardHttpProducer) StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConfiguredRequestMethodProvider(com.adaptris.core.http.client.ConfiguredRequestMethodProvider) Test(org.junit.Test)

Example 8 with StandardHttpProducer

use of com.adaptris.core.http.client.net.StandardHttpProducer in project interlok by adaptris.

the class RetryFromJettyTest method testRetry_NotFound.

@Test
public void testRetry_NotFound() throws Exception {
    RetryFromJetty retrier = create();
    StandardWorkflow workflow = createWorkflow();
    try {
        MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
        retrier.addWorkflow(workflow);
        retrier.addWorkflow(createWorkflow());
        start(workflow, retrier);
        AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        baseMsg.addMetadata(Workflow.WORKFLOW_ID_KEY, workflow.obtainWorkflowId());
        retryStore.write(baseMsg);
        assertNotNull(retryStore.getMetadata(baseMsg.getUniqueId()));
        // This should result in a msgId that isn't found; so we get a 500...
        AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_ENDPOINT_PREFIX + triggerMsg.getUniqueId());
        StandardHttpProducer http = buildProducer(url);
        http.setIgnoreServerResponseCode(true);
        ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
        assertEquals(RetryFromJetty.HTTP_ERROR, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
    } finally {
        stop(retrier, workflow);
    }
}
Also used : StandardHttpProducer(com.adaptris.core.http.client.net.StandardHttpProducer) StandaloneRequestor(com.adaptris.core.StandaloneRequestor) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 9 with StandardHttpProducer

use of com.adaptris.core.http.client.net.StandardHttpProducer in project interlok by adaptris.

the class RetryFromJettyTest method testDelete_BadRequest.

@Test
public void testDelete_BadRequest() throws Exception {
    RetryFromJetty retrier = create();
    try {
        start(retrier);
        AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        retryStore.write(baseMsg);
        assertNotNull(retryStore.getMetadata(baseMsg.getUniqueId()));
        // we're going to use a POST but with the correct URL.
        // so should be a BAD request.
        AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_DELETE_PREFIX + baseMsg.getUniqueId());
        StandardHttpProducer http = buildProducer(url);
        http.setIgnoreServerResponseCode(true);
        http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethod.POST));
        ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
        assertEquals(RetryFromJetty.HTTP_BAD, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
    } finally {
        stop(retrier);
    }
}
Also used : StandardHttpProducer(com.adaptris.core.http.client.net.StandardHttpProducer) StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConfiguredRequestMethodProvider(com.adaptris.core.http.client.ConfiguredRequestMethodProvider) Test(org.junit.Test)

Aggregations

StandardHttpProducer (com.adaptris.core.http.client.net.StandardHttpProducer)9 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)8 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)7 Test (org.junit.Test)7 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)3 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)3 MetadataContentTypeProvider (com.adaptris.core.http.MetadataContentTypeProvider)2 NullConnection (com.adaptris.core.NullConnection)1 ResponseHeadersAsMetadata (com.adaptris.core.http.client.net.ResponseHeadersAsMetadata)1