Skip to content

Commit dd207c2

Browse files
committed
Update tests to only use netty openssl on JDK 1.7+ and add note to docs.
1 parent c092320 commit dd207c2

4 files changed

Lines changed: 21 additions & 22 deletions

File tree

driver-core/src/test/java/com/datastax/driver/core/SSLAuthenticatedEncryptionTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ public SSLAuthenticatedEncryptionTest() {
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 @@ public void should_connect_with_ssl_with_client_auth_and_node_requires_auth(SslI
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
}

driver-core/src/test/java/com/datastax/driver/core/SSLEncryptionTest.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ public SSLEncryptionTest() {
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 @@ public void should_connect_with_ssl_without_client_auth_and_node_doesnt_require_
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 @@ public void should_not_connect_without_ssl_but_node_uses_ssl() throws Exception
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 {

driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ public SSLTestBase(boolean requireClientAuth) {
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")

features/ssl/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ Netty-tcnative provides the native integration with OpenSSL. Follow
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:

0 commit comments

Comments
 (0)