Skip to content

Commit

Permalink
[RESTEASY-1533] Misc minor changes to the testsuite to avoid relying …
Browse files Browse the repository at this point in the history
…on resteasy internals when not needed
  • Loading branch information
asoldano committed Sep 13, 2018
1 parent c14876d commit ba744a9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
Expand Up @@ -8,8 +8,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.jboss.resteasy.specimpl.LinkBuilderImpl;

import java.net.URI;

@Path("test")
Expand All @@ -25,7 +23,7 @@ public String get() {
@Path("/link-header")
public Response getWithHeader(@Context UriInfo uri) {
URI subUri = uri.getAbsolutePathBuilder().path("next-link").build();
Link link = new LinkBuilderImpl().uri(subUri).rel("nextLink").build();
Link link = Link.fromUri(subUri).rel("nextLink").build();
return Response.noContent().header("Link", link.toString()).build();
}

Expand Down
@@ -1,14 +1,15 @@
package org.jboss.resteasy.test.client.resource;

import org.jboss.logging.Logger;
import org.jboss.resteasy.plugins.delegates.LinkHeaderDelegate;
import org.jboss.resteasy.resteasy_jaxrs.i18n.Messages;
import org.jboss.resteasy.spi.LinkHeader;

import javax.ws.rs.HEAD;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Link;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
Expand All @@ -20,7 +21,7 @@ public class LinkHeaderService {

@POST
public Response post(@HeaderParam("Link") LinkHeader linkHeader) {
logger.info("SERVER LinkHeader: " + new LinkHeaderDelegate().toString(linkHeader));
logger.info("SERVER LinkHeader: " + toString(linkHeader));
return Response.noContent().header("Link", linkHeader).build();
}

Expand Down Expand Up @@ -56,5 +57,22 @@ protected String getTopLink(UriInfo info) {
String link = "<" + builder.build().toString() + ">; rel=\"top-message\"; title=\"top-message\"";
return link;
}

private static String toString(LinkHeader value)
{
if (value == null) throw new IllegalArgumentException(Messages.MESSAGES.paramNull());
return getString(value);
}

private static String getString(LinkHeader value)
{
StringBuffer buf = new StringBuffer();
for (Link link : value.getLinks())
{
if (buf.length() > 0) buf.append(", ");
buf.append(link.toString());
}
return buf.toString();
}

}
Expand Up @@ -8,7 +8,6 @@
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.specimpl.ResteasyUriBuilder;
import org.jboss.resteasy.test.core.encoding.resource.MatrixParamEncodingResource;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.resteasy.utils.PortProviderUtil;
Expand Down Expand Up @@ -105,7 +104,7 @@ public void testMatrixParamRequestEncoded() throws Exception {
*/
@Test
public void testMatrixParamUriBuilderDecoded() throws Exception {
UriBuilder uriBuilder = ResteasyUriBuilder.fromUri(generateURL("/decoded"));
UriBuilder uriBuilder = UriBuilder.fromUri(generateURL("/decoded"));
uriBuilder.matrixParam("param", "ac/dc");
ResteasyWebTarget target = client.target(uriBuilder.build().toString());
logger.info("Sending request to " + uriBuilder.build().toString());
Expand All @@ -122,7 +121,7 @@ public void testMatrixParamUriBuilderDecoded() throws Exception {
*/
@Test
public void testMatrixParamUriBuilderEncoded() throws Exception {
UriBuilder uriBuilder = ResteasyUriBuilder.fromUri(generateURL("/encoded"));
UriBuilder uriBuilder = UriBuilder.fromUri(generateURL("/encoded"));
uriBuilder.matrixParam("param", "ac/dc");
ResteasyWebTarget target = client.target(uriBuilder.build().toString());
logger.info("Sending request to " + uriBuilder.build().toString());
Expand Down
Expand Up @@ -7,8 +7,6 @@
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.core.Dispatcher;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.resteasy.test.providers.jaxb.resource.CharSetFavoriteMovieXmlRootElement;
import org.jboss.resteasy.test.providers.jaxb.resource.CharSetMovieResource;
import org.jboss.resteasy.util.HttpResponseCodes;
Expand Down Expand Up @@ -40,8 +38,6 @@
@RunAsClient
public class CharSetRE1066Test
{
protected static ResteasyDeployment deployment;
protected static Dispatcher dispatcher;
public static final MediaType APPLICATION_XML_UTF16_TYPE;
public static final MediaType TEXT_PLAIN_UTF16_TYPE;
public static final MediaType WILDCARD_UTF16_TYPE;
Expand Down

0 comments on commit ba744a9

Please sign in to comment.