Updating to tests to protect if IPv6 is unavailable.

+ Updating to jetty-test-helper 4.2.1 with new Net.class
+ Assume.assumeTrue(Net.isIpv6InterfaceAvailable());

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-04-16 18:10:55 -05:00
parent 1565b5f160
commit 72b4f92280
6 changed files with 31 additions and 14 deletions

View File

@ -50,7 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@ -79,6 +78,7 @@ import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.util.Callback;
@ -703,6 +703,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void testSendToIPv6Address() throws Exception
{
Assume.assumeTrue(Net.isIpv6InterfaceAvailable());
start(new EmptyServerHandler());
ContentResponse response = client.newRequest("[::1]", connector.getLocalPort())
@ -1539,6 +1540,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void test_IPv6_Host() throws Exception
{
Assume.assumeTrue(Net.isIpv6InterfaceAvailable());
start(new AbstractHandler()
{
@Override

View File

@ -18,8 +18,6 @@
package org.eclipse.jetty.client;
import static org.hamcrest.CoreMatchers.instanceOf;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -33,7 +31,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -45,14 +42,18 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.hamcrest.CoreMatchers.instanceOf;
public class HttpClientURITest extends AbstractHttpClientServerTest
{
@Rule
@ -66,6 +67,7 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
@Test
public void testIPv6Host() throws Exception
{
Assume.assumeTrue(Net.isIpv6InterfaceAvailable());
start(new EmptyServerHandler());
String host = "::1";

View File

@ -105,15 +105,24 @@ public abstract class AbstractHttpClientServerTest
{
System.gc();
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), Matchers.is(0L));
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), Matchers.is(0L));
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), Matchers.is(0L));
if (serverBufferPool != null)
{
assertThat("Server BufferPool - leaked acquires", serverBufferPool.getLeakedAcquires(), Matchers.is(0L));
assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), Matchers.is(0L));
assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), Matchers.is(0L));
}
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), Matchers.is(0L));
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), Matchers.is(0L));
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), Matchers.is(0L));
if (clientBufferPool != null)
{
assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), Matchers.is(0L));
assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), Matchers.is(0L));
assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), Matchers.is(0L));
}
assertThat("Connection Leaks", connectionLeaks.get(), Matchers.is(0L));
if (connectionLeaks != null)
{
assertThat("Connection Leaks", connectionLeaks.get(), Matchers.is(0L));
}
if (client != null)
client.stop();

View File

@ -32,7 +32,6 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@ -48,10 +47,12 @@ import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
public class HttpClientTest extends AbstractHttpClientServerTest
@ -504,6 +505,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void testSendToIPv6Address() throws Exception
{
Assume.assumeTrue(Net.isIpv6InterfaceAvailable());
start(new EmptyServerHandler());
ContentResponse response = client.newRequest("[::1]", connector.getLocalPort())

View File

@ -30,7 +30,6 @@ import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.concurrent.ConcurrentMap;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@ -43,10 +42,12 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
@ -87,6 +88,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
@Test
public void testCONNECTwithIPv6() throws Exception
{
Assume.assumeTrue(Net.isIpv6InterfaceAvailable());
String hostPort = "[::1]:" + serverConnector.getLocalPort();
String request = "" +
"CONNECT " + hostPort + " HTTP/1.1\r\n" +

View File

@ -812,7 +812,7 @@
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<version>4.2</version>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>