Elffuss BraidHub

kikocis/java-driver public

Update tests to only use netty openssl on JDK 1.7+ and add note to docs.
Changeset02fbe0add6d2bace22e852dbe096d2daca9d9e9a762e9b2920dedf2189ed52ec
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-16 12:40 -06:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-16 12:40 -06:00
Parentsc0be9f8b8e05

Browse the files at this changeset

4 files changed

modified driver-core/src/test/java/com/datastax/driver/core/SSLAuthenticatedEncryptionTest.java +2 −11
@@ -15,21 +15,12 @@
1515 */
1616 package com.datastax.driver.core;
1717
18-import org.testng.annotations.DataProvider;
1918 import org.testng.annotations.Test;
2019
2120 import com.datastax.driver.core.exceptions.NoHostAvailableException;
2221
23-import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK;
24-import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL;
25-
2622 public class SSLAuthenticatedEncryptionTest extends SSLTestBase {
2723
28- @DataProvider(name="sslImplementation")
29- public static Object[][] sslImplementation() {
30- return new Object[][]{ { JDK }, { NETTY_OPENSSL } };
31- }
32-
3324 public SSLAuthenticatedEncryptionTest() {
3425 super(true);
3526 }
@@ -44,7 +35,7 @@
4435 * @test_category connection:ssl, authentication
4536 * @expected_result Connection can be established to a cassandra node using SSL that requires client auth.
4637 */
47- @Test(groups="short", dataProvider = "sslImplementation")
38+ @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class)
4839 public void should_connect_with_ssl_with_client_auth_and_node_requires_auth(SslImplementation sslImplementation) throws Exception {
4940 connectWithSSLOptions(getSSLOptions(sslImplementation, true, true));
5041 }
@@ -59,7 +50,7 @@
5950 * @test_category connection:ssl, authentication
6051 * @expected_result Connection is not established.
6152 */
62- @Test(groups="short", dataProvider = "sslImplementation", expectedExceptions={NoHostAvailableException.class})
53+ @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class, expectedExceptions={NoHostAvailableException.class})
6354 public void should_not_connect_without_client_auth_but_node_requires_auth(SslImplementation sslImplementation) throws Exception {
6455 connectWithSSLOptions(getSSLOptions(sslImplementation, false, true));
6556 }
modified driver-core/src/test/java/com/datastax/driver/core/SSLEncryptionTest.java +3 −11
@@ -17,22 +17,14 @@
1717
1818 import java.util.concurrent.TimeUnit;
1919
20-import org.testng.annotations.DataProvider;
2120 import org.testng.annotations.Test;
2221
2322 import com.datastax.driver.core.exceptions.NoHostAvailableException;
2423
2524 import static com.datastax.driver.core.Assertions.assertThat;
26-import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK;
27-import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL;
2825
2926 public class SSLEncryptionTest extends SSLTestBase {
3027
31- @DataProvider(name="sslImplementation")
32- public static Object[][] sslImplementation() {
33- return new Object[][]{ { JDK }, { NETTY_OPENSSL } };
34- }
35-
3628 public SSLEncryptionTest() {
3729 super(false);
3830 }
@@ -46,7 +38,7 @@
4638 * @test_category connection:ssl
4739 * @expected_result Connection can be established to a cassandra node using SSL.
4840 */
49- @Test(groups="short", dataProvider = "sslImplementation")
41+ @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class)
5042 public void should_connect_with_ssl_without_client_auth_and_node_doesnt_require_auth(SslImplementation sslImplementation) throws Exception {
5143 connectWithSSLOptions(getSSLOptions(sslImplementation, false, true));
5244 }
@@ -60,7 +52,7 @@
6052 * @test_category connection:ssl
6153 * @expected_result Connection can not be established to a cassandra node using SSL with an untrusted cert.
6254 */
63- @Test(groups="short", dataProvider = "sslImplementation", expectedExceptions={NoHostAvailableException.class})
55+ @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class, expectedExceptions={NoHostAvailableException.class})
6456 public void should_not_connect_with_ssl_without_trusting_server_cert(SslImplementation sslImplementation) throws Exception {
6557 connectWithSSLOptions(getSSLOptions(sslImplementation, false, false));
6658 }
@@ -103,7 +95,7 @@
10395 * @test_category connection:ssl
10496 * @expected_result Connection is re-established within a sufficient amount of time after a node comes back online.
10597 */
106- @Test(groups="long", dataProvider = "sslImplementation")
98+ @Test(groups="long", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class)
10799 public void should_reconnect_with_ssl_on_node_up(SslImplementation sslImplementation) throws Exception {
108100 Cluster cluster = null;
109101 try {
modified driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java +14 −0
@@ -24,10 +24,13 @@
2424 import javax.net.ssl.TrustManagerFactory;
2525 import org.testng.annotations.AfterClass;
2626 import org.testng.annotations.BeforeClass;
27+import org.testng.annotations.DataProvider;
2728
2829 import static io.netty.handler.ssl.SslProvider.OPENSSL;
2930 import static org.assertj.core.api.Assertions.fail;
3031
32+import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK;
33+import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL;
3134
3235 public abstract class SSLTestBase {
3336
@@ -39,6 +42,17 @@
3942 this.requireClientAuth = requireClientAuth;
4043 }
4144
45+ @DataProvider(name="sslImplementation")
46+ public static Object[][] sslImplementation() {
47+ // Bypass Netty SSL if on JDK 1.6 since it only works on 1.7+.
48+ String javaVersion = System.getProperty("java.version");
49+ if(javaVersion.startsWith("1.6")) {
50+ return new Object[][]{ { JDK } };
51+ } else {
52+ return new Object[][]{ { JDK }, { NETTY_OPENSSL } };
53+ }
54+ }
55+
4256 @BeforeClass(groups={"isolated", "short", "long"})
4357 public void beforeClass() {
4458 ccm = CCMBridge.builder("test")
modified features/ssl/README.md +2 −0
@@ -149,6 +149,8 @@
149149 [these instructions](http://netty.io/wiki/forked-tomcat-native.html) to
150150 add it to your dependencies.
151151
152+Note that using netty-tcnative requires JDK 1.7 or above.
153+
152154 ##### Configuring the context
153155
154156 Use the following Java code to configure OpenSSL with your certificates: