Search in sources :

Example 1 with ComponentAnnotationLoader

use of org.xwiki.component.annotation.ComponentAnnotationLoader in project xwiki-platform by xwiki.

the class AbstractHttpTest method initializeSystem.

public static void initializeSystem() throws Exception {
    ComponentManager componentManager = new EmbeddableComponentManager();
    // Only load the minimal number of components required for the test framework, for both performance reasons
    // and for avoiding having to declare dependencies such as HttpServletRequest.
    ComponentAnnotationLoader loader = new ComponentAnnotationLoader();
    List<ComponentDeclaration> componentDeclarations = new ArrayList<>();
    componentDeclarations.add(new ComponentDeclaration(DefaultStringEntityReferenceResolver.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultStringEntityReferenceSerializer.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(RelativeStringEntityReferenceResolver.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultEntityReferenceProvider.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultModelConfiguration.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultSymbolScheme.class.getName()));
    loader.initialize(componentManager, AbstractTest.class.getClassLoader(), componentDeclarations);
    TestUtils.initializeComponent(componentManager);
}
Also used : AbstractTest(org.xwiki.test.ui.AbstractTest) ComponentDeclaration(org.xwiki.component.annotation.ComponentDeclaration) EmbeddableComponentManager(org.xwiki.component.embed.EmbeddableComponentManager) ComponentManager(org.xwiki.component.manager.ComponentManager) ArrayList(java.util.ArrayList) EmbeddableComponentManager(org.xwiki.component.embed.EmbeddableComponentManager) ComponentAnnotationLoader(org.xwiki.component.annotation.ComponentAnnotationLoader)

Example 2 with ComponentAnnotationLoader

use of org.xwiki.component.annotation.ComponentAnnotationLoader in project xwiki-platform by xwiki.

the class InstalledExtensionIndexTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    ComponentAnnotationLoader loader = new ComponentAnnotationLoader();
    List<ComponentDeclaration> componentDeclarations = new ArrayList<>();
    componentDeclarations.add(new ComponentDeclaration(ModelFactory.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(JAXBConverter.class.getName()));
    loader.initialize(AbstractTest.componentManager, AbstractTest.class.getClassLoader(), componentDeclarations);
    // Make sure extension utils is initialized and set.
    if (getExtensionTestUtils() == null) {
        AllTests.initExtensionTestUtils(context);
    }
}
Also used : AbstractTest(org.xwiki.test.ui.AbstractTest) ComponentDeclaration(org.xwiki.component.annotation.ComponentDeclaration) ArrayList(java.util.ArrayList) ComponentAnnotationLoader(org.xwiki.component.annotation.ComponentAnnotationLoader) BeforeClass(org.junit.BeforeClass)

Example 3 with ComponentAnnotationLoader

use of org.xwiki.component.annotation.ComponentAnnotationLoader in project xwiki-platform by xwiki.

the class XWikiMigrationManagerTest method registerComponent.

private void registerComponent(Class<?> klass) throws Exception {
    ComponentAnnotationLoader loader = new ComponentAnnotationLoader();
    List<ComponentDescriptor> descriptors = loader.getComponentsDescriptors(klass);
    for (ComponentDescriptor<?> descriptor : descriptors) {
        getComponentManager().registerComponent(descriptor);
    }
}
Also used : ComponentDescriptor(org.xwiki.component.descriptor.ComponentDescriptor) ComponentAnnotationLoader(org.xwiki.component.annotation.ComponentAnnotationLoader)

Example 4 with ComponentAnnotationLoader

use of org.xwiki.component.annotation.ComponentAnnotationLoader in project xwiki-platform by xwiki.

the class AbstractTest method initializeSystem.

/**
 * Used so that AllTests can set the persistent test context.
 */
public static void initializeSystem(PersistentTestContext context) throws Exception {
    AbstractTest.context = context;
    BaseElement.setContext(context);
    TestUtils.setContext(context);
    AbstractTest.componentManager = new EmbeddableComponentManager();
    // Only load the minimal number of components required for the test framework, for both performance reasons
    // and for avoiding having to declare dependencies such as HttpServletRequest.
    ComponentAnnotationLoader loader = new ComponentAnnotationLoader();
    List<ComponentDeclaration> componentDeclarations = new ArrayList<>();
    componentDeclarations.add(new ComponentDeclaration(DefaultStringEntityReferenceResolver.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultStringEntityReferenceSerializer.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(RelativeStringEntityReferenceResolver.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultEntityReferenceProvider.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultModelConfiguration.class.getName()));
    componentDeclarations.add(new ComponentDeclaration(DefaultSymbolScheme.class.getName()));
    loader.initialize(AbstractTest.componentManager, AbstractTest.class.getClassLoader(), componentDeclarations);
    TestUtils.initializeComponent(AbstractTest.componentManager);
}
Also used : ComponentDeclaration(org.xwiki.component.annotation.ComponentDeclaration) ArrayList(java.util.ArrayList) EmbeddableComponentManager(org.xwiki.component.embed.EmbeddableComponentManager) ComponentAnnotationLoader(org.xwiki.component.annotation.ComponentAnnotationLoader)

Aggregations

ComponentAnnotationLoader (org.xwiki.component.annotation.ComponentAnnotationLoader)4 ArrayList (java.util.ArrayList)3 ComponentDeclaration (org.xwiki.component.annotation.ComponentDeclaration)3 EmbeddableComponentManager (org.xwiki.component.embed.EmbeddableComponentManager)2 AbstractTest (org.xwiki.test.ui.AbstractTest)2 BeforeClass (org.junit.BeforeClass)1 ComponentDescriptor (org.xwiki.component.descriptor.ComponentDescriptor)1 ComponentManager (org.xwiki.component.manager.ComponentManager)1