Search in sources :

Example 1 with AnnotationProcessor

use of org.hotswap.agent.annotation.handler.AnnotationProcessor in project HotswapAgent by HotswapProjects.

the class AnnotationProcessorTest method testProcess.

@Test
public void testProcess() throws Exception {
    context.checking(new Expectations() {

        {
            allowing(pluginManager).getHotswapTransformer();
            will(returnValue(hotswapTransformer));
            // two @Init annotations in SimplePlugin
            exactly(2).of(initHandler).initMethod(with(any(PluginAnnotation.class)));
            will(returnValue(true));
            // @OnClassLoadEvent
            exactly(1).of(onClassLoadedHandler).initMethod(with(any(PluginAnnotation.class)));
            will(returnValue(true));
        // Not satisfied, because invoked via reflection
        // oneOf(simplePlugin).initPlugin();
        // oneOf(simplePlugin).initPlugin(pluginManager);
        }
    });
    final AnnotationProcessor annotationProcessor = new AnnotationProcessor(pluginManager);
    annotationProcessor.addAnnotationHandler(Init.class, initHandler);
    annotationProcessor.addAnnotationHandler(OnClassLoadEvent.class, onClassLoadedHandler);
    annotationProcessor.processAnnotations(new SimplePlugin());
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) SimplePlugin(org.hotswap.agent.testData.SimplePlugin) AnnotationProcessor(org.hotswap.agent.annotation.handler.AnnotationProcessor) PluginAnnotation(org.hotswap.agent.annotation.handler.PluginAnnotation) Test(org.junit.Test)

Aggregations

AnnotationProcessor (org.hotswap.agent.annotation.handler.AnnotationProcessor)1 PluginAnnotation (org.hotswap.agent.annotation.handler.PluginAnnotation)1 SimplePlugin (org.hotswap.agent.testData.SimplePlugin)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1