knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [23/25] knox git commit: KNOX-998 - Some more refactoring
Date Thu, 02 Nov 2017 18:48:27 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletRequest.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletRequest.java
new file mode 100644
index 0000000..b43465f
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletRequest.java
@@ -0,0 +1,410 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+public class MockHttpServletRequest implements HttpServletRequest {
+
+  private String queryString;
+  private String contentType;
+  private String characterEncoding;
+  private ServletInputStream inputStream;
+  private String method = "GET";
+
+  @Override
+  public String getAuthType() {
+    return null;
+  }
+
+  @Override
+  public Cookie[] getCookies() {
+    return new Cookie[ 0 ];
+  }
+
+  @Override
+  public long getDateHeader( String s ) {
+    return 0;
+  }
+
+  @Override
+  public String getHeader( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getHeaders( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getHeaderNames() {
+    return null;
+  }
+
+  @Override
+  public int getIntHeader( String s ) {
+    return 0;
+  }
+
+  @Override
+  public String getMethod() {
+    return method;
+  }
+
+  public void setMethod( String method ) {
+    this.method = method;
+  }
+
+  @Override
+  public String getPathInfo() {
+    return null;
+  }
+
+  @Override
+  public String getPathTranslated() {
+    return null;
+  }
+
+  @Override
+  public String getContextPath() {
+    return null;
+  }
+
+  @Override
+  public String getQueryString() {
+    return queryString;
+  }
+
+  public void setQueryString( String queryString ) {
+    this.queryString = queryString;
+  }
+
+  @Override
+  public String getRemoteUser() {
+    return null;
+  }
+
+  @Override
+  public boolean isUserInRole( String s ) {
+    return false;
+  }
+
+  @Override
+  public Principal getUserPrincipal() {
+    return null;
+  }
+
+  @Override
+  public String getRequestedSessionId() {
+    return null;
+  }
+
+  @Override
+  public String getRequestURI() {
+    return null;
+  }
+
+  @Override
+  public StringBuffer getRequestURL() {
+    return null;
+  }
+
+  @Override
+  public String getServletPath() {
+    return null;
+  }
+
+  @Override
+  public HttpSession getSession( boolean b ) {
+    return null;
+  }
+
+  @Override
+  public HttpSession getSession() {
+    return null;
+  }
+
+  @Override
+  public String changeSessionId() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public boolean isRequestedSessionIdValid() {
+    return false;
+  }
+
+  @Override
+  public boolean isRequestedSessionIdFromCookie() {
+    return false;
+  }
+
+  @Override
+  public boolean isRequestedSessionIdFromURL() {
+    return false;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public boolean isRequestedSessionIdFromUrl() {
+    return false;
+  }
+
+  @Override
+  public boolean authenticate( HttpServletResponse httpServletResponse ) throws IOException, ServletException {
+    return false;
+  }
+
+  @Override
+  public void login( String s, String s1 ) throws ServletException {
+  }
+
+  @Override
+  public void logout() throws ServletException {
+  }
+
+  @Override
+  public Collection<Part> getParts() throws IOException, ServletException {
+    return null;
+  }
+
+  @Override
+  public Part getPart( String s ) throws IOException, ServletException {
+    return null;
+  }
+
+  @Override
+  public <T extends HttpUpgradeHandler> T upgrade( Class<T> aClass ) throws IOException, ServletException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Object getAttribute( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getAttributeNames() {
+    return null;
+  }
+
+  @Override
+  public String getCharacterEncoding() {
+    return characterEncoding;
+  }
+
+  @Override
+  public void setCharacterEncoding( String characterEncoding ) throws UnsupportedEncodingException {
+    this.characterEncoding = characterEncoding;
+  }
+
+  @Override
+  public int getContentLength() {
+    return 0;
+  }
+
+  @Override
+  public long getContentLengthLong() {
+    return 0;
+  }
+
+  @Override
+  public String getContentType() {
+    return contentType;
+  }
+
+  public void setContentType( String contentType ) {
+    this.contentType = contentType;
+  }
+
+  @Override
+  public ServletInputStream getInputStream() throws IOException {
+    return inputStream;
+  }
+
+  public void setInputStream( ServletInputStream intputStream ) {
+    this.inputStream = intputStream;
+  }
+
+  @Override
+  public String getParameter( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getParameterNames() {
+    return null;
+  }
+
+  @Override
+  public String[] getParameterValues( String s ) {
+    return new String[ 0 ];
+  }
+
+  @Override
+  public Map<String, String[]> getParameterMap() {
+    return null;
+  }
+
+  @Override
+  public String getProtocol() {
+    return null;
+  }
+
+  @Override
+  public String getScheme() {
+    return null;
+  }
+
+  @Override
+  public String getServerName() {
+    return null;
+  }
+
+  @Override
+  public int getServerPort() {
+    return 0;
+  }
+
+  @Override
+  public BufferedReader getReader() throws IOException {
+    return null;
+  }
+
+  @Override
+  public String getRemoteAddr() {
+    return null;
+  }
+
+  @Override
+  public String getRemoteHost() {
+    return null;
+  }
+
+  @Override
+  public void setAttribute( String s, Object o ) {
+  }
+
+  @Override
+  public void removeAttribute( String s ) {
+  }
+
+  @Override
+  public Locale getLocale() {
+    return null;
+  }
+
+  @Override
+  public Enumeration<Locale> getLocales() {
+    return null;
+  }
+
+  @Override
+  public boolean isSecure() {
+    return false;
+  }
+
+  @Override
+  public RequestDispatcher getRequestDispatcher( String s ) {
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public String getRealPath( String s ) {
+    return null;
+  }
+
+  @Override
+  public int getRemotePort() {
+    return 0;
+  }
+
+  @Override
+  public String getLocalName() {
+    return null;
+  }
+
+  @Override
+  public String getLocalAddr() {
+    return null;
+  }
+
+  @Override
+  public int getLocalPort() {
+    return 0;
+  }
+
+  @Override
+  public ServletContext getServletContext() {
+    return null;
+  }
+
+  @Override
+  public AsyncContext startAsync() throws IllegalStateException {
+    return null;
+  }
+
+  @Override
+  public AsyncContext startAsync( ServletRequest servletRequest, ServletResponse servletResponse ) throws IllegalStateException {
+    return null;
+  }
+
+  @Override
+  public boolean isAsyncStarted() {
+    return false;
+  }
+
+  @Override
+  public boolean isAsyncSupported() {
+    return false;
+  }
+
+  @Override
+  public AsyncContext getAsyncContext() {
+    return null;
+  }
+
+  @Override
+  public DispatcherType getDispatcherType() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletResponse.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletResponse.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletResponse.java
new file mode 100644
index 0000000..69f69b3
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockHttpServletResponse.java
@@ -0,0 +1,195 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Locale;
+
+public class MockHttpServletResponse implements HttpServletResponse {
+
+  @Override
+  public void addCookie( Cookie cookie ) {
+  }
+
+  @Override
+  public boolean containsHeader( String s ) {
+    return false;
+  }
+
+  @Override
+  public String encodeURL( String s ) {
+    return null;
+  }
+
+  @Override
+  public String encodeRedirectURL( String s ) {
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public String encodeUrl( String s ) {
+    return null;
+  }
+
+  @Override
+  public String encodeRedirectUrl( String s ) {
+    return null;
+  }
+
+  @Override
+  public void sendError( int i, String s ) throws IOException {
+  }
+
+  @Override
+  public void sendError( int i ) throws IOException {
+  }
+
+  @Override
+  public void sendRedirect( String s ) throws IOException {
+  }
+
+  @Override
+  public void setDateHeader( String s, long l ) {
+  }
+
+  @Override
+  public void addDateHeader( String s, long l ) {
+  }
+
+  @Override
+  public void setHeader( String s, String s1 ) {
+  }
+
+  @Override
+  public void addHeader( String s, String s1 ) {
+  }
+
+  @Override
+  public void setIntHeader( String s, int i ) {
+  }
+
+  @Override
+  public void addIntHeader( String s, int i ) {
+  }
+
+  @Override
+  public void setStatus( int i ) {
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public void setStatus( int i, String s ) {
+  }
+
+  @Override
+  public int getStatus() {
+    return 0;
+  }
+
+  @Override
+  public String getHeader( String s ) {
+    return null;
+  }
+
+  @Override
+  public Collection<String> getHeaders( String s ) {
+    return null;
+  }
+
+  @Override
+  public Collection<String> getHeaderNames() {
+    return null;
+  }
+
+  @Override
+  public String getCharacterEncoding() {
+    return null;
+  }
+
+  @Override
+  public String getContentType() {
+    return null;
+  }
+
+  @Override
+  public ServletOutputStream getOutputStream() throws IOException {
+    return null;
+  }
+
+  @Override
+  public PrintWriter getWriter() throws IOException {
+    return null;
+  }
+
+  @Override
+  public void setCharacterEncoding( String s ) {
+  }
+
+  @Override
+  public void setContentLength( int i ) {
+  }
+
+  @Override
+  public void setContentLengthLong( long l ) {
+  }
+
+  @Override
+  public void setContentType( String s ) {
+  }
+
+  @Override
+  public void setBufferSize( int i ) {
+  }
+
+  @Override
+  public int getBufferSize() {
+    return 0;
+  }
+
+  @Override
+  public void flushBuffer() throws IOException {
+  }
+
+  @Override
+  public void resetBuffer() {
+  }
+
+  @Override
+  public boolean isCommitted() {
+    return false;
+  }
+
+  @Override
+  public void reset() {
+  }
+
+  @Override
+  public void setLocale( Locale locale ) {
+  }
+
+  @Override
+  public Locale getLocale() {
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockInteraction.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockInteraction.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockInteraction.java
new file mode 100644
index 0000000..b326ec4
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockInteraction.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+public class MockInteraction {
+
+  private MockResponseProvider response = new MockResponseProvider();
+  private MockRequestMatcher request = new MockRequestMatcher( response );
+
+  public MockRequestMatcher expect() {
+    return request;
+  }
+
+  public MockResponseProvider respond() {
+    return response;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
new file mode 100644
index 0000000..fc0a105
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
@@ -0,0 +1,330 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.message.BasicNameValuePair;
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
+import static org.xmlmatchers.XmlMatchers.isEquivalentTo;
+import static org.xmlmatchers.transform.XmlConverters.the;
+import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
+
+public class MockRequestMatcher {
+
+  private static final Charset UTF8 = Charset.forName( "UTF-8" );
+
+  private String from;
+  private MockResponseProvider response;
+  private Set<String> methods = null;
+  private String pathInfo = null;
+  private String requestURL = null;
+  Map<String,Matcher> headers = null;
+  Set<Cookie> cookies = null;
+  private Map<String,Object> attributes = null;
+  private Map<String,String> queryParams = null;
+  private String contentType = null;
+  private String characterEncoding = null;
+  private Integer contentLength = null;
+  private byte[] entity = null;
+  private Map<String,String[]> formParams = null;
+
+  public MockRequestMatcher( MockResponseProvider response ) {
+    this.response = response;
+  }
+
+  public MockResponseProvider respond() {
+    return response;
+  }
+
+  public MockRequestMatcher from( String from ) {
+    this.from = from;
+    return this;
+  }
+
+  public MockRequestMatcher method( String... methods ) {
+    if( this.methods == null ) {
+      this.methods = new HashSet<>();
+    }
+    if( methods != null ) {
+      for( String method: methods ) {
+        this.methods.add( method );
+      }
+    }
+    return this;
+  }
+
+  public MockRequestMatcher pathInfo( String pathInfo ) {
+    this.pathInfo = pathInfo;
+    return this;
+  }
+
+  public MockRequestMatcher requestUrl( String requestUrl ) {
+    this.requestURL = requestUrl;
+    return this;
+  }
+
+  public MockRequestMatcher header( String name, String value ) {
+    if( headers == null ) {
+      headers = new HashMap<>();
+    }
+    headers.put( name, Matchers.is(value) );
+    return this;
+  }
+
+  public MockRequestMatcher header( String name, Matcher matcher ) {
+    if( headers == null ) {
+      headers = new HashMap<>();
+    }
+    headers.put( name, matcher );
+    return this;
+  }
+
+  public MockRequestMatcher cookie( Cookie cookie ) {
+    if( cookies == null ) {
+      cookies = new HashSet<>();
+    }
+    cookies.add( cookie );
+    return this;
+  }
+
+  public MockRequestMatcher attribute( String name, Object value ) {
+    if( this.attributes == null ) {
+      this.attributes = new HashMap<>();
+    }
+    attributes.put( name, value );
+    return this;
+  }
+
+  public MockRequestMatcher queryParam( String name, String value ) {
+    if( this.queryParams == null ) {
+      this.queryParams = new HashMap<>();
+    }
+    queryParams.put( name, value );
+    return this;
+  }
+
+  public MockRequestMatcher formParam( String name, String... values ) {
+    if( entity != null ) {
+      throw new IllegalStateException( "Entity already specified." );
+    }
+    if( formParams == null ) {
+      formParams = new HashMap<>();
+    }
+    String[] currentValues = formParams.get( name );
+    if( currentValues == null ) {
+      currentValues = values;
+    } else if ( values != null ) {
+      currentValues = ArrayUtils.addAll( currentValues, values );
+    }
+    formParams.put( name, currentValues );
+    return this;
+  }
+
+  public MockRequestMatcher content( String string, Charset charset ) {
+    content( string.getBytes( charset ) );
+    return this;
+  }
+
+  public MockRequestMatcher content( byte[] entity ) {
+    if( formParams != null ) {
+      throw new IllegalStateException( "Form params already specified." );
+    }
+    this.entity = entity;
+    return this;
+  }
+
+  public MockRequestMatcher content( URL url ) throws IOException {
+    content( url.openStream() );
+    return this;
+  }
+
+  public MockRequestMatcher content( InputStream stream ) throws IOException {
+    content( IOUtils.toByteArray( stream ) );
+    return this;
+  }
+
+  public MockRequestMatcher contentType( String contentType ) {
+    this.contentType = contentType;
+    return this;
+  }
+
+  public MockRequestMatcher contentLength( int length ) {
+    this.contentLength = length;
+    return this;
+  }
+
+  public MockRequestMatcher characterEncoding( String charset ) {
+    this.characterEncoding = charset;
+    return this;
+  }
+
+  public void match( HttpServletRequest request ) throws IOException {
+    if( methods != null ) {
+      assertThat(
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " is not using one of the expected HTTP methods",
+          methods, hasItem( request.getMethod() ) );
+    }
+    if( pathInfo != null ) {
+      assertThat(
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " does not have the expected pathInfo",
+          request.getPathInfo(), is( pathInfo ) );
+    }
+    if( requestURL != null ) {
+      assertThat( 
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " does not have the expected requestURL",
+          request.getRequestURL().toString(), is( requestURL ) );
+    }
+    if( headers != null ) {
+      for( Entry<String, Matcher> entry : headers.entrySet() ) {
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " does not have the expected value for header " + entry.getKey(),
+            request.getHeader( entry.getKey() ),  entry.getValue() );
+      }
+    }
+    if( cookies != null ) {
+      List<Cookie> requestCookies = Arrays.asList( request.getCookies() );
+      for( Cookie cookie: cookies ) {
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " does not have the expected cookie " + cookie,
+            requestCookies, hasItem( cookie ) );
+      }
+    }
+    if( contentType != null ) {
+      String[] requestContentType = request.getContentType().split(";",2);
+      assertThat(
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " does not have the expected content type",
+          requestContentType[ 0 ], is( contentType ) );
+    }
+    if( characterEncoding != null ) {
+      assertThat(
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " does not have the expected character encoding",
+          request.getCharacterEncoding(), equalToIgnoringCase( characterEncoding ) );
+    }
+    if( contentLength != null ) {
+      assertThat(
+          "Request " + request.getMethod() + " " + request.getRequestURL() +
+              " does not have the expected content length",
+          request.getContentLength(), is( contentLength ) );
+    }
+    if( attributes != null ) {
+      for( String name: attributes.keySet() ) {
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " is missing attribute '" + name + "'",
+            request.getAttribute( name ), notNullValue() );
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " has wrong value for attribute '" + name + "'",
+            request.getAttribute( name ), is( request.getAttribute( name ) ) );
+      }
+    }
+    // Note: Cannot use any of the expect.getParameter*() methods because they will read the
+    // body and we don't want that to happen.
+    if( queryParams != null ) {
+      String queryString = request.getQueryString();
+      List<NameValuePair> requestParams = parseQueryString( queryString == null ? "" : queryString );
+      for( Entry<String, String> entry : queryParams.entrySet() ) {
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " query string " + queryString + " is missing parameter '" + entry.getKey() + "'",
+            requestParams, hasItem( new BasicNameValuePair(entry.getKey(), entry.getValue())) );
+      }
+    }
+    if( formParams != null ) {
+      String paramString = IOUtils.toString( request.getInputStream(), request.getCharacterEncoding() );
+      List<NameValuePair> requestParams = parseQueryString( paramString == null ? "" : paramString );
+      for( Entry<String, String[]> entry : formParams.entrySet() ) {
+        String[] expectedValues = entry.getValue();
+        for( String expectedValue : expectedValues ) {
+          assertThat(
+              "Request " + request.getMethod() + " " + request.getRequestURL() +
+                  " form params " + paramString + " is missing a value " + expectedValue + " for parameter '" + entry.getKey() + "'",
+              requestParams, hasItem( new BasicNameValuePair(entry.getKey(), expectedValue ) ));
+        }
+      }
+    }
+    if( entity != null ) {
+      if( contentType != null && contentType.endsWith( "/xml" ) ) {
+        String expectEncoding = characterEncoding;
+        String expect = new String( entity, ( expectEncoding == null ? UTF8.name() : expectEncoding ) );
+        String actualEncoding = request.getCharacterEncoding();
+        String actual = IOUtils.toString( request.getInputStream(), actualEncoding == null ? UTF8.name() : actualEncoding );
+        assertThat( the( actual ), isEquivalentTo( the( expect ) ) );
+      } else if ( contentType != null && contentType.endsWith( "/json" ) )  {
+        String expectEncoding = characterEncoding;
+        String expect = new String( entity, ( expectEncoding == null ? UTF8.name() : expectEncoding ) );
+        String actualEncoding = request.getCharacterEncoding();
+        String actual = IOUtils.toString( request.getInputStream(), actualEncoding == null ? UTF8.name() : actualEncoding );
+//        System.out.println( "EXPECT=" + expect );
+//        System.out.println( "ACTUAL=" + actual );
+        assertThat( actual, sameJSONAs( expect ) );
+      } else if( characterEncoding == null || request.getCharacterEncoding() == null ) {
+        byte[] bytes = IOUtils.toByteArray( request.getInputStream() );
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " content does not match the expected content",
+            bytes, is( entity ) );
+      } else {
+        String expect = new String( entity, characterEncoding );
+        String actual = IOUtils.toString( request.getInputStream(), request.getCharacterEncoding() );
+        assertThat(
+            "Request " + request.getMethod() + " " + request.getRequestURL() +
+                " content does not match the expected content",
+            actual, is( expect ) );
+      }
+    }
+  }
+
+  public String toString() {
+    return "from=" + from + ", pathInfo=" + pathInfo;
+  }
+
+  private static List<NameValuePair> parseQueryString( String queryString ) {
+    return URLEncodedUtils.parse(queryString, Charset.defaultCharset());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
new file mode 100644
index 0000000..503ff65
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import org.apache.commons.io.IOUtils;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+public class MockResponseProvider {
+
+  Integer errorCode = null;
+  String errorMsg = null;
+  Integer statusCode = null;
+  String redirectUrl = null;
+  Map<String,String> headers = null;
+  Set<Cookie> cookies = null;
+  byte[] entity = null;
+  String contentType = null;
+  String characterEncoding = null;
+  Integer contentLength = null;
+
+  public MockResponseProvider status( int statusCode ) {
+    this.statusCode = statusCode;
+    return this;
+  }
+
+  public MockResponseProvider error( int code, String message ) {
+    errorCode = code;
+    errorMsg = message;
+    return this;
+  }
+
+  public MockResponseProvider redirect( String location ) {
+    redirectUrl = location;
+    return this;
+  }
+
+  public MockResponseProvider header( String name, String value ) {
+    if( headers == null ) {
+      headers = new HashMap<>();
+    }
+    headers.put( name, value );
+    return this;
+  }
+
+  public MockResponseProvider cookie( Cookie cookie ) {
+    if( cookies == null ) {
+      cookies = new HashSet<>();
+    }
+    cookies.add( cookie );
+    return this;
+  }
+
+  public MockResponseProvider content( byte[] entity ) {
+    this.entity = entity;
+    return this;
+  }
+
+  public MockResponseProvider content( String string, Charset charset ) {
+    this.entity = string.getBytes( charset );
+    return this;
+  }
+
+  public MockResponseProvider content( URL url ) throws IOException {
+    content( url.openStream() );
+    return this;
+  }
+
+  public MockResponseProvider content( InputStream stream ) throws IOException {
+    content( IOUtils.toByteArray( stream ) );
+    return this;
+  }
+
+  public MockResponseProvider contentType( String contentType ) {
+    this.contentType = contentType;
+    return this;
+  }
+
+  public MockResponseProvider contentLength( int contentLength ) {
+    this.contentLength = contentLength;
+    return this;
+  }
+
+  public MockResponseProvider characterEncoding( String charset ) {
+    this.characterEncoding = charset;
+    return this;
+  }
+
+  public void apply( HttpServletResponse response ) throws IOException {
+    if( statusCode != null ) {
+      response.setStatus( statusCode );
+    } else {
+      response.setStatus( HttpServletResponse.SC_OK );
+    }
+    if( errorCode != null ) {
+      if( errorMsg != null ) {
+        response.sendError( errorCode, errorMsg );
+      } else {
+        response.sendError( errorCode );
+      }
+    }
+    if( redirectUrl != null ) {
+      response.sendRedirect( redirectUrl );
+    }
+    if( headers != null ) {
+      for( Entry<String, String> entry : headers.entrySet() ) {
+        response.addHeader( entry.getKey(), entry.getValue() );
+      }
+    }
+    if( cookies != null ) {
+      for( Cookie cookie: cookies ) {
+        response.addCookie( cookie );
+      }
+    }
+    if( contentType != null ) {
+      response.setContentType( contentType );
+    }
+    if( characterEncoding != null ) {
+      response.setCharacterEncoding( characterEncoding );
+    }
+    if( contentLength != null ) {
+      response.setContentLength( contentLength );
+    }
+    response.flushBuffer();
+    if( entity != null ) {
+      response.getOutputStream().write( entity );
+      //KNOX-685: response.getOutputStream().flush();
+      response.getOutputStream().close();
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServer.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServer.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServer.java
new file mode 100644
index 0000000..09905cd
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServer.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.Servlet;
+import java.util.LinkedList;
+import java.util.Queue;
+
+/**
+ * An embedded Jetty server with a single servlet deployed on "/*".
+ * It is used by populating a queue of "interactions".
+ * Each interaction is an expected request and a resulting response.
+ * These interactions are added to a queue in a fluent API style.
+ * So in most of the tests like GatewayBasicFuncTest.testBasicJsonUseCase you will see calls like
+ * driver.getMock( "WEBHDFS" ).expect()....respond()...;
+ * This adds a single interaction to the mock server which is returned via the driver.getMock( "WEBHDFS" ) above.
+ * Any number of interactions may be added.
+ * When the request comes in it will check the request against the expected request.
+ * If it matches return the response otherwise it will return a 500 error.
+ * Typically at the end of a test you should check to make sure the interaction queue is consumed by calling isEmpty().
+ * The reset() method can be used to ensure everything is cleaned up so that the mock server can be reused beteween tests.
+ * The whole idea was modeled after how the REST testing framework REST-assured and aims to be a server side equivalent.
+ */
+public class MockServer {
+
+  private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+  private String name;
+  private Server jetty;
+
+  private Queue<MockInteraction> interactions = new LinkedList<MockInteraction>();
+
+  public MockServer( String name ) {
+    this.name = name;
+  }
+
+  public MockServer( String name, boolean start ) throws Exception {
+    this.name = name;
+    if( start ) {
+      start();
+    }
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void start() throws Exception {
+    Handler context = createHandler();
+    jetty = new Server(0);
+    jetty.setHandler( context );
+    jetty.start();
+    log.info( "Mock server started on port " + getPort() );
+  }
+
+  public void stop() throws Exception {
+    jetty.stop();
+    jetty.join();
+  }
+
+  private ServletContextHandler createHandler() {
+    Servlet servlet = new MockServlet( getName(), interactions );
+    ServletHolder holder = new ServletHolder( servlet );
+    ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS );
+    context.setContextPath( "/" );
+    context.addServlet( holder, "/*" );
+    return context;
+  }
+
+  public int getPort() {
+    return jetty.getURI().getPort();
+  }
+
+  public MockRequestMatcher expect() {
+    MockInteraction interaction = new MockInteraction();
+    interactions.add( interaction );
+    return interaction.expect();
+  }
+
+  public MockResponseProvider respond() {
+    MockInteraction interaction = new MockInteraction();
+    interactions.add( interaction );
+    return interaction.respond();
+  }
+
+  public int getCount() {
+    return interactions.size();
+  }
+
+  public boolean isEmpty() {
+    return interactions.isEmpty();
+  }
+
+  public void reset() {
+    interactions.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServlet.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServlet.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServlet.java
new file mode 100644
index 0000000..2c82dfd
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServlet.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Queue;
+
+import org.apache.log4j.Logger;
+
+import static org.junit.Assert.fail;
+
+public class MockServlet extends HttpServlet {
+
+  private static final Logger LOG = Logger.getLogger(MockServlet.class.getName());
+
+  public String name;
+  public Queue<MockInteraction> interactions;
+
+  public MockServlet( String name, Queue<MockInteraction> interactions ) {
+    this.name = name;
+    this.interactions = interactions;
+  }
+
+  @Override
+  protected void service( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
+    LOG.debug( "service: request=" + request.getMethod() + " " + request.getRequestURL() + "?" + request.getQueryString() );
+    try {
+      if( interactions.isEmpty() ) {
+        fail( "Mock servlet " + name + " received a request but the expected interaction queue is empty." );
+      }
+      MockInteraction interaction = interactions.remove();
+      interaction.expect().match( request );
+      interaction.respond().apply( response );
+      LOG.debug( "service: response=" + response.getStatus() );
+    } catch( AssertionError e ) {
+      LOG.debug( "service: exception=" + e.getMessage() );
+      e.printStackTrace(); // I18N not required.
+      throw new ServletException( e );
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletContext.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletContext.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletContext.java
new file mode 100644
index 0000000..4181067
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletContext.java
@@ -0,0 +1,293 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
+import java.util.Set;
+
+public class MockServletContext implements ServletContext {
+
+  @Override
+  public String getContextPath() {
+    return null;
+  }
+
+  @Override
+  public ServletContext getContext( String s ) {
+    return null;
+  }
+
+  @Override
+  public int getMajorVersion() {
+    return 0;
+  }
+
+  @Override
+  public int getMinorVersion() {
+    return 0;
+  }
+
+  @Override
+  public int getEffectiveMajorVersion() {
+    return 0;
+  }
+
+  @Override
+  public int getEffectiveMinorVersion() {
+    return 0;
+  }
+
+  @Override
+  public String getMimeType( String s ) {
+    return null;
+  }
+
+  @Override
+  public Set<String> getResourcePaths( String s ) {
+    return null;
+  }
+
+  @Override
+  public URL getResource( String s ) throws MalformedURLException {
+    return null;
+  }
+
+  @Override
+  public InputStream getResourceAsStream( String s ) {
+    return null;
+  }
+
+  @Override
+  public RequestDispatcher getRequestDispatcher( String s ) {
+    return null;
+  }
+
+  @Override
+  public RequestDispatcher getNamedDispatcher( String s ) {
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public Servlet getServlet( String s ) throws ServletException {
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public Enumeration<Servlet> getServlets() {
+    return null;
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public Enumeration<String> getServletNames() {
+    return null;
+  }
+
+  @Override
+  public void log( String s ) {
+  }
+
+  @Override
+  @SuppressWarnings("deprecation")
+  public void log( Exception e, String s ) {
+  }
+
+  @Override
+  public void log( String s, Throwable throwable ) {
+  }
+
+  @Override
+  public String getRealPath( String s ) {
+    return null;
+  }
+
+  @Override
+  public String getServerInfo() {
+    return null;
+  }
+
+  @Override
+  public String getInitParameter( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getInitParameterNames() {
+    return null;
+  }
+
+  @Override
+  public boolean setInitParameter( String s, String s1 ) {
+    return false;
+  }
+
+  @Override
+  public Object getAttribute( String s ) {
+    return null;
+  }
+
+  @Override
+  public Enumeration<String> getAttributeNames() {
+    return null;
+  }
+
+  @Override
+  public void setAttribute( String s, Object o ) {
+  }
+
+  @Override
+  public void removeAttribute( String s ) {
+  }
+
+  @Override
+  public String getServletContextName() {
+    return null;
+  }
+
+  @Override
+  public ServletRegistration.Dynamic addServlet( String s, String s1 ) {
+    return null;
+  }
+
+  @Override
+  public ServletRegistration.Dynamic addServlet( String s, Servlet servlet ) {
+    return null;
+  }
+
+  @Override
+  public ServletRegistration.Dynamic addServlet( String s, Class<? extends Servlet> aClass ) {
+    return null;
+  }
+
+  @Override
+  public <T extends Servlet> T createServlet( Class<T> tClass ) throws ServletException {
+    return null;
+  }
+
+  @Override
+  public ServletRegistration getServletRegistration( String s ) {
+    return null;
+  }
+
+  @Override
+  public Map<String, ? extends ServletRegistration> getServletRegistrations() {
+    return null;
+  }
+
+  @Override
+  public FilterRegistration.Dynamic addFilter( String s, String s1 ) {
+    return null;
+  }
+
+  @Override
+  public FilterRegistration.Dynamic addFilter( String s, Filter filter ) {
+    return null;
+  }
+
+  @Override
+  public FilterRegistration.Dynamic addFilter( String s, Class<? extends Filter> aClass ) {
+    return null;
+  }
+
+  @Override
+  public <T extends Filter> T createFilter( Class<T> tClass ) throws ServletException {
+    return null;
+  }
+
+  @Override
+  public FilterRegistration getFilterRegistration( String s ) {
+    return null;
+  }
+
+  @Override
+  public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
+    return null;
+  }
+
+  @Override
+  public SessionCookieConfig getSessionCookieConfig() {
+    return null;
+  }
+
+  @Override
+  public void setSessionTrackingModes( Set<SessionTrackingMode> sessionTrackingModes ) {
+  }
+
+  @Override
+  public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
+    return null;
+  }
+
+  @Override
+  public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+    return null;
+  }
+
+  @Override
+  public void addListener( String s ) {
+  }
+
+  @Override
+  public <T extends EventListener> void addListener( T t ) {
+  }
+
+  @Override
+  public void addListener( Class<? extends EventListener> aClass ) {
+  }
+
+  @Override
+  public <T extends EventListener> T createListener( Class<T> tClass ) throws ServletException {
+    return null;
+  }
+
+  @Override
+  public JspConfigDescriptor getJspConfigDescriptor() {
+    return null;
+  }
+
+  @Override
+  public ClassLoader getClassLoader() {
+    return null;
+  }
+
+  @Override
+  public void declareRoles( String... strings ) {
+  }
+
+  @Override
+  public String getVirtualServerName() {
+    throw new UnsupportedOperationException();
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletInputStream.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletInputStream.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletInputStream.java
new file mode 100644
index 0000000..82eda72
--- /dev/null
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockServletInputStream.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.test.mock;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+
+public class MockServletInputStream extends ServletInputStream {
+
+  private InputStream stream;
+
+  public MockServletInputStream( InputStream stream ) {
+    this.stream = stream;
+  }
+
+  @Override
+  public int read() throws IOException {
+    return stream.read();
+  }
+
+  @Override
+  public boolean isFinished() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public boolean isReady() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public void setReadListener( ReadListener readListener ) {
+    throw new UnsupportedOperationException();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
index 79837e8..9478574 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
@@ -23,8 +23,8 @@ import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.topology.TopologyService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
@@ -48,8 +48,8 @@ import java.util.Properties;
 import java.util.UUID;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
index eba5de6..9778169 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
@@ -22,7 +22,7 @@ import com.mycila.xmltool.XMLTag;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.hamcrest.MatcherAssert;
 import org.junit.AfterClass;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
index 7dcb4e0..e6f7b80 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
@@ -34,9 +34,7 @@ import javax.ws.rs.core.MediaType;
 import io.restassured.http.ContentType;
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
@@ -49,7 +47,7 @@ import org.apache.knox.gateway.util.XmlUtils;
 import io.restassured.response.ResponseBody;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -63,8 +61,8 @@ import org.xml.sax.InputSource;
 
 import static io.restassured.RestAssured.given;
 import static junit.framework.TestCase.assertTrue;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAppFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAppFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAppFuncTest.java
index a282cfe..84bed16 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAppFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAppFuncTest.java
@@ -30,14 +30,12 @@ import java.util.Properties;
 import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.topology.TopologyService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -49,8 +47,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.Matchers.arrayWithSize;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
index 3adf41a..02be270 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
@@ -47,10 +47,10 @@ import com.mycila.xmltool.XMLTag;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.knox.gateway.util.KnoxCLI;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.MediumTests;
-import org.apache.hadoop.test.category.VerifyTest;
-import org.apache.hadoop.test.mock.MockRequestMatcher;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.MediumTests;
+import org.apache.knox.test.category.VerifyTest;
+import org.apache.knox.test.mock.MockRequestMatcher;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -87,8 +87,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.greaterThan;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
index 9349dca..137cd47 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
@@ -21,13 +21,11 @@ import io.restassured.response.Response;
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
 import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -51,8 +49,8 @@ import java.util.UUID;
 import java.util.regex.Pattern;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
index c7ac9ee..3c71248 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
@@ -25,7 +25,7 @@ import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.hamcrest.MatcherAssert;
 import org.junit.AfterClass;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
index 3a3d776..74b8a21 100755
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
@@ -18,8 +18,8 @@
 package org.apache.knox.gateway;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 
@@ -39,7 +39,7 @@ import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.security.AliasService;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
index 37ee90c..ba044b4 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
@@ -18,15 +18,14 @@
 package org.apache.knox.gateway;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 
 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;
@@ -39,7 +38,7 @@ import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.security.AliasService;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
index b623f06..2654db1 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
@@ -19,15 +19,13 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.security.AliasService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -43,7 +41,6 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.InetSocketAddress;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -51,8 +48,8 @@ import java.util.Map;
 import java.util.UUID;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
index 442a767..d73d200 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
@@ -20,13 +20,11 @@ package org.apache.knox.gateway;
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
 import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.log.NoOpAppender;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.log.NoOpAppender;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -44,8 +42,8 @@ import java.util.Map;
 import java.util.UUID;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.junit.Assert.assertThat;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
index 6dc469c..e14f44a 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayMultiFuncTest.java
@@ -29,14 +29,13 @@ import java.util.UUID;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.topology.TopologyService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpStatus;
 import org.apache.http.auth.AuthScope;
@@ -61,8 +60,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.notNullValue;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
index a4d8166..3c0429f 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
@@ -20,9 +20,9 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
@@ -36,8 +36,8 @@ import java.net.ConnectException;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 
 /**

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFailTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFailTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFailTest.java
index bc01c86..dcaa353 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFailTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFailTest.java
@@ -18,9 +18,9 @@ package org.apache.knox.gateway;
  * limitations under the License.
  */
 
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -31,8 +31,8 @@ import java.io.IOException;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 
 /**
  * Test the fail cases for the Port Mapping Feature

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
index cbf138b..18e1487 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
@@ -20,9 +20,9 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -33,8 +33,8 @@ import java.io.IOException;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 
 /**

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
index b146972..757ade7 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
@@ -19,12 +19,10 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.knox.gateway.config.GatewayConfig;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;
@@ -43,8 +41,8 @@ import java.util.Map;
 import java.util.UUID;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySslFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySslFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySslFuncTest.java
index 3726dbc..4e85542 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySslFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySslFuncTest.java
@@ -18,8 +18,6 @@
 package org.apache.knox.gateway;
 
 import java.io.File;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
@@ -42,15 +40,13 @@ import javax.net.ssl.X509TrustManager;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.topology.TopologyService;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpHost;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
@@ -75,8 +71,8 @@ import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
index cd30311..024919b 100755
--- a/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
@@ -18,16 +18,14 @@
 package org.apache.knox.gateway;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetSocketAddress;
 import java.net.URL;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
@@ -41,7 +39,7 @@ import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.services.security.AliasService;
-import org.apache.hadoop.test.TestUtils;
+import org.apache.knox.test.TestUtils;
 import org.apache.http.HttpStatus;
 import org.apache.log4j.Appender;
 import org.hamcrest.MatcherAssert;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
index fc2f601..e59f3a0 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
@@ -22,8 +22,8 @@ import com.mycila.xmltool.XMLTag;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.util.KnoxCLI;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.log.NoOpAppender;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
@@ -38,8 +38,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
index f612a4e..12a7c15 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
@@ -19,13 +19,11 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.util.KnoxCLI;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.log.NoOpAppender;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
@@ -40,8 +38,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.not;
 import static org.junit.Assert.assertThat;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
index 73336c7..d8b6496 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
@@ -19,13 +19,11 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.directory.server.protocol.shared.transport.TcpTransport;
-import org.apache.knox.gateway.security.ldap.SimpleLdapDirectoryServer;
 import org.apache.knox.gateway.services.DefaultGatewayServices;
 import org.apache.knox.gateway.services.ServiceLifecycleException;
 import org.apache.knox.gateway.util.KnoxCLI;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.log.NoOpAppender;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.log.NoOpAppender;
 import org.apache.log4j.Appender;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -40,8 +38,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/OozieServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/OozieServiceDefinitionTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/OozieServiceDefinitionTest.java
index b0f23e7..491b6bb 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/OozieServiceDefinitionTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/OozieServiceDefinitionTest.java
@@ -28,8 +28,8 @@ import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteRequest;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.registry.ServiceRegistry;
 import org.apache.knox.gateway.util.XmlUtils;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.mock.MockServletInputStream;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.mock.MockServletInputStream;
 import org.easymock.EasyMock;
 import org.junit.Test;
 import org.w3c.dom.Document;
@@ -40,8 +40,8 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.InputStream;
 import java.io.Reader;
 
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.xml.HasXPath.hasXPath;

http://git-wip-us.apache.org/repos/asf/knox/blob/1451428f/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
index 98739a1..f4f77e2 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
@@ -19,9 +19,9 @@ package org.apache.knox.gateway;
 
 import com.mycila.xmltool.XMLDoc;
 import com.mycila.xmltool.XMLTag;
-import org.apache.hadoop.test.TestUtils;
-import org.apache.hadoop.test.category.ReleaseTest;
-import org.apache.hadoop.test.mock.MockServer;
+import org.apache.knox.test.TestUtils;
+import org.apache.knox.test.category.ReleaseTest;
+import org.apache.knox.test.mock.MockServer;
 import org.apache.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
@@ -32,8 +32,8 @@ import org.junit.experimental.categories.Category;
 import java.io.IOException;
 
 import static io.restassured.RestAssured.given;
-import static org.apache.hadoop.test.TestUtils.LOG_ENTER;
-import static org.apache.hadoop.test.TestUtils.LOG_EXIT;
+import static org.apache.knox.test.TestUtils.LOG_ENTER;
+import static org.apache.knox.test.TestUtils.LOG_EXIT;
 import static org.hamcrest.CoreMatchers.is;
 
 @Category(ReleaseTest.class)


Mime
View raw message