Search in sources :

Example 76 with HtmlSourceCode

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

the class PageWithoutTitleCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/PageWithoutTitleCheck.html"), new PageWithoutTitleCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Add a <title> tag to this page.").next().atLine(5).next().atLine(15).next().atLine(21).next().atLine(25).next().atLine(31).next().atLine(37);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 77 with HtmlSourceCode

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

the class TableHeaderHasIdOrScopeCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/TableHeaderHasIdOrScopeCheck.html"), new TableHeaderHasIdOrScopeCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(41, 8, 41, 12).withMessage("Add either an 'id' or a 'scope' attribute to this <th> tag.").next().atLine(42).withMessage("Add either an 'id' or a 'scope' attribute to this <th> tag.").next().atLine(70).next().atLine(76).next().atLine(101).next().atLine(102).next().atLine(103).next().atLine(106).next().atLine(111).next().atLine(140).next().atLine(141).next().atLine(144).next().atLine(149).next().atLine(177).next().atLine(178).next().atLine(186).next().atLine(209).next().atLine(210).next().atLine(214).next().atLine(238).next().atLine(239).next().atLine(275).next().atLine(285).next().atLine(320).next().atLine(327).next().atLine(334).next().atLine(380).next().atLine(387).next().atLine(387).next().atLine(392).next().atLine(393).next().atLine(408).next().atLine(415).next().atLine(415).next().atLine(420).next().atLine(421).next().atLine(494).next().atLine(495).next().atLine(506).next().atLine(507).next().atLine(519).next().atLine(520).next().atLine(570).next().atLine(574).next().atLine(605).next().atLine(617).next().atLine(621).next().atLine(623);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 78 with HtmlSourceCode

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

the class TableWithoutCaptionCheckTest method detected.

@Test
public void detected() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/TableWithoutCaptionCheck.html"), new TableWithoutCaptionCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLocation(1, 0, 1, 7).withMessage("Add a description to this table.").next().atLine(8).next().atLine(32).next().atLine(39).next().atLine(47).next().atLine(53).next().atLine(61).next().atLine(65).next().atLine(66).next().atLine(78).next().atLine(89).next().atLine(95);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 79 with HtmlSourceCode

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

the class UnifiedExpressionCheckTest method should_not_detect_unknown_functions_with_empty_list.

@Test
public void should_not_detect_unknown_functions_with_empty_list() {
    UnifiedExpressionCheck check = new UnifiedExpressionCheck();
    check.functions = "";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/UnifiedExpressionCheck.jsp"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(5);
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 80 with HtmlSourceCode

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

the class ElementWithGivenIdPresentCheckTest method custom_ok.

@Test
public void custom_ok() throws Exception {
    ElementWithGivenIdPresentCheck check = new ElementWithGivenIdPresentCheck();
    check.id = "gotit";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ElementWithGivenIdPresentCheck/Ok.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues());
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Aggregations

HtmlSourceCode (org.sonar.plugins.html.visitor.HtmlSourceCode)115 File (java.io.File)111 Test (org.junit.Test)111 InputFile (org.sonar.api.batch.fs.InputFile)8 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)3 PageLexer (org.sonar.plugins.html.lex.PageLexer)3 Node (org.sonar.plugins.html.node.Node)3 HtmlAstScanner (org.sonar.plugins.html.visitor.HtmlAstScanner)3 FileReader (java.io.FileReader)2 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)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.html.analyzers.ComplexityVisitor)1 PageCountLines (org.sonar.plugins.html.analyzers.PageCountLines)1 VueLexer (org.sonar.plugins.html.lex.VueLexer)1