use of org.voltdb.importer.formatter.Formatter in project voltdb by VoltDB.
the class TestVoltCSVFormatter method testNowhitespace.
@Test
public void testNowhitespace() throws Exception {
ServiceReference[] refs = m_bundle.getRegisteredServices();
ServiceReference<AbstractFormatterFactory> reference = refs[0];
AbstractFormatterFactory o = m_bundle.getBundleContext().getService(reference);
Properties prop = new Properties();
prop.setProperty("nowhitespace", "true");
FormatterBuilder builder = new FormatterBuilder("csv", prop);
builder.setFormatterFactory(o);
Formatter formatter = builder.create();
try {
Object[] results = formatter.transform(ByteBuffer.wrap("12,10.05, test".getBytes(StandardCharsets.UTF_8)));
fail();
} catch (RuntimeException e) {
}
}
use of org.voltdb.importer.formatter.Formatter in project voltdb by VoltDB.
the class TestVoltCSVFormatter method testCustomNull.
@Test
public void testCustomNull() throws Exception {
ServiceReference[] refs = m_bundle.getRegisteredServices();
ServiceReference<AbstractFormatterFactory> reference = refs[0];
AbstractFormatterFactory o = m_bundle.getBundleContext().getService(reference);
Properties prop = new Properties();
prop.setProperty("separator", ",");
prop.setProperty("nullstring", "empty");
FormatterBuilder builder = new FormatterBuilder("csv", prop);
builder.setFormatterFactory(o);
Formatter formatter = builder.create();
Object[] results = formatter.transform(ByteBuffer.wrap("12,empty,test".getBytes(StandardCharsets.UTF_8)));
assertEquals(results.length, 3);
assertEquals(results[0], "12");
assertEquals(results[1], null);
assertEquals(results[2], "test");
}
use of org.voltdb.importer.formatter.Formatter in project voltdb by VoltDB.
the class TestVoltCSVFormatter method testTSVBundle.
@Test
public void testTSVBundle() throws Exception {
ServiceReference[] refs = m_bundle.getRegisteredServices();
ServiceReference<AbstractFormatterFactory> reference = refs[0];
AbstractFormatterFactory o = m_bundle.getBundleContext().getService(reference);
Properties prop = new Properties();
FormatterBuilder builder = new FormatterBuilder("tsv", prop);
builder.setFormatterFactory(o);
Formatter formatter = builder.create();
Object[] results = formatter.transform(ByteBuffer.wrap("12\t10.05\ttest".getBytes(StandardCharsets.UTF_8)));
assertEquals(results.length, 3);
assertEquals(results[0], "12");
assertEquals(results[1], "10.05");
assertEquals(results[2], "test");
}
use of org.voltdb.importer.formatter.Formatter in project voltdb by VoltDB.
the class TestVoltCSVFormatter method testEscape.
@Test
public void testEscape() throws Exception {
ServiceReference[] refs = m_bundle.getRegisteredServices();
ServiceReference<AbstractFormatterFactory> reference = refs[0];
AbstractFormatterFactory o = m_bundle.getBundleContext().getService(reference);
Properties prop = new Properties();
prop.setProperty("escape", "|");
FormatterBuilder builder = new FormatterBuilder("csv", prop);
builder.setFormatterFactory(o);
Formatter formatter = builder.create();
Object[] results = formatter.transform(ByteBuffer.wrap("12,\"10.05,|\"test|\"\"".getBytes(StandardCharsets.UTF_8)));
assertEquals(results.length, 2);
assertEquals(results[0], "12");
assertEquals(results[1], "10.05,\"test\"");
}
use of org.voltdb.importer.formatter.Formatter in project voltdb by VoltDB.
the class TestVoltCSVFormatter method testCSVBundle.
@Test
public void testCSVBundle() throws Exception {
ServiceReference[] refs = m_bundle.getRegisteredServices();
ServiceReference<AbstractFormatterFactory> reference = refs[0];
AbstractFormatterFactory o = m_bundle.getBundleContext().getService(reference);
Properties prop = new Properties();
FormatterBuilder builder = new FormatterBuilder("csv", prop);
builder.setFormatterFactory(o);
Formatter formatter = builder.create();
Object[] results = formatter.transform(ByteBuffer.wrap("12,10.05,test".getBytes(StandardCharsets.UTF_8)));
assertEquals(results.length, 3);
assertEquals(results[0], "12");
assertEquals(results[1], "10.05");
assertEquals(results[2], "test");
}
Aggregations