-
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.
- Loading branch information
Showing
5 changed files
with
147 additions
and
9 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
73 changes: 73 additions & 0 deletions
73
...uite/integration-tests/src/test/java/org/jboss/resteasy/test/client/JAXRS21PatchTest.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,73 @@ | ||
package org.jboss.resteasy.test.client; | ||
|
||
import javax.ws.rs.HttpMethod; | ||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.client.Entity; | ||
import javax.ws.rs.core.Response; | ||
|
||
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.test.client.resource.JAXRS21SyncInvokeResource; | ||
import org.jboss.resteasy.util.HttpResponseCodes; | ||
import org.jboss.resteasy.utils.TestUtil; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class JAXRS21PatchTest extends ClientTestBase { | ||
|
||
static Client client; | ||
|
||
@Deployment | ||
public static Archive<?> deploy() { | ||
WebArchive war = TestUtil.prepareArchive(JAXRS21PatchTest.class.getSimpleName()); | ||
war.addClass(JAXRS21PatchTest.class); | ||
return TestUtil.finishContainerPrepare(war, null, JAXRS21SyncInvokeResource.class); | ||
} | ||
|
||
@Before | ||
public void init() { | ||
client = ClientBuilder.newClient(); | ||
} | ||
|
||
@After | ||
public void after() throws Exception { | ||
client.close(); | ||
} | ||
|
||
@Test | ||
public void testMethods() throws Exception { | ||
{ | ||
Response res = client.target(generateURL("/test")).request().patch(Entity.text("hello")); | ||
Assert.assertEquals(HttpResponseCodes.SC_OK, res.getStatus()); | ||
String entity = res.readEntity(String.class); | ||
Assert.assertEquals("patch hello", entity); | ||
} | ||
{ | ||
String entity = client.target(generateURL("/test")).request().patch(Entity.text("hello"), String.class); | ||
Assert.assertEquals("patch hello", entity); | ||
} | ||
} | ||
|
||
@Test | ||
public void testInvoke() throws Exception { | ||
{ | ||
Response res = client.target(generateURL("/test")).request().build(HttpMethod.PATCH, Entity.text("hello")).invoke(); | ||
Assert.assertEquals(HttpResponseCodes.SC_OK, res.getStatus()); | ||
String entity = res.readEntity(String.class); | ||
Assert.assertEquals("patch hello", entity); | ||
} | ||
{ | ||
String entity = client.target(generateURL("/test")).request().build(HttpMethod.PATCH, Entity.text("hello")).invoke(String.class); | ||
Assert.assertEquals("patch hello", entity); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ests/src/test/java/org/jboss/resteasy/test/client/resource/JAXRS21SyncInvokeResource.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,44 @@ | ||
package org.jboss.resteasy.test.client.resource; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.DELETE; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.PATCH; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
|
||
@Path("/test") | ||
public class JAXRS21SyncInvokeResource { | ||
@GET | ||
@Produces("text/plain") | ||
public String get() { | ||
return "get"; | ||
} | ||
|
||
@PUT | ||
@Consumes("text/plain") | ||
public String put(String str) { | ||
return "put " + str; | ||
} | ||
|
||
@POST | ||
@Consumes("text/plain") | ||
public String post(String str) { | ||
return "post " + str; | ||
} | ||
|
||
@DELETE | ||
@Produces("text/plain") | ||
public String delete() { | ||
return "delete"; | ||
} | ||
|
||
@PATCH | ||
@Produces("text/plain") | ||
@Consumes("text/plain") | ||
public String patch(String str) { | ||
return "patch " + str; | ||
} | ||
} |