Package org.impalaframework.module

Examples of org.impalaframework.module.RootModuleDefinition


import junit.framework.TestCase;

public class RepairModificationExtractorTest extends TestCase {

    public void testGetTransitions() {
        RootModuleDefinition definition = ModificationTestUtils.spec("app-context1.xml", "plugin1, plugin2, plugin3, plugin4");
        ModuleDefinition plugin1 = definition.findChildDefinition("plugin1", true);
        plugin1.setState(ModuleState.ERROR);
        definition.findChildDefinition("plugin3", true).setState(ModuleState.DEPENDENCY_FAILED);
        definition.findChildDefinition("plugin4", true).setState(ModuleState.DEPENDENCY_FAILED);
       
        Application application = TestApplicationManager.newApplicationManager().getCurrentApplication();
       
        TransitionSet transitions = new RepairModificationExtractor().getTransitions(application, definition, null);
        assertEquals(definition, transitions.getNewRootModuleDefinition());
View Full Code Here


    static RootModuleDefinition spec(String contextString, String definitionString) {
        String[] locations = contextString.split(",");
        SingleStringModuleDefinitionSource builder = new SingleStringModuleDefinitionSource(new SimpleRootModuleDefinition("project1", locations),
                definitionString);
        RootModuleDefinition rootModuleDefinition = builder.getModuleDefinition();
        return rootModuleDefinition;
    }
View Full Code Here

        transitionManager.setTransitionProcessorRegistry(transitionProcessors);
    }
   
    public void testLoadRoot() {
       
        RootModuleDefinition rootModuleDefinition = newTest1().getModuleDefinition();
        rootModuleDefinition.freeze();
       
        ModuleStateChange moduleStateChange = new ModuleStateChange(Transition.UNLOADED_TO_LOADED, rootModuleDefinition);
       
        //expectations (round 1 - loading of parent)
        expect(moduleRuntimeManager.initModule(application, rootModuleDefinition)).andReturn(true);
View Full Code Here

        transitionManager.setTransitionProcessorRegistry(transitionProcessors);    

        ApplicationManager applicationManager = TestApplicationManager.newApplicationManager(new ModuleClassLoaderRegistry(), moduleStateHolder, new DelegatingServiceRegistry());
        Application application = applicationManager.getCurrentApplication();
       
        RootModuleDefinition test1Definition = newTest1().getModuleDefinition();
        ModificationExtractor calculator = new StrictModificationExtractor();
        TransitionSet transitions = calculator.getTransitions(application, null, test1Definition);
       
        transitionManager.processTransitions(moduleStateHolder, application, transitions);

        ConfigurableApplicationContext context = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        service((FileMonitor) context.getBean("bean1"));
        noService((FileMonitor) context.getBean("bean3"));

        RootModuleDefinition test2Definition = newTest2().getModuleDefinition();
        transitions = calculator.getTransitions(application, test1Definition, test2Definition);
        transitionManager.processTransitions(moduleStateHolder, application, transitions);

        context = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        service((FileMonitor) context.getBean("bean1"));
View Full Code Here

        // check that all three modules have loaded
        assertEquals(4, moduleStateHolder.getRuntimeModules().size());
    }

    private void addModule(ModuleDefinitionSource source) {
        RootModuleDefinition moduleDefinition = source.getModuleDefinition();
        addModule(moduleDefinition);
    }
View Full Code Here

}

class ModuleDefinitionWithParent implements ModuleDefinitionSource {

    public RootModuleDefinition getModuleDefinition() {
        final RootModuleDefinition moduleDefinition = new InternalModuleDefinitionSource(
                TypeReaderRegistryFactory.getTypeReaderRegistry(),
                Impala.getFacade().getModuleManagementFacade().getModuleLocationResolver(),
                new String[] { "impala-core", "sample-module4", "sample-module5" }).getModuleDefinition();
       
        final SimpleModuleDefinition childDefinition = (SimpleModuleDefinition) moduleDefinition.findChildDefinition("sample-module5", true);
       
        new SimpleModuleDefinition(
                childDefinition,
                "sample-module6",
                ModuleTypes.APPLICATION,
View Full Code Here

    public void testEmptyString() {
        SimpleRootModuleDefinition rootDefinition = new SimpleRootModuleDefinition(rootModuleName , new String[] { "parent-context" });
        String moduleString = "";
        SingleStringModuleDefinitionSource builder = new SingleStringModuleDefinitionSource(rootDefinition, moduleString);
        RootModuleDefinition result = builder.getModuleDefinition();
        assertSame(result, rootDefinition);
    }
View Full Code Here

   
    public void testModuleWithoutBeanSpec() {
        SimpleRootModuleDefinition rootDefinition = new SimpleRootModuleDefinition(rootModuleName, new String[] { "parent-context" });
        String moduleString = " example-hibernate , example-dao ";
        SingleStringModuleDefinitionSource builder = new SingleStringModuleDefinitionSource(rootDefinition, moduleString);
        RootModuleDefinition result = builder.getModuleDefinition();
        assertSame(result, rootDefinition);
        assertEquals(2, rootDefinition.getChildModuleNames().size());
        System.out.println(rootDefinition.getChildModuleNames());
        assertNotNull(result.getChildModuleDefinition("example-hibernate"));
        assertNotNull(result.getChildModuleDefinition("example-dao"));
    }
View Full Code Here

       
        TypeReaderRegistry typeReaderRegistry = TypeReaderRegistryFactory.getTypeReaderRegistry();
        ModuleLocationResolver resolver = new StandaloneModuleLocationResolver();
        InternalModuleDefinitionSource source = new InternalModuleDefinitionSource(typeReaderRegistry, resolver, new String[]{"impala-core", "sample-module4", "sample-module6"});

        RootModuleDefinition rootDefinition = source.getModuleDefinition();
       
        DependencyManager dependencyManager = new DependencyManager(rootDefinition);
        GraphClassLoaderFactory factory = new GraphClassLoaderFactory();
        factory.setModuleLocationResolver(resolver);
       
        GraphClassLoader rootClassLoader = factory.newClassLoader(classLoaderRegistry, dependencyManager, rootDefinition);
       
        System.out.println(rootClassLoader);
        String lineSeparator = System.getProperty("line.separator");
       
        assertEquals("Class loader for impala-core" + lineSeparator +
                "Options: ClassLoaderOptions [parentLoaderFirst=true, supportsModuleLibraries=true, exportsModuleLibraries=true, loadsModuleLibraryResources=true]" + lineSeparator, rootClassLoader.toString());
       
        ModuleDefinition moduleDefinition6 = rootDefinition.findChildDefinition("sample-module6", true);
       
        GraphClassLoader definition6Loader = factory.newClassLoader(classLoaderRegistry, dependencyManager, moduleDefinition6);
        System.out.println(definition6Loader);
       
        assertEquals(
View Full Code Here

import junit.framework.TestCase;

public class ModuleDefinitionToStringTest extends TestCase {

    public void testToString() throws Exception {
        RootModuleDefinition definition = new SimpleRootModuleDefinition("project1", new String[] { "location1.xml",
                "location2.xml" });
        SimpleModuleDefinition module1 = new SimpleModuleDefinition(definition, "module1");
        new SimpleModuleDefinition(definition, "module2", new String[] {
                "module2-1.xml", "module1-2.xml" });
        new SimpleModuleDefinition(definition, "module3", new String[] {
                "module3-1.xml", "module3-2.xml"});
       
        new SimpleModuleDefinition(module1, "module4");
        new SimpleModuleDefinition(module1, "module5");
       
        String output = definition.toString();
        System.out.println(output);
       
        String lineSeparator = System.getProperty("line.separator");
        String expected =
        "name=project1, configLocations=[location1.xml, location2.xml], type=ROOT, reloadable=true, dependencies=[], runtime=spring" + lineSeparator +
View Full Code Here

TOP

Related Classes of org.impalaframework.module.RootModuleDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.