Search in sources :

Example 41 with ConstraintViolationException

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());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) StreamingApplication(com.datatorrent.api.StreamingApplication) Test(org.junit.Test)

Example 42 with ConstraintViolationException

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());
    }
}
Also used : DAG(com.datatorrent.api.DAG) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) ConstraintViolationException(javax.validation.ConstraintViolationException) ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 43 with ConstraintViolationException

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);
}
Also used : ConstraintViolationException(javax.validation.ConstraintViolationException) File(java.io.File) Test(org.junit.Test)

Example 44 with ConstraintViolationException

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());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 45 with ConstraintViolationException

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());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) File(java.io.File) Test(org.junit.Test)

Aggregations

ConstraintViolationException (javax.validation.ConstraintViolationException)87 Test (org.junit.Test)67 LocalMode (com.datatorrent.api.LocalMode)35 Configuration (org.apache.hadoop.conf.Configuration)34 File (java.io.File)16 ConstraintViolation (javax.validation.ConstraintViolation)15 Session (org.hibernate.Session)11 Transaction (org.hibernate.Transaction)11 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)9 Map (java.util.Map)9 BigDecimal (java.math.BigDecimal)7 HashMap (java.util.HashMap)7 Set (java.util.Set)6 StramLocalCluster (com.datatorrent.stram.StramLocalCluster)5 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)5 HashSet (java.util.HashSet)5 ValidationException (javax.validation.ValidationException)5 Validator (javax.validation.Validator)5 Response (javax.ws.rs.core.Response)5 Path (org.apache.hadoop.fs.Path)5