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

Commit 6bb848d

Browse files
Adam LindenthalMarek Potociar
authored andcommitted
JERSEY-2840 ApacheConnector missing OSGi headers
Change-Id: Ifd217ce900e524ab7808c3ffcc07d3ca8c7b7060
1 parent ea75b7e commit 6bb848d

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

connectors/apache-connector/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
<groupId>org.apache.maven.plugins</groupId>
102102
<artifactId>maven-compiler-plugin</artifactId>
103103
</plugin>
104+
<plugin>
105+
<groupId>org.apache.felix</groupId>
106+
<artifactId>maven-bundle-plugin</artifactId>
107+
<inherited>true</inherited>
108+
</plugin>
104109
</plugins>
105110
</build>
106111

tests/osgi/functional/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,32 @@
189189
<artifactId>jersey-client</artifactId>
190190
<scope>test</scope>
191191
</dependency>
192+
193+
<!-- dependecies for OSGi test with Apache connector -->
194+
<dependency>
195+
<groupId>org.glassfish.jersey.connectors</groupId>
196+
<artifactId>jersey-apache-connector</artifactId>
197+
<scope>test</scope>
198+
</dependency>
199+
<dependency>
200+
<groupId>org.ops4j.pax.logging</groupId>
201+
<artifactId>pax-logging-api</artifactId>
202+
<scope>test</scope>
203+
<version>1.8.3</version>
204+
</dependency>
205+
<dependency>
206+
<groupId>org.apache.httpcomponents</groupId>
207+
<artifactId>httpcore-osgi</artifactId>
208+
<scope>test</scope>
209+
<version>4.4.3</version>
210+
</dependency>
211+
<dependency>
212+
<groupId>org.apache.httpcomponents</groupId>
213+
<artifactId>httpclient-osgi</artifactId>
214+
<scope>test</scope>
215+
<version>${httpclient.version}</version>
216+
</dependency>
217+
192218
<dependency>
193219
<groupId>org.glassfish.jersey.media</groupId>
194220
<artifactId>jersey-media-json-jackson</artifactId>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
package org.glassfish.jersey.osgi.test.basic;
41+
42+
import java.net.URI;
43+
import java.util.List;
44+
45+
import javax.ws.rs.GET;
46+
import javax.ws.rs.Path;
47+
import javax.ws.rs.client.Client;
48+
import javax.ws.rs.client.ClientBuilder;
49+
import javax.ws.rs.core.Response;
50+
import javax.ws.rs.core.UriBuilder;
51+
52+
import org.glassfish.grizzly.http.server.HttpServer;
53+
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
54+
import org.glassfish.jersey.client.ClientConfig;
55+
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
56+
import org.glassfish.jersey.osgi.test.util.Helper;
57+
import org.glassfish.jersey.server.ResourceConfig;
58+
59+
import org.junit.Test;
60+
import org.junit.runner.RunWith;
61+
import org.ops4j.pax.exam.Configuration;
62+
import org.ops4j.pax.exam.Option;
63+
import org.ops4j.pax.exam.junit.PaxExam;
64+
65+
import static org.junit.Assert.assertEquals;
66+
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
67+
68+
/**
69+
* @author Adam Lindenthal (adam.lindenthal at oracle.com)
70+
*/
71+
@RunWith(PaxExam.class)
72+
public class ApacheOsgiIntegrationTest {
73+
74+
private static final URI baseUri = UriBuilder.fromUri("http://localhost").port(Helper.getPort()).path("/jersey").build();
75+
76+
@Configuration
77+
public static Option[] configuration() {
78+
final List<Option> options = Helper.getCommonOsgiOptions();
79+
options.addAll(Helper.expandedList(
80+
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").versionAsInProject(),
81+
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").versionAsInProject(),
82+
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi").versionAsInProject(),
83+
mavenBundle().groupId("org.glassfish.jersey.connectors").artifactId("jersey-apache-connector")
84+
.versionAsInProject()
85+
86+
));
87+
return Helper.asArray(options);
88+
}
89+
90+
@Path("/apacheOsgiTest")
91+
public static class ApacheOsgiTestResource {
92+
93+
@GET
94+
public String getMe() {
95+
return "OK";
96+
}
97+
}
98+
99+
@Test
100+
public void testSimpleResource() throws Exception {
101+
final ResourceConfig resourceConfig = new ResourceConfig(ApacheOsgiTestResource.class);
102+
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
103+
104+
final ClientConfig clientConfig = new ClientConfig();
105+
clientConfig.connectorProvider(new ApacheConnectorProvider());
106+
final Client c = ClientBuilder.newClient(clientConfig);
107+
108+
final Response response = c.target(baseUri).path("/apacheOsgiTest").request().buildGet().invoke();
109+
110+
final String result = response.readEntity(String.class);
111+
assertEquals("OK", result);
112+
server.shutdownNow();
113+
}
114+
}

0 commit comments

Comments
 (0)