Skip to content

Commit a079120

Browse files
authored
Merge pull request apache#821 from datastax/guava-21-osgi
Allow Guava 21 to be imported in OSGi bundle
2 parents 109c529 + c7c4340 commit a079120

4 files changed

Lines changed: 75 additions & 4 deletions

File tree

driver-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
<_include>-osgi.bnd</_include>
201201
<Import-Package>
202202
<!-- JNR does not provide OSGi bundles, so exclude it; the driver can live without it -->
203-
<![CDATA[com.google.common*;version="[16.0.1,21)",!jnr.*,*]]></Import-Package>
203+
<![CDATA[com.google.common.*;version="[16.0.1,22)",!jnr.*,*]]></Import-Package>
204204
</instructions>
205205
<supportedProjectTypes>
206206
<supportedProjectType>jar</supportedProjectType>
@@ -224,7 +224,7 @@
224224
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
225225
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
226226
-->
227-
<![CDATA[com.google.common.*;version="[16.0.1,21)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
227+
<![CDATA[com.google.common.*;version="[16.0.1,22)",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
228228
<Private-Package>com.datastax.shaded.*</Private-Package>
229229
</instructions>
230230
</configuration>

driver-extras/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
<Bundle-SymbolicName>com.datastax.driver.extras</Bundle-SymbolicName>
231231
<Bundle-Version>${project.version}</Bundle-Version>
232232
<_include>-osgi.bnd</_include>
233-
<Import-Package><![CDATA[com.google.common*;version="[16.0.1,21)",*]]></Import-Package>
233+
<Import-Package><![CDATA[com.google.common.*;version="[16.0.1,22)",*]]></Import-Package>
234234
</instructions>
235235
<supportedProjectTypes>
236236
<supportedProjectType>jar</supportedProjectType>

driver-mapping/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
<Bundle-SymbolicName>com.datastax.driver.mapping</Bundle-SymbolicName>
159159
<Bundle-Version>${project.version}</Bundle-Version>
160160
<_include>-osgi.bnd</_include>
161-
<Import-Package><![CDATA[com.google.common*;version="[16.0.1,21)",*]]></Import-Package>
161+
<Import-Package><![CDATA[com.google.common.*;version="[16.0.1,22)",*]]></Import-Package>
162162
</instructions>
163163
<supportedProjectTypes>
164164
<supportedProjectType>jar</supportedProjectType>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (C) 2012-2015 DataStax Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.datastax.driver.osgi;
17+
18+
import com.datastax.driver.osgi.api.MailboxException;
19+
import org.ops4j.pax.exam.Configuration;
20+
import org.ops4j.pax.exam.Option;
21+
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
22+
import org.ops4j.pax.exam.testng.listener.PaxExam;
23+
import org.testng.SkipException;
24+
import org.testng.annotations.Listeners;
25+
import org.testng.annotations.Test;
26+
27+
import static com.datastax.driver.osgi.BundleOptions.*;
28+
import static org.ops4j.pax.exam.CoreOptions.options;
29+
30+
@Listeners({CCMBridgeListener.class, PaxExam.class})
31+
public class MailboxServiceGuava21IT extends MailboxServiceTests {
32+
33+
@Configuration
34+
public Option[] guava21Config() {
35+
MavenArtifactProvisionOption guavaBundle = guavaBundle();
36+
String javaVersion = System.getProperty("java.version");
37+
// Only bring in 21.0 if java version >= 1.8. If this is not done the framework
38+
// will fail to load for < 1.8 and we plan on skipping the test anyways.
39+
if (javaVersion.compareTo("1.8") >= 0) {
40+
guavaBundle = guavaBundle.version("21.0");
41+
}
42+
43+
return options(
44+
defaultOptions(),
45+
nettyBundles(),
46+
guavaBundle,
47+
driverBundle(),
48+
extrasBundle(),
49+
mappingBundle(),
50+
mailboxBundle()
51+
);
52+
}
53+
54+
/**
55+
* Exercises a 'mailbox' service provided by an OSGi bundle that depends on the driver with
56+
* Guava 21 explicitly enforced.
57+
*
58+
* @test_category packaging
59+
* @expected_result Can create, retrieve and delete data using the mailbox service.
60+
* @jira_ticket JAVA-620
61+
* @since 2.0.10, 2.1.5
62+
*/
63+
@Test(groups = "short")
64+
public void test_guava_21() throws MailboxException {
65+
String javaVersion = System.getProperty("java.version");
66+
if (javaVersion.compareTo("1.8") < 0) {
67+
throw new SkipException("Guava 21 requires Java 1.8");
68+
}
69+
checkService();
70+
}
71+
}

0 commit comments

Comments
 (0)