kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b68536f98e4a8377c9a2854e746c9cef1487d541f56d8f08caa53c910263d216 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-27 17:58 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-28 17:31 +01:00 |
| Parents | 5c67c2133880 |
3 files changed
modified driver-tests/osgi/pom.xml +14 −15
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | </parent> |
| 25 | 25 | |
| 26 | 26 | <artifactId>cassandra-driver-tests-osgi</artifactId> |
| 27 | - <packaging>bundle</packaging> | |
| 27 | + <packaging>jar</packaging> | |
| 28 | 28 | <name>DataStax Java Driver for Apache Cassandra Tests - OSGi</name> |
| 29 | 29 | <description>A test for the DataStax Java Driver in an OSGi container.</description> |
| 30 | 30 | <url>https://github.com/datastax/java-driver</url> |
| @@ -36,6 +36,7 @@ | ||
| 36 | 36 | <pax-exam.version>3.6.0</pax-exam.version> |
| 37 | 37 | <url.version>2.4.0</url.version> |
| 38 | 38 | <logback.version>1.1.3</logback.version> |
| 39 | + <slf4j.version>1.7.5</slf4j.version> | |
| 39 | 40 | <test.groups>none</test.groups> |
| 40 | 41 | <!-- |
| 41 | 42 | Skip tests by default, short or long profile is required to run tests in this module |
| @@ -75,7 +76,7 @@ | ||
| 75 | 76 | <dependency> |
| 76 | 77 | <groupId>org.slf4j</groupId> |
| 77 | 78 | <artifactId>slf4j-api</artifactId> |
| 78 | - <version>1.7.5</version> | |
| 79 | + <version>${slf4j.version}</version> | |
| 79 | 80 | </dependency> |
| 80 | 81 | |
| 81 | 82 | <dependency> |
| @@ -128,13 +129,6 @@ | ||
| 128 | 129 | <scope>test</scope> |
| 129 | 130 | </dependency> |
| 130 | 131 | |
| 131 | - <dependency> | |
| 132 | - <groupId>com.jcabi</groupId> | |
| 133 | - <artifactId>jcabi-manifests</artifactId> | |
| 134 | - <version>1.1</version> | |
| 135 | - <scope>test</scope> | |
| 136 | - </dependency> | |
| 137 | - | |
| 138 | 132 | <dependency> |
| 139 | 133 | <groupId>javax.servlet</groupId> |
| 140 | 134 | <artifactId>javax.servlet-api</artifactId> |
| @@ -203,6 +197,16 @@ | ||
| 203 | 197 | <groups>${test.groups}</groups> |
| 204 | 198 | <systemPropertyVariables> |
| 205 | 199 | <cassandra.version>${cassandra.version}</cassandra.version> |
| 200 | + <!-- pull in declared version properties, this ensures we test with the same versions used by the driver --> | |
| 201 | + <guava.version>${guava.version}</guava.version> | |
| 202 | + <lz4.version>${lz4.version}</lz4.version> | |
| 203 | + <snappy.version>${snappy.version}</snappy.version> | |
| 204 | + <hdr.version>${hdr.version}</hdr.version> | |
| 205 | + <netty.version>${netty.version}</netty.version> | |
| 206 | + <slf4j.version>${slf4j.version}</slf4j.version> | |
| 207 | + <logback.version>${logback.version}</logback.version> | |
| 208 | + <metrics.version>${metrics.version}</metrics.version> | |
| 209 | + <testng.version>${testng.version}</testng.version> | |
| 206 | 210 | <ipprefix>${ipprefix}</ipprefix> |
| 207 | 211 | </systemPropertyVariables> |
| 208 | 212 | </configuration> |
| @@ -229,13 +233,8 @@ | ||
| 229 | 233 | <Export-Package>com.datastax.driver.osgi.api,!com.datastax.driver.osgi.impl</Export-Package> |
| 230 | 234 | <Bundle-Activator>com.datastax.driver.osgi.impl.Activator</Bundle-Activator> |
| 231 | 235 | <_include>-osgi.bnd</_include> |
| 232 | - <Import-Package><![CDATA[com.google.common*;version="[16.0.1,20)",*]]></Import-Package> | |
| 236 | + <Import-Package><![CDATA[com.google.common.*;version="[16.0.1,20)",*]]></Import-Package> | |
| 233 | 237 | </instructions> |
| 234 | - <supportedProjectTypes> | |
| 235 | - <supportedProjectType>jar</supportedProjectType> | |
| 236 | - <supportedProjectType>bundle</supportedProjectType> | |
| 237 | - <supportedProjectType>pom</supportedProjectType> | |
| 238 | - </supportedProjectTypes> | |
| 239 | 238 | </configuration> |
| 240 | 239 | <executions> |
| 241 | 240 | <execution> |
modified driver-tests/osgi/src/test/java/com/datastax/driver/osgi/BundleOptions.java +46 −12
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | package com.datastax.driver.osgi; |
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.CCMBridge; |
| 19 | +import com.datastax.driver.core.Cluster; | |
| 19 | 20 | import com.datastax.driver.core.ProtocolOptions; |
| 20 | 21 | import com.datastax.driver.core.TestUtils; |
| 21 | 22 | import org.ops4j.pax.exam.Option; |
| @@ -24,7 +25,6 @@ | ||
| 24 | 25 | import org.ops4j.pax.exam.options.UrlProvisionOption; |
| 25 | 26 | import org.ops4j.pax.exam.util.PathUtils; |
| 26 | 27 | |
| 27 | -import static com.datastax.driver.osgi.VersionProvider.projectVersion; | |
| 28 | 28 | import static org.ops4j.pax.exam.CoreOptions.*; |
| 29 | 29 | |
| 30 | 30 | public class BundleOptions { |
| @@ -35,19 +35,19 @@ | ||
| 35 | 35 | |
| 36 | 36 | public static UrlProvisionOption driverBundle(boolean useShaded) { |
| 37 | 37 | String classifier = useShaded ? "-shaded" : ""; |
| 38 | - return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-core/target/cassandra-driver-core-" + projectVersion() + classifier + ".jar"); | |
| 38 | + return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-core/target/cassandra-driver-core-" + Cluster.getDriverVersion() + classifier + ".jar"); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public static UrlProvisionOption mappingBundle() { |
| 42 | - return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-mapping/target/cassandra-driver-mapping-" + projectVersion() + ".jar"); | |
| 42 | + return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-mapping/target/cassandra-driver-mapping-" + Cluster.getDriverVersion() + ".jar"); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static UrlProvisionOption extrasBundle() { |
| 46 | - return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-extras/target/cassandra-driver-extras-" + projectVersion() + ".jar"); | |
| 46 | + return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-extras/target/cassandra-driver-extras-" + Cluster.getDriverVersion() + ".jar"); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public static MavenArtifactProvisionOption guavaBundle() { |
| 50 | - return mavenBundle("com.google.guava", "guava", "16.0.1"); | |
| 50 | + return mavenBundle("com.google.guava", "guava", getVersion("guava.version")); | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public static CompositeOption lz4Bundle() { |
| @@ -57,14 +57,40 @@ | ||
| 57 | 57 | public Option[] getOptions() { |
| 58 | 58 | return options( |
| 59 | 59 | systemProperty("cassandra.compression").value(ProtocolOptions.Compression.LZ4.name()), |
| 60 | - mavenBundle("net.jpountz.lz4", "lz4", "1.3.0") | |
| 60 | + mavenBundle("net.jpountz.lz4", "lz4", getVersion("lz4.version")) | |
| 61 | + ); | |
| 62 | + } | |
| 63 | + }; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public static CompositeOption snappyBundle() { | |
| 67 | + return new CompositeOption() { | |
| 68 | + | |
| 69 | + @Override | |
| 70 | + public Option[] getOptions() { | |
| 71 | + return options( | |
| 72 | + systemProperty("cassandra.compression").value(ProtocolOptions.Compression.SNAPPY.name()), | |
| 73 | + mavenBundle("org.xerial.snappy", "snappy-java", getVersion("snappy.version")) | |
| 74 | + ); | |
| 75 | + } | |
| 76 | + }; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public static CompositeOption hdrHistogramBundle() { | |
| 80 | + return new CompositeOption() { | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public Option[] getOptions() { | |
| 84 | + return options( | |
| 85 | + systemProperty("cassandra.usePercentileSpeculativeExecutionPolicy").value("true"), | |
| 86 | + mavenBundle("org.hdrhistogram", "HdrHistogram", getVersion("hdr.version")) | |
| 61 | 87 | ); |
| 62 | 88 | } |
| 63 | 89 | }; |
| 64 | 90 | } |
| 65 | 91 | |
| 66 | 92 | public static CompositeOption nettyBundles() { |
| 67 | - final String nettyVersion = "4.0.33.Final"; | |
| 93 | + final String nettyVersion = getVersion("netty.version"); | |
| 68 | 94 | return new CompositeOption() { |
| 69 | 95 | |
| 70 | 96 | @Override |
| @@ -96,15 +122,23 @@ | ||
| 96 | 122 | systemProperty("cassandra.version").value(CCMBridge.getGlobalCassandraVersion().toString()), |
| 97 | 123 | systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1), |
| 98 | 124 | systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"), |
| 99 | - mavenBundle("org.slf4j", "slf4j-api", "1.7.5"), | |
| 100 | - mavenBundle("ch.qos.logback", "logback-classic", "1.1.3"), | |
| 101 | - mavenBundle("ch.qos.logback", "logback-core", "1.1.3"), | |
| 102 | - mavenBundle("io.dropwizard.metrics", "metrics-core", "3.1.2"), | |
| 103 | - mavenBundle("org.testng", "testng", "6.8.8"), | |
| 125 | + mavenBundle("org.slf4j", "slf4j-api", getVersion("slf4j.version")), | |
| 126 | + mavenBundle("ch.qos.logback", "logback-classic", getVersion("logback.version")), | |
| 127 | + mavenBundle("ch.qos.logback", "logback-core", getVersion("logback.version")), | |
| 128 | + mavenBundle("io.dropwizard.metrics", "metrics-core", getVersion("metrics.version")), | |
| 129 | + mavenBundle("org.testng", "testng", getVersion("testng.version")), | |
| 104 | 130 | systemPackages("org.testng", "org.junit", "org.junit.runner", "org.junit.runner.manipulation", |
| 105 | 131 | "org.junit.runner.notification", "com.jcabi.manifests") |
| 106 | 132 | ); |
| 107 | 133 | } |
| 108 | 134 | }; |
| 109 | 135 | } |
| 136 | + | |
| 137 | + private static String getVersion(String propertyName) { | |
| 138 | + String value = System.getProperty(propertyName); | |
| 139 | + if (value == null) { | |
| 140 | + throw new IllegalArgumentException(propertyName + " system property is not set."); | |
| 141 | + } | |
| 142 | + return value; | |
| 143 | + } | |
| 110 | 144 | } |
deleted driver-tests/osgi/src/test/java/com/datastax/driver/osgi/VersionProvider.java +0 −59
| @@ -1,59 +0,0 @@ | ||
| 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.jcabi.manifests.Manifests; | |
| 19 | - | |
| 20 | -import java.util.regex.Matcher; | |
| 21 | -import java.util.regex.Pattern; | |
| 22 | - | |
| 23 | -/** | |
| 24 | - * Attempts to resolve the project version from the Bundle manifest. If not present, will throw RuntimeException | |
| 25 | - * on initialization. If this happens, try building with 'mvn compile' to generate the Bundle manifest. | |
| 26 | - * <p/> | |
| 27 | - * In IntelliJ you can have compile run after make by right clicking on 'compile' in the 'Maven Projects' tool window. | |
| 28 | - */ | |
| 29 | -public class VersionProvider { | |
| 30 | - | |
| 31 | - private static final Pattern versionPattern = Pattern.compile(("(\\d+.\\d+\\.\\d+)(.*)")); | |
| 32 | - | |
| 33 | - private static final String PROJECT_VERSION; | |
| 34 | - | |
| 35 | - static { | |
| 36 | - String bundleName = Manifests.read("Bundle-SymbolicName"); | |
| 37 | - if (bundleName.equals("com.datastax.driver.osgi")) { | |
| 38 | - String bundleVersion = Manifests.read("Bundle-Version"); | |
| 39 | - Matcher matcher = versionPattern.matcher(bundleVersion); | |
| 40 | - if (matcher.matches()) { | |
| 41 | - String majorVersion = matcher.group(1); | |
| 42 | - // Replace all instances of '.' after the main version with '-' to properly | |
| 43 | - // resolve the correct version. | |
| 44 | - String rest = matcher.group(2).replaceAll("\\.", "-"); | |
| 45 | - PROJECT_VERSION = majorVersion + rest; | |
| 46 | - } else { | |
| 47 | - // This should never happen, but if we are using a non X.Y.Z version number | |
| 48 | - // we'll just back off to the bundle version. | |
| 49 | - PROJECT_VERSION = bundleVersion; | |
| 50 | - } | |
| 51 | - } else { | |
| 52 | - throw new RuntimeException("Couldn't resolve bundle manifest (try building with mvn compile)"); | |
| 53 | - } | |
| 54 | - } | |
| 55 | - | |
| 56 | - public static String projectVersion() { | |
| 57 | - return PROJECT_VERSION; | |
| 58 | - } | |
| 59 | -} |