use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class FilterAppTest method testFilterApplication.
@Test
public void testFilterApplication() throws Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
lma.prepareDAG(new Application(), 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 XmlParserApplicationTest method testApplication.
@Test
public void testApplication() {
try {
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
XmlDataEmitterOperator input = dag.addOperator("data", new XmlDataEmitterOperator());
XmlParser parser = dag.addOperator("xmlparser", new XmlParser());
ResultCollector rc = dag.addOperator("rc", new ResultCollector());
dag.getMeta(parser).getMeta(parser.out).getAttributes().put(Context.PortContext.TUPLE_CLASS, org.apache.apex.malhar.lib.parser.XmlParserTest.EmployeeBean.class);
ConsoleOutputOperator xmlObjectOp = dag.addOperator("xmlObjectOp", new ConsoleOutputOperator());
xmlObjectOp.setDebug(true);
dag.addStream("input", input.output, parser.in);
dag.addStream("output", parser.parsedOutput, xmlObjectOp.input);
dag.addStream("pojo", parser.out, rc.input);
LocalMode.Controller lc = lma.getController();
lc.setHeartbeatMonitoringEnabled(false);
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return TupleCount == 1;
}
});
// runs for 10 seconds and quits
lc.run(10000);
Assert.assertEquals(1, TupleCount);
Assert.assertEquals("john", obj.getName());
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class AbstractFileOutputOperatorTest method validateNegativeMaxLengthTest.
@Test
public void validateNegativeMaxLengthTest() {
ValidationTestApp validationTestApp = new ValidationTestApp(new File(testMeta.getDir()), -1L, new SingleHDFSByteExactlyOnceWriter());
boolean error = false;
try {
LocalMode.runApp(validationTestApp, 1);
} catch (RuntimeException e) {
if (e.getCause() instanceof ConstraintViolationException) {
error = true;
}
}
Assert.assertEquals("Max length validation not thrown with -1 max length", true, error);
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class CsvFormatterTest method testApplication.
@Test
public void testApplication() throws IOException, Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
lma.prepareDAG(new CsvParserApplication(), conf);
LocalMode.Controller lc = lma.getController();
// runs for 5 seconds and quits
lc.run(5000);
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of javax.validation.ConstraintViolationException in project apex-malhar by apache.
the class ApplicationTest method testApplication.
@Test
public void testApplication() throws IOException, Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
conf.set("dt.application.RecordReaderExample.operator.fileOutput.prop.filePath", outputDir);
File outputfile = FileUtils.getFile(outputDir, "output.txt_5.0");
lma.prepareDAG(new Application(), conf);
LocalMode.Controller lc = lma.getController();
lc.runAsync();
// wait for tuples to show up
while (!outputfile.exists()) {
Thread.sleep(1000);
}
lc.shutdown();
Assert.assertTrue(FileUtils.contentEquals(FileUtils.getFile(conf.get("dt.application.RecordReaderExample.operator.recordReader.prop.files")), outputfile));
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
Aggregations