Search in sources :

Example 56 with RuntimeCamelException

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Test(org.junit.Test)

Example 57 with 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;
}
Also used : RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Example 58 with 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, 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;
}
Also used : RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Example 59 with RuntimeCamelException

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);
    }
}
Also used : HashMap(java.util.HashMap) XpathEngine(org.custommonkey.xmlunit.XpathEngine) RuntimeCamelException(org.apache.camel.RuntimeCamelException) SimpleNamespaceContext(org.custommonkey.xmlunit.SimpleNamespaceContext) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Example 60 with RuntimeCamelException

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;
}
Also used : Receiver(com.splunk.Receiver) Index(com.splunk.Index) RuntimeCamelException(org.apache.camel.RuntimeCamelException) Socket(java.net.Socket)

Aggregations

RuntimeCamelException (org.apache.camel.RuntimeCamelException)196 HashMap (java.util.HashMap)52 CamelContextAware (org.apache.camel.CamelContextAware)45 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)45 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)45 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)45 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)45 Bean (org.springframework.context.annotation.Bean)45 IOException (java.io.IOException)36 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)32 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)11 Exchange (org.apache.camel.Exchange)11 InputStream (java.io.InputStream)9 GeneralSecurityException (java.security.GeneralSecurityException)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 TimeoutException (java.util.concurrent.TimeoutException)7 QName (javax.xml.namespace.QName)7 Message (org.apache.camel.Message)7 Method (java.lang.reflect.Method)6