This is an automated email from the ASF dual-hosted git repository.
kishor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new b92bccc7f RANGER-4559: Migrate Ranger modules to junit5 - phase 1
b92bccc7f is described below
commit b92bccc7ff3d3f2ac0535c6cdd4a2e52999f26fb
Author: Kishor Gollapalliwar <[email protected]>
AuthorDate: Sat Nov 25 22:59:42 2023 +0530
RANGER-4559: Migrate Ranger modules to junit5 - phase 1
---
credentialbuilder/pom.xml | 6 -
.../ranger/credentialapi/TestCredentialReader.java | 12 +-
.../apache/ranger/credentialapi/Testbuildks.java | 14 +--
hive-agent/pom.xml | 6 -
.../services/hive/HIVERangerAuthorizerTest.java | 137 +++++++++++----------
.../hive/TestAllHiveOperationInRanger.java | 4 +-
intg/pom.xml | 15 ++-
.../java/org/apache/ranger/TestRangerClient.java | 69 ++++++-----
plugin-kafka/pom.xml | 6 -
.../authorizer/KafkaRangerAuthorizerGSSTest.java | 16 +--
.../KafkaRangerAuthorizerSASLSSLTest.java | 17 +--
.../authorizer/KafkaRangerAuthorizerTest.java | 24 ++--
.../authorizer/KafkaRangerTopicCreationTest.java | 8 +-
ranger-authn/pom.xml | 6 -
ranger-common-ha/pom.xml | 6 -
.../service/TestRangerServiceServerIdSelector.java | 10 +-
ranger-examples/conditions-enrichers/pom.xml | 6 -
.../RangerSampleSimpleMatcherTest.java | 30 ++---
18 files changed, 189 insertions(+), 203 deletions(-)
diff --git a/credentialbuilder/pom.xml b/credentialbuilder/pom.xml
index c18d5585c..0f61148ee 100644
--- a/credentialbuilder/pom.xml
+++ b/credentialbuilder/pom.xml
@@ -150,12 +150,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
diff --git
a/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/TestCredentialReader.java
b/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/TestCredentialReader.java
index ff3ce843e..ab36a51d8 100644
---
a/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/TestCredentialReader.java
+++
b/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/TestCredentialReader.java
@@ -17,19 +17,19 @@
*/
package org.apache.ranger.credentialapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class TestCredentialReader {
private String keystoreFile;
- @Before
+ @BeforeEach
public void setup() throws Exception {
String basedir = System.getProperty("basedir");
if (basedir == null) {
@@ -43,7 +43,7 @@ public class TestCredentialReader {
assertEquals(0, rc2);
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
FileUtils.deleteQuietly(new File(keystoreFile));
}
diff --git
a/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/Testbuildks.java
b/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/Testbuildks.java
index c9fb54c00..dbe2ec600 100644
---
a/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/Testbuildks.java
+++
b/credentialbuilder/src/test/java/org/apache/ranger/credentialapi/Testbuildks.java
@@ -17,22 +17,22 @@
*/
package org.apache.ranger.credentialapi;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.util.Arrays;
import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class Testbuildks {
private String keystoreFile;
- @Before
+ @BeforeEach
public void setup() throws Exception {
String basedir = System.getProperty("basedir");
if (basedir == null) {
@@ -41,7 +41,7 @@ public class Testbuildks {
keystoreFile = basedir + File.separator + "target" + File.separator +
"testkeystore.jceks";
}
- @After
+ @AfterEach
public void cleanup() throws Exception {
FileUtils.deleteQuietly(new File(keystoreFile));
}
diff --git a/hive-agent/pom.xml b/hive-agent/pom.xml
index 8a21ab81d..494fad3c9 100644
--- a/hive-agent/pom.xml
+++ b/hive-agent/pom.xml
@@ -170,12 +170,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.tez</groupId>
<artifactId>tez-dag</artifactId>
diff --git
a/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
b/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
index 2f6f1d846..50ab113ed 100644
---
a/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
+++
b/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
@@ -33,8 +33,11 @@ import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hive.service.server.HiveServer2;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/**
*
@@ -57,14 +60,14 @@ import org.junit.Test;
* b) The tag "HiveDatabaseTag" is associated with "create" permission to the
"dev" group to the "hivetable" database.
* c) The tag "HiveColumnTag" is associated with "select" permission to the
"frank" user to the "word" column of the "words" table.
*/
[email protected]
+@Disabled
public class HIVERangerAuthorizerTest {
private static final File hdfsBaseDir = new
File("./target/hdfs/").getAbsoluteFile();
private static HiveServer2 hiveServer;
private static int port;
- @org.junit.BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
// Get a random port
ServerSocket serverSocket = new ServerSocket(0);
@@ -130,9 +133,9 @@ public class HIVERangerAuthorizerTest {
// Just test to make sure it's working
ResultSet resultSet = statement.executeQuery("SELECT * FROM words
where count == '100'");
if (resultSet.next()) {
- Assert.assertEquals("Mr.", resultSet.getString(1));
+ Assertions.assertEquals("Mr.", resultSet.getString(1));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -146,7 +149,7 @@ public class HIVERangerAuthorizerTest {
}
- @org.junit.AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
hiveServer.stop();
FileUtil.fullyDelete(hdfsBaseDir);
@@ -164,10 +167,10 @@ public class HIVERangerAuthorizerTest {
ResultSet resultSet = statement.executeQuery("SELECT * FROM words
where count == '100'");
if (resultSet.next()) {
- Assert.assertEquals("Mr.", resultSet.getString(1));
- Assert.assertEquals(100, resultSet.getInt(2));
+ Assertions.assertEquals("Mr.", resultSet.getString(1));
+ Assertions.assertEquals(100, resultSet.getInt(2));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -187,7 +190,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.executeQuery("SELECT * FROM words where count ==
'100'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -209,9 +212,9 @@ public class HIVERangerAuthorizerTest {
ResultSet resultSet = statement.executeQuery("SELECT count FROM words
where count == '100'");
if (resultSet.next()) {
- Assert.assertEquals(100, resultSet.getInt(1));
+ Assertions.assertEquals(100, resultSet.getInt(1));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -232,9 +235,9 @@ public class HIVERangerAuthorizerTest {
ResultSet resultSet = statement.executeQuery("SELECT count
FROM words where count == '100'");
if (resultSet.next()) {
- Assert.assertEquals(100, resultSet.getInt(1));
+ Assertions.assertEquals(100, resultSet.getInt(1));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -254,7 +257,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.executeQuery("SELECT count FROM words where count ==
'100'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -277,7 +280,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.executeQuery("SELECT count FROM words where
count == '100'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -292,7 +295,7 @@ public class HIVERangerAuthorizerTest {
// this should be allowed (by the policy - user)
// Insert launches a MR job which fails in the unit test
@Test
- @org.junit.Ignore
+ @Disabled
public void testHiveUpdateAllAsBob() throws Exception {
String url = "jdbc:hive2://localhost:" + port + "/rangerauthz";
@@ -303,10 +306,10 @@ public class HIVERangerAuthorizerTest {
ResultSet resultSet = statement.executeQuery("SELECT * FROM words
where word == 'newword'");
if (resultSet.next()) {
- Assert.assertEquals("newword", resultSet.getString(1));
- Assert.assertEquals(5, resultSet.getInt(2));
+ Assertions.assertEquals("newword", resultSet.getString(1));
+ Assertions.assertEquals(5, resultSet.getInt(2));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -325,7 +328,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("insert into words (word, count) values
('newword2', 5)");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -359,7 +362,7 @@ public class HIVERangerAuthorizerTest {
++rowCounter;
}
}
- Assert.assertEquals(2, rowCounter);
+ Assertions.assertEquals(2, rowCounter);
// clean up
statement.execute("DROP FUNCTION IF EXISTS tmp");
statement.execute("DROP FUNCTION IF EXISTS test1.tmp");
@@ -387,7 +390,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("CREATE DATABASE if not exists alicetemp");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -398,7 +401,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("drop DATABASE bobtemp");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -442,7 +445,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.executeQuery("SELECT count FROM words where count ==
'100'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -479,7 +482,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.executeQuery("SELECT count FROM words2 where count ==
'100'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -517,7 +520,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("ALTER TABLE WORDS2 ADD COLUMNS (newcol
STRING)");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -540,7 +543,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("ALTER TABLE WORDS2 REPLACE COLUMNS (word
STRING, count INT)");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
// expected
}
@@ -578,15 +581,15 @@ public class HIVERangerAuthorizerTest {
// "dave" can select where count >= 80
ResultSet resultSet = statement.executeQuery("SELECT * FROM words
where count == '100'");
if (resultSet.next()) {
- Assert.assertEquals("Mr.", resultSet.getString(1));
- Assert.assertEquals(100, resultSet.getInt(2));
+ Assertions.assertEquals("Mr.", resultSet.getString(1));
+ Assertions.assertEquals(100, resultSet.getInt(2));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
resultSet = statement.executeQuery("SELECT * FROM words where count ==
'79'");
if (resultSet.next()) {
- Assert.fail("Authorization should not be granted for count <
80");
+ Assertions.fail("Authorization should not be granted for count <
80");
}
statement.close();
@@ -598,10 +601,10 @@ public class HIVERangerAuthorizerTest {
resultSet = statement.executeQuery("SELECT * FROM words where count ==
'79'");
if (resultSet.next()) {
- Assert.assertEquals("cannot", resultSet.getString(1));
- Assert.assertEquals(79, resultSet.getInt(2));
+ Assertions.assertEquals("cannot", resultSet.getString(1));
+ Assertions.assertEquals(79, resultSet.getInt(2));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -618,11 +621,11 @@ public class HIVERangerAuthorizerTest {
// "jane" can only set a hash of the word, and not the word itself
ResultSet resultSet = statement.executeQuery("SELECT * FROM words
where count == '100'");
if (resultSet.next()) {
- Assert.assertNotEquals("Mr.", resultSet.getString(1));
-
Assert.assertEquals("1a24b7688c199c24d87b5984d152b37d1d528911ec852d9cdf98c3ef29b916ea",
resultSet.getString(1));
- Assert.assertEquals(100, resultSet.getInt(2));
+ Assertions.assertNotEquals("Mr.", resultSet.getString(1));
+
Assertions.assertEquals("1a24b7688c199c24d87b5984d152b37d1d528911ec852d9cdf98c3ef29b916ea",
resultSet.getString(1));
+ Assertions.assertEquals(100, resultSet.getInt(2));
} else {
- Assert.fail("No ResultSet found");
+ Assertions.fail("No ResultSet found");
}
statement.close();
@@ -631,7 +634,7 @@ public class HIVERangerAuthorizerTest {
// Insert launches a MR job which fails in the unit test
@Test
- @org.junit.Ignore
+ @Disabled
public void testCreateDropMacro() throws Exception {
String initialUrl = "jdbc:hive2://localhost:" + port;
Connection connection = DriverManager.getConnection(initialUrl,
"admin", "admin");
@@ -654,25 +657,25 @@ public class HIVERangerAuthorizerTest {
//Verify Table Created And Contains Data
if (resultSet.next()) {
- Assert.assertEquals(5, resultSet.getInt(2));
+ Assertions.assertEquals(5, resultSet.getInt(2));
} else {
- Assert.fail("No Resultset Found");
+ Assertions.fail("No Resultset Found");
}
statement.execute("create temporary macro math_cube(x int) x*x*x");
ResultSet resultSet2 = statement.executeQuery("select math_cube(b)
from rangerauthz2.macro_testing");
if (resultSet2.next()) {
- Assert.assertEquals(125, resultSet2.getInt(1));
+ Assertions.assertEquals(125, resultSet2.getInt(1));
} else {
- Assert.fail("Macro Not Created Properly");
+ Assertions.fail("Macro Not Created Properly");
}
statement.execute("drop temporary macro math_cube");
try{
statement.executeQuery("select math_cube(b) from
rangerauthz2.macro_testing");
- Assert.fail("macro deleted already");
+ Assertions.fail("macro deleted already");
}
catch(SQLException ex){
//expected
@@ -687,7 +690,7 @@ public class HIVERangerAuthorizerTest {
// Insert launches a MR job which fails in the unit test
@Test
- @org.junit.Ignore
+ @Disabled
public void testCreateDropFunction() throws Exception {
String initialUrl = "jdbc:hive2://localhost:" + port;
Connection connection = DriverManager.getConnection(initialUrl,
"admin", "admin");
@@ -705,9 +708,9 @@ public class HIVERangerAuthorizerTest {
ResultSet resultSet2 = statement.executeQuery("select round(b) from
rangerauthz3.function_testing");
if (resultSet2.next()) {
- Assert.assertEquals(6, resultSet2.getInt(1));
+ Assertions.assertEquals(6, resultSet2.getInt(1));
} else {
- Assert.fail("No Resultset Found");
+ Assertions.fail("No Resultset Found");
}
statement.execute("DROP TABLE rangerauthz3.function_testing");
@@ -727,7 +730,7 @@ public class HIVERangerAuthorizerTest {
connection = DriverManager.getConnection(url, "bob", "bob");
statement = connection.createStatement();
statement.executeQuery("create table if not exists words (word
STRING, count INT) row format delimited fields terminated by '\t' stored as
textfile LOCATION 's3a://test/data'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
//expected we don't get any resultset here
} catch(SQLException ex){
//expected
@@ -754,7 +757,7 @@ public class HIVERangerAuthorizerTest {
try{
statement.execute("use rangerauthzx");
statement.execute("grant select ON TABLE rangerauthzx.tbl1 to USER
jane with grant option");
- Assert.fail("access should not have been granted");
+ Assertions.fail("access should not have been granted");
}
catch(SQLException ex){
//expected
@@ -767,7 +770,7 @@ public class HIVERangerAuthorizerTest {
statement.execute("grant select ON TABLE rangerauthzx.tbl1 to USER
jane with grant option");
}
catch(SQLException ex){
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to da_test_user");
}
statement.close();
connection.close();
@@ -810,7 +813,7 @@ public class HIVERangerAuthorizerTest {
// "words" should work
ResultSet resultSet = statement.executeQuery("SELECT * FROM
words");
- Assert.assertNotNull(resultSet);
+ Assertions.assertNotNull(resultSet);
statement.close();
@@ -818,7 +821,7 @@ public class HIVERangerAuthorizerTest {
try {
// "words2" should not
statement.executeQuery("SELECT * FROM words2");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -860,7 +863,7 @@ public class HIVERangerAuthorizerTest {
try {
// "hivetable2" should not be allowed to be created by the
"dev" group
statement.execute("CREATE DATABASE hivetable2");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -914,13 +917,13 @@ public class HIVERangerAuthorizerTest {
// we can select "word" from "words"
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT word FROM
words");
- Assert.assertNotNull(resultSet);
+ Assertions.assertNotNull(resultSet);
statement.close();
try {
// we can't select "word" from "words2" as "frank"
statement.executeQuery("SELECT word FROM words2");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized
call");
} catch (SQLException ex) {
// expected
}
@@ -948,7 +951,7 @@ public class HIVERangerAuthorizerTest {
String initialUrl = "jdbc:hive2://localhost:" + port;
Connection connection = DriverManager.getConnection(initialUrl,
"admin", "admin");
Statement statement = connection.createStatement();
- Assert.assertTrue(statement.execute("show grant user admin on table
words"));
+ Assertions.assertTrue(statement.execute("show grant user admin on
table words"));
statement.close();
connection.close();
}
@@ -964,7 +967,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("repl dump rangerauthz");
} catch (SQLException ex) {
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to
da_test_user");
}
statement.close();
connection.close();
@@ -973,7 +976,7 @@ public class HIVERangerAuthorizerTest {
statement = connection.createStatement();
try {
statement.execute("repl dump rangerauthz");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
//Excepted
}
@@ -992,7 +995,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("repl dump rangerauthz.words");
} catch (SQLException ex) {
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to da_test_user");
}
statement.close();
connection.close();
@@ -1001,7 +1004,7 @@ public class HIVERangerAuthorizerTest {
statement = connection.createStatement();
try {
statement.execute("repl dump rangerauthz.words");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
//Excepted
}
@@ -1019,7 +1022,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("kill query 'dummyQueryId'");
} catch (SQLException ex) {
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to da_test_user");
}
statement.close();
connection.close();
@@ -1028,7 +1031,7 @@ public class HIVERangerAuthorizerTest {
statement = connection.createStatement();
try {
statement.execute("kill query 'dummyQueryId'");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
//Excepted
}
@@ -1046,7 +1049,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("show resource plans");
} catch (SQLException ex) {
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to da_test_user");
}
statement.close();
connection.close();
@@ -1056,7 +1059,7 @@ public class HIVERangerAuthorizerTest {
try {
statement.execute("create resource plan myplan1");
} catch (SQLException ex) {
- Assert.fail("access should have been granted to da_test_user");
+ Assertions.fail("access should have been granted to da_test_user");
}
statement.close();
connection.close();
@@ -1065,7 +1068,7 @@ public class HIVERangerAuthorizerTest {
statement = connection.createStatement();
try {
statement.execute("create resource plan myplan1");
- Assert.fail("Failure expected on an unauthorized call");
+ Assertions.fail("Failure expected on an unauthorized call");
} catch (SQLException ex) {
//Excepted
}
diff --git
a/hive-agent/src/test/java/org/apache/ranger/services/hive/TestAllHiveOperationInRanger.java
b/hive-agent/src/test/java/org/apache/ranger/services/hive/TestAllHiveOperationInRanger.java
index d424bb4fb..1a3d9a8a2 100644
---
a/hive-agent/src/test/java/org/apache/ranger/services/hive/TestAllHiveOperationInRanger.java
+++
b/hive-agent/src/test/java/org/apache/ranger/services/hive/TestAllHiveOperationInRanger.java
@@ -18,12 +18,12 @@ package org.apache.ranger.services.hive;
*/
import
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
public class TestAllHiveOperationInRanger{
diff --git a/intg/pom.xml b/intg/pom.xml
index 4654ef7f7..6d01dcff6 100644
--- a/intg/pom.xml
+++ b/intg/pom.xml
@@ -134,19 +134,22 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git a/intg/src/test/java/org/apache/ranger/TestRangerClient.java
b/intg/src/test/java/org/apache/ranger/TestRangerClient.java
index 7da6b18a5..804314d64 100644
--- a/intg/src/test/java/org/apache/ranger/TestRangerClient.java
+++ b/intg/src/test/java/org/apache/ranger/TestRangerClient.java
@@ -25,22 +25,29 @@ import org.apache.ranger.plugin.model.RangerService;
import org.apache.ranger.plugin.model.RangerServiceHeaderInfo;
import org.apache.ranger.plugin.util.RangerPurgeResult;
import org.apache.ranger.plugin.util.RangerRESTClient;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.*;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.testng.annotations.BeforeMethod;
-import java.util.*;
-
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.Response;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.anyString;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TestRangerClient {
private static final RangerClient.API GET_TEST_API = new
RangerClient.API("/relative/path/test", HttpMethod.GET, Response.Status.OK);
@@ -64,10 +71,10 @@ public class TestRangerClient {
RangerService ret = client.getService(service.getName());
- Assert.assertNotNull(ret);
- Assert.assertEquals(ret.getName(), service.getName());
+ Assertions.assertNotNull(ret);
+ Assertions.assertEquals(ret.getName(), service.getName());
} catch(RangerServiceException excp){
- Assert.fail("Not expected to fail! Found exception: " + excp);
+ Assertions.fail("Not expected to fail! Found exception: " + excp);
}
}
@@ -83,9 +90,9 @@ public class TestRangerClient {
RangerService ret = client.getService(1L);
- Assert.assertNull(ret);
+ Assertions.assertNull(ret);
} catch(RangerServiceException excp){
- Assert.fail("Not expected to fail! Found exception: " + excp);
+ Assertions.fail("Not expected to fail! Found exception: " + excp);
}
}
@@ -101,10 +108,10 @@ public class TestRangerClient {
client.getService(1L);
- Assert.fail("supposed to fail with RangerServiceException");
+ Assertions.fail("supposed to fail with RangerServiceException");
} catch(RangerServiceException excp) {
- Assert.assertTrue(excp.getMessage().contains("statusCode=" +
ClientResponse.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
- Assert.assertTrue(excp.getMessage().contains("status=" +
ClientResponse.Status.INTERNAL_SERVER_ERROR.getReasonPhrase()));
+ Assertions.assertTrue(excp.getMessage().contains("statusCode=" +
ClientResponse.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+ Assertions.assertTrue(excp.getMessage().contains("status=" +
ClientResponse.Status.INTERNAL_SERVER_ERROR.getReasonPhrase()));
}
}
@@ -118,10 +125,10 @@ public class TestRangerClient {
client.getService(1L);
- Assert.fail("supposed to fail with RangerServiceException");
+ Assertions.fail("supposed to fail with RangerServiceException");
} catch(RangerServiceException excp) {
- Assert.assertTrue(excp.getMessage().contains("statusCode=null"));
- Assert.assertTrue(excp.getMessage().contains("status=null"));
+
Assertions.assertTrue(excp.getMessage().contains("statusCode=null"));
+ Assertions.assertTrue(excp.getMessage().contains("status=null"));
}
}
@@ -129,9 +136,9 @@ public class TestRangerClient {
public void api_UrlMissingFormat() {
try {
new RangerClient.API("%dtest%dpath%d", HttpMethod.GET,
Response.Status.OK).applyUrlFormat(1,1);
- Assert.fail("supposed to fail with RangerServiceException");
+ Assertions.fail("supposed to fail with RangerServiceException");
} catch(RangerServiceException exp){
-
Assert.assertTrue(exp.getMessage().contains("MissingFormatArgumentException"));
+
Assertions.assertTrue(exp.getMessage().contains("MissingFormatArgumentException"));
}
}
@@ -139,16 +146,16 @@ public class TestRangerClient {
public void api_UrlIllegalFormatConversion() {
try {
new RangerClient.API("testpath%d", HttpMethod.GET,
Response.Status.OK).applyUrlFormat("1");
- Assert.fail("supposed to fail with RangerServiceException");
+ Assertions.fail("supposed to fail with RangerServiceException");
} catch(RangerServiceException exp){
-
Assert.assertTrue(exp.getMessage().contains("IllegalFormatConversionException"));
+
Assertions.assertTrue(exp.getMessage().contains("IllegalFormatConversionException"));
}
try {
new RangerClient.API("testpath%f", HttpMethod.GET,
Response.Status.OK).applyUrlFormat(1);
- Assert.fail("supposed to fail with RangerServiceException");
+ Assertions.fail("supposed to fail with RangerServiceException");
} catch(RangerServiceException exp){
-
Assert.assertTrue(exp.getMessage().contains("IllegalFormatConversionException"));
+
Assertions.assertTrue(exp.getMessage().contains("IllegalFormatConversionException"));
}
}
@@ -161,7 +168,7 @@ public class TestRangerClient {
List<RangerSecurityZoneHeaderInfo> zoneHeaders =
client.getSecurityZoneHeaders(filter);
- Assert.assertEquals(Collections.emptyList(), zoneHeaders);
+ Assertions.assertEquals(Collections.emptyList(), zoneHeaders);
}
@Test
@@ -173,7 +180,7 @@ public class TestRangerClient {
List<RangerServiceHeaderInfo> serviceHeaders =
client.getSecurityZoneServiceHeaders(filter);
- Assert.assertEquals(Collections.emptyList(), serviceHeaders);
+ Assertions.assertEquals(Collections.emptyList(), serviceHeaders);
}
@Test
@@ -189,7 +196,7 @@ public class TestRangerClient {
Set<String> zoneNames =
client.getSecurityZoneNamesForResource(serviceName, resource);
- Assert.assertEquals(Collections.emptySet(), zoneNames);
+ Assertions.assertEquals(Collections.emptySet(), zoneNames);
}
@Test
@@ -201,7 +208,7 @@ public class TestRangerClient {
List<RangerSecurityZone> securityZones =
client.findSecurityZones(filter);
- Assert.assertEquals(Collections.emptyList(), securityZones);
+ Assertions.assertEquals(Collections.emptyList(), securityZones);
}
@Test
@@ -214,6 +221,6 @@ public class TestRangerClient {
List<RangerPurgeResult> purgeResults = client.purgeRecords(recordType,
retentionDays);
- Assert.assertEquals(Collections.emptyList(), purgeResults);
+ Assertions.assertEquals(Collections.emptyList(), purgeResults);
}
}
\ No newline at end of file
diff --git a/plugin-kafka/pom.xml b/plugin-kafka/pom.xml
index 9fa913741..77d3c63ba 100644
--- a/plugin-kafka/pom.xml
+++ b/plugin-kafka/pom.xml
@@ -98,12 +98,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId>
diff --git
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerGSSTest.java
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerGSSTest.java
index f33405a2f..4ddf75818 100644
---
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerGSSTest.java
+++
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerGSSTest.java
@@ -49,8 +49,10 @@ import org.apache.kafka.common.PartitionInfo;
import org.apache.kafka.common.config.SaslConfigs;
import org.apache.kafka.common.utils.Time;
import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,7 +82,7 @@ public class KafkaRangerAuthorizerGSSTest {
private static Path tempDir;
private static SimpleKdcServer kerbyServer;
- @org.junit.BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
String basedir = System.getProperty("basedir");
if (basedir == null) {
@@ -189,7 +191,7 @@ public class KafkaRangerAuthorizerGSSTest {
kerbyServer.start();
}
- @org.junit.AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (kafkaServer != null) {
kafkaServer.shutdown();
@@ -255,8 +257,8 @@ public class KafkaRangerAuthorizerGSSTest {
sleep();
}
- Assert.assertNotNull(record);
- Assert.assertEquals("somevalue", record.value());
+ Assertions.assertNotNull(record);
+ Assertions.assertEquals("somevalue", record.value());
}
}
@@ -309,7 +311,7 @@ public class KafkaRangerAuthorizerGSSTest {
producer.flush();
record.get();
} catch (Exception ex) {
- Assert.assertTrue(ex.getMessage().contains("Not authorized to
access topics"));
+ Assertions.assertTrue(ex.getMessage().contains("Not authorized to
access topics"));
}
}
diff --git
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
index 90bd628f8..4c777c7fc 100644
---
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
+++
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerSASLSSLTest.java
@@ -43,8 +43,11 @@ import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.config.SaslConfigs;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.utils.Time;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
@@ -64,7 +67,7 @@ import scala.Some;
*
* Clients and services authenticate to Kafka using the SASL SSL protocol as
part of this test.
*/
[email protected]("Causing JVM to abort on some platforms")
+@Disabled("Causing JVM to abort on some platforms")
public class KafkaRangerAuthorizerSASLSSLTest {
private static KafkaServer kafkaServer;
private static TestingServer zkServer;
@@ -74,7 +77,7 @@ public class KafkaRangerAuthorizerSASLSSLTest {
private static String truststorePath;
private static Path tempDir;
- @org.junit.BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
// JAAS Config file
String basedir = System.getProperty("basedir");
@@ -163,7 +166,7 @@ public class KafkaRangerAuthorizerSASLSSLTest {
KafkaTestUtils.createSomeTopics(adminProps);
}
- @org.junit.AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (kafkaServer != null) {
kafkaServer.shutdown();
@@ -248,8 +251,8 @@ public class KafkaRangerAuthorizerSASLSSLTest {
Thread.sleep(1000);
}
- Assert.assertNotNull(record);
- Assert.assertEquals("somevalue", record.value());
+ Assertions.assertNotNull(record);
+ Assertions.assertEquals("somevalue", record.value());
}
}
}
diff --git
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
index 9a7d5fe83..2ff2c1083 100644
---
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
+++
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerAuthorizerTest.java
@@ -44,10 +44,12 @@ import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.utils.Time;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import kafka.server.KafkaConfig;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import scala.Some;
/**
@@ -76,7 +78,7 @@ public class KafkaRangerAuthorizerTest {
private static String truststorePath;
private static Path tempDir;
- @org.junit.BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
// Create keys
String serviceDN = "CN=localhost,O=Apache,L=Dublin,ST=Leinster,C=IE";
@@ -104,9 +106,9 @@ public class KafkaRangerAuthorizerTest {
// Get a random port
try (ServerSocket serverSocket = new ServerSocket(0)) {
- Assert.assertNotNull(serverSocket) ;
+ Assertions.assertNotNull(serverSocket) ;
port = serverSocket.getLocalPort() ;
- Assert.assertTrue(port > 0) ;
+ Assertions.assertTrue(port > 0) ;
} catch (java.io.IOException e) {
throw new RuntimeException("Local socket port not
available", e) ;
}
@@ -157,7 +159,7 @@ public class KafkaRangerAuthorizerTest {
KafkaTestUtils.createSomeTopics(adminProps);
}
- @org.junit.AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (kafkaServer != null) {
kafkaServer.shutdown();
@@ -238,8 +240,8 @@ public class KafkaRangerAuthorizerTest {
Thread.sleep(1000);
}
- Assert.assertNotNull(record);
- Assert.assertEquals("somevalue", record.value());
+ Assertions.assertNotNull(record);
+ Assertions.assertEquals("somevalue", record.value());
}
}
@@ -297,7 +299,7 @@ public class KafkaRangerAuthorizerTest {
producer.flush();
record.get();
} catch (Exception ex) {
- Assert.assertTrue(ex.getMessage().contains("Not authorized to
access topics"));
+ Assertions.assertTrue(ex.getMessage().contains("Not authorized
to access topics"));
}
}
}
@@ -357,8 +359,8 @@ public class KafkaRangerAuthorizerTest {
Thread.sleep(1000);
}
- Assert.assertNotNull(record);
- Assert.assertEquals("somevalue", record.value());
+ Assertions.assertNotNull(record);
+ Assertions.assertEquals("somevalue", record.value());
}
}
diff --git
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerTopicCreationTest.java
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerTopicCreationTest.java
index e48dd2535..6fb8ccc9f 100644
---
a/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerTopicCreationTest.java
+++
b/plugin-kafka/src/test/java/org/apache/ranger/authorization/kafka/authorizer/KafkaRangerTopicCreationTest.java
@@ -41,7 +41,9 @@ import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.common.KafkaFuture;
import org.apache.kafka.common.utils.Time;
import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,7 +61,7 @@ public class KafkaRangerTopicCreationTest {
private static Path tempDir;
private static SimpleKdcServer kerbyServer;
- @org.junit.BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
String basedir = System.getProperty("basedir");
if (basedir == null) {
@@ -162,7 +164,7 @@ public class KafkaRangerTopicCreationTest {
kerbyServer.start();
}
- @org.junit.AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (kafkaServer != null) {
kafkaServer.shutdown();
diff --git a/ranger-authn/pom.xml b/ranger-authn/pom.xml
index 4ee98f8a5..bd8ab1048 100644
--- a/ranger-authn/pom.xml
+++ b/ranger-authn/pom.xml
@@ -85,11 +85,5 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/ranger-common-ha/pom.xml b/ranger-common-ha/pom.xml
index 2faa243e4..36a42f786 100644
--- a/ranger-common-ha/pom.xml
+++ b/ranger-common-ha/pom.xml
@@ -123,11 +123,5 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git
a/ranger-common-ha/src/test/java/org/apache/ranger/ha/service/TestRangerServiceServerIdSelector.java
b/ranger-common-ha/src/test/java/org/apache/ranger/ha/service/TestRangerServiceServerIdSelector.java
index 0cd55a2a6..516c07ba7 100644
---
a/ranger-common-ha/src/test/java/org/apache/ranger/ha/service/TestRangerServiceServerIdSelector.java
+++
b/ranger-common-ha/src/test/java/org/apache/ranger/ha/service/TestRangerServiceServerIdSelector.java
@@ -22,9 +22,9 @@ package org.apache.ranger.ha.service;
import com.google.common.io.Resources;
import org.apache.hadoop.conf.Configuration;
import org.apache.ranger.ha.RangerServiceServerIdSelector;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ public class TestRangerServiceServerIdSelector {
private static final Logger LOG =
LoggerFactory.getLogger(TestRangerServiceServerIdSelector.class);
private static Configuration conf = new Configuration();
- @BeforeClass
+ @BeforeAll
public static void initialize(){
conf.addResource(Resources.getResource("ranger-tagsync-site.xml"),
true);
}
@@ -44,7 +44,7 @@ public class TestRangerServiceServerIdSelector {
try {
LOG.info("test started");
serverId = RangerServiceServerIdSelector.selectServerId(conf);
- Assert.assertEquals("id1", serverId);
+ Assertions.assertEquals("id1", serverId);
}catch(Exception e){
LOG.error(e.getMessage());
diff --git a/ranger-examples/conditions-enrichers/pom.xml
b/ranger-examples/conditions-enrichers/pom.xml
index 70e9c6c74..9eb1cb212 100644
--- a/ranger-examples/conditions-enrichers/pom.xml
+++ b/ranger-examples/conditions-enrichers/pom.xml
@@ -39,12 +39,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
diff --git
a/ranger-examples/conditions-enrichers/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerSampleSimpleMatcherTest.java
b/ranger-examples/conditions-enrichers/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerSampleSimpleMatcherTest.java
index 22e298df5..eb153862f 100644
---
a/ranger-examples/conditions-enrichers/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerSampleSimpleMatcherTest.java
+++
b/ranger-examples/conditions-enrichers/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerSampleSimpleMatcherTest.java
@@ -23,8 +23,8 @@ package org.apache.ranger.plugin.conditionevaluator;
import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition;
import
org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef;
import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.*;
@@ -41,12 +41,12 @@ public class RangerSampleSimpleMatcherTest {
public void testIsMatched_happyPath() {
// this documents some unexpected behavior of the ip matcher
RangerSampleSimpleMatcher ipMatcher = createMatcher(new
String[]{"US", "C*"} );
- Assert.assertTrue(ipMatcher.isMatched(createRequest("US")));
- Assert.assertTrue(ipMatcher.isMatched(createRequest("CA")));
- Assert.assertTrue(ipMatcher.isMatched(createRequest("C---")));
- Assert.assertFalse(ipMatcher.isMatched(createRequest(" US ")));
- Assert.assertFalse(ipMatcher.isMatched(createRequest("Us")));
- Assert.assertFalse(ipMatcher.isMatched(createRequest("ca")));
+ Assertions.assertTrue(ipMatcher.isMatched(createRequest("US")));
+ Assertions.assertTrue(ipMatcher.isMatched(createRequest("CA")));
+
Assertions.assertTrue(ipMatcher.isMatched(createRequest("C---")));
+ Assertions.assertFalse(ipMatcher.isMatched(createRequest(" US
")));
+
Assertions.assertFalse(ipMatcher.isMatched(createRequest("Us")));
+
Assertions.assertFalse(ipMatcher.isMatched(createRequest("ca")));
}
@Test
@@ -60,26 +60,26 @@ public class RangerSampleSimpleMatcherTest {
matcher.setConditionDef(null);
matcher.setPolicyItemCondition(null);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
RangerPolicyItemCondition policyItemCondition =
Mockito.mock(RangerPolicyItemCondition.class);
matcher.setConditionDef(null);
matcher.setPolicyItemCondition(policyItemCondition);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
RangerPolicyConditionDef conditionDef =
Mockito.mock(RangerPolicyConditionDef.class);
matcher.setConditionDef(conditionDef);
matcher.setPolicyItemCondition(null);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
// so should a policy item condition with initialized with null
list of values
Mockito.when(policyItemCondition.getValues()).thenReturn(null);
matcher.setConditionDef(conditionDef);
matcher.setPolicyItemCondition(policyItemCondition);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
// not null item condition with empty condition list
List<String> values = new ArrayList<String>();
@@ -87,7 +87,7 @@ public class RangerSampleSimpleMatcherTest {
matcher.setConditionDef(conditionDef);
matcher.setPolicyItemCondition(policyItemCondition);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
// values as sensible items in it, however, the conditionDef
has null evaluator option, so that too suppresses any check
values.add("AB");
@@ -96,14 +96,14 @@ public class RangerSampleSimpleMatcherTest {
matcher.setConditionDef(conditionDef);
matcher.setPolicyItemCondition(policyItemCondition);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
// If evaluator option on the condition def is non-null then it
starts to evaluate for real
Mockito.when(conditionDef.getEvaluatorOptions()).thenReturn(_conditionOptions);
matcher.setConditionDef(conditionDef);
matcher.setPolicyItemCondition(policyItemCondition);
matcher.init();
- Assert.assertTrue(matcher.isMatched(request));
+ Assertions.assertTrue(matcher.isMatched(request));
}
RangerSampleSimpleMatcher createMatcher(String[] ipArray) {