Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions jaxrs/resteasy-jsapi-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<artifactId>resteasy-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jsapi</artifactId>
Expand Down Expand Up @@ -61,26 +66,6 @@
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public String testPathParam(@PathParam("id") String id) {
}

@POST
@Produces("text/plain")
public String testFormParam(@FormParam("key") String[] values) {
String val = "";
for (String _val : values) {
Expand All @@ -29,11 +30,13 @@ public String testFormParam(@FormParam("key") String[] values) {

@Path("/post2")
@POST
@Produces("text/plain")
public String testFormParam2(@FormParam("key") String val) {
return val;
}

@GET
@Produces("text/plain")
public String testQueryParam(@QueryParam("key") String[] values) {
String val = "";
for (String _val : values) {
Expand All @@ -44,12 +47,14 @@ public String testQueryParam(@QueryParam("key") String[] values) {

@Path("/cookie")
@GET
@Produces("text/plain")
public String testCookieParam(@CookieParam("username") String key) {
return key;
}

@GET
@Path("/matrix")
@Produces("text/plain")
public String testMatrixParam(@MatrixParam("key") String[] key) {
String val = "";
for (String _val : key) {
Expand All @@ -60,24 +65,28 @@ public String testMatrixParam(@MatrixParam("key") String[] key) {

@GET
@Path("/header")
@Produces("text/plain")
public String testHeaderParam(@HeaderParam("Referer") String referer) {
return referer;
}

@POST
@Path("/RESTEASY-731/false")
@Produces("text/plain")
public String testRESTEasy731False(@FormParam("false") boolean bool) {
return ("RESTEASY-731-" + String.valueOf(bool));
}

@POST
@Path("/RESTEASY-731/zero")
@Produces("text/plain")
public String testRESTEasy731Zero(@FormParam("zero") int zero) {
return ("RESTEASY-731-" + String.valueOf(zero));
}

@POST
@Path("/RESTEASY-805/form1")
@Produces("text/plain")
public String testRESTEasy805(@Form MyForm myForm) {
StringBuilder ret = new StringBuilder();
for (String key : myForm.getMyMap().keySet()) {
Expand All @@ -88,12 +97,14 @@ public String testRESTEasy805(@Form MyForm myForm) {

@POST
@Path("/RESTEASY-805/form2")
@Produces("text/plain")
public String testRESTEasy805Case2(@Form MyForm2 myForm2) {
return myForm2.getHeader() + myForm2.getStuff() + myForm2.getNumber();
}

@POST
@Path("/RESTEASY-805/form3")
@Produces("text/plain")
public String testRESTEasy805Case3(@Form MyForm3 myForm3) {
StringBuilder ret = new StringBuilder();
for (Foo foo : myForm3.getFoos()) {
Expand All @@ -104,6 +115,7 @@ public String testRESTEasy805Case3(@Form MyForm3 myForm3) {

@POST
@Path("/postPrefixForm")
@Produces("text/plain")
public String postPrefixForm(@Form Person person) {
StringBuilder ret = new StringBuilder();
for (TelephoneNumber number : person.getTelephoneNumbers()) {
Expand All @@ -115,7 +127,5 @@ public String postPrefixForm(@Form Person person) {
ret.append(address.getHouseNumber()).append(address.getStreet());
}
return ret.toString();


}
}
44 changes: 30 additions & 14 deletions jaxrs/resteasy-jsapi-testing/src/test/java/SmokingTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;

Expand Down Expand Up @@ -86,19 +88,33 @@ public void smokeTest() throws Exception {

@Test
public void testJSAPICache() throws Exception {
HttpClient client = new HttpClient();
HttpMethod get1 = new GetMethod("http://127.0.0.1:8080/resteasy-jsapi-testing/rest-js");
int statusCode = client.executeMethod(get1);
assertEquals(HttpStatus.SC_OK, statusCode);

HttpMethod get2 = new GetMethod("http://127.0.0.1:8080/resteasy-jsapi-testing/rest-js");
String etag = get1.getResponseHeader("Etag").getValue();
get2.addRequestHeader("If-None-Match", etag);
statusCode = client.executeMethod(get2);
assertEquals(HttpStatus.SC_NOT_MODIFIED, statusCode);
{
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://127.0.0.1:8080/resteasy-jsapi-testing/rest-js");
Response response = target.request().get();
assertEquals(HttpStatus.SC_OK, response.getStatus());
response.close();
}

String etag;
{
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://127.0.0.1:8080/resteasy-jsapi-testing/rest-js");
Response response = target.request().get();
etag = response.getHeaderString("Etag");
response.close();

}

{
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://127.0.0.1:8080/resteasy-jsapi-testing/rest-js");
Response response = target.request().header("If-None-Match", etag).get();
assertEquals(HttpStatus.SC_NOT_MODIFIED, response.getStatus());
response.close();
}
}


@After
public void tearDown() throws Exception {
selenium.stop();
Expand Down