use of java.io.File in project camel by apache.
the class FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest method testUnmarshal.
@Test
public void testUnmarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:unmarshal");
// by default we get on big message
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(DataSetList.class);
mock.message(0).header("MyFirstHeader").isEqualTo("1");
mock.message(0).header("MySecondHeader").isEqualTo("2");
String data = IOConverter.toString(new File("src/test/data/headerandtrailer/PEOPLE-HeaderAndTrailer.txt"), null);
template.sendBody("direct:unmarshal", data);
assertMockEndpointsSatisfied();
DataSetList list = mock.getExchanges().get(0).getIn().getBody(DataSetList.class);
assertEquals(6, list.size());
// assert header
Map<?, ?> header = list.get(0);
assertEquals("HBT", header.get("INDICATOR"));
assertEquals("20080817", header.get("DATE"));
// assert data
Map<?, ?> row = list.get(1);
assertEquals("JOHN", row.get("FIRSTNAME"));
// assert trailer
Map<?, ?> trailer = list.get(5);
assertEquals("FBT", trailer.get("INDICATOR"));
assertEquals("SUCCESS", trailer.get("STATUS"));
}
use of java.io.File in project camel by apache.
the class FlinkProducerTest method shouldExecuteVoidCallback.
@Test
public void shouldExecuteVoidCallback() throws IOException {
final File output = File.createTempFile("camel", "flink");
output.delete();
template.sendBodyAndHeader(flinkDataSetUri, null, FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, new VoidDataSetCallback() {
@Override
public void doOnDataSet(DataSet ds, Object... payloads) {
ds.writeAsText(output.getAbsolutePath());
}
});
Truth.assertThat(output.length()).isAtLeast(0L);
}
use of java.io.File in project camel by apache.
the class FlinkProducerTest method shouldExecuteAnnotatedVoidCallback.
@Test
public void shouldExecuteAnnotatedVoidCallback() throws IOException {
final File output = File.createTempFile("camel", "flink");
output.delete();
DataSetCallback dataSetCallback = new AnnotatedDataSetCallback(new Object() {
@org.apache.camel.component.flink.annotations.DataSetCallback
void countLines(DataSet<String> textFile) {
textFile.writeAsText(output.getAbsolutePath());
}
});
template.sendBodyAndHeader(flinkDataSetUri, null, FlinkConstants.FLINK_DATASET_CALLBACK_HEADER, dataSetCallback);
Truth.assertThat(output.length()).isAtLeast(0L);
}
use of java.io.File in project camel by apache.
the class FlinkProducerTest method shouldExecuteVoidDataStreamCallback.
@Test
public void shouldExecuteVoidDataStreamCallback() throws IOException {
final File output = File.createTempFile("camel", "flink");
output.delete();
template.sendBodyAndHeader(flinkDataStreamUri, null, FlinkConstants.FLINK_DATASTREAM_CALLBACK_HEADER, new VoidDataStreamCallback() {
@Override
public void doOnDataStream(DataStream ds, Object... payloads) throws Exception {
ds.writeAsText(output.getAbsolutePath());
}
});
Truth.assertThat(output.length()).isAtLeast(0L);
}
use of java.io.File in project camel by apache.
the class FileToFtpTempFileNameTest method testFileToFtp.
@Test
public void testFileToFtp() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
template.sendBodyAndHeader("file:target/in", "Hello World", Exchange.FILE_NAME, "sub/hello.txt");
assertTrue(notify.matchesMockWaitTime());
File file = new File(FTP_ROOT_DIR + "/out/sub/hello.txt");
assertTrue("File should exists " + file, file.exists());
}
Aggregations