-
Notifications
You must be signed in to change notification settings - Fork 147
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
259 changed files
with
7,222 additions
and
7,688 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
67 changes: 32 additions & 35 deletions
67
1.5.my-first-service/src/test/java/my/restful/MyResourceTest.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 |
---|---|---|
@@ -1,48 +1,45 @@ | ||
package my.restful; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import javax.ws.rs.client.Client; | ||
import javax.ws.rs.client.ClientBuilder; | ||
import javax.ws.rs.client.WebTarget; | ||
|
||
import org.glassfish.grizzly.http.server.HttpServer; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class MyResourceTest { | ||
|
||
private HttpServer server; | ||
private WebTarget target; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
// start the server | ||
server = Main.startServer(); | ||
// create the client | ||
Client c = ClientBuilder.newClient(); | ||
|
||
// uncomment the following line if you want to enable | ||
// support for JSON in the client (you also have to uncomment | ||
// dependency on jersey-media-json module in pom.xml and Main.startServer()) | ||
// -- | ||
// c.configuration().enable(new org.glassfish.jersey.media.json.JsonJaxbFeature()); | ||
|
||
target = c.target(Main.BASE_URI); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
server.shutdownNow(); | ||
} | ||
|
||
/** | ||
* Test to see that the message "Got it!" is sent in the response. | ||
*/ | ||
@Test | ||
public void testGetIt() { | ||
String responseMsg = target.path("myresource").request().get(String.class); | ||
assertEquals("Got it!", responseMsg); | ||
} | ||
private HttpServer server; | ||
private WebTarget target; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
// start the server | ||
server = Main.startServer(); | ||
// create the client | ||
Client c = ClientBuilder.newClient(); | ||
|
||
// uncomment the following line if you want to enable | ||
// support for JSON in the client (you also have to uncomment | ||
// dependency on jersey-media-json module in pom.xml and Main.startServer()) | ||
// -- | ||
// c.configuration().enable(new org.glassfish.jersey.media.json.JsonJaxbFeature()); | ||
|
||
target = c.target(Main.BASE_URI); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
server.shutdownNow(); | ||
} | ||
|
||
/** Test to see that the message "Got it!" is sent in the response. */ | ||
@Test | ||
public void testGetIt() { | ||
String responseMsg = target.path("myresource").request().get(String.class); | ||
assertEquals("Got it!", responseMsg); | ||
} | ||
} |
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
Oops, something went wrong.