knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [2/2] knox git commit: Removing some (mostly unused) resource loading from the tests
Date Wed, 30 Aug 2017 16:00:08 GMT
Removing some (mostly unused) resource loading from the tests


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

Branch: refs/heads/master
Commit: 841295208ff9ae88e86c403542b884f59a2e6bf8
Parents: d5c2255
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Aug 30 16:59:43 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Aug 30 16:59:43 2017 +0100

----------------------------------------------------------------------
 .../gateway/AmbariServiceDefinitionTest.java    |  2 +-
 .../hadoop/gateway/GatewayAdminFuncTest.java    | 24 ----------------
 .../gateway/GatewayAdminTopologyFuncTest.java   | 22 ---------------
 .../hadoop/gateway/GatewayAppFuncTest.java      |  2 +-
 .../hadoop/gateway/GatewayDeployFuncTest.java   | 22 ---------------
 .../hadoop/gateway/GatewayHealthFuncTest.java   | 24 ----------------
 .../GatewayLdapDynamicGroupFuncTest.java        | 27 ------------------
 .../gateway/GatewayLdapGroupFuncTest.java       | 26 ------------------
 .../gateway/GatewayLdapPosixGroupFuncTest.java  | 22 +++------------
 .../gateway/GatewayLocalServiceFuncTest.java    | 23 ----------------
 .../hadoop/gateway/GatewayMultiFuncTest.java    |  3 +-
 .../gateway/GatewayPortMappingFuncTest.java     |  3 --
 .../hadoop/gateway/GatewaySampleFuncTest.java   | 24 ----------------
 .../hadoop/gateway/GatewaySslFuncTest.java      |  2 +-
 .../apache/hadoop/gateway/Knox242FuncTest.java  | 24 ----------------
 .../gateway/KnoxCliLdapFuncTestNegative.java    | 29 --------------------
 .../gateway/KnoxCliLdapFuncTestPositive.java    | 27 ------------------
 .../hadoop/gateway/KnoxCliSysBindTest.java      | 27 ------------------
 .../hadoop/gateway/WebHdfsHaFuncTest.java       |  1 -
 19 files changed, 8 insertions(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
index d17d0db..5e976cc 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java
@@ -57,7 +57,7 @@ import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
 public class AmbariServiceDefinitionTest {
 
   private static Logger LOG = LoggerFactory.getLogger( AmbariServiceDefinitionTest.class
);
-  private static Class DAT = AmbariServiceDefinitionTest.class;
+  private static Class<?> DAT = AmbariServiceDefinitionTest.class;
 
   private static GatewayTestConfig config;
   private static DefaultGatewayServices services;

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
index ea4c779..c19d2ef 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminFuncTest.java
@@ -25,10 +25,8 @@ import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,19 +35,15 @@ import javax.ws.rs.core.MediaType;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
 import static com.jayway.restassured.RestAssured.given;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
 public class GatewayAdminFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayAdminFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayAdminFuncTest.class );
 
   //public static Enumeration<Appender> appenders;
@@ -153,24 +147,6 @@ public class GatewayAdminFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   //@Test
   public void waitForManualTesting() throws IOException {
     System.out.println( clusterUrl );

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
index 9c8a38d..ec02b1f 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAdminTopologyFuncTest.java
@@ -20,11 +20,9 @@ package org.apache.hadoop.gateway;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.StringReader;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -48,7 +46,6 @@ import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -72,7 +69,6 @@ import static org.junit.Assert.fail;
 
 public class GatewayAdminTopologyFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayAdminTopologyFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayAdminTopologyFuncTest.class
);
 
   public static Enumeration<Appender> appenders;
@@ -233,24 +229,6 @@ public class GatewayAdminTopologyFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   //@Test
   public void waitForManualTesting() throws IOException {
     System.in.read();

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAppFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAppFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAppFuncTest.java
index 3007dfa..a78506d 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAppFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayAppFuncTest.java
@@ -63,7 +63,7 @@ import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
 public class GatewayAppFuncTest {
 
   private static Logger LOG = LoggerFactory.getLogger( GatewayAppFuncTest.class );
-  private static Class DAT = GatewayAppFuncTest.class;
+  private static Class<?> DAT = GatewayAppFuncTest.class;
 
   private static Enumeration<Appender> appenders;
   private static GatewayTestConfig config;

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
index 296f480..c1c0ffa 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
@@ -29,7 +29,6 @@ import org.apache.hadoop.test.category.ReleaseTest;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -43,8 +42,6 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -63,7 +60,6 @@ import static org.junit.Assert.assertThat;
 @Category(ReleaseTest.class)
 public class GatewayDeployFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayDeployFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayDeployFuncTest.class );
 
   public static Enumeration<Appender> appenders;
@@ -169,24 +165,6 @@ public class GatewayDeployFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   //@Test
   public void waitForManualTesting() throws IOException {
     System.in.read();

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayHealthFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayHealthFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayHealthFuncTest.java
index f78d309..159b952 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayHealthFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayHealthFuncTest.java
@@ -28,7 +28,6 @@ import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -39,9 +38,6 @@ import org.slf4j.LoggerFactory;
 import javax.ws.rs.core.MediaType;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.util.Arrays;
@@ -52,11 +48,9 @@ import java.util.UUID;
 
 import static com.jayway.restassured.RestAssured.given;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
 public class GatewayHealthFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayAdminFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger(GatewayAdminFuncTest.class);
 
   public static GatewayConfig config;
@@ -171,24 +165,6 @@ public class GatewayHealthFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream(String resource) throws IOException {
-    return getResourceUrl(resource).openStream();
-  }
-
-  public static URL getResourceUrl(String resource) {
-    URL url = ClassLoader.getSystemResource(getResourceName(resource));
-    assertThat("Failed to find test resource " + resource, url, Matchers.notNullValue());
-    return url;
-  }
-
-  public static String getResourceName(String resource) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll("\\.", "/") + "/";
-  }
-
   @Test(timeout = TestUtils.MEDIUM_TIMEOUT)
   public void testPingResource() {
     TestUtils.LOG_ENTER();

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
index 174eb58..2b5f0df 100755
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
@@ -22,14 +22,10 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
 import java.net.URL;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
@@ -39,20 +35,16 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.hadoop.gateway.config.GatewayConfig;
-import org.apache.hadoop.gateway.config.impl.GatewayConfigImpl;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.GatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.services.security.AliasService;
-import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -67,7 +59,6 @@ import com.mycila.xmltool.XMLTag;
  */
 public class GatewayLdapDynamicGroupFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayLdapDynamicGroupFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayLdapDynamicGroupFuncTest.class
);
 
   public static Enumeration<Appender> appenders;
@@ -254,24 +245,6 @@ public class GatewayLdapDynamicGroupFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   // @Test
   public void waitForManualTesting() throws IOException {
     System.in.read();

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
index d34decc..66cb311 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
@@ -22,14 +22,10 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -37,17 +33,14 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.hadoop.gateway.config.GatewayConfig;
-import org.apache.hadoop.gateway.config.impl.GatewayConfigImpl;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.GatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.services.security.AliasService;
-import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -65,7 +58,6 @@ import com.mycila.xmltool.XMLTag;
  */
 public class GatewayLdapGroupFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayLdapGroupFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayLdapGroupFuncTest.class );
 
   public static Enumeration<Appender> appenders;
@@ -246,24 +238,6 @@ public class GatewayLdapGroupFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   @Ignore
   // @Test
   public void waitForManualTesting() throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
index 4581623..6ca0c15 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
@@ -29,7 +29,6 @@ import org.apache.hadoop.test.category.ReleaseTest;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -41,7 +40,6 @@ import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
 import java.util.Enumeration;
@@ -54,8 +52,6 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
 
 /**
  * Functional test to verify : looking up ldap groups from directory
@@ -65,7 +61,7 @@ import static org.junit.Assert.fail;
 @Category(ReleaseTest.class)
 public class GatewayLdapPosixGroupFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayLdapPosixGroupFuncTest.class;
+  private static final Class<?> RESOURCE_BASE_CLASS = GatewayLdapPosixGroupFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayLdapPosixGroupFuncTest.class
);
 
   public static Enumeration<Appender> appenders;
@@ -80,7 +76,7 @@ public class GatewayLdapPosixGroupFuncTest {
   public static void setupSuite() throws Exception {
     LOG_ENTER();
     //appenders = NoOpAppender.setUp();
-    URL usersUrl = getResourceUrl( "users.ldif" );
+    URL usersUrl = TestUtils.getResourceUrl( GatewayLdapPosixGroupFuncTest.class, "users.ldif"
);
     driver.setupLdap( 0, new File( usersUrl.toURI() ) );
     setupGateway();
     TestUtils.awaitNon404HttpStatus( new URL( serviceUrl ), 10000, 100 );
@@ -225,21 +221,11 @@ public class GatewayLdapPosixGroupFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
+  private static String getResourceName( String resource ) {
     return getResourceBaseName() + resource;
   }
 
-  public static String getResourceBaseName() {
+  private static String getResourceBaseName() {
     return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLocalServiceFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLocalServiceFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLocalServiceFuncTest.java
index 57e3bd5..613eea7 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLocalServiceFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLocalServiceFuncTest.java
@@ -28,7 +28,6 @@ import org.apache.hadoop.test.log.NoOpAppender;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -37,9 +36,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -54,7 +50,6 @@ import static org.junit.Assert.assertThat;
 
 public class GatewayLocalServiceFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewayLocalServiceFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewayTestDriver.class );
 
   public static Enumeration<Appender> appenders;
@@ -182,22 +177,4 @@ public class GatewayLocalServiceFuncTest {
     LOG_EXIT();
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
index 47a8388..67852b9 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayMultiFuncTest.java
@@ -64,7 +64,6 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -75,7 +74,7 @@ import static org.xmlmatchers.transform.XmlConverters.the;
 public class GatewayMultiFuncTest {
 
   private static Logger LOG = LoggerFactory.getLogger( GatewayMultiFuncTest.class );
-  private static Class DAT = GatewayMultiFuncTest.class;
+  private static Class<?> DAT = GatewayMultiFuncTest.class;
 
   private static Enumeration<Appender> appenders;
   private static GatewayTestConfig config;

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayPortMappingFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayPortMappingFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayPortMappingFuncTest.java
index 91f54e3..0f7cc68 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayPortMappingFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayPortMappingFuncTest.java
@@ -24,15 +24,12 @@ import org.apache.hadoop.test.TestUtils;
 import org.apache.hadoop.test.category.ReleaseTest;
 import org.apache.hadoop.test.mock.MockServer;
 import org.apache.http.HttpStatus;
-import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.io.IOException;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static com.jayway.restassured.RestAssured.given;

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySampleFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySampleFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySampleFuncTest.java
index dc84cbd..5e71be2 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySampleFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySampleFuncTest.java
@@ -26,10 +26,8 @@ import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,8 +35,6 @@ import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -49,11 +45,9 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
 public class GatewaySampleFuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = GatewaySampleFuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( GatewaySampleFuncTest.class );
 
   public static Enumeration<Appender> appenders;
@@ -158,24 +152,6 @@ public class GatewaySampleFuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   //@Test
   public void waitForManualTesting() throws IOException {
     System.in.read();

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
index d2c2bf8..92c5d06 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewaySslFuncTest.java
@@ -83,7 +83,7 @@ import static org.xmlmatchers.xpath.HasXPath.hasXPath;
 public class GatewaySslFuncTest {
 
   private static Logger LOG = LoggerFactory.getLogger( GatewaySslFuncTest.class );
-  private static Class DAT = GatewaySslFuncTest.class;
+  private static Class<?> DAT = GatewaySslFuncTest.class;
 
   private static Enumeration<Appender> appenders;
   private static GatewayTestConfig config;

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
index 1910d96..4745640 100755
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
@@ -22,12 +22,10 @@ import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
 import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
@@ -37,17 +35,14 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.hadoop.gateway.config.GatewayConfig;
-import org.apache.hadoop.gateway.config.impl.GatewayConfigImpl;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.GatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.services.security.AliasService;
-import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -66,7 +61,6 @@ import com.mycila.xmltool.XMLTag;
  */
 public class Knox242FuncTest {
 
-  private static Class RESOURCE_BASE_CLASS = Knox242FuncTest.class;
   private static Logger LOG = LoggerFactory.getLogger( Knox242FuncTest.class );
 
   public static Enumeration<Appender> appenders;
@@ -245,24 +239,6 @@ public class Knox242FuncTest {
     return xml;
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   @Ignore
   // @Test
   public void waitForManualTesting() throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
index 9cf171d..5da00da 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestNegative.java
@@ -19,28 +19,20 @@ package org.apache.hadoop.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.commons.logging.impl.NoOpLog;
 import org.apache.hadoop.gateway.services.DefaultGatewayServices;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.hadoop.test.log.NoOpAppender;
-import org.apache.hadoop.test.log.NoOpLogger;
 import org.apache.log4j.Appender;
-import org.hamcrest.Matchers;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.PrintStream;
-import java.io.InputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.ByteArrayOutputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -54,9 +46,6 @@ import static org.junit.Assert.assertThat;
 
 public class KnoxCliLdapFuncTestNegative {
 
-  private static Class RESOURCE_BASE_CLASS = KnoxCliLdapFuncTestPositive.class;
-  private static Logger LOG = LoggerFactory.getLogger( KnoxCliLdapFuncTestPositive.class
);
-
   public static Enumeration<Appender> appenders;
   public static GatewayTestConfig config;
   public static GatewayServer gateway;
@@ -136,24 +125,6 @@ public class KnoxCliLdapFuncTestNegative {
 
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   private static XMLTag createBadTopology(){
     XMLTag xml = XMLDoc.newDocument(true)
         .addRoot("topology")

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
index db2b2f6..908f942 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliLdapFuncTestPositive.java
@@ -25,20 +25,14 @@ import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.hadoop.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
-import org.hamcrest.Matchers;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.PrintStream;
-import java.io.InputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.ByteArrayOutputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -52,9 +46,6 @@ import static org.junit.Assert.assertThat;
 
 public class KnoxCliLdapFuncTestPositive {
 
-  private static Class RESOURCE_BASE_CLASS = KnoxCliLdapFuncTestPositive.class;
-  private static Logger LOG = LoggerFactory.getLogger( KnoxCliLdapFuncTestPositive.class
);
-
   public static Enumeration<Appender> appenders;
   public static GatewayTestConfig config;
   public static GatewayServer gateway;
@@ -134,24 +125,6 @@ public class KnoxCliLdapFuncTestPositive {
 
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   private static XMLTag createBadTopology(){
     XMLTag xml = XMLDoc.newDocument(true)
         .addRoot("topology")

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliSysBindTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliSysBindTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliSysBindTest.java
index c9b94e7..0681f18 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliSysBindTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/KnoxCliSysBindTest.java
@@ -25,20 +25,14 @@ import org.apache.hadoop.gateway.util.KnoxCLI;
 import org.apache.hadoop.test.TestUtils;
 import org.apache.hadoop.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
-import org.hamcrest.Matchers;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -51,9 +45,6 @@ import static org.junit.Assert.assertThat;
 
 public class KnoxCliSysBindTest {
 
-  private static Class RESOURCE_BASE_CLASS = KnoxCliSysBindTest.class;
-  private static Logger LOG = LoggerFactory.getLogger( KnoxCliSysBindTest.class );
-
   public static Enumeration<Appender> appenders;
   public static GatewayTestConfig config;
   public static GatewayServer gateway;
@@ -138,24 +129,6 @@ public class KnoxCliSysBindTest {
 
   }
 
-  public static InputStream getResourceStream( String resource ) throws IOException {
-    return getResourceUrl( resource ).openStream();
-  }
-
-  public static URL getResourceUrl( String resource ) {
-    URL url = ClassLoader.getSystemResource( getResourceName( resource ) );
-    assertThat( "Failed to find test resource " + resource, url, Matchers.notNullValue()
);
-    return url;
-  }
-
-  public static String getResourceName( String resource ) {
-    return getResourceBaseName() + resource;
-  }
-
-  public static String getResourceBaseName() {
-    return RESOURCE_BASE_CLASS.getName().replaceAll( "\\.", "/" ) + "/";
-  }
-
   private static XMLTag createBadTopology(){
     XMLTag xml = XMLDoc.newDocument(true)
         .addRoot("topology")

http://git-wip-us.apache.org/repos/asf/knox/blob/84129520/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
index 39fb0ab..32aa11d 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
@@ -30,7 +30,6 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.io.IOException;
-import java.net.ServerSocket;
 
 import static com.jayway.restassured.RestAssured.given;
 import static org.apache.hadoop.test.TestUtils.LOG_ENTER;


Mime
View raw message