Search in sources :

Example 36 with ConstraintViolationException

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

Example 37 with ConstraintViolationException

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

Example 38 with ConstraintViolationException

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());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) ConstraintViolationException(javax.validation.ConstraintViolationException) EmbeddedAppLauncherImpl(org.apache.apex.engine.EmbeddedAppLauncherImpl) File(java.io.File) Test(org.junit.Test)

Example 39 with ConstraintViolationException

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

Example 40 with ConstraintViolationException

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