Skip to content

Instantly share code, notes, and snippets.

@michaelajr
Created May 26, 2018 17:46
Show Gist options
  • Save michaelajr/c6f27352d2528239e00b5f2f5b8cb42f to your computer and use it in GitHub Desktop.
Save michaelajr/c6f27352d2528239e00b5f2f5b8cb42f to your computer and use it in GitHub Desktop.
Maven For Pipelining, Part 3
package com.eoniantech.echoapi.portadaptor.rest;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Test class for the EchoResource's echo endpoint.
*
* @author Michael Andrews <Michael.Andrews@eoniantech.com>
* @since 1.0
*/
public class EchoResourceIT_echo {
private static final String URL
= "http://localhost:8080/echo/api/";
private static Client httpClient;
@BeforeClass
public static void before() {
httpClient = ClientBuilder.newClient();
}
@Test
public void testEcho() {
WebTarget webTarget
= httpClient
.target(URL)
.path("echo-message")
.queryParam("message", "hello");
Invocation invocation
= webTarget
.request()
.buildGet();
Response response
= invocation
.invoke();
assertEquals(200, response.getStatus());
assertEquals("hello", response.readEntity(String.class));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment