@Before
public void setup() throws ToolException {
annotationUtil = MaraAnnotationUtil.INSTANCE;
// Initialize our annotations handlers
Configuration conf = new Configuration();
this.job = mock(Job.class);
when(job.getConfiguration()).thenReturn(conf);
AnnotatedTool tool = mock(AnnotatedTool.class);
AnnotatedToolContext context = mock(AnnotatedToolContext.class);
when(tool.getContext()).thenReturn(context);
try {
Reflections reflections = new Reflections("com.conversantmedia.mapreduce.tool.annotation");
Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(Service.class);
for (Class<?> handlerClass : handlerClasses) {
if (MaraAnnotationHandler.class.isAssignableFrom(handlerClass)) {
MaraAnnotationHandler handler = (MaraAnnotationHandler) handlerClass.newInstance();
annotationUtil.registerAnnotationHandler(handler, tool);
}
}
} catch (InstantiationException | IllegalAccessException e) {
throw new ToolException(e);
}
}
JobAnnotationUtilTest.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:mara
作者:
评论列表
文章目录