Package org.auraframework.def

Examples of org.auraframework.def.ComponentDef


        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor, "<aura:component>"
                + "<aura:registerevent name='dupName' type='aura:click'/>"
                + "<aura:registerevent name='dupName' type='aura:click'/>" + "</aura:component>", "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraRuntimeException for registering two events with the same name");
        } catch (Exception e) {
            checkExceptionContains(e, InvalidDefinitionException.class,
                    "Multiple events registered with name");
        }
View Full Code Here


        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:set attribute='header' value='false'>Child Text</aura:set></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        assertNotNull(cd);
    }
View Full Code Here

        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:set attribute='header'><aura:foo/></aura:set></aura:component>", "myID",
                Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        assertNotNull(cd);
    }
View Full Code Here

    }

    @Override
    protected void setupValidateReferences() throws Exception {
        super.setupValidateReferences();
        ComponentDef def = Mockito.mock(ComponentDef.class);
        Mockito.doReturn(def).when(this.descriptor).getDef();
    }
View Full Code Here

     */
    public void testExtendsComponent() throws Exception {
        ComponentDefImpl.Builder builder = createAbstractBuilder();
        DefDescriptor<ComponentDef> desc = DefDescriptorImpl.getInstance("test:fakeComponent", ComponentDef.class);
        builder.extendsDescriptor = desc;
        ComponentDef cmp = builder.build();

        try {
            cmp.validateDefinition();
        } catch (AuraRuntimeException e) {
            fail("Should not have thrown AuraRuntimeException on abstract component extending component.");
        }
    }
View Full Code Here

        assertEquals("AttributeDesignDef 'else' datasource is incorrect or has wrong format", "one,two,three",
                attr.getDataSource());
    }

    public void testDesignTemplateWithRegions() throws Exception {
        ComponentDef cmp = Aura.getDefinitionService().getDefinition("test:fakeDesign", ComponentDef.class);
        DesignDef c = cmp.getDesignDefDescriptor().getDef();
        assertNotNull("DesignDef not found!", c);
        DesignTemplateDef template = c.getDesignTemplateDef();
        assertNotNull("DesignTemplateDef not found!", template);

        DesignTemplateRegionDef regionOne = template.getDesignTemplateRegionDef("regionOne");
View Full Code Here

    public void testDuplicateAttributeNames() throws Exception {
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:attribute name=\"implNumber\" type=\"String\"/>"
                        + "<aura:attribute name=\"implNumber\" type=\"String\"/></aura:component>", "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown Exception. Two attributes with the same name cannot exist");
        } catch (InvalidDefinitionException expected) {
        }
    }
View Full Code Here

    public void testDuplicateAttributeOnSystemTag() throws Exception {
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component extends='test:fakeAbstract' extends='test:fakeAbstractParent'></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown Exception. Same attribute specified twice on aura:component tag.");
        } catch (InvalidDefinitionException expected) {
        }
    }
View Full Code Here

     */
    public void testBlankValueForSystemTag() throws Exception {
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component extends=''></aura:component>", "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown Exception. Attribute value cannot be blank.");
        } catch (InvalidDefinitionException expected) {
        }
    }
View Full Code Here

     * Verify staleness check is done when CachingDefRegistry is not filled up.
     */
    public void _testForStaleCheckWhenRegistryPartiallyFull() throws Exception {
        String markup = "<aura:component> %s </aura:component>";
        DefDescriptor<ComponentDef> dd = addSourceAutoCleanup(ComponentDef.class, String.format(markup, ""));
        ComponentDef initialDef = dd.getDef();
        long initialTimeStamp = initialDef.getLocation().getLastModified();

        // Have to stop and start context because a given def is cached in MasterDefRegistry per request (context of the
        // request)
        Aura.getContextService().endContext();
        Aura.getContextService().startContext(Mode.PROD, null, Format.JSON, Authentication.AUTHENTICATED);

        StringSource<?> source = (StringSource<?>) getSource(dd);
        source.addOrUpdate(String.format(markup, "<aura:attribute type=\"String\" name=\"attr\"/>"));
        // Verify that the initial def object hasn't been updated
        assertEquals(initialTimeStamp, initialDef.getLocation().getLastModified());

        // Fetch the def
        assertTrue(Aura.getContextService().getCurrentContext().getDefRegistry().exists(dd));
        ComponentDef updatedDef = dd.getDef();
        // Verify that stale check has been performed
        long updatedTimeStamp = updatedDef.getLocation().getLastModified();
        assertTrue("Time stamp on def should have been updated", updatedTimeStamp > initialTimeStamp);
        assertTrue(updatedDef instanceof BaseComponentDefImpl);
        BaseComponentDefImpl<?> def = (BaseComponentDefImpl<?>) updatedDef;
        assertNotNull("Failed to obtain the updated component Def", def.getAttributeDef("attr"));
    }
View Full Code Here

TOP

Related Classes of org.auraframework.def.ComponentDef

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.