public class ServletContainerFeature extends SimpleFeature
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.
Constructor and Description |
---|
ServletContainerFeature() |
Modifier and Type | Method and Description |
---|---|
protected void |
configureServletContainer(ServletContainer conf) |
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 . |
void |
initialize(FeaturesRunner runner)
Called when preparing to run the test class.
|
afterMethodRun, afterRun, afterTeardown, beforeMethodRun, beforeRun, beforeSetup, configure, start, stop, testCreated
public ServletContainerFeature()
public void initialize(FeaturesRunner runner) throws Exception
RunnerFeature
initialize
in interface RunnerFeature
initialize
in class SimpleFeature
Exception
protected void configureServletContainer(ServletContainer conf)
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 © 2018 Nuxeo. All rights reserved.