Package org.auraframework.util.javascript

Examples of org.auraframework.util.javascript.JavascriptValidator


        DirectiveBasedJavascriptGroup jg = new DirectiveBasedJavascriptGroup("testDummy", file.getParentFile(),
                file.getName(), ImmutableList.<DirectiveType<?>> of(DirectiveFactory.getMockDirective()),
                EnumSet.of(JavascriptGeneratorMode.TESTING));
        DirectiveParser dp = new DirectiveParser(jg, jg.getStartFile());
        dp.parseFile();
        List<JavascriptProcessingError> error = dp.validate(new JavascriptValidator());
        assertTrue("Should have thrown one error for unrecognized directive", error.size() == 1);
    }
View Full Code Here


        DirectiveBasedJavascriptGroup jg = new DirectiveBasedJavascriptGroup("testDummy", file.getParentFile(),
                file.getName(), ImmutableList.<DirectiveType<?>> of(DirectiveFactory.getMultiLineMockDirectiveType()),
                EnumSet.of(JavascriptGeneratorMode.TESTING));
        DirectiveParser dp = new DirectiveParser(jg, jg.getStartFile());
        dp.parseFile();
        List<JavascriptProcessingError> error = dp.validate(new JavascriptValidator());
        assertTrue("Should have thrown an error for not closing a multiline directive", error.size() == 1);
        assertTrue("The only error should have been for an missing end directive.", error.listIterator().next()
                .getMessage().equals("no end found for directive"));
    }
View Full Code Here

        DirectiveBasedJavascriptGroup jg = new DirectiveBasedJavascriptGroup("testDummy", file.getParentFile(),
                file.getName(), ImmutableList.<DirectiveType<?>> of(DirectiveFactory.getMultiLineMockDirectiveType()),
                EnumSet.of(JavascriptGeneratorMode.TESTING));
        DirectiveParser dp = new DirectiveParser(jg, jg.getStartFile());
        dp.parseFile();
        List<JavascriptProcessingError> error = dp.validate(new JavascriptValidator());
        assertTrue(
                "Should have thrown an error for having just an end directive without a matching opening multiline directive",
                error.size() == 1);
        assertTrue("The only error should have been for an unmatched end directive.", error.listIterator().next()
                .getMessage().equals("unmatched end directive"));
View Full Code Here

        DirectiveBasedJavascriptGroup jg = new DirectiveBasedJavascriptGroup("testDummy", file.getParentFile(),
                file.getName(), ImmutableList.<DirectiveType<?>> of(DirectiveFactory.getMultiLineMockDirectiveType(),
                        new IncludeDirectiveType()), EnumSet.of(JavascriptGeneratorMode.TESTING));
        DirectiveParser dp = new DirectiveParser(jg, jg.getStartFile());
        dp.parseFile();
        List<JavascriptProcessingError> error = dp.validate(new JavascriptValidator());
        assertTrue("Should have thrown an error for encoutering a multi-line directive", error.size() == 1);
        assertTrue("The only error should have been for an unmatched end directive.", error.listIterator().next()
                .getMessage().equals("nested directive found, ignored"));

    }
View Full Code Here

        // compress the JS files.
        // Compression is handled in DirectivebasedJavascriptGroup
        goldFileText(dp.generate(JavascriptGeneratorMode.PRODUCTION), "_prod.js");
        goldFileText(dp.generate(JavascriptGeneratorMode.DEVELOPMENT), "_dev.js");
        // There should be just one error for the Nested Multiline Directive
        assertTrue("Should not have found any error while processing this file", dp.validate(new JavascriptValidator())
                .size() == 1);
    }
View Full Code Here

        assertFalse(last.hasOutput(JavascriptGeneratorMode.PRODUCTION));
        assertEquals(first.getLine(), "{\"modes\": [\"MOCK1\"]}");
        assertTrue(first.hasOutput(JavascriptGeneratorMode.MOCK1));
        assertFalse(first.hasOutput(JavascriptGeneratorMode.MOCK2));
        assertFalse(first.hasOutput(JavascriptGeneratorMode.PRODUCTION));
        List<JavascriptProcessingError> errors = parser.validate(new JavascriptValidator());
        assertTrue("should not have been any validation errors", errors.isEmpty());
    }
View Full Code Here

        assertEquals(first.getLine(), "{\"modes\": [\"MOCK2\"], \"blah\": \"my\"}");
        assertTrue(second.hasOutput(JavascriptGeneratorMode.MOCK1));
        assertFalse(second.hasOutput(JavascriptGeneratorMode.MOCK2));
        assertEquals(second.getLine(), "{\"modes\": [\"MOCK1\"], \"blah\": \"spatula\"}");
        assertTrue(third.isMultiline());
        List<JavascriptProcessingError> errors = parser.validate(new JavascriptValidator());
        assertTrue("should not have been any validation errors", errors.isEmpty());
    }
View Full Code Here

                    null, Level.Error);
        }

        // TODO: reuse validators for optimization?
        List<ValidationError> errors = Lists.newArrayList();
        List<JavascriptProcessingError> jsErrors = new JavascriptValidator()
                .validate(sourceUrl, sourceCode, false, false);
        errors.addAll(ValidationUtil.patchErrorLines(jsErrors, lineOffset));
        if (customError != null)
            errors.add(0, customError);
        return errors;
View Full Code Here

        }
        errors = null;
    }

    public void validate() throws IOException {
        JavascriptValidator jsv = new JavascriptValidator();
        List<JavascriptProcessingError> errors = parser.validate(jsv);
        if (!errors.isEmpty()) {
            StringBuilder errorSb = new StringBuilder();
            for (JavascriptProcessingError error : errors) {
                errorSb.append(error.toString());
View Full Code Here

TOP

Related Classes of org.auraframework.util.javascript.JavascriptValidator

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.