Skip to content

Commit

Permalink
Merge pull request #22 from obprado/master
Browse files Browse the repository at this point in the history
OPTIONS added to test
  • Loading branch information
danielbodart committed Oct 30, 2015
2 parents 3d377c8 + f19c1ff commit aceb659
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/com/googlecode/utterlyidle/examples/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.googlecode.utterlyidle.annotations.FormParam;
import com.googlecode.utterlyidle.annotations.GET;
import com.googlecode.utterlyidle.annotations.HeaderParam;
import com.googlecode.utterlyidle.annotations.OPTIONS;
import com.googlecode.utterlyidle.annotations.PATCH;
import com.googlecode.utterlyidle.annotations.POST;
import com.googlecode.utterlyidle.annotations.PUT;
Expand Down Expand Up @@ -82,6 +83,12 @@ public Response getx(@QueryParam("name") String name) {
return response(Status.OK).header("greeting", hello(name)).entity("").build();
}

@OPTIONS
@Path("helloworld/options")
public String options(@QueryParam("name") @DefaultValue("James") String name) {
return hello(name);
}

@GET
@Path("helloworld/queryparam")
public String get(@QueryParam("name") @DefaultValue("Matt") String name) {
Expand Down
1 change: 1 addition & 0 deletions src/com/googlecode/utterlyidle/rendering/OPTIONS.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p><span class="method">OPTIONS</span> $resource.path$</p>
9 changes: 9 additions & 0 deletions test/com/googlecode/utterlyidle/ServerContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static com.googlecode.utterlyidle.RequestBuilder.delete;
import static com.googlecode.utterlyidle.RequestBuilder.get;
import static com.googlecode.utterlyidle.RequestBuilder.head;
import static com.googlecode.utterlyidle.RequestBuilder.options;
import static com.googlecode.utterlyidle.RequestBuilder.patch;
import static com.googlecode.utterlyidle.RequestBuilder.post;
import static com.googlecode.utterlyidle.RequestBuilder.put;
Expand Down Expand Up @@ -149,6 +150,14 @@ public void preservesXForwardedProtoIfRequestHasOne() throws Exception {
assertThat(result, is("https"));
}

@Test
public void handlesOptions() throws Exception {
Response response = handle(options("helloworld/options").query("name", "foo"), server);

assertThat(response.status(), is(Status.OK));
assertThat(response.entity().toString(), is("Hello foo"));
}

@Test
public void handlesGets() throws Exception {
Response response = handle(get("helloworld/queryparam").query("name", "foo"), server);
Expand Down

0 comments on commit aceb659

Please sign in to comment.