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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations