Package org.auraframework.def

Examples of org.auraframework.def.ComponentDef


    public void testForStaleCheckWhenRegistryFull() throws Exception {
        long startTimeStamp = System.currentTimeMillis() - 60000;
        String markup = "<aura:component> %s </aura:component>";
        DefDescriptor<ComponentDef> dd = addSourceAutoCleanup(ComponentDef.class, String.format(markup, ""));
        ((StringSource<?>) getSource(dd)).setLastModified(startTimeStamp);
        ComponentDef initialDef = dd.getDef();
        long initialTimeStamp = initialDef.getLocation().getLastModified();
        assertEquals(startTimeStamp, initialTimeStamp);
        fillCachingDefRegistryForComponents();

        // 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.UNAUTHENTICATED, laxSecurityApp);
        StringSource<?> source = (StringSource<?>) getSource(dd);
        source.addOrUpdate(String.format(markup, "<aura:attribute type=\"String\" name=\"attr\"/>"));
        source.setLastModified(startTimeStamp + 5);
        // 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();
        assertEquals("Time stamp on def should have been updated", startTimeStamp + 5, updatedTimeStamp);
        assertTrue(updatedDef instanceof BaseComponentDefImpl);
        BaseComponentDefImpl<?> def = (BaseComponentDefImpl<?>) updatedDef;
        assertNotNull("Failed to obtain the updated component Def", def.getAttributeDef("attr"));
    }
View Full Code Here


    public void testLocationCaching() throws Exception {
        // Load something from a ResourceSource, which does caching... except it turns out that no such animal exists;
        // even the built-ins are loaded from source (and so from file) under "mvn test", so we have to look to see what
        // world we're in.
        ComponentDef component = definitionService.getDefinition("aura:component", ComponentDef.class);
        if (!component.getLocation().getFileName().contains("/src/main/components/")) {
            // Okay, we didn't load from source, go ahead and check:
            assertTrue("no cache for built-in component " + component.getLocation().getFileName(), component
                    .getLocation().hasCacheEntry());
            String cacheFile = component.getLocation().getCacheFile();
            assertTrue("built-in component has too-short cacheFile \"" + cacheFile + "\"", cacheFile.length() > 1);
        }

        // Assured non-resource has no caching set:
        String markup = "<aura:component> %s </aura:component>";
        DefDescriptor<ComponentDef> dd = addSourceAutoCleanup(ComponentDef.class, String.format(markup, ""));
        component = definitionService.getDefinition(dd);
        assertFalse("string source has caching, but shouldn't", component.getLocation().hasCacheEntry());
        assertNull("string source has non-null cache file", component.getLocation().getCacheFile());
    }
View Full Code Here

    public void testParseInvalid() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        descriptor = DefDescriptorImpl.getInstance("test:parserInvalid", ComponentDef.class);
        Source<?> source = getSource(descriptor);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Parsing invalid source should throw exception");
        } catch (InvalidDefinitionException e) {
            Location location = e.getLocation();
            assertTrue("Wrong filename.", location.getFileName().endsWith("parserInvalid.cmp"));
            assertEquals(19, location.getLine());
View Full Code Here

    public void testParseFragment() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        descriptor = DefDescriptorImpl.getInstance("test:parserFragment", ComponentDef.class);
        Source<?> source = getSource(descriptor);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Parsing invalid source should throw exception");
        } catch (AuraException e) {
            Location location = e.getLocation();
            assertTrue("Wrong filename.", location.getFileName().endsWith("parserFragment.cmp"));
            checkExceptionContains(e, InvalidDefinitionException.class,
View Full Code Here

    public void testExtendsAbstract() throws Exception {
        ComponentDefImpl.Builder builder = createAbstractBuilder();
        builder.setDescriptor(DefDescriptorImpl.getInstance("test:fakeAbstractChild", ComponentDef.class));
        DefDescriptor<ComponentDef> desc = DefDescriptorImpl.getInstance("test:fakeAbstractParent", 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 abstract component.");
        }
    }
View Full Code Here

        interfaces.add(DefDescriptorImpl.getInstance("test:fakeInterface", InterfaceDef.class));

        ComponentDefImpl.Builder builder = createAbstractBuilder();
        builder.interfaces = interfaces;

        ComponentDef cmp = builder.build();

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

        regBuilder.setAccess(new DefinitionAccessImpl(null, "public"));

        eventDefs.put("fakey", regBuilder.build());
        ComponentDefImpl.Builder builder = createAbstractBuilder();
        builder.events = eventDefs;
        ComponentDef cmp = builder.build();

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

     */
    public void testTextComponent() throws Exception {
        ComponentDefImpl.Builder builder = createAbstractBuilder();
        DefDescriptor<ComponentDef> desc = DefDescriptorImpl.getInstance("test:text", 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 text component.");
        }
    }
View Full Code Here

        attributes.put("listName", "listlist");
        attributes.put("setName", "setset");

        cmp = Aura.getInstanceService().getInstance("test:testAuraTypes", ComponentDef.class, attributes);
        DefDescriptor<ComponentDef> desc = cmp.getDescriptor();
        ComponentDef def = desc.getDef();
        Map<DefDescriptor<AttributeDef>, AttributeDef> attrMap = def.getAttributeDefs();
        Set<DefDescriptor<AttributeDef>> keys = attrMap.keySet();
        Object[] keyArray = keys.toArray();

        for (int j = 0; j < keys.size(); j++) {
            DefDescriptor<?> d = attrMap.get(keyArray[j]).getTypeDef().getDescriptor();
View Full Code Here

    public void testGetComponentDefWithExtends() throws Exception {
        DefDescriptor<ComponentDef> childDescriptor = DefDescriptorImpl.getInstance("test:extendsChild",
                ComponentDef.class);
        DefDescriptor<ComponentDef> parentDescriptor = DefDescriptorImpl.getInstance("test:extendsParent",
                ComponentDef.class);
        ComponentDef def = childDescriptor.getDef();
        assertEquals(parentDescriptor, def.getExtendsDescriptor());
        assertEquals(2, def.getModelDefDescriptors().size());
        assertEquals("java://org.auraframework.impl.java.controller.TestController", def.getControllerDefDescriptors()
                .get(0).getQualifiedName());
        assertEquals("java://org.auraframework.impl.java.model.TestModel", def.getModelDef().getDescriptor()
                .getQualifiedName());
    }
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.