Package org.apache.hivemind

Examples of org.apache.hivemind.SymbolExpander


        {
            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
            {
                List symbolSources = (List) context.getConfiguration("SymbolSources");

                SymbolExpander result = new SymbolExpanderImpl(errorHandler, symbolSources);
                return result;
            }
        };
        helper.addServiceImplementation(spd, constructor, ServiceModel.PRIMITIVE);
       
View Full Code Here


       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();

        ElementModelImpl em = new ElementModelImpl("module");

        em.setElementName("fred");
        em.setContentTranslator("smart");

        em.addRule(new CreateObjectRule(StringHolderImpl.class.getName()));

        ReadContentRule rule = new ReadContentRule();
        rule.setPropertyName("value");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));

        SchemaImpl schema = new SchemaImpl("module");
        schema.addElementModel(em);

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

        ElementImpl element = new ElementImpl();
        element.setElementName("fred");
        element.setContent("flintstone");

        List elements = Collections.singletonList(element);
       
        m.getRegistry();
        control.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m);

        m.resolveType("hivemind.test.services.impl.StringHolderImpl");
        control.setReturnValue(StringHolderImpl.class);

        m.getService(SymbolExpander.class);
        control.setReturnValue(symbolExpander);

        symbolExpander.expandSymbols("flintstone", null);
        symbolExpanderControl.setReturnValue("flintstone");
       
        m.getService(TranslatorManager.class);
        control.setReturnValue(tm);
View Full Code Here

       
        MockControl registryControl = newControl(RegistryInfrastructure.class);
        RegistryInfrastructure registry = (RegistryInfrastructure) registryControl.getMock();

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();

        ElementModelImpl em = new ElementModelImpl("module");

        em.setElementName("fred");
        // No content handler specified

        em.addRule(new CreateObjectRule(StringHolderImpl.class.getName()));

        ReadContentRule rule = new ReadContentRule();
        rule.setPropertyName("value");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));

        SchemaImpl schema = new SchemaImpl("module");
        schema.addElementModel(em);

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

        ElementImpl element = new ElementImpl();
        element.setElementName("fred");
        element.setContent("flintstone");

        List elements = Collections.singletonList(element);
       
        m.getRegistry();
        control.setReturnValue(registry);
       
        registry.getModule(schema.getDefiningModuleId());
        registryControl.setReturnValue(m);

        m.resolveType("hivemind.test.services.impl.StringHolderImpl");
        control.setReturnValue(StringHolderImpl.class);

        m.getService(SymbolExpander.class);
        control.setReturnValue(symbolExpander);

        symbolExpander.expandSymbols("flintstone", null);
        symbolExpanderControl.setReturnValue("flintstone");

        replayControls();

        List dest = new ArrayList();
View Full Code Here

        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();

        ElementModelImpl em = new ElementModelImpl("module");

        AttributeModelImpl am = new AttributeModelImpl();
        am.setName("wife");
        am.setTranslator("service");

        em.setElementName("fred");
        em.addAttributeModel(am);

        em.addRule(new CreateObjectRule(StringHolderImpl.class.getName()));

        ReadAttributeRule rule = new ReadAttributeRule();
        rule.setPropertyName("value");
        rule.setAttributeName("wife");

        em.addRule(rule);

        em.addRule(new InvokeParentRule("addElement"));

        SchemaImpl schema = new SchemaImpl("module");
        schema.addElementModel(em);

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

        ElementImpl element = new ElementImpl();
        element.setElementName("fred");
        element.addAttribute(new AttributeImpl("wife", "wilma"));

        List elements = Collections.singletonList(element);
       
        m.getRegistry();
        control.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m);

        m.resolveType("hivemind.test.services.impl.StringHolderImpl");
        control.setReturnValue(StringHolderImpl.class);

        m.getService(SymbolExpander.class);
        control.setReturnValue(symbolExpander);

        symbolExpander.expandSymbols("wilma", null);
        symbolExpanderControl.setReturnValue("wilma");
       
        m.getService(TranslatorManager.class);
        control.setReturnValue(tm);
View Full Code Here

       
        MockControl registryControl = newControl(RegistryInfrastructure.class);
        RegistryInfrastructure registry = (RegistryInfrastructure) registryControl.getMock();

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();

        em.setElementName("cartoon");
        em.setKeyAttribute("name");

        AttributeModelImpl am = new AttributeModelImpl();
        am.setName("name");
        am.setTranslator("cartoon");

        em.addAttributeModel(am);
       
        em.addRule(new CreateObjectRule("StringHolderImpl"));
       
        ReadContentRule rule = new ReadContentRule();
        rule.setPropertyName("value");

        em.addRule(rule);
       
        em.addRule(new InvokeParentRule("addElement"));

        SchemaImpl schema = new SchemaImpl("module");
        schema.addElementModel(em);

        MockControl control = newControl(Module.class);
        Module m = (Module) control.getMock();

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

        ElementImpl element = new ElementImpl();
        element.setElementName("cartoon");
        element.setContent("${fred}");
        element.addAttribute(new AttributeImpl("name", "${flintstone}"));

        List elements = Collections.singletonList(element);

        m.getRegistry();
        control.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m);

        m.resolveType("StringHolderImpl");
        control.setReturnValue(StringHolderImpl.class);

        m.getService(SymbolExpander.class);
        control.setReturnValue(symbolExpander);
       
        symbolExpander.expandSymbols("${fred}", null);
        symbolExpanderControl.setReturnValue("fred");

        symbolExpander.expandSymbols("${flintstone}", null);
        symbolExpanderControl.setReturnValue("flintstone");

        MockControl tControl = newControl(Translator.class);
        Translator t = (Translator) tControl.getMock();
View Full Code Here

       
        MockControl registryControl = newControl(RegistryInfrastructure.class);
        RegistryInfrastructure registry = (RegistryInfrastructure) registryControl.getMock();

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

        Location location1 = newLocation();
        ElementImpl element1 = new ElementImpl();
        element1.setElementName("cartoon");
        element1.addAttribute(new AttributeImpl("name", "flintstone"));
        element1.setLocation(location1);

        List elements1 = Collections.singletonList(element1);

        Location location2 = newLocation();
        ElementImpl element2 = new ElementImpl();
        element2.setElementName("cartoon");
        element2.addAttribute(new AttributeImpl("name", "flintstone"));
        element2.setLocation(location2);

        List elements2 = Collections.singletonList(element2);

        MockControl tControl1 = newControl(Translator.class);
        Translator t1 = (Translator) tControl1.getMock();
       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();
       
        m1.getRegistry();
        control1.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m1);

        m2.getRegistry();
        control2.setReturnValue(registry);
       
        registry.getModule("module");
        registryControl.setReturnValue(m2);
       
        m1.resolveType("StringHolderImpl");
        control1.setReturnValue(StringHolderImpl.class);

        m1.getService(SymbolExpander.class);
        control1.setReturnValue(symbolExpander);
       
        symbolExpander.expandSymbols("flintstone", location1);
        symbolExpanderControl.setReturnValue("flintstone");
       
        m1.getService(TranslatorManager.class);
        control1.setReturnValue(tm);
       
        symbolExpander.expandSymbols("flintstone", location1);
        symbolExpanderControl.setReturnValue("flintstone");

        String flintstoneKeyModule1 = "m1.flintstone";
        t1.translate(m1, String.class, "flintstone", element1.getLocation());
        tControl1.setReturnValue(flintstoneKeyModule1);

        t1.translate(m1, Object.class, "flintstone", element1.getLocation());
        tControl1.setReturnValue(flintstoneKeyModule1);

        m2.resolveType("StringHolderImpl");
        control2.setReturnValue(StringHolderImpl.class);

        symbolExpander.expandSymbols("flintstone", location2);
        symbolExpanderControl.setReturnValue("flintstone");
       
        symbolExpander.expandSymbols("flintstone", location2);
        symbolExpanderControl.setReturnValue("flintstone");

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t1);
View Full Code Here

        Module mockModule = (Module) moduleControl.getMock();

        control.setReturnValue(mockModule);

        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();
       
        mockProcessor.getSymbolExpander();
        control.setReturnValue(symbolExpander);

        mockProcessor.getAttributeTranslator("fred");
        control.setReturnValue(new NullTranslator());

        mockProcessor.getContributingModule();
        control.setReturnValue(mockModule);

        symbolExpander.expandSymbols("${flintstone}", element.getLocation());
        symbolExpanderControl.setReturnValue("FLINTSTONE");

        mockProcessor.push("FLINTSTONE");
        mockProcessor.pop();
View Full Code Here

        Module mockModule = (Module) moduleControl.getMock();

        control.setReturnValue(mockModule);
       
        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();
       
        mockProcessor.getSymbolExpander();
        control.setReturnValue(symbolExpander);

        mockProcessor.peek();

        StringHolderImpl target = new StringHolderImpl();
        control.setReturnValue(target);

        mockProcessor.getAttributeTranslator("fred");
        control.setReturnValue(new NullTranslator());

        mockProcessor.getContributingModule();
        control.setReturnValue(mockModule);

        symbolExpander.expandSymbols("${flintstone}", element.getLocation());
        symbolExpanderControl.setReturnValue("FLINTSTONE");

        replayControls();

        rule.begin(mockProcessor, element);
View Full Code Here

        Module mockModule = (Module) moduleControl.getMock();

        control.setReturnValue(mockModule);
       
        MockControl symbolExpanderControl = newControl(SymbolExpander.class);
        SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock();
       
        mockProcessor.getSymbolExpander();
        control.setReturnValue(symbolExpander);

        symbolExpander.expandSymbols("${flintstone}", element.getLocation());
        symbolExpanderControl.setReturnValue("FLINTSTONE");
       
        mockProcessor.getContributingModule();
        control.setReturnValue(mockModule);
View Full Code Here

        RegistryExposingHiveMindFilterFixture f = new RegistryExposingHiveMindFilterFixture();

        f.init(config);

        Registry r = f.getRegistry();
        SymbolExpander symbolExpander = (SymbolExpander) r.getService(SymbolExpander.class);

        assertEquals("was here", symbolExpander.expandSymbols("${kilroy}", null));

        verifyControls();
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.SymbolExpander

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.