Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit db98401

Browse files
committed
Put in better unit test for example
1 parent 6e7d95a commit db98401

File tree

2 files changed

+10
-6
lines changed
  • examples/declarative-linking/src

2 files changed

+10
-6
lines changed

examples/declarative-linking/src/main/java/org/glassfish/jersey/examples/linking/App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
public class App {
6464

6565
private static final URI BASE_URI = URI.create("http://localhost:8080/");
66-
public static final String ROOT_PATH = "items/0";
66+
public static final String ROOT_PATH = "items";
6767

6868
public static void main(String[] args) {
6969
try {
@@ -77,7 +77,7 @@ public static void main(String[] args) {
7777
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);
7878

7979

80-
System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
80+
System.out.println(String.format("Application started.\nTry out curl -L %s%s\nHit enter to stop it...",
8181
BASE_URI, ROOT_PATH));
8282
System.in.read();
8383
server.shutdownNow();

examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking/LinkWebAppTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
import org.junit.Test;
5656
import static org.junit.Assert.assertEquals;
57+
import static org.junit.Assert.assertTrue;
5758

5859
/**
5960
* @author Naresh ([email protected])
@@ -75,12 +76,15 @@ protected ResourceConfig configure() {
7576
@Test
7677
public void testLinks() throws Exception {
7778

78-
String wadl = target().path("application.wadl").request().get(String.class);
79-
Response response = target().path("items/1").request().accept(MediaType.APPLICATION_XML_TYPE).get(Response.class);
79+
Response response = target().path("items").queryParam("offset", 10).queryParam("limit", "10").request().accept(MediaType.APPLICATION_XML_TYPE).get(Response.class);
8080
final Response.StatusType statusInfo = response.getStatusInfo();
81-
Object content = response.readEntity(String.class);
81+
assertEquals("Should have succeeded", 200, statusInfo.getStatusCode());
82+
83+
84+
String content = response.readEntity(String.class);
8285
List<Object> linkHeaders = response.getHeaders().get("Link");
8386

84-
assertEquals(2, linkHeaders.size());
87+
assertEquals("Should have two link headers", 2, linkHeaders.size());
88+
assertTrue("Content should contain next link",content.contains("http://localhost:9998/items?offset=20&amp;limit=10"));
8589
}
8690
}

0 commit comments

Comments
 (0)