This is an automated email from the ASF dual-hosted git repository.
bpatel 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 1d5ac0923 RANGER-3722: Fix Test-case failure
1d5ac0923 is described below
commit 1d5ac0923d96f9e181ce8786f5cbd911cfb80a45
Author: Bhavik Patel <[email protected]>
AuthorDate: Wed Apr 20 17:59:47 2022 +0530
RANGER-3722: Fix Test-case failure
---
.../test/java/org/apache/ranger/rest/TestServiceREST.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git
a/security-admin/src/test/java/org/apache/ranger/rest/TestServiceREST.java
b/security-admin/src/test/java/org/apache/ranger/rest/TestServiceREST.java
index 6c5addbc9..d049f9949 100644
--- a/security-admin/src/test/java/org/apache/ranger/rest/TestServiceREST.java
+++ b/security-admin/src/test/java/org/apache/ranger/rest/TestServiceREST.java
@@ -19,6 +19,7 @@ package org.apache.ranger.rest;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
@@ -1762,7 +1763,7 @@ public class TestServiceREST {
SearchFilter filter = new SearchFilter();
filter.setParam("serviceType", "value");
- File jsonPolicyFile = new File(importPoliceTestFilePath);
+ File jsonPolicyFile = getFile(importPoliceTestFilePath);
InputStream uploadedInputStream = new
FileInputStream(jsonPolicyFile);
FormDataContentDisposition fileDetail =
FormDataContentDisposition.name("file")
.fileName(jsonPolicyFile.getName()).size(uploadedInputStream.toString().length()).build();
@@ -1827,7 +1828,7 @@ public class TestServiceREST {
SearchFilter filter = new SearchFilter();
filter.setParam("serviceType", "value");
- File jsonPolicyFile = new File(importPoliceTestFilePath);
+ File jsonPolicyFile = getFile(importPoliceTestFilePath);
InputStream uploadedInputStream = new
FileInputStream(jsonPolicyFile);
FormDataContentDisposition fileDetail =
FormDataContentDisposition.name("file")
.fileName(jsonPolicyFile.getName()).size(uploadedInputStream.toString().length()).build();
@@ -1860,6 +1861,14 @@ public class TestServiceREST {
}
+ private File getFile(String testFilePath) throws IOException {
+ File jsonPolicyFile = new File(testFilePath);
+ if
(jsonPolicyFile.getCanonicalPath().contains("/target/jstest")) {
+ jsonPolicyFile = new
File(jsonPolicyFile.getCanonicalPath().replace("/target/jstest", ""));
+ }
+ return jsonPolicyFile;
+ }
+
@Test
public void test51getMetricByType() throws Exception {
String type = "usergroup";