public class ServletContainerFeature extends Object implements RunnerFeature
Note that at initialization the feature disables the retryPostProp
property of
HttpClient
, the underlying HTTP client used by Client
.
This is to prevent the JDK's default behavior kept for backward compatibility: an unsuccessful HTTP POST request is
automatically resent to the server, unsuccessful in this case meaning the server did not send a valid HTTP response
or an IOException
occurred. Yet in the tests using the Jersey client to make calls to Nuxeo we don't want
this as it can hide errors occurring in the HTTP communication that should prevent an appropriate response from being
sent by the server.
Modifier and Type | Field and Description |
---|---|
protected int |
port |
protected static int |
RETRIES |
Constructor and Description |
---|
ServletContainerFeature() |
Modifier and Type | Method and Description |
---|---|
static void |
disableSunHttpClientRetryPostProp()
Prevents the JDK's default behavior of resending an unsuccessful HTTP POST request automatically to the server by
disabling the the
retryPostProp property of HttpClient . |
protected int |
findFreePort() |
int |
getPort()
Returns the port allocated for this servlet container.
|
void |
initialize(FeaturesRunner runner)
Called when preparing to run the test class.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterMethodRun, afterRun, afterTeardown, beforeMethodRun, beforeRun, beforeSetup, configure, start, stop, testCreated
protected static final int RETRIES
protected int port
public ServletContainerFeature()
public void initialize(FeaturesRunner runner) throws Exception
RunnerFeature
initialize
in interface RunnerFeature
Exception
protected int findFreePort()
public int getPort()
public static void disableSunHttpClientRetryPostProp() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
retryPostProp
property of HttpClient
.
This can also be achieved by setting the sun.net.http.retryPost
system property to false
.
NoSuchFieldException
SecurityException
IllegalArgumentException
IllegalAccessException
Copyright © 2019 Nuxeo. All rights reserved.