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

Commit acd4135

Browse files
author
Michal Gajdos
committed
Small changes to be able to build Jersey on JDK8.
Change-Id: Id1f30b2f696f7ecb5c4b5f011f0d2563cdc5f594 Signed-off-by: Michal Gajdos <[email protected]>
1 parent 3fe9577 commit acd4135

File tree

13 files changed

+227
-123
lines changed

13 files changed

+227
-123
lines changed

bundles/repackaged/jersey-jsr166e/src/main/java/jersey/repackaged/jsr166e/ConcurrentHashMapV8.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4507,7 +4507,7 @@ public boolean equals(Object o) {
45074507
(containsAll(c) && c.containsAll(this))));
45084508
}
45094509

4510-
public ConcurrentHashMapSpliterator<K> spliterator() {
4510+
public ConcurrentHashMapSpliterator<K> spliteratorV8() {
45114511
Node<K,V>[] t;
45124512
ConcurrentHashMapV8<K,V> m = map;
45134513
long n = m.sumCount();
@@ -4565,7 +4565,7 @@ public final boolean addAll(Collection<? extends V> c) {
45654565
throw new UnsupportedOperationException();
45664566
}
45674567

4568-
public ConcurrentHashMapSpliterator<V> spliterator() {
4568+
public ConcurrentHashMapSpliterator<V> spliteratorV8() {
45694569
Node<K,V>[] t;
45704570
ConcurrentHashMapV8<K,V> m = map;
45714571
long n = m.sumCount();
@@ -4653,7 +4653,7 @@ public final boolean equals(Object o) {
46534653
(containsAll(c) && c.containsAll(this))));
46544654
}
46554655

4656-
public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliterator() {
4656+
public ConcurrentHashMapSpliterator<Map.Entry<K,V>> spliteratorV8() {
46574657
Node<K,V>[] t;
46584658
ConcurrentHashMapV8<K,V> m = map;
46594659
long n = m.sumCount();

core-client/src/test/java/org/glassfish/jersey/client/JerseyInvocationTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
package org.glassfish.jersey.client;
4141

4242
import java.io.IOException;
43+
import java.net.ConnectException;
4344
import java.net.ProtocolException;
4445
import java.util.concurrent.CountDownLatch;
4546
import java.util.concurrent.ExecutionException;
@@ -63,6 +64,7 @@
6364

6465
import org.hamcrest.CoreMatchers;
6566
import org.junit.Test;
67+
import static org.hamcrest.CoreMatchers.anyOf;
6668
import static org.hamcrest.CoreMatchers.hasItem;
6769
import static org.hamcrest.CoreMatchers.is;
6870
import static org.junit.Assert.assertEquals;
@@ -134,7 +136,8 @@ public void overrideHttpMethodBasedComplianceCheckTest() {
134136
c1.target("http://localhost:8080/myPath").request().method("DELETE", Entity.text("body"));
135137
fail("ProcessingException expected.");
136138
} catch (final ProcessingException ex) {
137-
assertEquals(ProtocolException.class, ex.getCause().getClass());
139+
assertThat(ex.getCause().getClass(), anyOf(CoreMatchers.<Class<?>>equalTo(ProtocolException.class),
140+
CoreMatchers.<Class<?>>equalTo(ConnectException.class)));
138141
}
139142

140143
final Client c2 = ClientBuilder.newClient();
@@ -143,7 +146,8 @@ public void overrideHttpMethodBasedComplianceCheckTest() {
143146
true).method("DELETE", Entity.text("body"));
144147
fail("ProcessingException expected.");
145148
} catch (final ProcessingException ex) {
146-
assertEquals(ProtocolException.class, ex.getCause().getClass());
149+
assertThat(ex.getCause().getClass(), anyOf(CoreMatchers.<Class<?>>equalTo(ProtocolException.class),
150+
CoreMatchers.<Class<?>>equalTo(ConnectException.class)));
147151
}
148152

149153
final Client c3 = ClientBuilder.newClient().property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, false);
@@ -152,7 +156,8 @@ public void overrideHttpMethodBasedComplianceCheckTest() {
152156
true).method("DELETE", Entity.text("body"));
153157
fail("ProcessingException expected.");
154158
} catch (final ProcessingException ex) {
155-
assertEquals(ProtocolException.class, ex.getCause().getClass());
159+
assertThat(ex.getCause().getClass(), anyOf(CoreMatchers.<Class<?>>equalTo(ProtocolException.class),
160+
CoreMatchers.<Class<?>>equalTo(ConnectException.class)));
156161
}
157162
}
158163

core-server/src/test/java/org/glassfish/jersey/server/model/AmbiguousTemplateTest.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -40,6 +40,8 @@
4040

4141
package org.glassfish.jersey.server.model;
4242

43+
import java.util.Arrays;
44+
import java.util.List;
4345
import java.util.concurrent.ExecutionException;
4446

4547
import javax.ws.rs.GET;
@@ -57,6 +59,9 @@
5759

5860
import org.junit.Assert;
5961
import org.junit.Test;
62+
import static org.hamcrest.CoreMatchers.hasItems;
63+
import static org.hamcrest.CoreMatchers.is;
64+
import static org.junit.Assert.assertThat;
6065

6166
/**
6267
* Test matching of resources with ambiguous templates.
@@ -278,7 +283,11 @@ public void testOptionsOnRoot() throws ExecutionException, InterruptedException
278283
final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "OPTIONS")
279284
.accept(MediaType.TEXT_PLAIN).build()).get();
280285
Assert.assertEquals(200, containerResponse.getStatus());
281-
Assert.assertEquals("POST, GET, OPTIONS, HEAD", containerResponse.getEntity());
286+
287+
final List<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
288+
assertThat(methods, hasItems("POST", "GET", "OPTIONS", "HEAD"));
289+
assertThat(methods.size(), is(4));
290+
282291
}
283292

284293
@Test
@@ -299,7 +308,11 @@ public void testOptionsOnChild() throws ExecutionException, InterruptedException
299308
final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/c", "OPTIONS")
300309
.accept(MediaType.TEXT_PLAIN).build()).get();
301310
Assert.assertEquals(200, containerResponse.getStatus());
302-
Assert.assertEquals("GET, OPTIONS, HEAD, PUT", containerResponse.getEntity());
311+
312+
final List<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
313+
assertThat(methods, hasItems("PUT", "GET", "OPTIONS", "HEAD"));
314+
assertThat(methods.size(), is(4));
315+
303316
}
304317

305318
@Test

ext/wadl-doclet/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@
7272
</dependency>
7373
</dependencies>
7474
</profile>
75+
<profile>
76+
<id>jdk1.8</id>
77+
<activation>
78+
<jdk>1.8</jdk>
79+
</activation>
80+
<dependencies>
81+
<dependency>
82+
<groupId>com.sun</groupId>
83+
<artifactId>tools</artifactId>
84+
<version>1.8.0</version>
85+
<scope>system</scope>
86+
<systemPath>${java.home}/../lib/tools.jar</systemPath>
87+
</dependency>
88+
</dependencies>
89+
</profile>
7590
<profile>
7691
<id>tools.jar</id>
7792
<activation>

ext/wadl-doclet/src/main/java/org/glassfish/jersey/wadl/doclet/DocProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public interface DocProcessor {
8787
void processClassDoc(ClassDoc classDoc, ClassDocType classDocType);
8888

8989
/**
90-
* Process the provided methodDoc and add your custom information to the methodDocType.<br/>
90+
* Process the provided methodDoc and add your custom information to the methodDocType.<br>
9191
* Use e.g. {@link MethodDocType#getAny()} to store custom elements.
9292
* @param methodDoc the {@link MethodDoc} representing the docs of your method.
9393
* @param methodDocType the related {@link MethodDocType} that will later be processed by the

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringClientTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -55,7 +55,6 @@
5555
import org.glassfish.jersey.internal.inject.CustomAnnotationImpl;
5656
import org.glassfish.jersey.message.filtering.EntityFilteringFeature;
5757
import org.glassfish.jersey.server.ResourceConfig;
58-
import org.glassfish.jersey.test.JerseyTest;
5958
import org.glassfish.jersey.test.TestProperties;
6059
import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity;
6160
import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity;
@@ -67,7 +66,7 @@
6766
/**
6867
* @author Michal Gajdos (michal.gajdos at oracle.com)
6968
*/
70-
public class EntityFilteringClientTest extends JerseyTest {
69+
public class EntityFilteringClientTest extends EntityFilteringTest {
7170

7271
public static final MediaType ENTITY_FILTERING = new MediaType("entity", "filtering");
7372

@@ -107,8 +106,8 @@ public void testEntityAnnotationsPrimaryView() throws Exception {
107106
new Annotation[]{PrimaryDetailedView.Factory.get()}),
108107
String.class);
109108

110-
assertThat(fields, equalTo("field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," +
111-
"subEntities.field1,defaultEntities.field,defaultEntities.property"));
109+
assertSameFields(fields, "field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," +
110+
"subEntities.field1,defaultEntities.field,defaultEntities.property");
112111
}
113112

114113
@Test
@@ -165,7 +164,7 @@ private void testConfiguration(final String expected, final Annotation... annota
165164
.request()
166165
.post(Entity.entity(new OneFilteringOnClassEntity(), ENTITY_FILTERING), String.class);
167166

168-
assertThat(fields, equalTo(expected));
167+
assertSameFields(fields, expected);
169168
}
170169

171170
@Test
@@ -198,7 +197,7 @@ public void testEntityAnnotationsOverConfiguration() throws Exception {
198197
new Annotation[]{PrimaryDetailedView.Factory.get()}),
199198
String.class);
200199

201-
assertThat(fields, equalTo("field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," +
202-
"oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities.property"));
200+
assertSameFields(fields, "field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," +
201+
"oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities.property");
203202
}
204203
}

tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2013-2014 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -52,21 +52,18 @@
5252

5353
import org.glassfish.jersey.message.filtering.EntityFilteringFeature;
5454
import org.glassfish.jersey.server.ResourceConfig;
55-
import org.glassfish.jersey.test.JerseyTest;
5655
import org.glassfish.jersey.test.TestProperties;
5756
import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity;
5857
import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity;
5958

6059
import org.junit.Test;
61-
import static org.hamcrest.CoreMatchers.equalTo;
62-
import static org.hamcrest.MatcherAssert.assertThat;
6360

6461
/**
6562
* Use-cases with entity-filtering annotations on class.
6663
*
6764
* @author Michal Gajdos (michal.gajdos at oracle.com)
6865
*/
69-
public class EntityFilteringOnClassTest extends JerseyTest {
66+
public class EntityFilteringOnClassTest extends EntityFilteringTest {
7067

7168
@Override
7269
protected Application configure() {
@@ -144,22 +141,22 @@ public ManyFilteringsOnClassEntity getManyFilteringsEntityManyViews() {
144141
public void testOneEntityFilteringOnClass() throws Exception {
145142
final String fields = target("OneFilteringEntity").request().get(String.class);
146143

147-
assertThat(fields, equalTo("field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," +
148-
"subEntities.field1,defaultEntities.field,defaultEntities.property"));
144+
assertSameFields(fields, "field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," +
145+
"subEntities.field1,defaultEntities.field,defaultEntities.property");
149146
}
150147

151148
@Test
152149
public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception {
153150
final String fields = target("OneFilteringEntityDefaultViewResponse").request().get(String.class);
154151

155-
assertThat(fields, equalTo(""));
152+
assertSameFields(fields, "");
156153
}
157154

158155
@Test
159156
public void testOneEntityFilteringOnClassDefaultView() throws Exception {
160157
final String fields = target("OneFilteringEntityDefaultView").request().get(String.class);
161158

162-
assertThat(fields, equalTo(""));
159+
assertSameFields(fields, "");
163160
}
164161

165162
@Test
@@ -172,31 +169,31 @@ public void testMultipleViewsOnClass() throws Exception {
172169
public void testManyFilteringsEntityPrimaryView() throws Exception {
173170
final String fields = target("ManyFilteringsEntityPrimaryView").request().get(String.class);
174171

175-
assertThat(fields, equalTo("field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," +
176-
"oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities.property"));
172+
assertSameFields(fields, "field,accessor,property,manyEntities.property1,manyEntities.field1,oneEntities.field2," +
173+
"oneEntities.property2,oneEntities.property1,oneEntities.field1,defaultEntities.field,defaultEntities.property");
177174
}
178175

179176
@Test
180177
public void testManyFilteringsEntitySecondaryView() throws Exception {
181178
final String fields = target("ManyFilteringsEntitySecondaryView").request().get(String.class);
182179

183-
assertThat(fields, equalTo("field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.field1," +
184-
"oneEntities.property2,oneEntities.field1,defaultEntities.field,defaultEntities.property"));
180+
assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.field1," +
181+
"oneEntities.property2,oneEntities.field1,defaultEntities.field,defaultEntities.property");
185182
}
186183

187184
@Test
188185
public void testManyFilteringsEntityDefaultView() throws Exception {
189186
final String fields = target("ManyFilteringsEntityDefaultView").request().get(String.class);
190187

191-
assertThat(fields, equalTo(""));
188+
assertSameFields(fields, "");
192189
}
193190

194191
@Test
195192
public void testManyFilteringsEntityManyViews() throws Exception {
196193
final String fields = target("ManyFilteringsEntityManyViews").request().get(String.class);
197194

198-
assertThat(fields, equalTo("field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.property1," +
195+
assertSameFields(fields, "field,accessor,property,manyEntities.field2,manyEntities.property2,manyEntities.property1," +
199196
"manyEntities.field1,oneEntities.field2,oneEntities.property2,oneEntities.property1,oneEntities.field1," +
200-
"defaultEntities.field,defaultEntities.property"));
197+
"defaultEntities.field,defaultEntities.property");
201198
}
202199
}

0 commit comments

Comments
 (0)