Elffuss BraidHub

kikocis/java-driver public

44e46587819e · 3.2 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.Cluster;
19import org.ops4j.pax.exam.Configuration;
20import org.ops4j.pax.exam.Option;
21import org.ops4j.pax.exam.testng.listener.PaxExam;
22import org.testng.annotations.Listeners;
23import org.testng.annotations.Test;
24
25import static com.datastax.driver.osgi.BundleOptions.*;
26import static org.ops4j.pax.exam.CoreOptions.options;
27import static org.testng.Assert.assertTrue;
28import static org.testng.Assert.fail;
29
30/**
31 * This test is no longer valid since the driver bundle has the following new requirement
32 * for Guava: {@code [16.0.1,19)}.
33 */
34@Listeners({PaxExam.class})
35@Test(groups = "short", enabled = false)
36public class GuavaSanityCheckNegativeIT {
37
38 @Configuration
39 public Option[] guava14_0_1Config() {
40 return options(
41 driverBundle(),
42 nettyBundles(),
43 guavaBundle().version("14.0.1"),
44 defaultOptions()
45 );
46 }
47
48 @Configuration
49 public Option[] guava15Config() {
50 return options(
51 driverBundle(),
52 nettyBundles(),
53 guavaBundle().version("15.0"),
54 defaultOptions()
55 );
56 }
57
58 @Configuration
59 public Option[] guava16Config() {
60 return options(
61 driverBundle(),
62 nettyBundles(),
63 guavaBundle().version("16.0"),
64 defaultOptions()
65 );
66 }
67
68 /**
69 * <p>
70 * Validates that the driver is able to detect that the guava library in the classpath is
71 * less than version 16.01 and throws an {@link IllegalStateException} in this case and
72 * is raised as the cause of an {@link ExceptionInInitializerError} since the failure
73 * occurs at static initialization.
74 * </p>
75 * <p/>
76 * The following configurations are tried (defined via methods with the @Configuration annotation):
77 * <ol>
78 * <li>With Guava 14.0.1</li>
79 * <li>With Guava 15.0</li>
80 * <li>With Guava 16.0</li>
81 * </ol>
82 *
83 * @test_category packaging
84 * @expected_result An {@link IllegalStateException} is thrown.
85 * @jira_ticket JAVA-961
86 * @since 3.0.0-beta1
87 */
88 public void should_raise_guava_version_error_if_lt_16_0_1() throws Throwable {
89 try {
90 Cluster.builder();
91 fail("Expected an IllegalStateException for Guava version incompatibility");
92 } catch (ExceptionInInitializerError e) {
93 try {
94 throw e.getCause();
95 } catch (IllegalStateException ise) {
96 assertTrue(ise.getMessage().contains("Detected Guava issue #1635"));
97 }
98 }
99 }
100}