Package org.apache.hivemind.internal

Examples of org.apache.hivemind.internal.Module


    }

    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


    }

    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

        verifyControls();
    }

    public void testBadClass()
    {
        Module m = getModule();

        replayControls();

        EnumerationTranslator t =
            new EnumerationTranslator("lava.jang.Boolean,true=TRUE,false=FALSE");
View Full Code Here

        verifyControls();
    }

    public void testUnrecognizedValue() throws Exception
    {
        Module m = getModule();

        replayControls();

        EnumerationTranslator t =
            new EnumerationTranslator("java.lang.Boolean,true=TRUE,false=FALSE");
View Full Code Here

        verifyControls();
    }

    public void testBadField() throws Exception
    {
        Module m = getModule();

        replayControls();

        EnumerationTranslator t =
            new EnumerationTranslator("java.lang.Boolean,true=HONEST_TO_GOD_TRUE,false=FALSE");
View Full Code Here

    {
        RegistryInfrastructure r =
            (RegistryInfrastructure) buildFrameworkRegistry("CustomRule.xml");

        List l = r.getConfiguration("hivemind.test.config.CustomRule");
        Module m = r.getConfigurationPoint("hivemind.test.config.CustomRule").getModule();

        Datum d = (Datum) l.get(0);

        // Put this check second, just to get some code coverage
        // on ElementsInnerProxyList
View Full Code Here

{

    private Module getModule()
    {
        MockControl c = newControl(Module.class);
        Module result = (Module) c.getMock();

        result.getClassResolver();
        c.setReturnValue(new DefaultClassResolver());

        return result;
    }
View Full Code Here

        return e;
    }

    public void testNull()
    {
        Module m = (Module) newMock(Module.class);

        replayControls();

        EnumerationTranslator t =
            new EnumerationTranslator("java.lang.Boolean,true=TRUE,false=FALSE");
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.