Skip to content

Commit 7a681d5

Browse files
authored
PHOENIX-7266 Fix SSLConfigDir in ITs (#150)
1 parent bff4778 commit 7a681d5

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/QueryServerEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private void setHdfsSecuredConfiguration(Configuration conf) throws Exception {
178178
// Generate SSL certs
179179
File keystoresDir = new File(UTIL.getDataTestDir("keystore").toUri().getPath());
180180
keystoresDir.mkdirs();
181-
String sslConfDir = TlsUtil.getClasspathDir(QueryServerEnvironment.class);
181+
String sslConfDir = TlsUtil.TEST_CLASSES_DIR.getPath();
182182
TlsUtil.setupSSLConfig(keystoresDir.getAbsolutePath(), sslConfDir, conf, false);
183183

184184
// Magic flag to tell hdfs to not fail on using ports above 1024

phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static void setHdfsSecuredConfiguration(Configuration conf) throws Excep
158158
// Generate SSL certs
159159
File keystoresDir = new File(UTIL.getDataTestDir("keystore").toUri().getPath());
160160
keystoresDir.mkdirs();
161-
String sslConfDir = TlsUtil.getClasspathDir(SecureQueryServerPhoenixDBIT.class);
161+
String sslConfDir = TlsUtil.TEST_CLASSES_DIR.getPath();
162162
TlsUtil.setupSSLConfig(keystoresDir.getAbsolutePath(), sslConfDir, conf, false);
163163

164164
// Magic flag to tell hdfs to not fail on using ports above 1024

phoenix-queryserver-it/src/it/java/org/apache/phoenix/end2end/TlsUtil.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public class TlsUtil {
5151
protected static final String TARGET_DIR_NAME = System.getProperty("target.dir", "target");
5252
protected static final File TARGET_DIR =
5353
new File(System.getProperty("user.dir"), TARGET_DIR_NAME);
54+
protected static final String TEST_CLASSES_DIR_NAME =
55+
System.getProperty("test-classes.dir", "test-classes");
56+
public static final File TEST_CLASSES_DIR =
57+
new File(TARGET_DIR, TEST_CLASSES_DIR_NAME);
5458
protected static final File KEYSTORE = new File(TARGET_DIR, "avatica-test-ks.jks");
5559
protected static final File TRUSTSTORE = new File(TARGET_DIR, "avatica-test-ts.jks");
5660

@@ -142,15 +146,6 @@ private static X509Certificate generateCertificate(String dn, KeyPair pair, int
142146
return cert;
143147
}
144148

145-
public static String getClasspathDir(Class<?> klass) throws Exception {
146-
String file = klass.getName();
147-
file = file.replace('.', '/') + ".class";
148-
URL url = Thread.currentThread().getContextClassLoader().getResource(file);
149-
String baseDir = url.toURI().getPath();
150-
baseDir = baseDir.substring(0, baseDir.length() - file.length() - 1);
151-
return baseDir;
152-
}
153-
154149
/**
155150
* Performs complete setup of SSL configuration in preparation for testing an
156151
* SSLFactory. This includes keys, certs, keystores, truststores, the server

0 commit comments

Comments
 (0)