本文整理汇总了Java中org.apache.camel.CamelExecutionException类的典型用法代码示例。如果您正苦于以下问题:Java CamelExecutionException类的具体用法?Java CamelExecutionException怎么用?Java CamelExecutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CamelExecutionException类属于org.apache.camel包,在下文中一共展示了CamelExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTooMuchFields
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@DirtiesContext
@Test
public void testTooMuchFields() throws Exception {
String record6 = ",,,,,,,,,,,,,,"; // too much data in the record (only
// 11 are accepted by the model
resultEndpoint1.expectedMessageCount(0);
try {
template1.sendBody(record6);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
// expected
Assert.isInstanceOf(IllegalArgumentException.class, e.getCause());
}
resultEndpoint1.assertIsSatisfied();
}
示例2: tesDamn
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@Test
public void tesDamn() throws Exception {
if (classPathHasSpaces()) {
return;
}
getMockEndpoint("mock:result").expectedMessageCount(0);
try {
template.sendBody("direct:echo", "Hello World");
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(DamnException.class, e.getCause());
assertEquals("Damn this did not work", e.getCause().getMessage());
}
assertMockEndpointsSatisfied();
}
示例3: testJettyAsyncTimeout
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@Test
public void testJettyAsyncTimeout() throws Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
StopWatch watch = new StopWatch();
try {
template.requestBody("http://localhost:{{port}}/myservice", null, String.class);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
log.info("Timeout hit and client got reply with failure status code");
long taken = watch.stop();
HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
assertEquals(503, cause.getStatusCode());
// should be approx 3-4 sec.
assertTrue("Timeout should occur faster than " + taken, taken < 4500);
}
assertMockEndpointsSatisfied();
}
示例4: testBasicAuth
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@Test
public void testBasicAuth() throws Exception {
try {
template.requestBody("netty-http:http://localhost:{{port}}/foo", "Hello World", String.class);
fail("Should send back 401");
} catch (CamelExecutionException e) {
NettyHttpOperationFailedException cause = assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
assertEquals(401, cause.getStatusCode());
}
getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
// username:password is scott:secret
String auth = "Basic c2NvdHQ6c2VjcmV0";
String out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World", "Authorization", auth, String.class);
assertEquals("Bye World", out);
assertMockEndpointsSatisfied();
}
示例5: testMissing
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testMissing() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.to("bean:myBean?method=concat(${body}, ${header.foo}")
.to("mock:result");
}
});
context.start();
try {
template.sendBodyAndHeader("direct:start", "Hello", "foo", "Camel");
fail("Should throw exception");
} catch (CamelExecutionException e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Method should end with parenthesis, was concat(${body}, ${header.foo}", iae.getMessage());
}
}
示例6: testFailAgain
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testFailAgain() throws Exception {
getMockEndpoint("mock:bar").expectedMessageCount(0);
getMockEndpoint("mock:donkey").expectedMessageCount(1);
getMockEndpoint("mock:catch").expectedMessageCount(1);
getMockEndpoint("mock:kong").expectedMessageCount(1);
getMockEndpoint("mock:finally").expectedMessageCount(1);
getMockEndpoint("mock:finallyEnd").expectedMessageCount(0);
getMockEndpoint("mock:end").expectedMessageCount(0);
try {
template.sendBody("direct:start", "Donkey Kong");
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(IllegalStateException.class, e.getCause());
assertEquals("Damn Kong", e.getCause().getMessage());
}
assertMockEndpointsSatisfied();
}
示例7: testInOut
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testInOut() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct-vm:start").to("direct-vm:foo");
}
});
context.start();
try {
template.requestBody("direct-vm:start", "Hello World");
fail("Should throw an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause());
}
}
示例8: testAsyncEndpoint
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testAsyncEndpoint() throws Exception {
getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
getMockEndpoint("mock:result").expectedMessageCount(0);
try {
template.requestBody("direct:start", "Hello Camel", String.class);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("Damn", e.getCause().getMessage());
}
assertMockEndpointsSatisfied();
assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
}
示例9: tesIllegal
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@Test
public void tesIllegal() throws Exception {
if (classPathHasSpaces()) {
return;
}
getMockEndpoint("mock:result").expectedMessageCount(0);
try {
template.sendBody("direct:echo", "Hello World");
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(RemoteException.class, e.getCause());
// wrapped far down
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause().getCause().getCause());
assertEquals("Illegal", iae.getMessage());
}
assertMockEndpointsSatisfied();
}
示例10: testTwoWereSentToDoneAndFailed
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testTwoWereSentToDoneAndFailed() throws Exception {
// we expect 2+ done messages which were sent to mock:bar
// and 1+ failed message which were sent to mock:fail
NotifyBuilder notify = new NotifyBuilder(context)
.whenDone(2).wereSentTo("mock:bar")
.and()
.whenFailed(1).wereSentTo("mock:fail")
.create();
template.sendBody("direct:bar", "Hello World");
assertEquals(false, notify.matches());
template.sendBody("direct:bar", "Hello World");
assertEquals(false, notify.matches());
template.sendBody("direct:foo", "Hello World");
assertEquals(false, notify.matches());
try {
template.sendBody("direct:fail", "Bye World");
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
// expected
}
assertEquals(true, notify.matches());
}
示例11: testRestletPostPojoError
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
@Test
public void testRestletPostPojoError() throws Exception {
getMockEndpoint("mock:input").expectedMessageCount(0);
getMockEndpoint("mock:error").expectedMessageCount(1);
String body = "This is not json";
try {
template.sendBody("http://localhost:" + portNum + "/users/new", body);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
assertEquals(400, cause.getStatusCode());
assertEquals("Invalid json data", cause.getResponseBody());
}
assertMockEndpointsSatisfied();
}
示例12: testOnException
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testOnException() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new RouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("seda:*")
.skipSendToOriginalEndpoint()
.throwException(new ConnectException("Forced"));
}
});
getMockEndpoint("mock:local").expectedMessageCount(0);
getMockEndpoint("mock:seda").expectedMessageCount(0);
// we fail all redeliveries so after that we send to mock:exhausted
getMockEndpoint("mock:exhausted").expectedMessageCount(1);
try {
template.sendBody("direct:start", "Hello World");
fail("Should thrown an exception");
} catch (CamelExecutionException e) {
ConnectException cause = assertIsInstanceOf(ConnectException.class, e.getCause());
assertEquals("Forced", cause.getMessage());
}
assertMockEndpointsSatisfied();
}
示例13: testMultipleNodeList
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
/**
* Regression test to ensure that a NodeList of length > 1 is not processed by the new converters.
* @throws Exception
*/
@Test
public void testMultipleNodeList() throws Exception {
getMockEndpoint("mock:found").expectedMessageCount(0);
getMockEndpoint("mock:found").setResultWaitTime(500);
getMockEndpoint("mock:notfound").expectedMessageCount(0);
getMockEndpoint("mock:notfound").setResultWaitTime(500);
try {
template.requestBody("direct:doTest", XML_INPUT_MULTIPLE, String.class);
fail("NoTypeConversionAvailableException expected");
} catch (CamelExecutionException ex) {
assertEquals(RuntimeCamelException.class, ex.getCause().getClass());
assertEquals(NoTypeConversionAvailableException.class, ex.getCause().getCause().getClass());
}
assertMockEndpointsSatisfied();
}
示例14: testBeanHeaderNoTypeConvertionPossibleFail
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testBeanHeaderNoTypeConvertionPossibleFail() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(0);
// we send in a bar string as header which cannot be converted to a number so it should fail
try {
template.requestBodyAndHeader("direct:start", "Hello World", "foo", 555);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
ParameterBindingException pbe = assertIsInstanceOf(ParameterBindingException.class, e.getCause());
assertEquals(1, pbe.getIndex());
assertTrue(pbe.getMethod().getName().contains("hello"));
assertEquals(555, pbe.getParameterValue());
NoTypeConversionAvailableException ntae = assertIsInstanceOf(NoTypeConversionAvailableException.class, e.getCause().getCause());
assertEquals(Integer.class, ntae.getFromType());
assertEquals(Document.class, ntae.getToType());
assertEquals(555, ntae.getValue());
assertNotNull(ntae.getMessage());
}
assertMockEndpointsSatisfied();
}
示例15: testBodyAs
import org.apache.camel.CamelExecutionException; //导入依赖的package包/类
public void testBodyAs() throws Exception {
assertExpression("${bodyAs(String)}", "<hello id='m123'>world!</hello>");
assertExpression("${bodyAs('String')}", "<hello id='m123'>world!</hello>");
exchange.getIn().setBody(null);
assertExpression("${bodyAs('String')}", null);
exchange.getIn().setBody(456);
assertExpression("${bodyAs(Integer)}", 456);
assertExpression("${bodyAs(int)}", 456);
assertExpression("${bodyAs('int')}", 456);
try {
assertExpression("${bodyAs(XXX)}", 456);
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(ClassNotFoundException.class, e.getCause());
}
}