use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class StandardHttpProducerTest method testRequest_GetMethod_WithErrorResponse.
@Test
public void testRequest_GetMethod_WithErrorResponse() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
ServiceList services = new ServiceList();
services.add(new StandaloneProducer(new StandardResponseProducer(HttpStatus.UNAUTHORIZED_401)));
Channel c = createChannel(jc, createWorkflow(mc, mock, services));
StandardHttpProducer stdHttp = new StandardHttpProducer().withURL(HttpHelper.createURL(c));
;
stdHttp.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethodProvider.RequestMethod.GET));
StandaloneRequestor producer = new StandaloneRequestor(stdHttp);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(ALT_TEXT);
try {
start(c);
start(producer);
producer.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(c);
stop(producer);
}
assertEquals(1, mock.messageCount());
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_GetMethod_NonZeroBytes_WithErrorResponse.
@Test
public void testRequest_GetMethod_NonZeroBytes_WithErrorResponse() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(TEXT), new StandaloneProducer(new StandardResponseProducer(HttpStatus.UNAUTHORIZED_401)) })));
HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("GET");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
start(c);
execute(service, msg);
fail();
} catch (ServiceException expect) {
} finally {
stop(c);
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class JettyResponseServiceTest method testResponseWithError.
@Test
public void testResponseWithError() throws Exception {
JettyResponseService responder = new JettyResponseService().withHttpStatus("500").withContentType("text/plain").withResponseHeaderProvider(new NoOpResponseHeaderProvider());
HttpConnection httpConnection = createConnection();
ServiceList list = new ServiceList(responder);
Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), list));
StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
AdaptrisMessage msg = createMessage();
try {
c.requestStart();
start(requestor);
requestor.doService(msg);
fail("StandaloneRequestor.doService() success even though we should have got a 500 error back");
} catch (ServiceException expected) {
;
} finally {
c.requestClose();
stop(requestor);
PortManager.release(httpConnection.getPort());
}
}
use of com.adaptris.core.ServiceException 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);
}
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneMetadataParamInButDoesntExist.
@Test
public void testOneMetadataParamInButDoesntExist() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_in"));
JdbcMetadataParameter inParameter = new JdbcMetadataParameter();
inParameter.setMetadataKey("xType");
inParameter.setName("xType");
inParameter.setType(ParameterValueType.VARCHAR);
InParameters inParameters = new InParameters();
inParameters.add(inParameter);
spp.setInParameters(inParameters);
StandaloneProducer producer = configureForTests(spp, true);
AdaptrisMessage message = createMessage();
try {
start(producer);
producer.doService(message);
fail("Should have thrown ProduceException, because the metadata does not exist in the message.");
} catch (ServiceException ex) {
// pass, expected
} finally {
stop(producer);
}
}
}
Aggregations