use of org.apache.samza.testUtils.TestStreamTask in project samza by apache.
the class TestTaskFactoryUtil method testStreamTaskClassWithInvalidStreamApplication.
@Test
public void testStreamTaskClassWithInvalidStreamApplication() throws Exception {
Config config = new MapConfig(new HashMap<String, String>() {
{
this.put(ApplicationConfig.APP_CLASS, "org.apache.samza.testUtils.InvalidStreamApplication");
}
});
try {
TaskFactoryUtil.createStreamApplication(config);
fail("Should have failed w/ no.such.class");
} catch (ConfigException ce) {
// expected
}
config = new MapConfig(new HashMap<String, String>() {
{
this.put("task.class", "org.apache.samza.testUtils.TestStreamTask");
this.put(ApplicationConfig.APP_CLASS, "");
}
});
StreamApplication streamApp = TaskFactoryUtil.createStreamApplication(config);
Object retFactory = TaskFactoryUtil.createTaskFactory(config, streamApp, mockRunner);
assertTrue(retFactory instanceof StreamTaskFactory);
assertTrue(((StreamTaskFactory) retFactory).createInstance() instanceof TestStreamTask);
config = new MapConfig(new HashMap<String, String>() {
{
this.put("task.class", "");
this.put(ApplicationConfig.APP_CLASS, "org.apache.samza.testUtils.InvalidStreamApplication");
}
});
try {
TaskFactoryUtil.createStreamApplication(config);
fail("Should have failed w/ no class not found");
} catch (ConfigException cne) {
// expected
}
}
use of org.apache.samza.testUtils.TestStreamTask in project samza by apache.
the class TestTaskFactoryUtil method testStreamTaskClass.
@Test
public void testStreamTaskClass() {
Config config = new MapConfig(new HashMap<String, String>() {
{
this.put("task.class", "org.apache.samza.testUtils.TestStreamTask");
}
});
Object retFactory = TaskFactoryUtil.createTaskFactory(config, null, null);
assertTrue(retFactory instanceof StreamTaskFactory);
assertTrue(((StreamTaskFactory) retFactory).createInstance() instanceof TestStreamTask);
config = new MapConfig(new HashMap<String, String>() {
{
this.put("task.class", "no.such.class");
}
});
try {
TaskFactoryUtil.createTaskFactory(config, null, null);
fail("Should have failed w/ no.such.class");
} catch (ConfigException cfe) {
// expected
}
}
Aggregations