[plsql] Migrate tests to Junit5

This commit is contained in:
Andreas Dangel
2022-07-29 18:17:42 +02:00
parent 3da4f37744
commit 67cc06e60d
67 changed files with 477 additions and 431 deletions

View File

@ -88,8 +88,13 @@
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -4,29 +4,29 @@
package net.sourceforge.pmd;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.LanguageVersionDiscoverer;
import net.sourceforge.pmd.lang.plsql.PLSQLLanguageModule;
public class LanguageVersionDiscovererTest {
class LanguageVersionDiscovererTest {
/**
* Test on PLSQL file with default version
*/
@Test
public void testPlsql() {
void testPlsql() {
LanguageVersionDiscoverer discoverer = new LanguageVersionDiscoverer();
File plsqlFile = new File("/path/to/MY_PACKAGE.sql");
LanguageVersion languageVersion = discoverer.getDefaultLanguageVersionForFile(plsqlFile);
assertEquals("LanguageVersion must be PLSQL!",
LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion(), languageVersion);
assertEquals(LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion(), languageVersion,
"LanguageVersion must be PLSQL!");
}
}

View File

@ -6,13 +6,13 @@ package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
public class PLSQLTokenizerTest extends CpdTextComparisonTest {
class PLSQLTokenizerTest extends CpdTextComparisonTest {
public PLSQLTokenizerTest() {
PLSQLTokenizerTest() {
super(".sql");
}
@ -28,17 +28,17 @@ public class PLSQLTokenizerTest extends CpdTextComparisonTest {
@Test
public void testSimple() {
void testSimple() {
doTest("sample-plsql");
}
@Test
public void testSpecialComments() {
void testSpecialComments() {
doTest("specialComments");
}
@Test
public void testTabWidth() {
void testTabWidth() {
doTest("tabWidth");
}
}

View File

@ -4,8 +4,9 @@
package net.sourceforge.pmd.lang.plsql;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.lang.LanguageRegistry;
@ -15,21 +16,18 @@ import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
/**
* Tests to use XPath rules with PLSQL.
*/
public class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
private static final String SOURCE =
"create or replace\n" + "package pkg_xpath_problem\n" + "AS\n" + " PROCEDURE pkg_minimal\n" + " IS\n"
+ " a_variable VARCHAR2(1);\n" + " BEGIN \n" + " --PRAGMA INLINE(output,'YES');\n"
+ " a_variable := 'Y' ;\n" + " END ;\n" + "end pkg_xpath_problem;\n" + "/\n";
public PLSQLXPathRuleTest() {
}
/**
* See https://sourceforge.net/p/pmd/bugs/1166/
*/
@Test
public void testXPathRule1() {
void testXPathRule1() {
testOnVersion(XPathVersion.XPATH_1_0);
}
@ -37,7 +35,7 @@ public class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
* See https://sourceforge.net/p/pmd/bugs/1166/
*/
@Test
public void testXPathRule1Compatibility() {
void testXPathRule1Compatibility() {
testOnVersion(XPathVersion.XPATH_1_0_COMPATIBILITY);
}
@ -45,7 +43,7 @@ public class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
* See https://sourceforge.net/p/pmd/bugs/1166/
*/
@Test
public void testXPathRule2() {
void testXPathRule2() {
testOnVersion(XPathVersion.XPATH_2_0);
}
@ -56,8 +54,7 @@ public class PLSQLXPathRuleTest extends AbstractPLSQLParserTst {
rule.setMessage("Test Violation");
Report report = plsql.executeRule(rule, SOURCE);
Assert.assertEquals(2, report.getViolations().size());
assertEquals(2, report.getViolations().size());
}
}

View File

@ -4,20 +4,21 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTComparisonConditionTest extends AbstractPLSQLParserTst {
class ASTComparisonConditionTest extends AbstractPLSQLParserTst {
@Test
public void testOperator() {
void testOperator() {
ASTInput input = plsql.parse("BEGIN SELECT COUNT(1) INTO MY_TABLE FROM USERS_TABLE WHERE user_id = 1; END;");
List<ASTComparisonCondition> conditions = input.findDescendantsOfType(ASTComparisonCondition.class);
Assert.assertEquals(1, conditions.size());
Assert.assertEquals("=", conditions.get(0).getOperator());
assertEquals(1, conditions.size());
assertEquals("=", conditions.get(0).getOperator());
}
}

View File

@ -4,21 +4,22 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTCompoundConditionTest extends AbstractPLSQLParserTst {
class ASTCompoundConditionTest extends AbstractPLSQLParserTst {
@Test
public void testParseType() {
void testParseType() {
ASTInput input = plsql.parse("BEGIN SELECT COUNT(1) INTO MY_TABLE FROM USERS_TABLE WHERE user_id = 1 AnD user_id = 2; END;");
List<ASTCompoundCondition> compoundConditions = input.findDescendantsOfType(ASTCompoundCondition.class);
Assert.assertFalse(compoundConditions.isEmpty());
Assert.assertEquals("AND", compoundConditions.get(0).getType());
assertFalse(compoundConditions.isEmpty());
assertEquals("AND", compoundConditions.get(0).getType());
}
}

View File

@ -4,22 +4,23 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTExtractExpressionTest extends AbstractPLSQLParserTst {
@Test
public void testXml() {
void testXml() {
ASTInput unit = plsql.parse("SELECT warehouse_name, EXTRACT(warehouse_spec, '/Warehouse/Docks', "
+ "'xmlns:a=\"http://warehouse/1\" xmlns:b=\"http://warehouse/2\"') \"Number of Docks\" "
+ " FROM warehouses WHERE warehouse_spec IS NOT NULL;");
ASTExtractExpression extract = unit.getFirstDescendantOfType(ASTExtractExpression.class);
Assert.assertTrue(extract.isXml());
Assert.assertEquals("/Warehouse/Docks", extract.getXPath());
Assert.assertEquals("xmlns:a=\"http://warehouse/1\" xmlns:b=\"http://warehouse/2\"", extract.getNamespace());
assertTrue(extract.isXml());
assertEquals("/Warehouse/Docks", extract.getXPath());
assertEquals("xmlns:a=\"http://warehouse/1\" xmlns:b=\"http://warehouse/2\"", extract.getNamespace());
}
}

View File

@ -4,32 +4,35 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTFetchStatementTest extends AbstractPLSQLParserTst {
class ASTFetchStatementTest extends AbstractPLSQLParserTst {
@Test
public void testBulkCollectLimit() {
void testBulkCollectLimit() {
ASTInput input = plsql.parseResource("FetchStatementBulkCollectLimit.pls");
List<ASTFetchStatement> fetchStatements = input.findDescendantsOfType(ASTFetchStatement.class);
Assert.assertEquals(1, fetchStatements.size());
assertEquals(1, fetchStatements.size());
ASTFetchStatement fetch = fetchStatements.get(0);
Assert.assertTrue(fetch.isBulkCollect());
Assert.assertTrue(fetch.isLimit());
assertTrue(fetch.isBulkCollect());
assertTrue(fetch.isLimit());
}
@Test
public void testFetch() {
void testFetch() {
ASTInput input = plsql.parseResource("FetchStatement.pls");
List<ASTFetchStatement> fetchStatements = input.findDescendantsOfType(ASTFetchStatement.class);
Assert.assertEquals(1, fetchStatements.size());
assertEquals(1, fetchStatements.size());
ASTFetchStatement fetch = fetchStatements.get(0);
Assert.assertFalse(fetch.isBulkCollect());
Assert.assertFalse(fetch.isLimit());
assertFalse(fetch.isBulkCollect());
assertFalse(fetch.isLimit());
}
}

View File

@ -4,51 +4,52 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ASTSqlStatementTest extends AbstractPLSQLParserTst {
class ASTSqlStatementTest extends AbstractPLSQLParserTst {
@Test
public void testCommit() {
void testCommit() {
ASTInput input = plsql.parseResource("CommitStatement.pls");
List<ASTSqlStatement> sqlStatements = input.findDescendantsOfType(ASTSqlStatement.class);
Assert.assertEquals(1, sqlStatements.size());
assertEquals(1, sqlStatements.size());
assertType(sqlStatements, 0, ASTSqlStatement.Type.COMMIT);
}
@Test
public void testRollback() {
void testRollback() {
ASTInput input = plsql.parseResource("RollbackStatement.pls");
List<ASTSqlStatement> sqlStatements = input.findDescendantsOfType(ASTSqlStatement.class);
Assert.assertEquals(1, sqlStatements.size());
assertEquals(1, sqlStatements.size());
assertType(sqlStatements, 0, ASTSqlStatement.Type.ROLLBACK);
}
@Test
public void testSavepoint() {
void testSavepoint() {
ASTInput input = plsql.parseResource("SavepointStatement.pls");
List<ASTSqlStatement> sqlStatements = input.findDescendantsOfType(ASTSqlStatement.class);
Assert.assertEquals(2, sqlStatements.size());
assertEquals(2, sqlStatements.size());
assertType(sqlStatements, 0, ASTSqlStatement.Type.SAVEPOINT);
assertType(sqlStatements, 1, ASTSqlStatement.Type.ROLLBACK);
}
@Test
public void testSetTransaction() {
void testSetTransaction() {
ASTInput input = plsql.parseResource("SetTransactionStatement.pls");
List<ASTSqlStatement> sqlStatements = input.findDescendantsOfType(ASTSqlStatement.class);
Assert.assertEquals(3, sqlStatements.size());
assertEquals(3, sqlStatements.size());
assertType(sqlStatements, 0, ASTSqlStatement.Type.COMMIT);
assertType(sqlStatements, 1, ASTSqlStatement.Type.SET_TRANSACTION);
assertType(sqlStatements, 2, ASTSqlStatement.Type.COMMIT);
}
private void assertType(List<ASTSqlStatement> sqlStatements, int index, ASTSqlStatement.Type expectedType) {
Assert.assertEquals(expectedType, sqlStatements.get(index).getType());
assertEquals(expectedType, sqlStatements.get(index).getType());
}
}

View File

@ -4,16 +4,15 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
@RunWith(Suite.class)
@SuiteClasses({
@Suite
@SelectClasses({
PlsqlTreeDumpTest.class,
ParenthesisGroupTest.class,
ExecuteImmediateBulkCollectTest.class
})
public class AllPlsqlAstTreeDumpTest {
class AllPlsqlAstTreeDumpTest {
}

View File

@ -4,19 +4,19 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class AnonymousBlockTest extends AbstractPLSQLParserTst {
class AnonymousBlockTest extends AbstractPLSQLParserTst {
@Test
public void parseCursorInsideProcAnonymousBlock() {
void parseCursorInsideProcAnonymousBlock() {
plsql.parseResource("AnonymousBlock1.sql");
}
@Test
public void parseCursorInsideAnonymousBlock() {
void parseCursorInsideAnonymousBlock() {
plsql.parseResource("AnonymousBlock2.sql");
}
}

View File

@ -4,25 +4,26 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class CreateTableTest extends AbstractPLSQLParserTst {
class CreateTableTest extends AbstractPLSQLParserTst {
@Test
public void parseCreateTable() {
void parseCreateTable() {
ASTInput input = plsql.parseResource("CreateTable.pls");
// 5th column of first table statement has a inline constraint of type check
ASTTableColumn columnStatus = input.findChildrenOfType(ASTTable.class).get(0).findChildrenOfType(ASTTableColumn.class).get(4);
Assert.assertEquals("status", columnStatus.getFirstChildOfType(ASTID.class).getImage());
Assert.assertEquals(ConstraintType.CHECK, columnStatus.getFirstChildOfType(ASTInlineConstraint.class).getType());
assertEquals("status", columnStatus.getFirstChildOfType(ASTID.class).getImage());
assertEquals(ConstraintType.CHECK, columnStatus.getFirstChildOfType(ASTInlineConstraint.class).getType());
}
@Test
public void parseCreateOrganizedTable() {
void parseCreateOrganizedTable() {
plsql.parseResource("CreateOrganizedTable.pls");
}
}

View File

@ -4,22 +4,23 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class CursorAttributesTest extends AbstractPLSQLParserTst {
class CursorAttributesTest extends AbstractPLSQLParserTst {
@Test
public void parseCursorWithAttribute() {
void parseCursorWithAttribute() {
ASTInput input = plsql.parseResource("CursorAttributes.pls");
ASTExpression exp = input.getFirstDescendantOfType(ASTIfStatement.class).getFirstChildOfType(ASTExpression.class);
Assert.assertEquals("TestSearch%notfound", exp.getImage());
assertEquals("TestSearch%notfound", exp.getImage());
}
@Test
public void parseImplicitCursorAttributeBulkExceptions() {
void parseImplicitCursorAttributeBulkExceptions() {
plsql.parseResource("CursorAttributesBulkExceptions.pls");
}

View File

@ -4,56 +4,58 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class CursorForLoopTest extends AbstractPLSQLParserTst {
class CursorForLoopTest extends AbstractPLSQLParserTst {
@Test
public void parseCursorForLoopSimple() {
void parseCursorForLoopSimple() {
ASTInput input = plsql.parseResource("CursorForLoopSimple.pls");
ASTCursorForLoopStatement forloop = input.getFirstDescendantOfType(ASTCursorForLoopStatement.class);
Assert.assertNotNull(forloop);
assertNotNull(forloop);
ASTForIndex forindex = forloop.getFirstChildOfType(ASTForIndex.class);
Assert.assertNotNull(forindex);
Assert.assertEquals("someone", forindex.getImage());
assertNotNull(forindex);
assertEquals("someone", forindex.getImage());
}
@Test
public void parseCursorForLoopNested() {
void parseCursorForLoopNested() {
ASTInput input = plsql.parseResource("CursorForLoopNested.pls");
ASTCursorForLoopStatement forloop = input.getFirstDescendantOfType(ASTCursorForLoopStatement.class);
Assert.assertNotNull(forloop);
assertNotNull(forloop);
ASTForIndex forindex = forloop.getFirstChildOfType(ASTForIndex.class);
Assert.assertNotNull(forindex);
Assert.assertEquals("c_cmp", forindex.getImage());
assertNotNull(forindex);
assertEquals("c_cmp", forindex.getImage());
ASTCursorForLoopStatement forloop2 = forloop.getFirstDescendantOfType(ASTCursorForLoopStatement.class);
ASTForIndex forindex2 = forloop2.getFirstChildOfType(ASTForIndex.class);
Assert.assertEquals("c_con", forindex2.getImage());
assertEquals("c_con", forindex2.getImage());
ASTCursorForLoopStatement forloop3 = forloop2.getFirstDescendantOfType(ASTCursorForLoopStatement.class);
ASTForIndex forindex3 = forloop3.getFirstChildOfType(ASTForIndex.class);
Assert.assertEquals("c_pa", forindex3.getImage());
assertEquals("c_pa", forindex3.getImage());
}
@Test
public void parseCursorForLoop1047a() {
void parseCursorForLoop1047a() {
ASTInput input = plsql.parseResource("CursorForLoop1047a.pls");
Assert.assertNotNull(input);
assertNotNull(input);
}
@Test
public void parseCursorForLoop1047b() {
void parseCursorForLoop1047b() {
ASTInput input = plsql.parseResource("CursorForLoop1047b.pls");
Assert.assertNotNull(input);
assertNotNull(input);
}
@Test
public void parseCursorForLoop681() {
void parseCursorForLoop681() {
ASTInput input = plsql.parseResource("CursorForLoop681.pls");
Assert.assertNotNull(input);
assertNotNull(input);
}
}

View File

@ -4,20 +4,21 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class CursorWithWithTest extends AbstractPLSQLParserTst {
class CursorWithWithTest extends AbstractPLSQLParserTst {
@Test
public void parseCursorWithWith() {
void parseCursorWithWith() {
ASTInput input = plsql.parseResource("CursorWithWith.pls");
ASTCursorUnit cursor = input.getFirstDescendantOfType(ASTCursorUnit.class);
ASTSelectStatement select = (ASTSelectStatement) cursor.getChild(1);
ASTWithClause with = (ASTWithClause) select.getChild(0);
ASTName queryName = (ASTName) with.getChild(0);
Assert.assertEquals("risk_set", queryName.getImage());
assertEquals("risk_set", queryName.getImage());
}
}

View File

@ -4,22 +4,23 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class DeleteStatementTest extends AbstractPLSQLParserTst {
class DeleteStatementTest extends AbstractPLSQLParserTst {
@Test
public void parseDeleteStatementExample() {
void parseDeleteStatementExample() {
ASTInput input = plsql.parseResource("DeleteStatementExample.pls");
List<ASTDeleteStatement> deleteStatements = input.findDescendantsOfType(ASTDeleteStatement.class);
Assert.assertEquals(3, deleteStatements.size());
assertEquals(3, deleteStatements.size());
Assert.assertEquals("product_descriptions", deleteStatements.get(0).getChild(0)
assertEquals("product_descriptions", deleteStatements.get(0).getChild(0)
.getFirstChildOfType(ASTTableName.class).getImage());
}
}

View File

@ -4,16 +4,16 @@
package net.sourceforge.pmd.lang.plsql.ast;
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.plsql.PlsqlParsingHelper;
public class ExecuteImmediateBulkCollectTest extends BaseTreeDumpTest {
class ExecuteImmediateBulkCollectTest extends BaseTreeDumpTest {
public ExecuteImmediateBulkCollectTest() {
ExecuteImmediateBulkCollectTest() {
super(new RelevantAttributePrinter(), ".pls");
}
@ -23,17 +23,17 @@ public class ExecuteImmediateBulkCollectTest extends BaseTreeDumpTest {
}
@Test
public void testExecuteImmediateBulkCollect1() {
void testExecuteImmediateBulkCollect1() {
doTest("ExecuteImmediateBulkCollect1");
}
@Test
public void testExecuteImmediateBulkCollect2() {
void testExecuteImmediateBulkCollect2() {
doTest("ExecuteImmediateBulkCollect2");
}
@Test
public void testExecuteImmediateBulkCollect3() {
void testExecuteImmediateBulkCollect3() {
doTest("ExecuteImmediateBulkCollect3");
}
}

View File

@ -4,24 +4,24 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class ExecuteImmediateTest extends AbstractPLSQLParserTst {
class ExecuteImmediateTest extends AbstractPLSQLParserTst {
@Test
public void parseExecuteImmediate1047a() {
void parseExecuteImmediate1047a() {
plsql.parseResource("ExecuteImmediate1047a.pls");
}
@Test
public void parseExecuteImmediate1047b() {
void parseExecuteImmediate1047b() {
plsql.parseResource("ExecuteImmediate1047b.pls");
}
@Test
public void parseExecuteImmediateString() {
void parseExecuteImmediateString() {
plsql.parseResource("ExecuteImmediateString.pls");
}
}

View File

@ -4,24 +4,24 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class FunctionsTest extends AbstractPLSQLParserTst {
class FunctionsTest extends AbstractPLSQLParserTst {
@Test
public void parseTrimCall() {
void parseTrimCall() {
plsql.parseResource("TrimFunction.pls");
}
@Test
public void parseSelectExtractExpression() {
void parseSelectExtractExpression() {
plsql.parseResource("ExtractExpressions.pls");
}
@Test
public void parseXMLExpression() {
void parseXMLExpression() {
plsql.parseResource("XMLFunctions.pls");
}
}

View File

@ -4,17 +4,18 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class IfStatementTest extends AbstractPLSQLParserTst {
class IfStatementTest extends AbstractPLSQLParserTst {
@Test
public void parseIfWithElseIf() throws Exception {
void parseIfWithElseIf() throws Exception {
String code = "BEGIN\nIF 1 = 1 THEN null;\nELSIF (2 = 2) THEN null;\nELSE null;\nEND IF;\nEND;\n/\n";
ASTInput input = plsql.parse(code);
Assert.assertNotNull(input);
assertNotNull(input);
}
}

View File

@ -4,47 +4,51 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class InOutNoCopyTest extends AbstractPLSQLParserTst {
class InOutNoCopyTest extends AbstractPLSQLParserTst {
@Test
public void parseInOutNoCopy() {
void parseInOutNoCopy() {
ASTInput input = plsql.parseResource("InOutNoCopy.pls");
Assert.assertNotNull(input);
assertNotNull(input);
List<ASTFormalParameter> params = input.findDescendantsOfType(ASTFormalParameter.class);
Assert.assertEquals(18, params.size());
assertEquals(18, params.size());
//detailed check of first 6 test cases
Assert.assertFalse(params.get(0).isIn());
Assert.assertFalse(params.get(0).isOut());
Assert.assertFalse(params.get(0).isNoCopy());
Assert.assertTrue(params.get(1).isIn());
Assert.assertFalse(params.get(1).isOut());
Assert.assertFalse(params.get(1).isNoCopy());
Assert.assertFalse(params.get(2).isIn());
Assert.assertTrue(params.get(2).isOut());
Assert.assertFalse(params.get(2).isNoCopy());
Assert.assertTrue(params.get(3).isIn());
Assert.assertTrue(params.get(3).isOut());
Assert.assertFalse(params.get(3).isNoCopy());
Assert.assertTrue(params.get(4).isIn());
Assert.assertTrue(params.get(4).isOut());
Assert.assertTrue(params.get(4).isNoCopy());
Assert.assertFalse(params.get(5).isIn());
Assert.assertTrue(params.get(5).isOut());
Assert.assertTrue(params.get(5).isNoCopy());
assertFalse(params.get(0).isIn());
assertFalse(params.get(0).isOut());
assertFalse(params.get(0).isNoCopy());
assertTrue(params.get(1).isIn());
assertFalse(params.get(1).isOut());
assertFalse(params.get(1).isNoCopy());
assertFalse(params.get(2).isIn());
assertTrue(params.get(2).isOut());
assertFalse(params.get(2).isNoCopy());
assertTrue(params.get(3).isIn());
assertTrue(params.get(3).isOut());
assertFalse(params.get(3).isNoCopy());
assertTrue(params.get(4).isIn());
assertTrue(params.get(4).isOut());
assertTrue(params.get(4).isNoCopy());
assertFalse(params.get(5).isIn());
assertTrue(params.get(5).isOut());
assertTrue(params.get(5).isNoCopy());
//piecemeal test of other test cases
Assert.assertFalse(params.get(11).isIn());
Assert.assertTrue(params.get(11).isOut());
Assert.assertTrue(params.get(11).isNoCopy());
Assert.assertTrue(params.get(16).isIn());
Assert.assertTrue(params.get(16).isOut());
Assert.assertTrue(params.get(16).isNoCopy());
assertFalse(params.get(11).isIn());
assertTrue(params.get(11).isOut());
assertTrue(params.get(11).isNoCopy());
assertTrue(params.get(16).isIn());
assertTrue(params.get(16).isOut());
assertTrue(params.get(16).isNoCopy());
}
}

View File

@ -4,24 +4,24 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class InsertIntoClauseTest extends AbstractPLSQLParserTst {
class InsertIntoClauseTest extends AbstractPLSQLParserTst {
@Test
public void parseInsertInto() {
void parseInsertInto() {
plsql.parseResource("InsertIntoClause.pls");
}
@Test
public void parseInsertIntoReturning() {
void parseInsertIntoReturning() {
plsql.parseResource("InsertIntoClauseReturning.pls");
}
@Test
public void parseInsertIntoWithRecord() {
void parseInsertIntoWithRecord() {
plsql.parseResource("InsertIntoClauseRecord.pls");
}
}

View File

@ -4,115 +4,119 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class JoinClauseTest extends AbstractPLSQLParserTst {
class JoinClauseTest extends AbstractPLSQLParserTst {
@Test
public void testInnerCrossJoin() {
void testInnerCrossJoin() {
ASTInput input = plsql.parseResource("InnerCrossJoin.pls");
List<ASTInnerCrossJoinClause> joins = input.findDescendantsOfType(ASTInnerCrossJoinClause.class);
Assert.assertEquals(1, joins.size());
Assert.assertTrue(joins.get(0).isCross());
Assert.assertFalse(joins.get(0).isNatural());
assertEquals(1, joins.size());
assertTrue(joins.get(0).isCross());
assertFalse(joins.get(0).isNatural());
}
@Test
public void testInnerNaturalJoin() {
void testInnerNaturalJoin() {
ASTInput input = plsql.parseResource("InnerNaturalJoin.pls");
List<ASTInnerCrossJoinClause> joins = input.findDescendantsOfType(ASTInnerCrossJoinClause.class);
Assert.assertEquals(2, joins.size());
Assert.assertFalse(joins.get(0).isCross());
Assert.assertTrue(joins.get(0).isNatural());
assertEquals(2, joins.size());
assertFalse(joins.get(0).isCross());
assertTrue(joins.get(0).isNatural());
}
@Test
public void testInnerJoinUsing() {
void testInnerJoinUsing() {
ASTInput input = plsql.parseResource("InnerJoinUsing.pls");
List<ASTInnerCrossJoinClause> joins = input.findDescendantsOfType(ASTInnerCrossJoinClause.class);
Assert.assertEquals(3, joins.size());
Assert.assertFalse(joins.get(0).isCross());
Assert.assertFalse(joins.get(0).isNatural());
assertEquals(3, joins.size());
assertFalse(joins.get(0).isCross());
assertFalse(joins.get(0).isNatural());
List<ASTColumn> columns = joins.get(0).findChildrenOfType(ASTColumn.class);
Assert.assertEquals(1, columns.size());
Assert.assertEquals("department_id", columns.get(0).getImage());
assertEquals(1, columns.size());
assertEquals("department_id", columns.get(0).getImage());
}
@Test
public void testOuterJoinUsing() {
void testOuterJoinUsing() {
ASTInput input = plsql.parseResource("OuterJoinUsing.pls");
List<ASTOuterJoinClause> joins = input.findDescendantsOfType(ASTOuterJoinClause.class);
Assert.assertEquals(1, joins.size());
assertEquals(1, joins.size());
ASTOuterJoinType type = joins.get(0).getFirstChildOfType(ASTOuterJoinType.class);
Assert.assertEquals(ASTOuterJoinType.Type.FULL, type.getType());
assertEquals(ASTOuterJoinType.Type.FULL, type.getType());
List<ASTColumn> columns = joins.get(0).findChildrenOfType(ASTColumn.class);
Assert.assertEquals(1, columns.size());
Assert.assertEquals("department_id", columns.get(0).getImage());
assertEquals(1, columns.size());
assertEquals("department_id", columns.get(0).getImage());
}
@Test
public void testRightOuterJoin() {
void testRightOuterJoin() {
ASTInput input = plsql.parseResource("RightOuterJoin.pls");
List<ASTOuterJoinClause> joins = input.findDescendantsOfType(ASTOuterJoinClause.class);
Assert.assertEquals(2, joins.size());
assertEquals(2, joins.size());
ASTOuterJoinType type = joins.get(0).getFirstChildOfType(ASTOuterJoinType.class);
Assert.assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
}
@Test
public void testLeftOuterJoin() {
void testLeftOuterJoin() {
ASTInput input = plsql.parseResource("LeftOuterJoin.pls");
List<ASTOuterJoinClause> joins = input.findDescendantsOfType(ASTOuterJoinClause.class);
Assert.assertEquals(2, joins.size());
assertEquals(2, joins.size());
ASTOuterJoinType type = joins.get(0).getFirstChildOfType(ASTOuterJoinType.class);
Assert.assertEquals(ASTOuterJoinType.Type.LEFT, type.getType());
assertEquals(ASTOuterJoinType.Type.LEFT, type.getType());
List<ASTSelectStatement> selects = input.findDescendantsOfType(ASTSelectStatement.class);
Assert.assertEquals(2, selects.size());
Assert.assertTrue(selects.get(0).getFromClause().getChild(0) instanceof ASTJoinClause);
Assert.assertTrue(selects.get(1).getFromClause().getChild(0) instanceof ASTJoinClause);
assertEquals(2, selects.size());
assertTrue(selects.get(0).getFromClause().getChild(0) instanceof ASTJoinClause);
assertTrue(selects.get(1).getFromClause().getChild(0) instanceof ASTJoinClause);
}
@Test
public void testNaturalRightOuterJoin() {
void testNaturalRightOuterJoin() {
ASTInput input = plsql.parseResource("NaturalRightOuterJoin.pls");
List<ASTOuterJoinClause> joins = input.findDescendantsOfType(ASTOuterJoinClause.class);
Assert.assertEquals(1, joins.size());
assertEquals(1, joins.size());
ASTOuterJoinType type = joins.get(0).getFirstChildOfType(ASTOuterJoinType.class);
Assert.assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
Assert.assertTrue(joins.get(0).isNatural());
assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
assertTrue(joins.get(0).isNatural());
}
@Test
public void testOuterJoinPartitioned() {
void testOuterJoinPartitioned() {
ASTInput input = plsql.parseResource("OuterJoinPartitioned.pls");
List<ASTOuterJoinClause> joins = input.findDescendantsOfType(ASTOuterJoinClause.class);
Assert.assertEquals(1, joins.size());
assertEquals(1, joins.size());
ASTOuterJoinType type = joins.get(0).getFirstChildOfType(ASTOuterJoinType.class);
Assert.assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
Assert.assertNotNull(joins.get(0).getFirstChildOfType(ASTQueryPartitionClause.class));
assertEquals(ASTOuterJoinType.Type.RIGHT, type.getType());
assertNotNull(joins.get(0).getFirstChildOfType(ASTQueryPartitionClause.class));
}
@Test
public void testFullOuterJoin() {
void testFullOuterJoin() {
plsql.parseResource("FullOuterJoin.pls");
}
@Test
public void testInnerJoinSubquery() {
void testInnerJoinSubquery() {
plsql.parseResource("InnerJoinSubquery.pls");
}
@Test
public void testJoinOperator() {
void testJoinOperator() {
ASTInput input = plsql.parseResource("JoinOperator.pls");
List<ASTOuterJoinExpression> expressions = input.findDescendantsOfType(ASTOuterJoinExpression.class);
Assert.assertEquals(4, expressions.size());
Assert.assertEquals("h.opp_id", expressions.get(3).getImage());
assertEquals(4, expressions.size());
assertEquals("h.opp_id", expressions.get(3).getImage());
}
}

View File

@ -4,14 +4,14 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class LexicalParametersTest extends AbstractPLSQLParserTst {
class LexicalParametersTest extends AbstractPLSQLParserTst {
@Test
public void parseLexicalParameters() {
void parseLexicalParameters() {
plsql.parseResource("LexicalParameters.sql");
}
}

View File

@ -4,22 +4,23 @@
package net.sourceforge.pmd.lang.plsql.ast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class MultipleDDLStatementsTest extends AbstractPLSQLParserTst {
class MultipleDDLStatementsTest extends AbstractPLSQLParserTst {
@Test
public void parseDDLCommands() throws Exception {
void parseDDLCommands() throws Exception {
ASTInput input = plsql.parseResource("DDLCommands.sql");
List<ASTDDLCommand> ddlcommands = input.findDescendantsOfType(ASTDDLCommand.class);
Assert.assertEquals(6, ddlcommands.size());
assertEquals(6, ddlcommands.size());
List<ASTComment> comments = input.findDescendantsOfType(ASTComment.class);
Assert.assertEquals(5, comments.size());
Assert.assertEquals("'abbreviated job title'", comments.get(0).getFirstChildOfType(ASTStringLiteral.class).getImage());
assertEquals(5, comments.size());
assertEquals("'abbreviated job title'", comments.get(0).getFirstChildOfType(ASTStringLiteral.class).getImage());
}
}

View File

@ -4,14 +4,14 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class OrderByExpressionsTest extends AbstractPLSQLParserTst {
class OrderByExpressionsTest extends AbstractPLSQLParserTst {
@Test
public void parseOrderByExpression() {
void parseOrderByExpression() {
plsql.parseResource("OrderByExpression.pls");
}
}

View File

@ -4,14 +4,19 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTimeout;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class PLSQLParserTest extends AbstractPLSQLParserTst {
class PLSQLParserTest extends AbstractPLSQLParserTst {
@Test
public void testExceptions() {
void testExceptions() {
plsql.parse("CREATE OR REPLACE PROCEDURE bar IS BEGIN" + " doSomething;" + " EXCEPTION"
+ " WHEN FooException THEN" + " doSomethingElse;" + " WHEN OTHERS THEN"
+ " doSomethingElse;" + "END;");
@ -21,67 +26,68 @@ public class PLSQLParserTest extends AbstractPLSQLParserTst {
* See https://sourceforge.net/p/pmd/bugs/1167/
*/
@Test
public void testBOM() {
void testBOM() {
plsql.parse("\ufeff" + "CREATE OR REPLACE PROCEDURE bar IS BEGIN" + " doSomething;" + " EXCEPTION"
+ " WHEN FooException THEN" + " doSomethingElse;" + " WHEN OTHERS THEN"
+ " doSomethingElse;" + "END;");
}
@Test(timeout = 5000)
public void testBug1531() {
plsql.parse("create or replace force view oxa.o_xa_function_role_types as\n"
+ "select \"CFT_ID\",\"CFR_ID\",\"CFT_NAME\",\"TCN\",\"LOG_MODULE\",\"LOG_USER\",\"LOG_DATE\",\"LOG_TIME\" from crm_function_role_types\n"
+ "/");
@Test
void testBug1531() {
assertTimeout(Duration.of(5, ChronoUnit.SECONDS), () ->
plsql.parse("create or replace force view oxa.o_xa_function_role_types as\n"
+ "select \"CFT_ID\",\"CFR_ID\",\"CFT_NAME\",\"TCN\",\"LOG_MODULE\",\"LOG_USER\",\"LOG_DATE\",\"LOG_TIME\" from crm_function_role_types\n"
+ "/"));
}
@Test
public void testBug1527() {
void testBug1527() {
plsql.parseResource("InlinePragmaProcError.pls");
}
@Test
public void testBug1520IsOfType() {
void testBug1520IsOfType() {
plsql.parseResource("IsOfType.pls");
}
@Test
public void testBug1520Using() {
void testBug1520Using() {
plsql.parseResource("Using.pls");
}
@Test
public void testSingleLineSelect() {
void testSingleLineSelect() {
plsql.parseResource("SingleLineSelect.pls");
}
@Test
public void testMultiLineSelect() {
void testMultiLineSelect() {
plsql.parseResource("MultiLineSelect.pls");
}
@Test
public void testIsNull() {
void testIsNull() {
plsql.parseResource("IsNull.pls");
}
@Test
public void testCodingStyleExample() {
void testCodingStyleExample() {
plsql.parseResource("CodingStyleExample.pls");
}
@Test
public void testCaseIssue1454() {
void testCaseIssue1454() {
plsql.parseResource("CaseIssue1454.pls");
}
@Test
public void testRelationalOperators() {
void testRelationalOperators() {
// https://github.com/pmd/pmd/issues/3746
plsql.parseResource("RelationalOperators.pls");
}
@Test
public void testExecuteImmediateIssue3106() {
void testExecuteImmediateIssue3106() {
plsql.parseResource("ExecuteImmediateIssue3106.pls");
}
}

View File

@ -4,16 +4,16 @@
package net.sourceforge.pmd.lang.plsql.ast;
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.plsql.PlsqlParsingHelper;
public class ParenthesisGroupTest extends BaseTreeDumpTest {
class ParenthesisGroupTest extends BaseTreeDumpTest {
public ParenthesisGroupTest() {
ParenthesisGroupTest() {
super(new RelevantAttributePrinter(), ".pls");
}
@ -23,17 +23,17 @@ public class ParenthesisGroupTest extends BaseTreeDumpTest {
}
@Test
public void parseParenthesisGroup0() {
void parseParenthesisGroup0() {
doTest("ParenthesisGroup0");
}
@Test
public void parseParenthesisGroup1() {
void parseParenthesisGroup1() {
doTest("ParenthesisGroup1");
}
@Test
public void parseParenthesisGroup2() {
void parseParenthesisGroup2() {
doTest("ParenthesisGroup2");
}

View File

@ -4,16 +4,16 @@
package net.sourceforge.pmd.lang.plsql.ast;
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.plsql.PlsqlParsingHelper;
public class PlsqlTreeDumpTest extends BaseTreeDumpTest {
class PlsqlTreeDumpTest extends BaseTreeDumpTest {
public PlsqlTreeDumpTest() {
PlsqlTreeDumpTest() {
super(new RelevantAttributePrinter(), ".pls");
}
@ -23,22 +23,22 @@ public class PlsqlTreeDumpTest extends BaseTreeDumpTest {
}
@Test
public void sqlPlusLexicalVariables() {
void sqlPlusLexicalVariables() {
doTest("SqlPlusLexicalVariablesIssue195");
}
@Test
public void parseParsingExclusion() {
void parseParsingExclusion() {
doTest("ParsingExclusion");
}
@Test
public void parseOpenForStatement() {
void parseOpenForStatement() {
doTest("OpenForStatement");
}
@Test
public void parseSelectIntoAssociativeArrayType() {
void parseSelectIntoAssociativeArrayType() {
doTest("SelectIntoArray");
}
}

View File

@ -4,14 +4,14 @@
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class RecordTypeTest extends AbstractPLSQLParserTst {
class RecordTypeTest extends AbstractPLSQLParserTst {
@Test
public void parseRecordType() {
void parseRecordType() {
plsql.parseResource("RecordType.pls");
}
}

Some files were not shown because too many files have changed in this diff Show More