Skip to content

Commit f11d2dd

Browse files
committed
Fix isSSLAvailable() so it's good enough for "ant test-ssl"
That said, it's probably too limited for "mvn test". This method will need to be adapted to how Maven handles external properties.
1 parent 1a80caa commit f11d2dd

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/test/java/com/rabbitmq/client/test/AbstractRMQTestSuite.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
import org.junit.Assume;
1313

1414
public abstract class AbstractRMQTestSuite extends TestSuite {
15-
private static final int DEFAULT_SSL_PORT = 443;
16-
15+
private static final String DEFAULT_SSL_HOSTNAME = "localhost";
16+
private static final int DEFAULT_SSL_PORT = 5671;
17+
1718
private static boolean buildPropertiesFound = false;
1819

1920
private static final Properties TESTS_PROPS = new Properties(System.getProperties());
@@ -37,14 +38,19 @@ public static boolean isUnderUmbrella() {
3738
return new File("../../UMBRELLA.md").isFile();
3839
}
3940

40-
public static boolean isSSlAvailable() {
41+
public static boolean isSSLAvailable() {
42+
/*
43+
* FIXME: This method tries to reproduce what was done in Ant's
44+
* build.xml. It's probably not enough to have a working SSL
45+
* testsuite with Maven.
46+
*/
4147
System.setProperty("SSL_CERTS_DIR", System.getenv("SSL_CERTS_DIR"));
42-
String sslClientPath = System.getProperty("SSL_CERTS_DIR") + FileSystems.getDefault().getSeparator() + "client";
43-
System.setProperty("CLIENT_KEYSTORE_PHRASE", System.getenv("bunnies"));
44-
System.setProperty("SSL_P12_PASSWORD", System.getenv("PASSWORD"));
45-
// IF certificate is present and some server is listening on port 443
46-
if (new File(sslClientPath).isFile() && checkServerListening(System.getProperty("broker.hostname"), DEFAULT_SSL_PORT)) {
47-
System.setProperty("SSL_AVAILABLE", sslClientPath);
48+
String sslClientCertsDir = System.getProperty("SSL_CERTS_DIR") +
49+
FileSystems.getDefault().getSeparator() + "client";
50+
// If certificate is present and some server is listening on port 5671
51+
if (new File(sslClientCertsDir).exists() &&
52+
checkServerListening(DEFAULT_SSL_HOSTNAME, DEFAULT_SSL_PORT)) {
53+
System.setProperty("SSL_AVAILABLE", sslClientCertsDir);
4854
return true;
4955
} else
5056
return false;

src/test/java/com/rabbitmq/client/test/ssl/SSLTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class SSLTests extends AbstractRMQTestSuite {
2525
public static TestSuite suite() {
2626
TestSuite suite = new TestSuite("ssl");
2727
//Skip the tests if not under umbrella and not SSL available
28-
if(!(isUnderUmbrella() && isSSlAvailable())) return suite;
28+
if(!(isUnderUmbrella() && isSSLAvailable())) return suite;
2929
suite.addTestSuite(UnverifiedConnection.class);
3030
suite.addTestSuite(VerifiedConnection.class);
3131
suite.addTestSuite(BadVerifiedConnection.class);

0 commit comments

Comments
 (0)