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

Commit ac38236

Browse files
author
Michal Gajdos
committed
Declarative Linking example test fixed.
Change-Id: I856b918388b356b23595a4e7791974f4d4657d04 Signed-off-by: Michal Gajdos <[email protected]>
1 parent c5133fc commit ac38236

File tree

1 file changed

+15
-10
lines changed
  • examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
package org.glassfish.jersey.examples.linking;
4242

4343
import java.util.List;
44-
import javax.ws.rs.core.MediaType;
4544

45+
import javax.ws.rs.core.MediaType;
4646
import javax.ws.rs.core.Response;
47-
import org.glassfish.jersey.client.ClientResponse;
4847

4948
import org.glassfish.jersey.examples.linking.resources.ItemsResource;
5049
import org.glassfish.jersey.linking.DeclarativeLinkingFeature;
@@ -53,8 +52,9 @@
5352
import org.glassfish.jersey.test.TestProperties;
5453

5554
import org.junit.Test;
55+
import static org.hamcrest.CoreMatchers.containsString;
56+
import static org.hamcrest.MatcherAssert.assertThat;
5657
import static org.junit.Assert.assertEquals;
57-
import static org.junit.Assert.assertTrue;
5858

5959
/**
6060
* @author Naresh ([email protected])
@@ -65,7 +65,7 @@ public class LinkWebAppTest extends JerseyTest {
6565
@Override
6666
protected ResourceConfig configure() {
6767
enable(TestProperties.LOG_TRAFFIC);
68-
ResourceConfig rc = new ResourceConfig(ItemsResource.class);
68+
final ResourceConfig rc = new ResourceConfig(ItemsResource.class);
6969
rc.register(DeclarativeLinkingFeature.class);
7070
return rc;
7171
}
@@ -75,16 +75,21 @@ protected ResourceConfig configure() {
7575
*/
7676
@Test
7777
public void testLinks() throws Exception {
78-
79-
Response response = target().path("items").queryParam("offset", 10).queryParam("limit", "10").request().accept(MediaType.APPLICATION_XML_TYPE).get(Response.class);
78+
final Response response = target().path("items")
79+
.queryParam("offset", 10)
80+
.queryParam("limit", "10")
81+
.request(MediaType.APPLICATION_XML_TYPE)
82+
.get(Response.class);
83+
8084
final Response.StatusType statusInfo = response.getStatusInfo();
8185
assertEquals("Should have succeeded", 200, statusInfo.getStatusCode());
8286

83-
84-
String content = response.readEntity(String.class);
85-
List<Object> linkHeaders = response.getHeaders().get("Link");
87+
final String content = response.readEntity(String.class);
88+
final List<Object> linkHeaders = response.getHeaders().get("Link");
8689

8790
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"));
91+
assertThat("Content should contain next link",
92+
content,
93+
containsString("http://localhost:" + getPort() + "/items?offset=20&amp;limit=10"));
8994
}
9095
}

0 commit comments

Comments
 (0)