use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.
the class TopWikipediaSessionsTest method TopWikipediaSessionsTest.
@Test
public void TopWikipediaSessionsTest() throws Exception {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.set("dt.application.TopWikipediaSessions.operator.console.silent", "true");
lma.prepareDAG(new TopWikipediaSessions(), conf);
LocalMode.Controller lc = lma.getController();
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return TopWikipediaSessions.SessionGen.getTupleCount() >= 250;
}
});
lc.run(30000);
for (int i = 0; i < TopWikipediaSessions.Collector.getResult().size(); i++) {
Assert.assertTrue(isInOrder(TopWikipediaSessions.Collector.getResult().get(i)));
}
}
use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.
the class DeDupExampleTest method DeDupExampleTest.
@Test
public void DeDupExampleTest() throws Exception {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.set("dt.application.DeDupExample.operator.console.silent", "true");
DeDupExample app = new DeDupExample();
lma.prepareDAG(app, conf);
LocalMode.Controller lc = lma.getController();
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return DeDupExample.Collector.isDone();
}
});
lc.run(50000);
Assert.assertEquals(9, DeDupExample.Collector.getResult().getValue().size());
}
use of com.datatorrent.stram.StramLocalCluster 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());
}
}
use of com.datatorrent.stram.StramLocalCluster 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());
}
}
use of com.datatorrent.stram.StramLocalCluster 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());
}
}
Aggregations