use of java.io.InputStream in project camel by apache.
the class FileProducerCharsetUTFtoISOConvertBodyToTest method testFileProducerCharsetUTFtoISOConvertBodyTo.
public void testFileProducerCharsetUTFtoISOConvertBodyTo() throws Exception {
oneExchangeDone.matchesMockWaitTime();
File file = new File("target/charset/output.txt");
assertTrue("File should exist", file.exists());
InputStream fis = IOHelper.buffered(new FileInputStream(file));
byte[] buffer = new byte[100];
int len = fis.read(buffer);
assertTrue("Should read data: " + len, len != -1);
byte[] data = new byte[len];
System.arraycopy(buffer, 0, data, 0, len);
fis.close();
for (byte b : data) {
log.info("loaded byte: {}", b);
}
// data should be in iso, where the danish ae is -26
assertEquals(4, data.length);
assertEquals(65, data[0]);
assertEquals(66, data[1]);
assertEquals(67, data[2]);
assertEquals(-26, data[3]);
}
use of java.io.InputStream in project camel by apache.
the class FileProducerCharsetUTFtoUTFTest method testFileProducerCharsetUTFtoUTF.
public void testFileProducerCharsetUTFtoUTF() throws Exception {
oneExchangeDone.matchesMockWaitTime();
File file = new File("target/charset/output.txt");
assertTrue("File should exist", file.exists());
InputStream fis = IOHelper.buffered(new FileInputStream(file));
byte[] buffer = new byte[100];
int len = fis.read(buffer);
assertTrue("Should read data: " + len, len != -1);
byte[] data = new byte[len];
System.arraycopy(buffer, 0, data, 0, len);
fis.close();
// data should be in utf, where the danish ae is -61 -90
assertEquals(5, data.length);
assertEquals(65, data[0]);
assertEquals(66, data[1]);
assertEquals(67, data[2]);
assertEquals(-61, data[3]);
assertEquals(-90, data[4]);
}
use of java.io.InputStream in project camel by apache.
the class FileProducerCharsetUTFOptimizedTest method testFileProducerCharsetUTFOptimized.
public void testFileProducerCharsetUTFOptimized() throws Exception {
oneExchangeDone.matchesMockWaitTime();
File file = new File("target/charset/output.txt");
assertTrue("File should exist", file.exists());
InputStream fis = IOHelper.buffered(new FileInputStream(file));
byte[] buffer = new byte[100];
int len = fis.read(buffer);
assertTrue("Should read data: " + len, len != -1);
byte[] data = new byte[len];
System.arraycopy(buffer, 0, data, 0, len);
fis.close();
// data should be in utf, where the danish ae is -61 -90
assertEquals(5, data.length);
assertEquals(65, data[0]);
assertEquals(66, data[1]);
assertEquals(67, data[2]);
assertEquals(-61, data[3]);
assertEquals(-90, data[4]);
}
use of java.io.InputStream in project camel by apache.
the class MockEndpointTest method testSetMultipleExpectedHeaders4.
public void testSetMultipleExpectedHeaders4() throws Exception {
// to test the header value with Stream which can only be consumed once
InputStream is = new ByteArrayInputStream("Test".getBytes());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedHeaderReceived("foo", 123);
mock.expectedHeaderReceived("bar", "Test");
Map<String, Object> map = new HashMap<String, Object>();
map.put("foo", 123);
map.put("bar", is);
template.sendBodyAndHeaders("direct:a", "Hello World", map);
mock.assertIsSatisfied();
}
use of java.io.InputStream in project camel by apache.
the class LogInputStreamTest method testB.
public void testB() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:b");
mock.expectedMessageCount(1);
mock.message(0).body().convertToString().isEqualTo("Hello World");
InputStream is = new ByteArrayInputStream("Hello World".getBytes());
template.sendBody("direct:b", is);
assertMockEndpointsSatisfied();
}
Aggregations