use of com.datatorrent.api.LocalMode in project apex-core by apache.
the class OperatorContextTest method testInjectionOfOperatorName.
@Test
public void testInjectionOfOperatorName() throws Exception {
StreamingApplication application = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
dag.addOperator("input", new MockInputOperator());
}
};
LocalMode lma = LocalMode.newInstance();
lma.prepareDAG(application, new Configuration());
LocalMode.Controller lc = lma.getController();
lc.runAsync();
latch.await();
Assert.assertEquals("operator name", "input", operatorName);
lc.shutdown();
}
use of com.datatorrent.api.LocalMode in project apex-core by apache.
the class CustomControlTupleTest method testApp.
public void testApp(StreamingApplication app) throws Exception {
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
lma.prepareDAG(app, conf);
LocalMode.Controller lc = lma.getController();
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return endApp;
}
});
// runs for 20 seconds and quits if terminating condition not reached
lc.run(200000);
LOG.info("Control Tuples received {} expected {}", numControlTuples, controlIndex);
Assert.assertTrue("Incorrect Control Tuples", numControlTuples == controlIndex);
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of com.datatorrent.api.LocalMode in project apex-core by apache.
the class StramLocalClusterTest method testDynamicLoading.
@Test
public void testDynamicLoading() throws Exception {
String generatedJar = generatejar("POJO");
URLClassLoader uCl = URLClassLoader.newInstance(new URL[] { new File(generatedJar).toURI().toURL() });
Class<?> pojo = uCl.loadClass("POJO");
DynamicLoaderApp app = new DynamicLoaderApp();
app.generatedJar = generatedJar;
app.pojo = pojo;
LocalMode lma = LocalMode.newInstance();
lma.prepareDAG(app, new Configuration());
LocalMode.Controller lc = lma.getController();
lc.runAsync();
DynamicLoaderApp.latch.await();
Assert.assertTrue(DynamicLoaderApp.passed);
lc.shutdown();
}
use of com.datatorrent.api.LocalMode in project apex-core 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"));
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());
}
}
Aggregations