Search in sources :

Example 6 with HtmlSourceCode

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

the class WhiteSpaceAroundCheckTest method test.

@Test
public void test() throws Exception {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/whiteSpaceAroundCheck.html"), new WhiteSpaceAroundCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("A whitespace is missing after the starting tag at column 4.").next().atLine(1).withMessage("Add a space at column 18.").next().atLine(3).withMessage("Add a space at column 18.").next().atLine(5).withMessage("A whitespace is missing after the starting tag at column 2.").next().atLine(7).withMessage("A whitespace is missing after the starting tag at column 3.").next().atLine(9).withMessage("A whitespace is missing after the starting tag at column 3.").next().atLine(11).withMessage("A whitespace is missing after the starting tag at column 3.").next().atLine(13).withMessage("A whitespace is missing after the starting tag at column 4.").next().atLine(13).withMessage("Add a space at column 18.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 7 with HtmlSourceCode

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

the class LibraryDependencyCheckTest method illegal_fully_qualified_identifier.

@Test
public void illegal_fully_qualified_identifier() {
    LibraryDependencyCheck check = new LibraryDependencyCheck();
    check.libraries = "java.sql";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LibraryDependencyCheck/IllegalFullyQualifiedIdentifier.jsp"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Remove the usage of this library which is not allowed.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 8 with HtmlSourceCode

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

the class DynamicJspIncludeCheckTest method test.

@Test
public void test() {
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/DynamicJspIncludeCheck.jsp"), new DynamicJspIncludeCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(2).withMessage("Use an include action instead of an include directive.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) File(java.io.File) Test(org.junit.Test)

Example 9 with HtmlSourceCode

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

the class HeaderCheckTest method correct_header.

@Test
public void correct_header() {
    HeaderCheck check = new HeaderCheck();
    check.headerFormat = "<!-- Copyright foo -->";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/HeaderCheck/CorrectHeader.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues());
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) Test(org.junit.Test)

Example 10 with HtmlSourceCode

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

the class HeaderCheckTest method misspelled_header.

@Test
public void misspelled_header() {
    HeaderCheck check = new HeaderCheck();
    check.headerFormat = "<!-- Copyright foo -->";
    HtmlSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/HeaderCheck/MisspelledHeader.html"), check);
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(null).withMessage("Add or update the header of this file.");
}
Also used : HtmlSourceCode(org.sonar.plugins.html.visitor.HtmlSourceCode) InputFile(org.sonar.api.batch.fs.InputFile) 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