use of java.io.BufferedReader in project camel by apache.
the class IOConverterCharsetTest method testToInputStreamFileWithCharsetLatin1.
public void testToInputStreamFileWithCharsetLatin1() throws Exception {
switchToDefaultCharset("UTF-8");
File file = new File("src/test/resources/org/apache/camel/converter/german.iso-8859-1.txt");
InputStream in = IOConverter.toInputStream(file, "ISO-8859-1");
// do read with default charset!
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
BufferedReader naiveReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "ISO-8859-1"));
try {
String line = reader.readLine();
String naiveLine = naiveReader.readLine();
assertEquals(naiveLine, line);
assertEquals(CONTENT, line);
} finally {
reader.close();
naiveReader.close();
}
}
use of java.io.BufferedReader in project camel by apache.
the class AbstractGoogleDriveTestSupport method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
final InputStream in = getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES);
if (in == null) {
throw new IOException(TEST_OPTIONS_PROPERTIES + " could not be found");
}
final StringBuilder builder = new StringBuilder();
final BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line).append(LINE_SEPARATOR);
}
propertyText = builder.toString();
final Properties properties = new Properties();
try {
properties.load(new StringReader(propertyText));
} catch (IOException e) {
throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), e);
}
//
// // cache test properties
// refreshToken = properties.getProperty(REFRESH_TOKEN_PROPERTY);
// testFolderId = properties.getProperty("testFolderId");
// testFileId = properties.getProperty("testFileId");
// testUserId = properties.getProperty("testUserId");
//
Map<String, Object> options = new HashMap<String, Object>();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
options.put(entry.getKey().toString(), entry.getValue());
}
final GoogleDriveConfiguration configuration = new GoogleDriveConfiguration();
IntrospectionSupport.setProperties(configuration, options);
// add GoogleDriveComponent to Camel context
final CamelContext context = super.createCamelContext();
final GoogleDriveComponent component = new GoogleDriveComponent(context);
component.setConfiguration(configuration);
context.addComponent("google-drive", component);
return context;
}
use of java.io.BufferedReader in project camel by apache.
the class HdfsProducerSplitTest method doTest.
private void doTest(int routeNr) throws Exception {
if (!canTest()) {
return;
}
for (int i = 0; i < 10; ++i) {
template.sendBody("direct:start" + routeNr, "CIAO" + i);
}
stopCamelContext();
FileSystem fs = FileSystem.get(new Configuration());
FileStatus[] status = fs.listStatus(new Path("file:///" + BASE_FILE.toUri() + routeNr));
assertEquals(10, status.length);
for (FileStatus fileStatus : status) {
BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(fileStatus.getPath())));
assertTrue(br.readLine().startsWith("CIAO"));
assertNull(br.readLine());
}
}
use of java.io.BufferedReader in project camel by apache.
the class HL7MLLPCodecBoundaryTest method testSendHL7Message.
@Test
public void testSendHL7Message() throws Exception {
BufferedReader in = IOHelper.buffered(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02-1022.txt")));
String line = "";
String message = "";
while (line != null) {
if ((line = in.readLine()) != null) {
message += line + "\r";
}
}
message = message.substring(0, message.length() - 1);
assertEquals(1022, message.length());
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedMessageCount(1);
template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", message);
mockEndpoint.assertIsSatisfied();
}
use of java.io.BufferedReader in project camel by apache.
the class HL7MLLPNettyCodecBoundaryTest method testSendHL7Message.
@Test
public void testSendHL7Message() throws Exception {
BufferedReader in = IOHelper.buffered(new InputStreamReader(getClass().getResourceAsStream("/mdm_t02-1022.txt")));
String line = "";
String message = "";
while (line != null) {
if ((line = in.readLine()) != null) {
message += line + "\r";
}
}
message = message.substring(0, message.length() - 1);
assertEquals(1022, message.length());
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedMessageCount(1);
template.requestBody("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder", message);
mockEndpoint.assertIsSatisfied();
}
Aggregations