Search in sources :

Example 1 with PlexusAnnotatedBeanModule

use of org.sonatype.guice.plexus.binders.PlexusAnnotatedBeanModule in project pom-manipulation-ext by release-engineering.

the class PlexusTestRunner method createTest.

@Override
protected Object createTest() throws Exception {
    final TestClass testClass = getTestClass();
    final DefaultContainerConfiguration config = new DefaultContainerConfiguration();
    config.setAutoWiring(true);
    config.setClassPathScanning(PlexusConstants.SCANNING_ON);
    config.setComponentVisibility(PlexusConstants.GLOBAL_VISIBILITY);
    config.setName(testClass.getName());
    final DefaultPlexusContainer container = new DefaultPlexusContainer(config);
    final ClassSpace cs = new URLClassSpace(Thread.currentThread().getContextClassLoader());
    container.addPlexusInjector(Arrays.<PlexusBeanModule>asList(new PlexusAnnotatedBeanModule(cs, Collections.emptyMap())));
    return container.lookup(testClass.getJavaClass());
}
Also used : DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ClassSpace(org.sonatype.guice.bean.reflect.ClassSpace) URLClassSpace(org.sonatype.guice.bean.reflect.URLClassSpace) TestClass(org.junit.runners.model.TestClass) URLClassSpace(org.sonatype.guice.bean.reflect.URLClassSpace) PlexusAnnotatedBeanModule(org.sonatype.guice.plexus.binders.PlexusAnnotatedBeanModule)

Aggregations

DefaultContainerConfiguration (org.codehaus.plexus.DefaultContainerConfiguration)1 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)1 TestClass (org.junit.runners.model.TestClass)1 ClassSpace (org.sonatype.guice.bean.reflect.ClassSpace)1 URLClassSpace (org.sonatype.guice.bean.reflect.URLClassSpace)1 PlexusAnnotatedBeanModule (org.sonatype.guice.plexus.binders.PlexusAnnotatedBeanModule)1