Package org.auraframework.def

Examples of org.auraframework.def.ClientLibraryDef


    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ClientLibraryDef) {
            ClientLibraryDef c = (ClientLibraryDef) obj;

            // equals if (same name and no url) or (same url and not blank url) and same type and same modes
            return  equalsIgnoreModes(c) && (this.getModes().isEmpty() ||
                    this.getModes().containsAll(c.getModes()));

        }
        return false;
    }
View Full Code Here


        service = Aura.getClientLibraryService();
    }

    public void testValidation() throws Exception {

        ClientLibraryDef def;
        Set<AuraContext.Mode> modes = Collections.emptySet();

        try {
            def = vendor.makeClientLibraryDef(null, null, ClientLibraryDef.Type.JS, modes, false,
                    vendor.makeComponentDefDescriptor("comp"), vendor.makeLocation("f1", 5, 5, 0));
            def.validateDefinition();
            fail("Should have thrown InvalidDefinitionException for no name");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Must have either a name or url");
        }

        try {
            def = vendor.makeClientLibraryDef("", null, ClientLibraryDef.Type.JS, modes, false,
                    vendor.makeComponentDefDescriptor("comp"), vendor.makeLocation("f1", 5, 5, 0));
            def.validateDefinition();
            fail("Should have thrown InvalidDefinitionException for Empty name");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Must have either a name or url");
        }

        try {
            def = vendor.makeClientLibraryDef("hello", null, null, modes, false,
                    vendor.makeComponentDefDescriptor("comp"), vendor.makeLocation("f1", 5, 5, 0));
            def.validateDefinition();
            fail("Should have thrown InvalidDefinitionException for no type");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Missing required type");
        }

        try {
            def = vendor.makeClientLibraryDef("hello", null, ClientLibraryDef.Type.JS, modes, false,
                    null, vendor.makeLocation("f1", 5, 5, 0));
            def.validateDefinition();
            fail("Should have thrown InvalidDefinitionException for no parent descriptor");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "No parent for ClientLibraryDef");
        }

        try {
            def = vendor.makeClientLibraryDef("hello", "somewhere/somefile.css", ClientLibraryDef.Type.JS, modes, false,
                    vendor.makeComponentDefDescriptor("comp"), vendor.makeLocation("f1", 5, 5, 0));
            def.validateDefinition();
            fail("Should have thrown InvalidDefinitionException for invalid file extension ");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Url file extension must match type");
        }
View Full Code Here

     *
     * @throws Exception
     */
    public void testCommaSeparatedStringInNameWillNotResolve() throws Exception {
        ClientLibraryService service = new ClientLibraryServiceImpl();
        ClientLibraryDef clientLibrary = vendor.makeClientLibraryDef("UIPerf, UIPerfUi", null, ClientLibraryDef.Type.JS,
                null, false, null, null);
        String url = service.getResolvedUrl(clientLibrary);
        assertNull("Expected null if a invalid library name was specified", url);
    }
View Full Code Here

    /**
     * Verify which modes are accepted when no mode is specified in aura:clientLibrary tag.
     */
    public void testDefaultModeIfNoneSpecified() {
        Set<Mode> modes = Collections.emptySet();
        ClientLibraryDef clientLibrary = vendor.makeClientLibraryDef("UIPerf", null, ClientLibraryDef.Type.JS,
                modes, false, null, null);
        assertTrue(clientLibrary.shouldInclude(null));
        for (Mode mode : AuraContext.Mode.values()) {
            assertTrue("When no mode is specified, library should be included in all modes",
                    clientLibrary.shouldInclude(mode));
        }
        assertTrue(clientLibrary.shouldInclude(Mode.DEV, ClientLibraryDef.Type.JS));
        assertFalse(clientLibrary.shouldInclude(Mode.DEV, ClientLibraryDef.Type.CSS));
    }
View Full Code Here

            assertEquals("ResourceDef type must match library type", e.getMessage());
        }
    }

    public void testComparingLibraryDefs() throws Exception{
        ClientLibraryDef cdf1 = getElement("<aura:clientLibrary name='HTML5Shiv' type='JS'/>");
        assertFalse(cdf1.equals(null));
        assertFalse(cdf1.equals(""));
       
        ClientLibraryDef sameLibraryTag = getElement("<aura:clientLibrary name='HTML5Shiv' type='JS'/>");
        assertTrue("Same library tag should be considered duplicates",
                cdf1.equals(sameLibraryTag));
       
        //When two components include same library for different modes, the final clientLibrary set should include for both modes
        ClientLibraryDef sameLibraryButDifferentModes1 = getElement("<aura:clientLibrary name='HTML5Shiv' type='JS' modes='DEV'/>");
        ClientLibraryDef sameLibraryButDifferentModes2 = getElement("<aura:clientLibrary name='HTML5Shiv' type='JS' modes='JSTEST'/>");
        assertFalse("Same library tag marked for different modes should not be considered duplicates",
                sameLibraryButDifferentModes1.equals(sameLibraryButDifferentModes2));

        ClientLibraryDef sameNameButDifferentType1 = getElement("<aura:clientLibrary name='UIPerf' type='CSS'/>");
        ClientLibraryDef sameNameButDifferentType2 = getElement("<aura:clientLibrary name='UIPerf' type='JS'/>");
        assertFalse("Same library with diffrent types should not be considered duplicates",
                sameNameButDifferentType1.equals(sameNameButDifferentType2));

        ClientLibraryDef sameNameButDifferentUrl1 = getElement("<aura:clientLibrary name='UIPerf' url='/auraFW/resources/UIPerf/UIPerf.js' type='CSS'/>");
        ClientLibraryDef sameNameButDifferentUrl2 = getElement("<aura:clientLibrary name='UIPerf' url='/auraFW/resources/UIPerf/UIPerf1.js' type='JS'/>");
        assertFalse("Same library with diffrent types should not be considered duplicates",
                sameNameButDifferentUrl1.equals(sameNameButDifferentUrl2));

        ClientLibraryDef sameUrlButDifferentName1 = getElement("<aura:clientLibrary name='UIPerf' url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        ClientLibraryDef sameUrlButDifferentName2 = getElement("<aura:clientLibrary name='Kylie' url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        assertTrue("Same library url with different names should not be considered duplicates",
                sameUrlButDifferentName1.equals(sameUrlButDifferentName2));

        ClientLibraryDef sameUrl1 = getElement("<aura:clientLibrary url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        ClientLibraryDef sameUrl2 = getElement("<aura:clientLibrary url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        assertTrue("Library tags without a name but same URL should be considered equal", sameUrl1.equals(sameUrl2));

        ClientLibraryDef sameUrlDifferentName1 = getElement("<aura:clientLibrary name='name' url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        ClientLibraryDef sameUrlDifferentName2 = getElement("<aura:clientLibrary name='name2' url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        assertTrue("Library tags without a name but same URL should be considered equal", sameUrlDifferentName1.equals(sameUrlDifferentName2));

        ClientLibraryDef sameUrl3 = getElement("<aura:clientLibrary url='/auraFW/resources/UIPerf/UIPerf.js' type='JS'/>");
        ClientLibraryDef sameUrl4 = getElement("<aura:clientLibrary url='/auraFW/resources/UIPerf/UIPerf1.js' type='JS'/>");
        assertFalse("Library tags without a name and different URLs should not equal", sameUrl3.equals(sameUrl4));

        ClientLibraryDef sameButAllMode = getElement("<aura:clientLibrary name='UIPerf' type='JS' />");
        ClientLibraryDef sameButDifferentMode = getElement("<aura:clientLibrary name='UIPerf' type='JS' modes='PTEST' />");
        assertTrue("Library which includes all modes is equal to one which specifies one",
                sameButAllMode.equals(sameButDifferentMode));

        ClientLibraryDef sameButCombine = getElement("<aura:clientLibrary name='UIPerf' type='JS' combine='true' />");
        ClientLibraryDef sameButNotCombine = getElement("<aura:clientLibrary name='UIPerf' type='JS' modes='PTEST' />");
        assertTrue("Library with different combine attribute is still the same",
                sameButCombine.equals(sameButNotCombine));
    }
View Full Code Here

    }

    // SFDC uses UIPerf
    @UnAdaptableTest
    public void testUIPerfCSS() throws Exception {
        ClientLibraryDef clientLibrary = vendor.makeClientLibraryDef("UIPerfCSS", null, ClientLibraryDef.Type.CSS,
                null, false, null, null);
        String url = clientLibraryService.getResolvedUrl(clientLibrary);
        assertTrue(url.contains("UIPerf.css"));
    }
View Full Code Here

    }

    // SFDC uses UIPerf
    @UnAdaptableTest
    public void testUIPerfJS() throws Exception {
        ClientLibraryDef clientLibrary = vendor.makeClientLibraryDef("UIPerf", null, ClientLibraryDef.Type.JS,
                null, false, null, null);
        String url = clientLibraryService.getResolvedUrl(clientLibrary);
        assertTrue(url.contains("UIPerf.js"));
    }
View Full Code Here

    }

    // SFDC uses UIPerf
    @UnAdaptableTest
    public void testUIPerfUiJS() throws Exception {
        ClientLibraryDef clientLibrary = vendor.makeClientLibraryDef("UIPerfUi", null, ClientLibraryDef.Type.JS,
                null, false, null, null);
        String url = clientLibraryService.getResolvedUrl(clientLibrary);
        assertTrue(url.contains("UIPerfUi.js"));
    }
View Full Code Here

    public void testGetResolvedUrl() {
        assertNull(clientLibraryService.getResolvedUrl(null));

        // Non existing
        ClientLibraryDef badClientLibrary = vendor.makeClientLibraryDef("UIPerfCSS", null, Type.JS,
                null, false, null, null);
        assertNull(clientLibraryService.getResolvedUrl(badClientLibrary));

        // Null name and null type
        ClientLibraryDef nullsClientLibrary = vendor.makeClientLibraryDef(null, null, null,
                null, false, null, null);
        assertNull(clientLibraryService.getResolvedUrl(nullsClientLibrary));

        // When url is present, no resolving required
        ClientLibraryDef urlClientLibrary = vendor.makeClientLibraryDef(null,
                "js://clientLibraryTest.clientLibraryTest", Type.JS,
                null, false, null, null);
        assertEquals("js://clientLibraryTest.clientLibraryTest", clientLibraryService.getResolvedUrl(urlClientLibrary));
    }
View Full Code Here

    }

    public void testCanCombine() throws Exception {
        assertFalse(clientLibraryService.canCombine(null));

        ClientLibraryDef combinableURL = vendor.makeClientLibraryDef("combinableUrl_test", "", Type.JS,
                null, true, null, null);
        ClientLibraryResolver combinableResolver = new ClientLibraryResolver() {
            @Override
            public String getName() {
                return "combinableUrl_test";
View Full Code Here

TOP

Related Classes of org.auraframework.def.ClientLibraryDef

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.