Search in sources :

Example 66 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class MultiplePageDirectivesCheckTest method test3.

@Test
public void test3() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/multiplePageDirectivesCheck3.html"), new MultiplePageDirectivesCheck());
    assertThat(sourceCode.getIssues()).isEmpty();
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 67 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class AbsoluteURICheckTest method custom.

@Test
public void custom() {
    AbsoluteURICheck check = new AbsoluteURICheck();
    check.attributes = "img.src";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/absoluteURICheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(7).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(8).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.").next().atLine(9).withMessage("Replace this absolute URI \"src\" with a relative one, or move this absolute URI to a configuration file.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 68 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class BoldAndItalicTagsCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/BoldAndItalicTagsCheck.html"), new BoldAndItalicTagsCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Replace this <b> tag by <strong>.").next().atLine(5).withMessage("Replace this <i> tag by <em>.").next().atLine(7).withMessage("Replace this <B> tag by <strong>.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 69 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class DeprecatedAttributesInHtml5CheckTest method test.

@Test
public void test() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/deprecatedAttributesInHtml5.html"), new DeprecatedAttributesInHtml5Check());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Remove this deprecated \"CHARSET\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"COORDS\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"NAME\" attribute.").next().atLine(3).withMessage("Remove this deprecated \"SHAPE\" attribute.").next().atLine(6).withMessage("Remove this deprecated \"bordercolor\" attribute.").next().atLine(15).withMessage("Remove this deprecated \"code\" attribute.").next().atLine(18).withMessage("Remove this deprecated \"border\" attribute.").next().atLine(20).withMessage("Remove this deprecated \"name\" attribute.").next().atLine(22).withMessage("Remove this deprecated \"name\" attribute.").next().atLine(25).withMessage("Remove this deprecated \"align\" attribute.").next().atLine(27).withMessage("Remove this deprecated \"language\" attribute.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 70 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class DoctypePresenceCheckTest method no_doctype_before_foo.

@Test
public void no_doctype_before_foo() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/DoctypePresenceCheck/NoDoctypeBeforeFoo.html"), new DoctypePresenceCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues());
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Aggregations

WebSourceCode (org.sonar.plugins.web.visitor.WebSourceCode)93 File (java.io.File)91 Test (org.junit.Test)89 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)10 InputFile (org.sonar.api.batch.fs.InputFile)8 FileReader (java.io.FileReader)6 PageLexer (org.sonar.plugins.web.lex.PageLexer)3 Node (org.sonar.plugins.web.node.Node)3 HtmlAstScanner (org.sonar.plugins.web.visitor.HtmlAstScanner)3 FileNotFoundException (java.io.FileNotFoundException)1 ExpectedException (org.junit.rules.ExpectedException)1 FilePredicates (org.sonar.api.batch.fs.FilePredicates)1 FileSystem (org.sonar.api.batch.fs.FileSystem)1 ComplexityVisitor (org.sonar.plugins.web.analyzers.ComplexityVisitor)1 PageCountLines (org.sonar.plugins.web.analyzers.PageCountLines)1