use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class NettyHttpBridgeRouteUsingHttpClientTest method testBridge.
@Test
public void testBridge() throws Exception {
String response = template.requestBodyAndHeader("http://localhost:" + port2 + "/test/hello", new ByteArrayInputStream("This is a test".getBytes()), "Content-Type", "application/xml", String.class);
assertEquals("Get a wrong response", "/", response);
response = template.requestBody("http://localhost:" + port1 + "/hello/world", "hello", String.class);
assertEquals("Get a wrong response", "/hello/world", response);
try {
template.requestBody("http://localhost:" + port2 + "/hello/world", "hello", String.class);
fail("Expect exception here!");
} catch (Exception ex) {
assertTrue("We should get a RuntimeCamelException", ex instanceof RuntimeCamelException);
}
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ReactiveInjector method newInstance.
@Override
public <T> T newInstance(Class<T> type) {
T answer = delegate.newInstance(type);
if (answer != null) {
try {
postProcessor.postProcessBeforeInitialization(answer, answer.getClass().getName());
postProcessor.postProcessAfterInitialization(answer, answer.getClass().getName());
} catch (Exception e) {
throw new RuntimeCamelException("Error during post processing of bean " + answer, e);
}
}
return answer;
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class ReactiveInjector method newInstance.
@Override
public <T> T newInstance(Class<T> type, Object instance) {
T answer = delegate.newInstance(type, instance);
if (answer != null) {
try {
postProcessor.postProcessBeforeInitialization(answer, answer.getClass().getName());
postProcessor.postProcessAfterInitialization(answer, answer.getClass().getName());
} catch (Exception e) {
throw new RuntimeCamelException("Error during post processing of bean " + answer, e);
}
}
return answer;
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class Utils method evaluate.
/**
* Evaluate an XPATH expression.
*
* @param xpath
* @param xml
* @return
*/
public static String evaluate(final String xpath, final String xml) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("svrl", Constants.HTTP_PURL_OCLC_ORG_DSDL_SVRL);
XpathEngine xpathEngine = XMLUnit.newXpathEngine();
xpathEngine.setNamespaceContext(new SimpleNamespaceContext(m));
try {
return xpathEngine.evaluate(xpath, XMLUnit.buildControlDocument(xml));
} catch (Exception e) {
LOG.error("Failed to apply xpath {} on xml {}", xpath, xml);
throw new RuntimeCamelException(e);
}
}
use of org.apache.camel.RuntimeCamelException in project camel by apache.
the class StreamDataWriter method createSocket.
@Override
protected Socket createSocket(Service service) throws IOException {
Index indexObject = null;
Receiver receiver = null;
Socket socket = null;
if (index != null) {
indexObject = service.getIndexes().get(index);
if (indexObject == null) {
throw new RuntimeCamelException(String.format("cannot find index [%s]", index));
}
socket = indexObject.attach(args);
} else {
receiver = service.getReceiver();
socket = receiver.attach(args);
}
socket.setTcpNoDelay(true);
LOG.trace(String.format("created a socket on %s", socket.getRemoteSocketAddress()));
return socket;
}
Aggregations