first step towards jax-rs support, first tests passing

This commit is contained in:
Jonas Boner 2009-05-15 15:39:52 +02:00
parent 9349bc3ad8
commit b1900b0a25
11 changed files with 1144 additions and 669 deletions

View file

@ -0,0 +1,54 @@
/**
* Copyright (C) 2009 Scalable Solutions.
*/
package se.scalablesolutions.akka.api;
import com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.grizzly.http.SelectorThread;
import javax.ws.rs.core.UriBuilder;
import org.junit.*;
import static org.junit.Assert.*;
import java.util.Map;
import java.io.IOException;
import java.net.URI;
import junit.framework.TestSuite;
public class RestTest extends TestSuite {
private static URI URI = UriBuilder.fromUri("http://localhost/").port(9998).build();
private static SelectorThread selector = null;
@BeforeClass
public static void initialize() throws IOException {
selector = startJersey();
}
@AfterClass
public static void cleanup() throws IOException {
selector.stopEndpoint();
System.exit(0);
}
@Test
public void simpleRequest() throws IOException, InstantiationException {
selector.start();
Client client = Client.create();
WebResource webResource = client.resource(URI);
String responseMsg = webResource.path("/foo").get(String.class);
assertEquals("hello foo", responseMsg);
selector.stopEndpoint();
}
private static SelectorThread startJersey() throws IOException {
Map initParams = new java.util.HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", "se.scalablesolutions.akka.api");
return GrizzlyWebContainerFactory.create(URI, initParams);
}
}