This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

J-445: Checkstyle verification during build.

 - added new checkstyle-verify.xml definitions
 - removed unnecessary definitions from checkstyle.xml
 - new profile - checkstyleSkip (renamed similar profiles to *Skip)
 - fixed checkstyle problems

Change-Id: I05e0c94d6b2babd48c799171b852d7a931f6143c
Signed-off-by: Michal Gajdos <michal.gajdos@oracle.com>
  • Loading branch information...
Michal Gajdos
Michal Gajdos committed Mar 1, 2015
1 parent 0bec346 commit 4c99cdefe97766c29efd77afdafa2271d1871613
Showing 752 changed files with 9,911 additions and 8,365 deletions.
@@ -279,7 +279,6 @@
.get(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION);
this.preemptiveBasicAuth = (preemptiveBasicAuthProperty != null) ? preemptiveBasicAuthProperty : false;
if (reqConfig != null) {
final RequestConfig.Builder reqConfigBuilder = RequestConfig.copy((RequestConfig) reqConfig);
if (connectTimeout > 0) {
@@ -453,12 +452,11 @@ public ClientResponse apply(final ClientRequest clientRequest) throws Processing
context.setAuthCache(authCache);
}
response = client.execute(getHost(request), request, context);
HeaderUtils.checkHeaderChanges(clientHeadersSnapshot, clientRequest.getHeaders(),
this.getClass().getName());
HeaderUtils.checkHeaderChanges(clientHeadersSnapshot, clientRequest.getHeaders(), this.getClass().getName());
final Response.StatusType status = response.getStatusLine().getReasonPhrase() == null ?
Statuses.from(response.getStatusLine().getStatusCode()) :
Statuses.from(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
final Response.StatusType status = response.getStatusLine().getReasonPhrase() == null
? Statuses.from(response.getStatusLine().getStatusCode())
: Statuses.from(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
final ClientResponse responseContext = new ClientResponse(status, clientRequest);
final List<URI> redirectLocations = context.getRedirectLocations();
@@ -491,7 +489,6 @@ public ClientResponse apply(final ClientRequest clientRequest) throws Processing
}
}
try {
responseContext.setEntityStream(new HttpClientResponseInputStream(getInputStream(response)));
} catch (final IOException e) {
@@ -555,7 +552,6 @@ private HttpUriRequest getUriHttpRequest(final ClientRequest clientRequest) {
.build();
}
private HttpEntity getHttpEntity(final ClientRequest clientRequest, final boolean bufferingEnabled) {
final Object entity = clientRequest.getEntity();
@@ -613,7 +609,8 @@ public boolean isStreaming() {
}
}
private static Map<String, String> writeOutBoundHeaders(final MultivaluedMap<String, Object> headers, final HttpUriRequest request) {
private static Map<String, String> writeOutBoundHeaders(final MultivaluedMap<String, Object> headers,
final HttpUriRequest request) {
final Map<String, String> stringHeaders = HeaderUtils.asStringHeadersSingleValue(headers);
for (final Map.Entry<String, String> e : stringHeaders.entrySet()) {
@@ -83,6 +83,7 @@ protected Application configure() {
@Path("/")
public static class PreemptiveAuthResource {
@GET
public String get(@Context HttpHeaders h) {
String value = h.getRequestHeaders().getFirst("Authorization");
@@ -107,7 +108,8 @@ public void testPreemptiveAuth() {
);
ClientConfig cc = new ClientConfig();
cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider).property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, true);
cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider)
.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, true);
cc.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(cc);
@@ -136,6 +138,7 @@ public void testPreemptiveAuthPost() {
@Path("/test")
@Singleton
public static class AuthResource {
int requestCount = 0;
@GET
@@ -144,7 +147,8 @@ public String get(@Context HttpHeaders h) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
assertEquals(1, requestCount);
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
} else {
assertTrue(requestCount > 1);
}
@@ -157,7 +161,8 @@ public String get(@Context HttpHeaders h) {
public String getFilter(@Context HttpHeaders h) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
}
return "GET";
@@ -169,7 +174,8 @@ public String post(@Context HttpHeaders h, String e) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
assertEquals(1, requestCount);
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
} else {
assertTrue(requestCount > 1);
}
@@ -182,7 +188,8 @@ public String post(@Context HttpHeaders h, String e) {
public String postFilter(@Context HttpHeaders h, String e) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
}
return e;
@@ -194,7 +201,8 @@ public void delete(@Context HttpHeaders h) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
assertEquals(1, requestCount);
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
} else {
assertTrue(requestCount > 1);
}
@@ -205,7 +213,8 @@ public void delete(@Context HttpHeaders h) {
public void deleteFilter(@Context HttpHeaders h) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
}
}
@@ -214,7 +223,8 @@ public void deleteFilter(@Context HttpHeaders h) {
public String deleteFilterWithEntity(@Context HttpHeaders h, String e) {
String value = h.getRequestHeaders().getFirst("Authorization");
if (value == null) {
throw new WebApplicationException(Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
throw new WebApplicationException(
Response.status(401).header("WWW-Authenticate", "Basic realm=\"WallyWorld\"").build());
}
return e;
@@ -250,8 +260,8 @@ public void testAuthGetWithClientFilter() {
}
@Test
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" +
" Allow repeatable write in jersey?")
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?"
+ " Allow repeatable write in jersey?")
public void testAuthPost() {
CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider();
credentialsProvider.setCredentials(
@@ -322,13 +332,12 @@ public void testAuthInteractiveGet() {
WebTarget r = client.target(getBaseUri()).path("test");
assertEquals("GET", r.request().get(String.class));
}
@Test
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" +
" Allow repeatable write in jersey?")
@Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?"
+ " Allow repeatable write in jersey?")
public void testAuthInteractivePost() {
CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider();
credentialsProvider.setCredentials(
@@ -342,7 +351,6 @@ public void testAuthInteractivePost() {
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri()).path("test");
assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
}
}
@@ -72,12 +72,13 @@
@Path("/")
public static class CookieResource {
@GET
public Response get(@Context HttpHeaders h) {
Cookie c = h.getCookies().get("name");
String e = (c == null) ? "NO-COOKIE" : c.getValue();
return Response.ok(e).
cookie(new NewCookie("name", "value")).build();
return Response.ok(e)
.cookie(new NewCookie("name", "value")).build();
}
}
@@ -93,7 +94,6 @@ public void testCookieResource() {
Client client = ClientBuilder.newClient(cc);
WebTarget r = client.target(getBaseUri());
assertEquals("NO-COOKIE", r.request().get(String.class));
assertEquals("value", r.request().get(String.class));
}
@@ -74,6 +74,7 @@ protected Application configure() {
@Path("/")
public static class Resource {
@POST
public byte[] post(byte[] content) {
return content;
@@ -88,7 +89,8 @@ public void testPost() {
WebTarget r = client.target(getBaseUri());
byte[] content = new byte[1024 * 1024];
assertTrue(Arrays.equals(content, r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
assertTrue(Arrays.equals(content,
r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
Response cr = r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE));
assertTrue(cr.hasEntity());
@@ -105,7 +107,8 @@ public void testPostChunked() {
WebTarget r = client.target(getBaseUri());
byte[] content = new byte[1024 * 1024];
assertTrue(Arrays.equals(content, r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
assertTrue(Arrays.equals(content,
r.request().post(Entity.entity(content, MediaType.APPLICATION_OCTET_STREAM_TYPE)).readEntity(byte[].class)));
Response cr = r.request().post(Entity.text("POST"));
assertTrue(cr.hasEntity());
@@ -76,19 +76,22 @@
* @author Arul Dhesiaseelan (aruld at acm.org)
*/
public class HttpHeadersTest extends JerseyTest {
private static final Logger LOGGER = Logger.getLogger(HttpHeadersTest.class.getName());
@Path("/test")
public static class HttpMethodResource {
@POST
public String post(
@HeaderParam("Transfer-Encoding") String transferEncoding,
@HeaderParam("X-CLIENT") String xClient,
@HeaderParam("X-WRITER") String xWriter,
String entity) {
assertEquals("client", xClient);
if (transferEncoding == null || !transferEncoding.equals("chunked"))
if (transferEncoding == null || !transferEncoding.equals("chunked")) {
assertEquals("writer", xWriter);
}
return entity;
}
}
@@ -105,7 +108,13 @@ public long getSize(String t, Class<?> type, Type genericType, Annotation[] anno
return -1;
}
public void writeTo(String t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
public void writeTo(String t,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
httpHeaders.add("X-WRITER", "writer");
entityStream.write(t.getBytes());
}
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013-2015 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
package org.glassfish.jersey.apache.connector;
import java.io.IOException;
@@ -122,6 +123,7 @@
@Documented
@Target(ElementType.METHOD)
public static @interface Require {
/**
* Expected custom header name to be validated by the {@link CustomHeaderFilter}.
*/
@@ -155,6 +157,7 @@ public void configure(ResourceInfo resourceInfo, FeatureContext context) {
* @author Marek Potociar (marek.potociar at oracle.com)
*/
public static class CustomHeaderFilter implements ContainerRequestFilter, ClientRequestFilter {
private final String headerName;
private final String headerValue;
@@ -171,7 +174,8 @@ public void filter(ContainerRequestContext ctx) throws IOException { // validate
if (!headerValue.equals(ctx.getHeaderString(headerName))) {
ctx.abortWith(Response.status(Response.Status.FORBIDDEN)
.type(MediaType.TEXT_PLAIN)
.entity(String.format("Expected header '%s' not present or value not equal to '%s'", headerName, headerValue))
.entity(String
.format("Expected header '%s' not present or value not equal to '%s'", headerName, headerValue))
.build());
}
}
@@ -205,7 +209,6 @@ public String getB() {
}
}
/**
* A resource that uses managed clients to retrieve values of internal
* resources 'A' and 'B', which are protected by a {@link CustomHeaderFilter}
@@ -220,6 +223,7 @@ public String getB() {
*/
@Path("public")
public static class PublicResource {
@Uri("a")
@ClientA // resolves to <base>/internal/a
private WebTarget targetA;
@@ -248,18 +252,19 @@ protected Application configure() {
}
public static class MyClientAConfig extends ClientConfig {
public MyClientAConfig() {
this.register(new CustomHeaderFilter("custom-header", "a"));
}
}
public static class MyClientBConfig extends ClientConfig {
public MyClientBConfig() {
this.register(new CustomHeaderFilter("custom-header", "b"));
}
}
@Override
protected void configureClient(ClientConfig config) {
config.connectorProvider(new ApacheConnectorProvider());
@@ -284,5 +289,4 @@ public void testManagedClient() throws Exception {
assertEquals("b", response.readEntity(String.class));
}
}
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -72,8 +72,8 @@ public void testHttpClientInstanceAccess() {
assertNotNull("HTTP client instance set on JerseyClient should not be null.", hcOnClient);
assertNotNull("HTTP client instance set on JerseyWebTarget should not be null.", hcOnTarget);
assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" +
"(provided the target instance has not been further configured).",
assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget"
+ "(provided the target instance has not been further configured).",
hcOnClient, hcOnTarget
);
}
Oops, something went wrong.

0 comments on commit 4c99cde

Please sign in to comment.