Skip to content

Commit

Permalink
Add a test for @context with netty
Browse files Browse the repository at this point in the history
  • Loading branch information
avram committed Apr 2, 2014
1 parent cab5ba9 commit cb70216
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.resteasy.test;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
Expand All @@ -11,6 +12,7 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;

import static org.jboss.resteasy.test.TestPortProvider.generateURL;
Expand Down Expand Up @@ -38,6 +40,13 @@ public String hello()
public String exception() {
throw new RuntimeException();
}

@GET
@Path("/context")
@Produces("text/plain")
public String context(@Context ChannelHandlerContext context) {
return context.getChannel().toString();
}
}

@BeforeClass
Expand Down Expand Up @@ -69,4 +78,13 @@ public void testUnhandledException() throws Exception
Response resp = target.request().get();
Assert.assertEquals(500, resp.getStatus());
}

@Test
public void testChannelContext() throws Exception {
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(generateURL("/context"));
String val = target.request().get(String.class);
Assert.assertNotNull(val);
Assert.assertFalse(val.isEmpty());
}
}

0 comments on commit cb70216

Please sign in to comment.