Package org.apache.hivemind.internal

Examples of org.apache.hivemind.internal.Module


{

    public void testGetContentTranslator()
    {
        MockControl control = newControl(Module.class);
        Module m = (Module) control.getMock();

        ElementModelImpl em = new ElementModelImpl();

        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();
        schema.addElementModel(em);
        schema.setModule(m);

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

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

        List elements = Collections.singletonList(element);

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

        m.expandSymbols("flintstone", null);
        control.setReturnValue("flintstone");

        m.getTranslator("smart");
        control.setReturnValue(new NullTranslator());

        replayControls();

        p.process(elements, m);
View Full Code Here


    }

    public void testGetContentTranslatorUnspecified()
    {
        MockControl control = newControl(Module.class);
        Module m = (Module) control.getMock();

        ElementModelImpl em = new ElementModelImpl();

        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();
        schema.addElementModel(em);
        schema.setModule(m);

        SchemaProcessorImpl p = new SchemaProcessorImpl(null, schema);

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

        List elements = Collections.singletonList(element);

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

        m.expandSymbols("flintstone", null);
        control.setReturnValue("flintstone");

        replayControls();

        p.process(elements, m);
View Full Code Here

                .getMock();

        Log log = (Log) newMock(Log.class);

        MockControl mc = newControl(Module.class);
        Module module = (Module) mc.getMock();

        MockControl errorLogc = newControl(ErrorLog.class);
        ErrorLog errorLog = (ErrorLog) errorLogc.getMock();

        fp.getLog();
        fpc.setReturnValue(log);

        fp.getServiceId();
        fpc.setReturnValue("foo.Bar");

        fp.getInvokingModule();
        fpc.setReturnValue(module);

        module.resolveType("org.apache.hivemind.service.impl.InitializerErrorRunnable");
        mc.setReturnValue(InitializerErrorRunnable.class);

        fp.getErrorLog();
        fpc.setReturnValue(errorLog);
View Full Code Here

    }

    public void testGetAttributeTranslator()
    {
        MockControl control = newControl(Module.class);
        Module m = (Module) control.getMock();

        ElementModelImpl em = new ElementModelImpl();

        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();
        schema.addElementModel(em);
        schema.setModule(m);

        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.resolveType("hivemind.test.services.impl.StringHolderImpl");
        control.setReturnValue(StringHolderImpl.class);

        m.expandSymbols("wilma", null);
        control.setReturnValue("wilma");

        m.getTranslator("service");
        control.setReturnValue(new NullTranslator());

        replayControls();

        p.process(elements, m);
View Full Code Here

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

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

        schema.setModule(m);

        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.getTranslator("cartoon");
        control.setReturnValue(new NullTranslator());

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

        m.expandSymbols("${fred}", null);
        control.setReturnValue("fred");

        m.expandSymbols("${flintstone}", null);
        control.setReturnValue("flintstone");

        MockControl tControl = newControl(Translator.class);
        Translator t = (Translator) tControl.getMock();

        m.getTranslator("cartoon");
        control.setReturnValue(t);

        Object flintstoneKey = new Object();
        t.translate(m, Object.class, "flintstone", element.getLocation());
        tControl.setReturnValue(flintstoneKey);
View Full Code Here

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

        MockControl control1 = newControl(Module.class);
        Module m1 = (Module) control1.getMock();

        MockControl control2 = newControl(Module.class);
        Module m2 = (Module) control2.getMock();

        schema.setModule(m1);

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

        m1.getTranslator("qualified-id");
        control1.setReturnValue(t1);

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

        m1.resolveType("StringHolderImpl");
        control1.setReturnValue(StringHolderImpl.class);

        m1.expandSymbols("flintstone", location1);
        control1.setReturnValue("flintstone");

        m1.getTranslator("qualified-id");
        control1.setReturnValue(t1);

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

        m1.resolveType("StringHolderImpl");
        control1.setReturnValue(StringHolderImpl.class);

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

        m2.getTranslator("qualified-id");
        control2.setReturnValue(t2);

        String flintstoneKeyModule2 = "m2.flintstone";
        t2.translate(m2, Object.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);

        m2.expandSymbols("flintstone", location2);
        control2.setReturnValue("flintstone");

        m2.getTranslator("qualified-id");
        control2.setReturnValue(t2);

        t2.translate(m2, String.class, "flintstone", element2.getLocation());
        tControl2.setReturnValue(flintstoneKeyModule2);
View Full Code Here

public class TestInvokeFactoryServiceConstructor extends XmlTestCase
{
    public void testWrongNumberOfParameters()
    {
        MockControl moduleControl = newControl(Module.class);
        Module module = (Module) moduleControl.getMock();

        MockControl factoryPointControl = newControl(ServicePoint.class);
        ServicePoint factoryPoint = (ServicePoint) factoryPointControl.getMock();

        MockControl factoryControl = newControl(ServiceImplementationFactory.class);
        ServiceImplementationFactory factory = (ServiceImplementationFactory) factoryControl
                .getMock();

        MockControl pointControl = newControl(ServicePoint.class);
        ServicePoint point = (ServicePoint) pointControl.getMock();
       
        SchemaImpl schema = new SchemaImpl("module");
        schema.setRootElementClassName(ArrayList.class.getName());
       
        ModuleDefinition md = createModuleDefinition("test");
        XmlServicePointDefinitionImpl xmlSpd = new XmlServicePointDefinitionImpl(md);
        xmlSpd.setParametersCount(Occurances.REQUIRED);
        xmlSpd.setParametersSchema(schema);
       
        Location location = newLocation();
        InvokeFactoryServiceConstructor c = new InvokeFactoryServiceConstructor(location, "module");

        ErrorLog log = (ErrorLog) newMock(ErrorLog.class);

        // Training !
       
        point.getErrorLog();
        pointControl.setReturnValue(log);

        module.getServicePoint("foo.bar.Baz");
        moduleControl.setReturnValue(factoryPoint);
       
        module.resolveType(ArrayList.class.getName());
        moduleControl.setReturnValue(ArrayList.class);

        factoryPoint.getService(ServiceImplementationFactory.class);
        factoryPointControl.setReturnValue(factory);
View Full Code Here

    /**
     * @since 1.1
     */
    public Messages getModuleMessages(String moduleId)
    {
        final Module module = _infrastructure.getModule(moduleId);
        return module == null ? null : module.getMessages();
    }
View Full Code Here

                .getMock();

        Log log = (Log) newMock(Log.class);

        MockControl mc = newControl(Module.class);
        Module module = (Module) mc.getMock();

        MockControl errorLogc = newControl(ErrorLog.class);
        ErrorLog errorLog = (ErrorLog) errorLogc.getMock();

        fp.getLog();
        fpc.setReturnValue(log);

        fp.getServiceId();
        fpc.setReturnValue("foo.Bar");

        fp.getInvokingModule();
        fpc.setReturnValue(module);

        module.resolveType("org.apache.hivemind.service.impl.InitializerErrorRunnable");
        mc.setReturnValue(InitializerErrorRunnable.class);

        fp.getErrorLog();
        fpc.setReturnValue(errorLog);
View Full Code Here

        // And now we can finally do this!
        try
        {
            _interceptorDefinition = interceptorDefinition;
            Module contributingModule = getServiceModule().getRegistry().getModule(interceptorDefinition.getModuleId());
            _interceptorDefinition.getInterceptorConstructor().constructServiceInterceptor(this, contributingModule);
        }
        finally
        {
            _interceptorDefinition = null;
View Full Code Here

TOP

Related Classes of org.apache.hivemind.internal.Module

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.