-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTEASY-2324: RESTEasy client should disable Apache Http Client cook…
…ie management feature by default (#2135) * Disable cookie management by default Signed-off-by: NicoNes <nicolas.nesmon@gmail.com> * Fix tests Signed-off-by: NicoNes <nicolas.nesmon@gmail.com> * - Use ClientBuilder and ResteasyClientBuilder cast instead of ResteasyClientBuilderImpl. - Enrich userguide Signed-off-by: NicoNes <nicolas.nesmon@gmail.com>
- Loading branch information
Showing
7 changed files
with
142 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...uite/integration-tests/src/test/java/org/jboss/resteasy/test/client/ClientCookieTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.jboss.resteasy.test.client; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.resteasy.utils.TestUtil; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.HttpHeaders; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.NewCookie; | ||
import javax.ws.rs.core.Response; | ||
|
||
/** | ||
* @author Nicolas NESMON | ||
* @tpSubChapter Resteasy-client | ||
* @tpChapter Integration tests | ||
* @tpTestCaseDetails Test for cookie management support in Resteasy client. | ||
* @tpSince RESTEasy | ||
* | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class ClientCookieTest extends ClientTestBase | ||
{ | ||
|
||
@Path("/") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public static class ClienCookieResource | ||
{ | ||
|
||
@GET | ||
@Path("createCookie") | ||
public Response createCookie() | ||
{ | ||
return Response.ok().cookie(new NewCookie("Cookie", "CookieValue")).build(); | ||
} | ||
|
||
@GET | ||
@Path("getCookiesCount") | ||
public Response getCookiesCount(@Context HttpHeaders httpHeaders) | ||
{ | ||
return Response.ok(httpHeaders.getCookies().size()).build(); | ||
} | ||
|
||
} | ||
|
||
@Deployment | ||
public static Archive<?> deploy() | ||
{ | ||
WebArchive war = TestUtil.prepareArchive(ClientCookieTest.class.getSimpleName()); | ||
war.addClass(ClientTestBase.class); | ||
return TestUtil.finishContainerPrepare(war, null, ClienCookieResource.class); | ||
} | ||
|
||
@Test | ||
public void client_Should_NotStoreCookie_When_NotConfigured() | ||
{ | ||
Client client = ClientBuilder.newClient(); | ||
try | ||
{ | ||
|
||
try (Response response = client.target(generateURL("/createCookie")).request(MediaType.TEXT_PLAIN_TYPE).get()) | ||
{ | ||
NewCookie cookie = response.getCookies().get("Cookie"); | ||
Assert.assertNotNull(cookie); | ||
} | ||
|
||
int cookiesCount = client.target(generateURL("/getCookiesCount")).request(MediaType.TEXT_PLAIN_TYPE) | ||
.get(Integer.class); | ||
Assert.assertEquals(0, cookiesCount); | ||
|
||
} | ||
finally | ||
{ | ||
client.close(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters