Search in sources :

Example 76 with ConstraintViolationException

use of javax.validation.ConstraintViolationException in project apex-malhar by apache.

the class ApplicationTest method testApplication.

@Test
@Ignore
public void testApplication() throws IOException, Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties-JdbcToJdbcApp.xml"));
        lma.prepareDAG(new JdbcToJdbcApp(), conf);
        LocalMode.Controller lc = lma.getController();
        // runs for 10 seconds and quits
        lc.run(50000);
    } 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 77 with ConstraintViolationException

use of javax.validation.ConstraintViolationException in project apex-malhar by apache.

the class JdbcPollerApplicationTest method testApplication.

@Test
public void testApplication() throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.store.databaseUrl", URL);
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.store.databaseDriver", DB_DRIVER);
        conf.setInt("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.partitionCount", 2);
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.key", "ACCOUNT_NO");
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.columnsExpression", "ACCOUNT_NO,NAME,AMOUNT");
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.prop.tableName", TABLE_NAME);
        conf.set("dt.application.PollJdbcToHDFSApp.operator.JdbcPoller.port.outputPort.attr.TUPLE_CLASS", "org.apache.apex.examples.JdbcIngest.PojoEvent");
        conf.set("dt.application.PollJdbcToHDFSApp.operator.Writer.filePath", OUTPUT_DIR_NAME);
        lma.prepareDAG(new JdbcPollerApplication(), conf);
        LocalMode.Controller lc = lma.getController();
        lc.runAsync();
        // wait for output files to roll
        Thread.sleep(45000);
        String[] extensions = { "dat.0", "tmp" };
        Collection<File> list = FileUtils.listFiles(new File(OUTPUT_DIR_NAME), extensions, false);
        int recordsCount = 0;
        for (File file : list) {
            recordsCount += FileUtils.readLines(file).size();
        }
        Assert.assertEquals("Records in file", 10, recordsCount);
    } 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)

Example 78 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.FilterExample.operator.selectedOutput.prop.filePath", outputDir);
        conf.set("dt.application.FilterExample.operator.rejectedOutput.prop.filePath", outputDir);
        final File selectedfile = FileUtils.getFile(outputDir, "selected.txt_8.0");
        final File rejectedfile = FileUtils.getFile(outputDir, "rejected.txt_6.0");
        lma.prepareDAG(new Application(), conf);
        LocalMode.Controller lc = lma.getController();
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                if (selectedfile.exists() && rejectedfile.exists()) {
                    return true;
                }
                return false;
            }
        });
    } 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) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) IOException(java.io.IOException) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 79 with ConstraintViolationException

use of javax.validation.ConstraintViolationException in project apex-malhar by apache.

the class JdbcPojoOperatorApplicationTest method testApplication.

@Test
public void testApplication() throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/JdbcProperties.xml"));
        lma.prepareDAG(new JdbcPojoOperatorApplication(), conf);
        LocalMode.Controller lc = lma.getController();
        lc.setHeartbeatMonitoringEnabled(false);
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return getNumOfRowsinTable(TABLE_POJO_NAME) == 10;
            }
        });
        // runs for 10 seconds and quits
        lc.run(10000);
        Assert.assertEquals("rows in db", 10, getNumOfRowsinTable(TABLE_POJO_NAME));
    } 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) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) SQLException(java.sql.SQLException) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 80 with ConstraintViolationException

use of javax.validation.ConstraintViolationException in project apex-malhar by apache.

the class JdbcInputOperatorApplicationTest method testApplication.

public void testApplication(StreamingApplication streamingApplication) throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/JdbcProperties.xml"));
        lma.prepareDAG(streamingApplication, conf);
        LocalMode.Controller lc = lma.getController();
        lc.setHeartbeatMonitoringEnabled(false);
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return TupleCount == 10;
            }
        });
        // runs for 10 seconds and quits
        lc.run(10000);
        Assert.assertEquals("rows in db", TupleCount, getNumOfRowsinTable(TABLE_POJO_NAME));
    } 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) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) SQLException(java.sql.SQLException) ConstraintViolationException(javax.validation.ConstraintViolationException)

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