Repository: ranger
Updated Branches:
  refs/heads/master 2e0691984 -> 23624c64f


RANGER-1799 - Knox Ranger test coverity fixes

Signed-off-by: Colm O hEigeartaigh <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/51d918f6
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/51d918f6
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/51d918f6

Branch: refs/heads/master
Commit: 51d918f68dc24a5be37b59d0db2709aef26eaf6f
Parents: 2e06919
Author: Colm O hEigeartaigh <[email protected]>
Authored: Fri Sep 22 12:51:12 2017 +0100
Committer: Colm O hEigeartaigh <[email protected]>
Committed: Tue Sep 26 13:21:14 2017 +0100

----------------------------------------------------------------------
 .../org/apache/ranger/services/knox/KnoxRangerTest.java | 12 ++++++------
 .../ranger/services/knox/RangerAdminClientImpl.java     |  3 ++-
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/51d918f6/knox-agent/src/test/java/org/apache/ranger/services/knox/KnoxRangerTest.java
----------------------------------------------------------------------
diff --git 
a/knox-agent/src/test/java/org/apache/ranger/services/knox/KnoxRangerTest.java 
b/knox-agent/src/test/java/org/apache/ranger/services/knox/KnoxRangerTest.java
index deae684..53e66df 100644
--- 
a/knox-agent/src/test/java/org/apache/ranger/services/knox/KnoxRangerTest.java
+++ 
b/knox-agent/src/test/java/org/apache/ranger/services/knox/KnoxRangerTest.java
@@ -40,6 +40,7 @@ import 
org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -95,8 +96,7 @@ public class KnoxRangerTest {
         ldap.stop( true );
     }
 
-
-    public static void setupLdap() throws Exception {
+    private static void setupLdap() throws Exception {
         String basedir = System.getProperty("basedir");
         if (basedir == null) {
             basedir = new File(".").getCanonicalPath();
@@ -107,11 +107,11 @@ public class KnoxRangerTest {
         ldap.start();
     }
 
-    public static void setupGateway() throws Exception {
+    private static void setupGateway() throws Exception {
 
         File targetDir = new File( System.getProperty( "user.dir" ), "target" 
);
         File gatewayDir = new File( targetDir, "gateway-home-" + 
UUID.randomUUID() );
-        gatewayDir.mkdirs();
+        Assert.assertTrue(gatewayDir.mkdirs());
 
         config = new GatewayTestConfig();
         config.setGatewayHomeDir( gatewayDir.getAbsolutePath() );
@@ -119,10 +119,10 @@ public class KnoxRangerTest {
         config.setGatewayServicesDir(targetDir.getPath() + File.separator + 
"services");
 
         File topoDir = new File( config.getGatewayTopologyDir() );
-        topoDir.mkdirs();
+        Assert.assertTrue(topoDir.mkdirs());
 
         File deployDir = new File( config.getGatewayDeploymentDir() );
-        deployDir.mkdirs();
+        Assert.assertTrue(deployDir.mkdirs());
 
         File descriptor = new File( topoDir, "cluster.xml" );
         FileOutputStream stream = new FileOutputStream( descriptor );

http://git-wip-us.apache.org/repos/asf/ranger/blob/51d918f6/knox-agent/src/test/java/org/apache/ranger/services/knox/RangerAdminClientImpl.java
----------------------------------------------------------------------
diff --git 
a/knox-agent/src/test/java/org/apache/ranger/services/knox/RangerAdminClientImpl.java
 
b/knox-agent/src/test/java/org/apache/ranger/services/knox/RangerAdminClientImpl.java
index 6ce6979..a15905e 100644
--- 
a/knox-agent/src/test/java/org/apache/ranger/services/knox/RangerAdminClientImpl.java
+++ 
b/knox-agent/src/test/java/org/apache/ranger/services/knox/RangerAdminClientImpl.java
@@ -29,6 +29,7 @@ import org.apache.ranger.plugin.util.ServiceTags;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Charsets;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
@@ -60,7 +61,7 @@ public class RangerAdminClientImpl implements 
RangerAdminClient {
         java.nio.file.Path cachePath = 
FileSystems.getDefault().getPath(basedir, "/src/test/resources/" + 
cacheFilename);
         byte[] cacheBytes = Files.readAllBytes(cachePath);
 
-        return gson.fromJson(new String(cacheBytes), ServicePolicies.class);
+        return gson.fromJson(new String(cacheBytes, Charsets.UTF_8), 
ServicePolicies.class);
     }
 
     public void grantAccess(GrantRevokeRequest request) throws Exception {

Reply via email to