Package org.auraframework.impl.javascript

Examples of org.auraframework.impl.javascript.AuraJavascriptGroup


public class GenerateJavascript {
    public static void main(String[] args) throws IOException {
        Logger logger = Logger.getLogger(GenerateJavascript.class.getName());
        // aura js
        logger.info("Generating framework javascript");
        AuraJavascriptGroup js = new AuraJavascriptGroup();
        // generate the js into this package, this one right here I say.
        File dest = AuraImplFiles.AuraResourceJavascriptDirectory.asFile();
        if (!dest.exists()) {
            dest.mkdirs();
        } else if (!dest.isDirectory()) {
            throw new IOException(dest.getPath() + " is supposed to be a directory");
        }
        logger.info("Parsing framework javascript");
        js.parse();
        logger.info("Generating scripts to " + dest);
        js.generate(dest, false);

        // Store the precomputed hash into a file.
        logger.info("Saving framework version to filesystem");
        Properties props = new Properties();
        props.setProperty(CompiledGroup.UUID_PROPERTY, js.getGroupHash().toString());
        props.setProperty(CompiledGroup.LASTMOD_PROPERTY, Long.toString(js.getLastMod()));

        File propertyFile = new File(dest, AuraJavascriptGroup.FILE_NAME);
        FileWriter writer = new FileWriter(propertyFile);
        props.store(writer, "Aura framework version information by GenerateJavascript");
        writer.close();
View Full Code Here


    /**
     * Creates a new Javascript group. This method exists to allow tests to override, so they can substitute e.g. an
     * AuraJavascriptGroup that experiences synthetic errors.
     */
    protected AuraJavascriptGroup newAuraJavascriptGroup() throws IOException {
        return new AuraJavascriptGroup(true);
    }
View Full Code Here

     * @priority high
     * @hierarchy Aura.Unit Tests.Javascript Library
     * @userStory a07B0000000FDWP
     */
    public void testJSLintValidationForAuraJavascriptGroup() throws Exception {
        AuraJavascriptGroup js = new AuraJavascriptGroup();
        try {
            // Should be ideally in setup, but this step might have some errors,
            // so won't assume its reliable
            js.parse();
            js.validate();
        } catch (RuntimeException e) {
            fail("AuraJavascriptGroup failed validation with the following error:" + e.getMessage());
        }
    }
View Full Code Here

     * @priority high
     * @hierarchy Aura.Unit Tests.Javascript Library
     * @userStory a07B0000000FDWP
     */
    public void testCompressionOfAuraJavascriptGroup() throws Exception {
        AuraJavascriptGroup js = new AuraJavascriptGroup();
        Set<JavascriptGeneratorMode> jsModes = js.getJavascriptGeneratorModes();
        DirectiveParser parser = new DirectiveParser(js, js.getStartFile());
        parser.parseFile();

        StringBuffer errorTxt = new StringBuffer();
        // Have to do it for All modes because each mode has specific settings
        // for comments and such
        for (JavascriptGeneratorMode mode : jsModes) {
            if (mode.getJavascriptWriter() != null) {
                String jsContents = parser.generate(mode);
                List<JavascriptProcessingError> errors = mode.getJavascriptWriter().compress(jsContents,
                        new StringWriter(), js.getStartFile().getName());
                for (JavascriptProcessingError e : errors) {
                    errorTxt.append(e.toString());
                }
            }
        }
View Full Code Here

        ConfigAdapterImpl impl = new ConfigAdapterImpl();
        impl.regenerateAuraJS();
        assertTrue("Framework nonce should not be empty", impl.getAuraFrameworkNonce().length() > 0);

        // But an error case should fail, and not be swallowed.
        final AuraJavascriptGroup mockJsGroup = mock(AuraJavascriptGroup.class);

        impl = new ConfigAdapterImpl() {
            @Override
            public AuraJavascriptGroup newAuraJavascriptGroup() throws IOException {
                return mockJsGroup;
            }

            @Override
            public boolean isProduction() {
                return false;
            }
        };
        try {
            when(mockJsGroup.isStale()).thenReturn(true);
            Mockito.doThrow(new MockException("Pretend we had a compile error in regeneration")).when(mockJsGroup)
                    .regenerate(AuraImplFiles.AuraResourceJavascriptDirectory.asFile());
            impl.regenerateAuraJS();
            fail("Compilation failure should have been caught!");
        } catch (AuraRuntimeException e) {
            assertTrue("expected ARTE caused by MockException, not " + e.getCause().toString(),
                    e.getCause() instanceof MockException);
        }

        // Try again, without changes; it should still fail.
        try {
            when(mockJsGroup.isStale()).thenReturn(false);
            impl.regenerateAuraJS();
            fail("Second compilation failure should have been caught!");
        } catch (AuraRuntimeException e2) {
            assertTrue("expected ARTE caused by MockException, not " + e2.getCause().toString(),
                    e2.getCause() instanceof MockException);
        }

        // Third time's the charm, we stop pretending there are errors and it
        // should work. Unless
        // we're in a resources-only environment, in which case the copying done
        // after our
        // jsGroup.regenerate() can't work, even though the mock
        // jsGroup.regenerate() will..
        if (!AuraImplFiles.AuraResourceJavascriptDirectory.asFile().exists()) {
            reset(mockJsGroup);
            when(mockJsGroup.isStale()).thenReturn(true);
            impl.regenerateAuraJS();
        }
    }
View Full Code Here

     *
     * Also testing the hash results are consistent
     */
    public void testFrameworkUid() throws Exception {

        final AuraJavascriptGroup jsGroup = mock(AuraJavascriptGroup.class);
        Hash jsHash = mock(Hash.class);
        when(jsGroup.isStale()).thenReturn(false);
        when(jsGroup.getGroupHash()).thenReturn(jsHash);

        final AuraResourcesHashingGroup resourcesGroup = mock(AuraResourcesHashingGroup.class);
        Hash resourcesHash = mock(Hash.class);
        when(resourcesGroup.isStale()).thenReturn(false);
        when(resourcesGroup.getGroupHash()).thenReturn(resourcesHash);
View Full Code Here

TOP

Related Classes of org.auraframework.impl.javascript.AuraJavascriptGroup

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.