Skip to content

Commit 4af251a

Browse files
hhughesabsurdfarce
andauthored
Fix MailboxServiceShadedIT for shaded dropwizard deps (#1724)
* Don't load dropwizard dependency for shaded osgi tests * Remove com.codahale.metrics import from shaded jar manifest and add javax.management (required by dropwizard) * Separate osgi tests into shaded and non-shaded to each compile with respective version of driver-code * Move common osgi test harness to separate subproject, osgi-unshaded and osgi-shaded depend on osgi-common sources which they recompile with the respective version of the driver-core jar --------- Co-authored-by: Bret McGuire <[email protected]>
1 parent e96d148 commit 4af251a

28 files changed

+493
-47
lines changed

driver-core/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@
256256
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
257257
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
258258
-->
259-
<Import-Package><![CDATA[com.google.common.*;version="16.0.1",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
259+
<Import-Package><![CDATA[com.google.common.*;version="16.0.1",!jnr.*,!io.netty.*,!com.codahale.metrics,javax.security.cert,javax.management,*]]></Import-Package>
260260
<Private-Package>com.datastax.shaded.*</Private-Package>
261+
<Export-Package>com.datastax.shaded.metrics;*</Export-Package>
261262
</instructions>
262263
</configuration>
263264
</execution>
@@ -302,6 +303,8 @@
302303
<resource>META-INF/maven/io.netty/netty-handler/pom.xml</resource>
303304
<resource>META-INF/maven/io.netty/netty-transport/pom.properties</resource>
304305
<resource>META-INF/maven/io.netty/netty-transport/pom.xml</resource>
306+
<resource>META-INF/maven/io.dropwizard.metrics/metrics-core/pom.properties</resource>
307+
<resource>META-INF/maven/io.dropwizard.metrics/metrics-core/pom.xml</resource>
305308
</resources>
306309
</transformer>
307310
<!-- Pick up the alternate manifest that was generated by the alternate execution of the bundle plugin -->

driver-tests/osgi/common/pom.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--
2+
3+
Copyright DataStax, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19+
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<parent>
23+
<groupId>com.datastax.cassandra</groupId>
24+
<artifactId>cassandra-driver-tests-osgi</artifactId>
25+
<version>3.11.5-SNAPSHOT</version>
26+
</parent>
27+
28+
<packaging>jar</packaging>
29+
<artifactId>cassandra-driver-tests-osgi-common</artifactId>
30+
<name>DataStax Java Driver for Apache Cassandra Tests - OSGi - Shaded</name>
31+
<description>Common classes for testing DataStax Java Driver in an OSGi container.</description>
32+
33+
<!--
34+
This submodule holds the common test classes for the shaded and unshaded osgi tests.
35+
Since each testing submodule uses a different version of driver-core, each copies
36+
these common classes into it's build-dir and recompiles them with the correct driver
37+
artifact. This is required because MailboxImpl uses dropwizard classes that may or
38+
may not be shaded. In order for the shaded/unshaded classes on the classpath to match
39+
those referenced in the compiled .class files we need the correct driver-core
40+
dependency loaded at compile-time, hence why each submodule must recompile the common
41+
test code.
42+
-->
43+
44+
</project>

driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java renamed to driver-tests/osgi/common/src/test/java/com/datastax/driver/osgi/BundleOptions.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.datastax.driver.osgi;
1717

18-
import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackage;
18+
import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
1919
import static org.ops4j.pax.exam.CoreOptions.bundle;
2020
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
2121
import static org.ops4j.pax.exam.CoreOptions.options;
@@ -60,7 +60,7 @@ public static UrlProvisionOption driverBundle(boolean useShaded) {
6060
return bundle(
6161
"reference:file:"
6262
+ PathUtils.getBaseDir()
63-
+ "/../../driver-core/target/cassandra-driver-core-"
63+
+ "/../../../driver-core/target/cassandra-driver-core-"
6464
+ Cluster.getDriverVersion()
6565
+ classifier
6666
+ ".jar");
@@ -70,7 +70,7 @@ public static UrlProvisionOption mappingBundle() {
7070
return bundle(
7171
"reference:file:"
7272
+ PathUtils.getBaseDir()
73-
+ "/../../driver-mapping/target/cassandra-driver-mapping-"
73+
+ "/../../../driver-mapping/target/cassandra-driver-mapping-"
7474
+ Cluster.getDriverVersion()
7575
+ ".jar");
7676
}
@@ -79,7 +79,7 @@ public static UrlProvisionOption extrasBundle() {
7979
return bundle(
8080
"reference:file:"
8181
+ PathUtils.getBaseDir()
82-
+ "/../../driver-extras/target/cassandra-driver-extras-"
82+
+ "/../../../driver-extras/target/cassandra-driver-extras-"
8383
+ Cluster.getDriverVersion()
8484
+ ".jar");
8585
}
@@ -143,6 +143,17 @@ public Option[] getOptions() {
143143
};
144144
}
145145

146+
public static CompositeOption dropwizardMetricsBundle() {
147+
return new CompositeOption() {
148+
149+
@Override
150+
public Option[] getOptions() {
151+
return options(
152+
mavenBundle("io.dropwizard.metrics", "metrics-core", getVersion("metrics.version")));
153+
}
154+
};
155+
}
156+
146157
public static UrlProvisionOption mailboxBundle() {
147158
return bundle("reference:file:" + PathUtils.getBaseDir() + "/target/classes");
148159
}
@@ -157,7 +168,7 @@ public Option[] getOptions() {
157168
// Delegate javax.security.cert to the parent classloader.
158169
// javax.security.cert.X509Certificate is used in
159170
// io.netty.util.internal.EmptyArrays, but not directly by the driver.
160-
bootDelegationPackage("javax.security.cert"),
171+
bootDelegationPackages("javax.security.cert", "javax.management"),
161172
systemProperty("cassandra.version")
162173
.value(CCMBridge.getGlobalCassandraVersion().toString()),
163174
systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1),
@@ -166,7 +177,6 @@ public Option[] getOptions() {
166177
mavenBundle("org.slf4j", "slf4j-api", getVersion("slf4j.version")),
167178
mavenBundle("ch.qos.logback", "logback-classic", getVersion("logback.version")),
168179
mavenBundle("ch.qos.logback", "logback-core", getVersion("logback.version")),
169-
mavenBundle("io.dropwizard.metrics", "metrics-core", getVersion("metrics.version")),
170180
mavenBundle(
171181
"com.fasterxml.jackson.core",
172182
"jackson-databind",

0 commit comments

Comments
 (0)