use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class AvroFileInputOperatorTest method testApplicationWithPojoConversion.
@Test
public void testApplicationWithPojoConversion() throws IOException, Exception {
try {
FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
int cnt = 7;
createAvroInput(cnt);
writeAvroFile(new File(FILENAME));
createAvroInput(cnt - 2);
writeAvroFile(new File(OTHER_FILE));
avroFileInput.setDirectory(testMeta.dir);
AvroToPojo avroToPojo = new AvroToPojo();
avroToPojo.setPojoClass(SimpleOrder.class);
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
AvroToPojoApplication avroToPojoApplication = new AvroToPojoApplication();
avroToPojoApplication.setAvroFileInputOperator(avroFileInput);
avroToPojoApplication.setAvroToPojo(avroToPojo);
lma.prepareDAG(avroToPojoApplication, conf);
LocalMode.Controller lc = lma.getController();
// runs for 10 seconds and quits
lc.run(10000);
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class AvroFileInputOperatorTest method testApplication.
@Test
public void testApplication() throws IOException, Exception {
try {
FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
int cnt = 7;
createAvroInput(cnt);
writeAvroFile(new File(FILENAME));
createAvroInput(cnt - 2);
writeAvroFile(new File(OTHER_FILE));
avroFileInput.setDirectory(testMeta.dir);
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
AvroReaderApplication avroReaderApplication = new AvroReaderApplication();
avroReaderApplication.setAvroFileInputOperator(avroFileInput);
lma.prepareDAG(avroReaderApplication, conf);
LocalMode.Controller lc = lma.getController();
// runs for 10 seconds and quits
lc.run(10000);
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class AvroFileToPojoModuleTest method testAvroToPojoModule.
@Test
public void testAvroToPojoModule() throws Exception {
try {
FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
int cnt = 7;
createAvroInput(cnt);
writeAvroFile(new File(FILENAME));
createAvroInput(cnt - 2);
writeAvroFile(new File(OTHER_FILE));
avroFileToPojoModule.setAvroFileDirectory(testMeta.dir);
avroFileToPojoModule.setPojoClass(SimpleOrder.class);
AvroToPojo avroToPojo = new AvroToPojo();
avroToPojo.setPojoClass(SimpleOrder.class);
EmbeddedAppLauncherImpl lma = new EmbeddedAppLauncherImpl();
Configuration conf = new Configuration(false);
AvroToPojoApplication avroToPojoApplication = new AvroToPojoApplication();
avroToPojoApplication.setAvroFileToPojoModule(avroFileToPojoModule);
lma.prepareDAG(avroToPojoApplication, conf);
EmbeddedAppLauncherImpl.Controller lc = lma.getController();
// runs for 10 seconds and quits
lc.run(10000);
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class RegexParserApplicationTest method testApplication.
@Test
public void testApplication() throws IOException, Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/properties-regexParserApplication.xml"));
conf.setLong("dt.application.RegexParser.operator.logGenerator.prop.tupleRate", 10);
final String dataFolderPath = conf.get("dt.application.RegexParser.operator.*.prop.filePath");
final String dataFileName = conf.get("dt.application.RegexParser.operator.regexWriter.prop.outputFileName");
FileUtils.deleteDirectory(new File(dataFolderPath));
lma.prepareDAG(new RegexParserApplication(), conf);
LocalMode.Controller lc = lma.getController();
lc.setHeartbeatMonitoringEnabled(false);
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
if (new File(dataFolderPath).exists()) {
Collection<File> files = FileUtils.listFiles(new File(dataFolderPath), new WildcardFileFilter(dataFileName + "*"), null);
if (files.size() >= 1) {
File parsedFile = files.iterator().next();
String fileData = FileUtils.readFileToString(parsedFile);
String[] regexData = fileData.split("\n");
return regexData.length == 10;
}
}
return false;
}
});
// runs for 30 seconds and quitxs
lc.run(30 * 1000);
Collection<File> files = FileUtils.listFiles(new File(dataFolderPath), new WildcardFileFilter(dataFileName + "*"), null);
File parsedFile = files.iterator().next();
String fileData = FileUtils.readFileToString(parsedFile);
String[] logData = fileData.split("\n");
for (String logLine : logData) {
Assert.assertTrue(logLine.contains("id=" + 101));
Assert.assertTrue(logLine.contains("signInId=" + "'11111@psop.com'"));
Assert.assertTrue(logLine.contains("serviceId=" + "'IP1234-NPB12345_00'"));
Assert.assertTrue(logLine.contains("accountId=" + "'11111'"));
Assert.assertTrue(logLine.contains("platform=" + "'pik'"));
}
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class JdbcIOAppTest method testApplication.
@Test
public void testApplication() throws Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
lma.prepareDAG(new JdbcIOApp(), conf);
LocalMode.Controller lc = lma.getController();
lc.runAsync();
// wait for records to be added to table
Thread.sleep(3000);
lc.shutdown();
Assert.assertEquals("Events in store", 10, getNumOfEventsInStore());
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
Aggregations