Search in sources :

Example 71 with DefaultExchange

use of org.apache.camel.impl.DefaultExchange in project camel by apache.

the class DeleteDomainCommandTest method setUp.

@Before
public void setUp() {
    sdbClient = new AmazonSDBClientMock();
    configuration = new SdbConfiguration();
    configuration.setDomainName("DOMAIN1");
    exchange = new DefaultExchange(new DefaultCamelContext());
    command = new DeleteDomainCommand(sdbClient, configuration, exchange);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 72 with DefaultExchange

use of org.apache.camel.impl.DefaultExchange in project camel by apache.

the class DomainMetadataCommandTest method setUp.

@Before
public void setUp() {
    sdbClient = new AmazonSDBClientMock();
    configuration = new SdbConfiguration();
    configuration.setDomainName("DOMAIN1");
    exchange = new DefaultExchange(new DefaultCamelContext());
    command = new DomainMetadataCommand(sdbClient, configuration, exchange);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 73 with DefaultExchange

use of org.apache.camel.impl.DefaultExchange in project camel by apache.

the class ListDomainsCommandTest method setUp.

@Before
public void setUp() {
    sdbClient = new AmazonSDBClientMock();
    configuration = new SdbConfiguration();
    configuration.setDomainName("DOMAIN1");
    configuration.setMaxNumberOfDomains(new Integer(5));
    exchange = new DefaultExchange(new DefaultCamelContext());
    command = new ListDomainsCommand(sdbClient, configuration, exchange);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 74 with DefaultExchange

use of org.apache.camel.impl.DefaultExchange in project camel by apache.

the class PutAttributesCommandTest method setUp.

@Before
public void setUp() {
    sdbClient = new AmazonSDBClientMock();
    configuration = new SdbConfiguration();
    configuration.setDomainName("DOMAIN1");
    exchange = new DefaultExchange(new DefaultCamelContext());
    command = new PutAttributesCommand(sdbClient, configuration, exchange);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 75 with DefaultExchange

use of org.apache.camel.impl.DefaultExchange in project camel by apache.

the class ResourceHelper method resolveMandatoryResourceAsInputStream.

/**
     * Resolves the mandatory resource.
     * <p/>
     * The resource uri can refer to the following systems to be loaded from
     * <ul>
     *     <il>file:nameOfFile - to refer to the file system</il>
     *     <il>classpath:nameOfFile - to refer to the classpath (default)</il>
     *     <il>http:uri - to load the resource using HTTP</il>
     *     <il>ref:nameOfBean - to lookup the resource in the {@link org.apache.camel.spi.Registry}</il>
     *     <il>bean:nameOfBean.methodName - to lookup a bean in the {@link org.apache.camel.spi.Registry} and call the method</il>
     * </ul>
     * If no prefix has been given, then the resource is loaded from the classpath
     * <p/>
     * If possible recommended to use {@link #resolveMandatoryResourceAsUrl(org.apache.camel.spi.ClassResolver, String)}
     *
     * @param camelContext the Camel Context
     * @param uri URI of the resource
     * @return the resource as an {@link InputStream}.  Remember to close this stream after usage.
     * @throws java.io.IOException is thrown if the resource file could not be found or loaded as {@link InputStream}
     */
public static InputStream resolveMandatoryResourceAsInputStream(CamelContext camelContext, String uri) throws IOException {
    if (uri.startsWith("ref:")) {
        String ref = uri.substring(4);
        String value = CamelContextHelper.mandatoryLookup(camelContext, ref, String.class);
        return new ByteArrayInputStream(value.getBytes());
    } else if (uri.startsWith("bean:")) {
        String bean = uri.substring(5);
        if (bean.contains(".")) {
            String method = StringHelper.after(bean, ".");
            bean = StringHelper.before(bean, ".") + "?method=" + method;
        }
        Exchange dummy = new DefaultExchange(camelContext);
        Object out = camelContext.resolveLanguage("bean").createExpression(bean).evaluate(dummy, Object.class);
        if (dummy.getException() != null) {
            IOException io = new IOException("Cannot find resource: " + uri + " from calling the bean");
            io.initCause(dummy.getException());
            throw io;
        }
        if (out != null) {
            InputStream is = camelContext.getTypeConverter().tryConvertTo(InputStream.class, dummy, out);
            if (is == null) {
                String text = camelContext.getTypeConverter().tryConvertTo(String.class, dummy, out);
                if (text != null) {
                    return new ByteArrayInputStream(text.getBytes());
                }
            } else {
                return is;
            }
        } else {
            throw new IOException("Cannot find resource: " + uri + " from calling the bean");
        }
    }
    InputStream is = resolveResourceAsInputStream(camelContext.getClassResolver(), uri);
    if (is == null) {
        String resolvedName = resolveUriPath(uri);
        throw new FileNotFoundException("Cannot find resource: " + resolvedName + " in classpath for URI: " + uri);
    } else {
        return is;
    }
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Aggregations

DefaultExchange (org.apache.camel.impl.DefaultExchange)473 Exchange (org.apache.camel.Exchange)381 Test (org.junit.Test)254 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)127 CamelContext (org.apache.camel.CamelContext)54 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 HashMap (java.util.HashMap)33 Message (org.apache.camel.Message)32 Before (org.junit.Before)32 Tx (org.nhindirect.common.tx.model.Tx)31 ESMClass (org.jsmpp.bean.ESMClass)30 Processor (org.apache.camel.Processor)22 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)22 Expression (org.apache.camel.Expression)21 File (java.io.File)20 DefaultMessage (org.apache.camel.impl.DefaultMessage)20 ArrayList (java.util.ArrayList)18 ByteArrayInputStream (java.io.ByteArrayInputStream)17 URL (java.net.URL)16 Date (java.util.Date)16