Search in sources :

Example 26 with WebSourceCode

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

the class InputWithoutLabelCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/InputWithoutLabelCheck.html"), new InputWithoutLabelCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(6).withMessage("Associate a valid label to this input field.").next().atLine(19).next().atLine(23).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(25).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(26).withMessage("Add an \"id\" attribute to this input field and associate it with a label.").next().atLine(28).withMessage("Associate a valid label to this input field.").next().atLine(32);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 27 with WebSourceCode

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

the class ItemTagNotWithinContainerTagCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/ItemTagNotWithinContainerTagCheck.html"), new ItemTagNotWithinContainerTagCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Surround this <li> item tag by a <ul> or <ol> container one.").next().atLine(4).withMessage("Surround this <DT> item tag by a <dl> container one.").next().atLine(8).withMessage("Surround this <lI> item tag by a <ul> or <ol> container one.").next().atLine(18);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 28 with WebSourceCode

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

the class LinkToImageCheckTest method test.

@Test
public void test() {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LinkToImageCheck.html"), new LinkToImageCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Change this link to not directly target an image.").next().atLine(4).next().atLine(5).next().atLine(6).next().atLine(7).next().atLine(8);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 29 with WebSourceCode

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

the class LinkToNothingCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LinkToNothingCheck.html"), new LinkToNothingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(3).withMessage("Give this link a valid reference or remove the reference.").next().atLine(4).next().atLine(5).next().atLine(6);
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 30 with WebSourceCode

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

the class LinksIdenticalTextsDifferentTargetsCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/LinksIdenticalTextsDifferentTargetsCheck.html"), new LinksIdenticalTextsDifferentTargetsCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(5).next().atLine(8).next().atLine(11).next().atLine(15);
}
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