Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions hbase-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.http;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -215,7 +215,7 @@ public static void stop(HttpServer server) throws Exception {
* @throws MalformedURLException if the URL cannot be created.
*/
public static URL getServerURL(HttpServer server) throws MalformedURLException {
assertNotNull("No server", server);
assertNotNull(server, "No server");
return new URL("http://" + NetUtils.getHostPortString(server.getConnectorAddress(0)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.http;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.Set;
Expand All @@ -30,21 +30,17 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.net.NetUtils;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Category({ MiscTests.class, SmallTests.class })
@Tag(MiscTests.TAG)
@Tag(SmallTests.TAG)
public class TestGlobalFilter extends HttpServerFunctionalTest {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestGlobalFilter.class);

private static final Logger LOG = LoggerFactory.getLogger(HttpServer.class);
private static final Set<String> RECORDS = new TreeSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,22 @@
*/
package org.apache.hadoop.hbase.http;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

@Category({ MiscTests.class, SmallTests.class })
@Tag(MiscTests.TAG)
@Tag(SmallTests.TAG)
public class TestHtmlQuoting {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHtmlQuoting.class);

@Test
public void testNeedsQuoting() throws Exception {
Expand Down Expand Up @@ -85,17 +81,17 @@ public void testRequestQuoting() throws Exception {
new HttpServer.QuotingInputFilter.RequestQuoter(mockReq);

Mockito.doReturn("a<b").when(mockReq).getParameter("x");
assertEquals("Test simple param quoting", "a&lt;b", quoter.getParameter("x"));
assertEquals("a&lt;b", quoter.getParameter("x"), "Test simple param quoting");

Mockito.doReturn(null).when(mockReq).getParameter("x");
assertEquals("Test that missing parameters dont cause NPE", null, quoter.getParameter("x"));
assertEquals(null, quoter.getParameter("x"), "Test that missing parameters dont cause NPE");

Mockito.doReturn(new String[] { "a<b", "b" }).when(mockReq).getParameterValues("x");
assertArrayEquals("Test escaping of an array", new String[] { "a&lt;b", "b" },
quoter.getParameterValues("x"));
assertArrayEquals(new String[] { "a&lt;b", "b" }, quoter.getParameterValues("x"),
"Test escaping of an array");

Mockito.doReturn(null).when(mockReq).getParameterValues("x");
assertNull("Test that missing parameters dont cause NPE for array",
quoter.getParameterValues("x"));
assertNull(quoter.getParameterValues("x"),
"Test that missing parameters dont cause NPE for array");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hbase.http;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.net.HttpCookie;
Expand All @@ -35,25 +37,20 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.apache.hadoop.security.ssl.SSLFactory;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@Category({ MiscTests.class, SmallTests.class })
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Tag(MiscTests.TAG)
@Tag(SmallTests.TAG)
public class TestHttpCookieFlag {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHttpCookieFlag.class);

private static final String BASEDIR = System.getProperty("test.build.dir", "target/test-dir")
+ "/" + org.apache.hadoop.hbase.http.TestHttpCookieFlag.class.getSimpleName();
Expand Down Expand Up @@ -89,7 +86,7 @@ public void initFilter(FilterContainer container, Configuration conf) {
}
}

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
Configuration conf = new Configuration();
conf.set(HttpServer.FILTER_INITIALIZERS_PROPERTY, DummyFilterInitializer.class.getName());
Expand Down Expand Up @@ -127,11 +124,11 @@ public void testHttpCookie() throws IOException {
HttpURLConnection conn = (HttpURLConnection) new URL(base, "/echo").openConnection();

String header = conn.getHeaderField("Set-Cookie");
Assert.assertTrue(header != null);
assertTrue(header != null);
List<HttpCookie> cookies = HttpCookie.parse(header);
Assert.assertTrue(!cookies.isEmpty());
Assert.assertTrue(header.contains("; HttpOnly"));
Assert.assertTrue("token".equals(cookies.get(0).getValue()));
assertTrue(!cookies.isEmpty());
assertTrue(header.contains("; HttpOnly"));
assertTrue("token".equals(cookies.get(0).getValue()));
}

@Test
Expand All @@ -141,13 +138,13 @@ public void testHttpsCookie() throws IOException, GeneralSecurityException {
conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());

String header = conn.getHeaderField("Set-Cookie");
Assert.assertTrue(header != null);
assertTrue(header != null);

List<HttpCookie> cookies = HttpCookie.parse(header);
Assert.assertTrue(!cookies.isEmpty());
Assert.assertTrue(header.contains("; HttpOnly"));
Assert.assertTrue(cookies.get(0).getSecure());
Assert.assertTrue("token".equals(cookies.get(0).getValue()));
assertTrue(!cookies.isEmpty());
assertTrue(header.contains("; HttpOnly"));
assertTrue(cookies.get(0).getSecure());
assertTrue("token".equals(cookies.get(0).getValue()));
}

@Test
Expand All @@ -162,16 +159,16 @@ public void testHttpsCookieDefaultServlets() throws Exception {
conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());

String header = conn.getHeaderField("Set-Cookie");
Assert.assertTrue(header != null);
assertTrue(header != null);
List<HttpCookie> cookies = HttpCookie.parse(header);
Assert.assertTrue(!cookies.isEmpty());
Assert.assertTrue(header.contains("; HttpOnly"));
Assert.assertTrue(cookies.get(0).getSecure());
Assert.assertTrue("token".equals(cookies.get(0).getValue()));
assertTrue(!cookies.isEmpty());
assertTrue(header.contains("; HttpOnly"));
assertTrue(cookies.get(0).getSecure());
assertTrue("token".equals(cookies.get(0).getValue()));
}
}

@AfterClass
@AfterAll
public static void cleanup() throws Exception {
server.stop();
FileUtil.fullyDelete(new File(BASEDIR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,26 @@

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import org.apache.hbase.thirdparty.org.eclipse.jetty.server.CustomRequestLog;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLogWriter;

@Category({ MiscTests.class, SmallTests.class })
@Tag(MiscTests.TAG)
@Tag(SmallTests.TAG)
public class TestHttpRequestLog {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHttpRequestLog.class);

@Test
public void testAppenderDefined() {
RequestLog requestLog = HttpRequestLog.getRequestLog("test");
assertNotNull("RequestLog should not be null", requestLog);
assertNotNull(requestLog, "RequestLog should not be null");
assertThat(requestLog, instanceOf(CustomRequestLog.class));
CustomRequestLog crl = (CustomRequestLog) requestLog;
assertThat(crl.getWriter(), instanceOf(Slf4jRequestLogWriter.class));
Expand Down
Loading