Package org.apache.hivemind

Examples of org.apache.hivemind.TranslatorManager


        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation())
        {
            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
            {
                List translators = (List) context.getConfiguration("Translators");
                TranslatorManager result = new TranslatorManagerImpl(translators, errorHandler);
                return result;
            }
        };
        helper.addServiceImplementation(spd, constructor, ServiceModel.PRIMITIVE);
    }
View Full Code Here


       
        MockControl registryControl = newControl(RegistryInfrastructure.class);
        RegistryInfrastructure registry = (RegistryInfrastructure) registryControl.getMock();
       
        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);

        tm.getTranslator("smart");
        tmControl.setReturnValue(new NullTranslator());
        
        replayControls();

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

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

        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);

        tm.getTranslator("service");
        tmControl.setReturnValue(new NullTranslator());

        replayControls();

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

    public void testKeyedElement()
    {
        ElementModelImpl em = new ElementModelImpl("module");
       
        MockControl tmControl = newControl(TranslatorManager.class);
        TranslatorManager tm = (TranslatorManager) tmControl.getMock();
       
        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();

        tm.getTranslator("cartoon");
        tmControl.setReturnValue(t);

        m.getService(TranslatorManager.class);
        control.setReturnValue(tm);
View Full Code Here

        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);

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t1);

        MockControl tControl2 = newControl(Translator.class);
        Translator t2 = (Translator) tControl2.getMock();

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t2);
       
        String flintstoneKeyModule2 = "m2.flintstone";
        t2.translate(m2, String.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);
       
        t2.translate(m2, Object.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);

        tm.getTranslator("qualified-id");
        tmControl.setReturnValue(t2);


        replayControls();
View Full Code Here

    {
        Object result = _valuesCache.get(targetType);

        if (result == null)
        {
            TranslatorManager translatorManager = (TranslatorManager) factoryParameters.getInvokingModule().getService(TranslatorManager.class);
            Translator translator = translatorManager.getTranslator(_translatorName);

            result = translator.translate(
                    factoryParameters.getInvokingModule(),
                    targetType,
                    _literalValue,
View Full Code Here

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

        BuilderPropertyFacet facet = new BuilderPropertyFacet();

        facet.setTranslator("foo");
        facet.setValue("bar");

        params.getInvokingModule();
        paramsControl.setDefaultReturnValue(module);
       
        module.getService(TranslatorManager.class);
        moduleControl.setReturnValue(tm);

        tm.getTranslator("foo");
        tmControl.setReturnValue(translator);

        translator.translate(module, Object.class, "bar", null);
        translatorControl.setReturnValue("BAR");
View Full Code Here

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

        BuilderPropertyFacet facet = new BuilderPropertyFacet();

        facet.setTranslator("foo");
        facet.setValue("bar");

        params.getInvokingModule();
        paramsControl.setDefaultReturnValue(module);

        module.getService(TranslatorManager.class);
        moduleControl.setReturnValue(tm);

        tm.getTranslator("foo");
        tmControl.setReturnValue(translator);

        translator.translate(module, Object.class, "bar", null);
        ApplicationRuntimeException exception = new ApplicationRuntimeException("");
        translatorControl.setThrowable(exception);
View Full Code Here

TOP

Related Classes of org.apache.hivemind.TranslatorManager

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.