Search in sources :

Example 81 with WebSourceCode

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

the class PasswordAutocompleteCheckTest method test.

@Test
public void test() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/PasswordAutocompleteCheck.html"), new PasswordAutocompleteCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Set the \"autocomplete\" attribute of this password input to \"off\".").next().atLine(2);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 82 with WebSourceCode

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

the class UnsupportedTagsInHtml5CheckTest method test.

@Test
public void test() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnsupportedTagsInHtml5Check.html"), new UnsupportedTagsInHtml5Check());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Remove this deprecated \"acronym\" element.").next().atLine(2).withMessage("Remove this deprecated \"applet\" element.").next().atLine(3).next().atLine(4).next().atLine(5).next().atLine(6).next().atLine(7).next().atLine(8).next().atLine(9).next().atLine(10).next().atLine(11).next().atLine(12).next().atLine(13).next().atLine(15).withMessage("Remove this deprecated \"sTrIkE\" element.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 83 with WebSourceCode

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

the class ChildElementIllegalCheckTest method custom.

@Test
public void custom() {
    ChildElementIllegalCheck check = new ChildElementIllegalCheck();
    check.child = "bar";
    check.parent = "foo";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ChildElementIllegalCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Remove this \"bar\" tag; it is not a legal child of \"foo\".");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 84 with WebSourceCode

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

the class IllegalElementCheckTest method custom.

@Test
public void custom() {
    IllegalElementCheck check = new IllegalElementCheck();
    check.elements = "title,body";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/IllegalElementCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Remove this \"title\" element.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 85 with WebSourceCode

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

the class ParentElementIllegalCheckTest method custom.

@Test
public void custom() {
    ParentElementIllegalCheck check = new ParentElementIllegalCheck();
    check.child = "bar";
    check.parent = "foo";
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ParentElementIllegalCheck.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("The element 'bar' must not have a 'foo' parent.");
}
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