use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsProducerTest method testProducer.
@Test
public void testProducer() throws Exception {
if (!canTest()) {
return;
}
template.sendBody("direct:start1", "PAPPO");
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel1");
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(file1));
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
assertEquals("PAPPO", value.toString());
IOHelper.close(reader);
}
use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsProducerTest method testWriteBoolean.
@Test
public void testWriteBoolean() throws Exception {
if (!canTest()) {
return;
}
Boolean aBoolean = true;
template.sendBody("direct:write_boolean", aBoolean);
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-boolean");
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(file1));
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
Boolean rBoolean = ((BooleanWritable) value).get();
assertEquals(rBoolean, aBoolean);
IOHelper.close(reader);
}
use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsProducerTest method testMapWriteTextWithKey.
@Test
public void testMapWriteTextWithKey() throws Exception {
if (!canTest()) {
return;
}
String txtKey = "THEKEY";
String txtValue = "CIAO MONDO !";
template.sendBodyAndHeader("direct:write_text3", txtValue, "KEY", txtKey);
Configuration conf = new Configuration();
MapFile.Reader reader = new MapFile.Reader(new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-text3"), conf);
Text key = (Text) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Text value = (Text) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
assertEquals(key.toString(), txtKey);
assertEquals(value.toString(), txtValue);
IOHelper.close(reader);
}
use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsProducerTest method testWriteFloat.
@Test
public void testWriteFloat() throws Exception {
if (!canTest()) {
return;
}
float aFloat = 12.34f;
template.sendBody("direct:write_float", aFloat);
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-float");
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(file1));
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
float rFloat = ((FloatWritable) value).get();
assertEquals(rFloat, aFloat, 0.0F);
IOHelper.close(reader);
}
use of org.apache.hadoop.conf.Configuration in project camel by apache.
the class HdfsProducerTest method testWriteDouble.
@Test
public void testWriteDouble() throws Exception {
if (!canTest()) {
return;
}
Double aDouble = 12.34D;
template.sendBody("direct:write_double", aDouble);
Configuration conf = new Configuration();
Path file1 = new Path("file:///" + TEMP_DIR.toUri() + "/test-camel-double");
SequenceFile.Reader reader = new SequenceFile.Reader(conf, SequenceFile.Reader.file(file1));
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
reader.next(key, value);
Double rDouble = ((DoubleWritable) value).get();
assertEquals(rDouble, aDouble);
IOHelper.close(reader);
}
Aggregations