[xml] Migrate tests to JUnit5

This commit is contained in:
Andreas Dangel 2022-10-03 10:32:00 +02:00
parent 5005ae56cb
commit a934c5f12d
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
10 changed files with 43 additions and 43 deletions

View File

@ -45,8 +45,8 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.pom.rule.errorprone;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class InvalidDependencyTypesTest extends PmdRuleTst {
class InvalidDependencyTypesTest extends PmdRuleTst {
// no additional unit tests
}

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.pom.rule.errorprone;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class ProjectVersionAsDependencyVersionTest extends PmdRuleTst {
class ProjectVersionAsDependencyVersionTest extends PmdRuleTst {
// no additional unit tests
}

View File

@ -5,7 +5,7 @@
package net.sourceforge.pmd.lang.xml.ast;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest;
@ -13,9 +13,9 @@ import net.sourceforge.pmd.lang.ast.test.CoordinatesPrinter;
import net.sourceforge.pmd.lang.ast.test.TestUtilsKt;
import net.sourceforge.pmd.lang.xml.XmlParsingHelper;
public class XmlCoordinatesTest extends BaseTreeDumpTest {
class XmlCoordinatesTest extends BaseTreeDumpTest {
public XmlCoordinatesTest() {
XmlCoordinatesTest() {
super(CoordinatesPrinter.INSTANCE, ".xml");
}
@ -29,12 +29,12 @@ public class XmlCoordinatesTest extends BaseTreeDumpTest {
* where the error occurs
*/
@Test
public void testLineNumbers() {
void testLineNumbers() {
doTest("xmlCoords");
}
@Test
public void testAutoclosingElementLength() {
void testAutoclosingElementLength() {
final String xml = "<elementName att1='foo' att2='bar' att3='other' />";
TestUtilsKt.assertPosition(XmlParsingHelper.XML.parse(xml), 1, 1, 1, xml.length());
}

View File

@ -5,16 +5,16 @@
package net.sourceforge.pmd.lang.xml.ast;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest;
import net.sourceforge.pmd.lang.ast.test.RelevantAttributePrinter;
import net.sourceforge.pmd.lang.xml.XmlParsingHelper;
public class XmlParserTest extends BaseTreeDumpTest {
class XmlParserTest extends BaseTreeDumpTest {
public XmlParserTest() {
XmlParserTest() {
super(new RelevantAttributePrinter(), ".xml");
}
@ -27,23 +27,23 @@ public class XmlParserTest extends BaseTreeDumpTest {
* Verifies the default parsing behavior of the XML parser.
*/
@Test
public void testDefaultParsing() {
void testDefaultParsing() {
doTest("sampleXml");
}
@Test
public void testNamespaces() {
void testNamespaces() {
doTest("sampleNs");
}
@Test
public void testBug1518() {
void testBug1518() {
doTest("bug1518");
}
@Test
public void dtdIsNotLookedUp() {
void dtdIsNotLookedUp() {
// no exception should be thrown
XmlParsingHelper.XML.parse(
"<!DOCTYPE struts-config PUBLIC "
@ -53,7 +53,7 @@ public class XmlParserTest extends BaseTreeDumpTest {
}
@Test
public void xsdIsNotLookedUp() {
void xsdIsNotLookedUp() {
// no exception should be thrown
XmlParsingHelper.XML.parse(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> "

View File

@ -6,13 +6,13 @@ package net.sourceforge.pmd.lang.xml.rule;
import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.xml.XmlParsingHelper;
public class XmlXPathRuleTest {
class XmlXPathRuleTest {
private static final String A_URI = "http://soap.sforce.com/2006/04/metadata";
private static final String FXML_IMPORTS = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@ -41,7 +41,7 @@ public class XmlXPathRuleTest {
@Test
public void testFileNameInXpath() {
void testFileNameInXpath() {
Report report = xml.executeRule(makeXPath("//b[pmd:fileName() = 'Foo.xml']"),
"<a><b></b></a>",
"src/Foo.xml");
@ -50,7 +50,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testTextFunctionInXpath() {
void testTextFunctionInXpath() {
// https://github.com/pmd/pmd/issues/915
Report report = xml.executeRule(makeXPath("//app[text()[1]='app2']"),
"<a><app>app2</app></a>");
@ -59,7 +59,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testRootNodeWildcardUri() {
void testRootNodeWildcardUri() {
// https://github.com/pmd/pmd/issues/3413#issuecomment-1072614398
Report report = xml.executeRule(makeXPath("/*:Flow"),
"<Flow xmlns=\"http://soap.sforce.com/2006/04/metadata\">\n"
@ -69,7 +69,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNoNamespaceRoot() {
void testNoNamespaceRoot() {
Report report = xml.executeRule(makeXPath("/Flow"),
"<Flow>\n"
+ "</Flow>");
@ -78,7 +78,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespaceDescendantWrongDefaultUri() {
void testNamespaceDescendantWrongDefaultUri() {
Report report = xml.executeRule(makeXPath("//a"),
"<Flow xmlns='" + A_URI + "'><a/></Flow>");
@ -86,7 +86,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespaceDescendantOkUri() {
void testNamespaceDescendantOkUri() {
Report report = xml.executeRule(makeXPath("//a", A_URI),
"<Flow xmlns='" + A_URI + "'><a/></Flow>");
@ -99,7 +99,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespaceDescendantWildcardUri() {
void testNamespaceDescendantWildcardUri() {
Report report = xml.executeRule(makeXPath("//*:a"),
"<Flow xmlns='" + A_URI + "'><a/></Flow>");
@ -107,7 +107,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespacePrefixDescendantWildcardUri() {
void testNamespacePrefixDescendantWildcardUri() {
Report report = xml.executeRule(makeXPath("//*:Flow"),
"<my:Flow xmlns:my='" + A_URI + "'><a/></my:Flow>");
@ -115,7 +115,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespacePrefixDescendantOkUri() {
void testNamespacePrefixDescendantOkUri() {
Report report = xml.executeRule(makeXPath("//Flow", A_URI),
"<my:Flow xmlns:my='" + A_URI + "'><a/></my:Flow>");
@ -123,7 +123,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testNamespacePrefixDescendantWrongUri() {
void testNamespacePrefixDescendantWrongUri() {
Report report = xml.executeRule(makeXPath("//Flow", "wrongURI"),
"<my:Flow xmlns:my='" + A_URI + "'><a/></my:Flow>");
@ -131,7 +131,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testRootExpr() {
void testRootExpr() {
Report report = xml.executeRule(makeXPath("/"),
"<Flow><a/></Flow>");
@ -139,7 +139,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testProcessingInstructions() {
void testProcessingInstructions() {
Report report = xml.executeRule(makeXPath("/child::processing-instruction()", "http://javafx.com/javafx/8"),
FXML_IMPORTS);
@ -147,7 +147,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testProcessingInstructionsNamed() {
void testProcessingInstructionsNamed() {
Report report = xml.executeRule(makeXPath("/child::processing-instruction('import')"),
FXML_IMPORTS);
@ -155,7 +155,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testProcessingInstructionXML() {
void testProcessingInstructionXML() {
// <?xml ?> does not create a PI
Report report = xml.executeRule(makeXPath("/child::processing-instruction('xml')", "http://javafx.com/javafx/8"),
FXML_IMPORTS);
@ -164,7 +164,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testComments() {
void testComments() {
Report report = xml.executeRule(makeXPath("/child::comment()[fn:starts-with(fn:string(.), 'suppress')]"),
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!--suppress JavaFxDefaultTag -->\n"
@ -175,7 +175,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testXmlNsFunctions() {
void testXmlNsFunctions() {
// https://github.com/pmd/pmd/issues/2766
Report report = xml.executeRule(
makeXPath("/manifest[namespace-uri-for-prefix('android', .) = 'http://schemas.android.com/apk/res/android']"),
@ -205,7 +205,7 @@ public class XmlXPathRuleTest {
}
@Test
public void testLocationFuns() {
void testLocationFuns() {
Rule rule = makeXPath("//Flow[pmd:startLine(.) != pmd:endLine(.)]");
Report report = xml.executeRule(rule, "<Flow><a/></Flow>");
assertSize(report, 0);

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.xml.rule.errorprone;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class MistypedCDATASectionTest extends PmdRuleTst {
class MistypedCDATASectionTest extends PmdRuleTst {
// no additional unit tests
}

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.xsl.rule.codestyle;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class UseConcatOnceTest extends PmdRuleTst {
class UseConcatOnceTest extends PmdRuleTst {
// no additional unit tests
}

View File

@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.xsl.rule.performance;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class AvoidAxisNavigationTest extends PmdRuleTst {
class AvoidAxisNavigationTest extends PmdRuleTst {
// no additional unit tests
}

View File

@ -6,14 +6,14 @@ package net.sourceforge.pmd.xml.cpd;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
public class XmlCPDTokenizerTest extends CpdTextComparisonTest {
class XmlCPDTokenizerTest extends CpdTextComparisonTest {
public XmlCPDTokenizerTest() {
XmlCPDTokenizerTest() {
super(".xml");
}
@ -23,7 +23,7 @@ public class XmlCPDTokenizerTest extends CpdTextComparisonTest {
}
@Test
public void tokenizeTest() {
void tokenizeTest() {
doTest("simple");
}
}