Elffuss BraidHub

kikocis/java-driver public

a4b9527bac4a · 6.3 KiBRawPermalink
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 */
16package com.datastax.driver.osgi;
17
18import com.datastax.driver.core.CCMBridge;
19import com.datastax.driver.core.ProtocolOptions;
20import com.datastax.driver.core.TestUtils;
21import com.google.common.collect.Lists;
22import org.ops4j.pax.exam.Option;
23import org.ops4j.pax.exam.options.CompositeOption;
24import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
25import org.ops4j.pax.exam.options.UrlProvisionOption;
26import org.ops4j.pax.exam.util.PathUtils;
27
28import java.util.List;
29
30import static com.datastax.driver.osgi.VersionProvider.projectVersion;
31import static org.ops4j.pax.exam.CoreOptions.*;
32
33public class BundleOptions {
34
35 public static UrlProvisionOption driverBundle() {
36 return driverBundle(false);
37 }
38
39 public static UrlProvisionOption driverBundle(boolean useShaded) {
40 String classifier = useShaded ? "-shaded" : "";
41 return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-core/target/cassandra-driver-core-" + projectVersion() + classifier + ".jar");
42 }
43
44 public static UrlProvisionOption mappingBundle() {
45 return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-mapping/target/cassandra-driver-mapping-" + projectVersion() + ".jar");
46 }
47
48 public static UrlProvisionOption extrasBundle() {
49 return bundle("reference:file:" + PathUtils.getBaseDir() + "/../../driver-extras/target/cassandra-driver-extras-" + projectVersion() + ".jar");
50 }
51
52 public static MavenArtifactProvisionOption guavaBundle() {
53 return mavenBundle("com.google.guava", "guava", "16.0.1");
54 }
55
56 public static CompositeOption lz4Bundle() {
57 return new CompositeOption() {
58
59 @Override
60 public Option[] getOptions() {
61 return options(
62 systemProperty("cassandra.compression").value(ProtocolOptions.Compression.LZ4.name()),
63 mavenBundle("net.jpountz.lz4", "lz4", "1.3.0")
64 );
65 }
66 };
67 }
68
69 public static CompositeOption snappyBundle() {
70 return new CompositeOption() {
71
72 @Override
73 public Option[] getOptions() {
74 return options(
75 systemProperty("cassandra.compression").value(ProtocolOptions.Compression.SNAPPY.name()),
76 mavenBundle("org.xerial.snappy", "snappy-java", "1.1.2.6")
77 );
78 }
79 };
80 }
81
82 public static CompositeOption hdrHistogramBundle() {
83 return new CompositeOption() {
84
85 @Override
86 public Option[] getOptions() {
87 return options(
88 systemProperty("cassandra.usePercentileSpeculativeExecutionPolicy").value("true"),
89 mavenBundle("org.hdrhistogram", "HdrHistogram", "2.1.9")
90 );
91 }
92 };
93 }
94
95 public static CompositeOption nettyBundles() {
96 final String nettyVersion = "4.0.33.Final";
97 return new CompositeOption() {
98
99 @Override
100 public Option[] getOptions() {
101 return options(
102 mavenBundle("io.netty", "netty-buffer", nettyVersion),
103 mavenBundle("io.netty", "netty-codec", nettyVersion),
104 mavenBundle("io.netty", "netty-common", nettyVersion),
105 mavenBundle("io.netty", "netty-handler", nettyVersion),
106 mavenBundle("io.netty", "netty-transport", nettyVersion)
107 );
108 }
109 };
110 }
111
112 public static UrlProvisionOption mailboxBundle() {
113 return bundle("reference:file:" + PathUtils.getBaseDir() + "/target/classes");
114 }
115
116 public static CompositeOption defaultOptions() {
117 return new CompositeOption() {
118
119 @Override
120 public Option[] getOptions() {
121 List<Option> options = Lists.newArrayList(
122 // Delegate javax.security.cert to the parent classloader. javax.security.cert.X509Certificate is used in
123 // io.netty.util.internal.EmptyArrays, but not directly by the driver.
124 bootDelegationPackage("javax.security.cert"),
125 systemProperty("cassandra.version").value(CCMBridge.getCassandraVersion()),
126 systemProperty("cassandra.contactpoints").value(TestUtils.IP_PREFIX + 1),
127 systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"),
128 mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
129 mavenBundle("ch.qos.logback", "logback-classic", "1.1.3"),
130 mavenBundle("ch.qos.logback", "logback-core", "1.1.3"),
131 mavenBundle("io.dropwizard.metrics", "metrics-core", "3.1.2"),
132 mavenBundle("org.testng", "testng", "6.8.8"),
133 systemPackages("org.testng", "org.junit", "org.junit.runner", "org.junit.runner.manipulation",
134 "org.junit.runner.notification", "com.jcabi.manifests")
135 );
136 if (CCMBridge.isWindows()) {
137 // Workaround for Felix + Windows Server 2012. Felix does not properly alias 'windowsserver2012'
138 // to 'win32', because of this some native libraries may fail to load. To work around this, force
139 // the os.name property to win32 if on a windows platform.
140 // See: https://issues.apache.org/jira/browse/FELIX-5184
141 options.add(systemProperty("os.name").value("win32"));
142 }
143
144 return options.toArray(new Option[options.size()]);
145 }
146 };
147 }
148}