Search in sources :

Example 96 with DefaultExchange

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

the class IOConverterTest method testInputStreamToString.

public void testInputStreamToString() throws Exception {
    String data = "46°37'00\"N\"";
    ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes("UTF-8"));
    Exchange exchange = new DefaultExchange(context);
    exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
    String result = IOConverter.toString(is, exchange);
    assertEquals("Get a wrong result", data, result);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 97 with DefaultExchange

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

the class InstanceFallbackConverterTest method testInstanceFallbackConverter.

public void testInstanceFallbackConverter() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Currency cur = Currency.getInstance(Locale.US);
    String money = context.getTypeConverter().convertTo(String.class, exchange, cur);
    assertEquals("Money talks says " + context.getName(), money);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Currency(java.util.Currency)

Example 98 with DefaultExchange

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

the class InstanceFallbackConverterTest method testInstanceFallbackFailed.

public void testInstanceFallbackFailed() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Date out = context.getTypeConverter().convertTo(Date.class, exchange, new Timestamp(0));
    assertNull(out);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Example 99 with DefaultExchange

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

the class InstanceFallbackConverterTest method testInstanceFallbackMandatoryConverter.

public void testInstanceFallbackMandatoryConverter() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Currency cur = Currency.getInstance(Locale.US);
    String money = context.getTypeConverter().mandatoryConvertTo(String.class, exchange, cur);
    assertEquals("Money talks says " + context.getName(), money);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Currency(java.util.Currency)

Example 100 with DefaultExchange

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

the class IOConverterTest method testToInputStreamExchange.

public void testToInputStreamExchange() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    exchange.setProperty(Exchange.CHARSET_NAME, ObjectHelper.getDefaultCharacterSet());
    InputStream is = IOConverter.toInputStream("Hello World", exchange);
    assertNotNull(is);
    assertEquals("Hello World", IOConverter.toString(is, exchange));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

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