Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
01d539e2be
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -47,10 +49,15 @@ 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.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class HttpClientURITest extends AbstractHttpClientServerTest
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
public HttpClientURITest(SslContextFactory sslContextFactory)
|
||||
{
|
||||
super(sslContextFactory);
|
||||
|
@ -74,14 +81,15 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
|||
Assert.assertEquals(HttpStatus.OK_200, request.send().getStatus());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testIDNHost() throws Exception
|
||||
{
|
||||
startClient();
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
client.newRequest(scheme + "://пример.рф"); // example.com-like host in IDN domain
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testIDNRedirect() throws Exception
|
||||
{
|
||||
// Internationalized Domain Name.
|
||||
|
@ -104,20 +112,13 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
|||
HttpField location = response.getHeaders().getField(HttpHeader.LOCATION);
|
||||
Assert.assertEquals(incorrectlyDecoded, location.getValue());
|
||||
|
||||
try
|
||||
{
|
||||
expectedException.expect(ExecutionException.class);
|
||||
expectedException.expectCause(instanceOf(IllegalArgumentException.class));
|
||||
client.newRequest("localhost", server.getLocalPort())
|
||||
.timeout(5, TimeUnit.SECONDS)
|
||||
.followRedirects(true)
|
||||
.send();
|
||||
}
|
||||
catch (ExecutionException x)
|
||||
{
|
||||
Throwable cause = x.getCause();
|
||||
if (cause instanceof IllegalArgumentException)
|
||||
throw (IllegalArgumentException)cause;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<bundle-symbolic-name>${project.groupId}.boot.test.osgi</bundle-symbolic-name>
|
||||
<jetty-orbit-url>http://download.eclipse.org/jetty/orbit/</jetty-orbit-url>
|
||||
<assembly-directory>target/distribution</assembly-directory>
|
||||
<exam.version>3.5.0</exam.version>
|
||||
<exam.version>4.9.2</exam.version>
|
||||
<url.version>1.5.2</url.version>
|
||||
<injection.bundle.version>1.0</injection.bundle.version>
|
||||
</properties>
|
||||
|
@ -401,6 +401,8 @@
|
|||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<!-- downgrading to version 2.18 here as there's a known JVM crash issue with the 2.19.x series -->
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<!-- No point defining -Xbootclasspath as the actual OSGi VM is run as a forked process by pax-exam -->
|
||||
<!-- But we do pass the sys property of the alpn-boot jar so that it can be configured inside tests -->
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.websocket.client;
|
||||
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -106,7 +105,7 @@ public class ClientCloseTest
|
|||
public void assertReceivedCloseEvent(int clientTimeoutMs, Matcher<Integer> statusCodeMatcher, Matcher<String> reasonMatcher)
|
||||
throws InterruptedException
|
||||
{
|
||||
long maxTimeout = clientTimeoutMs * 2;
|
||||
long maxTimeout = clientTimeoutMs * 4;
|
||||
|
||||
assertThat("Client Close Event Occurred",closeLatch.await(maxTimeout,TimeUnit.MILLISECONDS),is(true));
|
||||
assertThat("Client Close Event Count",closeCount.get(),is(1));
|
||||
|
@ -148,7 +147,7 @@ public class ClientCloseTest
|
|||
@Override
|
||||
public void onWebSocketError(Throwable cause)
|
||||
{
|
||||
LOG.debug("onWebSocketError",cause);
|
||||
LOG.warn("onWebSocketError",cause);
|
||||
assertThat("Unique Error Event", error.compareAndSet(null, cause), is(true));
|
||||
errorLatch.countDown();
|
||||
}
|
||||
|
@ -401,16 +400,11 @@ public class ClientCloseTest
|
|||
writeCount++;
|
||||
writeSize += msg.length;
|
||||
}
|
||||
LOG.debug("Wrote {} frames totalling {} bytes of payload before congestion kicked in",writeCount,writeSize);
|
||||
LOG.info("Wrote {} frames totalling {} bytes of payload before congestion kicked in",writeCount,writeSize);
|
||||
|
||||
// Verify that there are no errors
|
||||
assertThat("Error events",clientSocket.error.get(),nullValue());
|
||||
|
||||
// client idle timeout triggers close event on client ws-endpoint
|
||||
// client close event on ws-endpoint
|
||||
clientSocket.assertReceivedCloseEvent(timeout,
|
||||
anyOf(is(StatusCode.SHUTDOWN),is(StatusCode.ABNORMAL)),
|
||||
anyOf(containsString("Timeout"),containsString("timeout"),containsString("Write")));
|
||||
// Verify timeout error
|
||||
assertThat("OnError Latch", clientSocket.errorLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat("OnError", clientSocket.error.get(), instanceOf(SocketTimeoutException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue