You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/03/01 06:44:50 UTC

[flink] 04/04: [FLINK-10585][tests] Extract method getTestResource in RestServerEndpointITCase

This is an automated email from the ASF dual-hosted git repository.

gary pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git

commit f8d0855949c24c8c283d1ace6350175d837d9cd2
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Feb 26 13:18:44 2019 +0100

    [FLINK-10585][tests] Extract method getTestResource in RestServerEndpointITCase
---
 .../flink/runtime/rest/RestServerEndpointITCase.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
index 5e2f853..51d1d2e 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
@@ -147,13 +147,8 @@ public class RestServerEndpointITCase extends TestLogger {
 	public static Collection<Object[]> data() {
 		final Configuration config = getBaseConfig();
 
-		final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
-		final String truststorePath = new File(classLoader
-			.getResource("local127.truststore")
-			.getFile()).getAbsolutePath();
-		final String keystorePath = new File(classLoader
-			.getResource("local127.keystore")
-			.getFile()).getAbsolutePath();
+		final String truststorePath = getTestResource("local127.truststore").getAbsolutePath();
+		final String keystorePath = getTestResource("local127.keystore").getAbsolutePath();
 
 		final Configuration sslConfig = new Configuration(config);
 		sslConfig.setBoolean(SecurityOptions.SSL_REST_ENABLED, true);
@@ -592,6 +587,15 @@ public class RestServerEndpointITCase extends TestLogger {
 		}
 	}
 
+	private static File getTestResource(final String fileName) {
+		final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+		final URL resource = classLoader.getResource(fileName);
+		if (resource == null) {
+			throw new IllegalArgumentException(String.format("Test resource %s does not exist", fileName));
+		}
+		return new File(resource.getFile());
+	}
+
 	private HttpURLConnection openHttpConnectionForUpload(final String boundary) throws IOException {
 		final HttpURLConnection connection =
 			(HttpURLConnection) new URL(serverEndpoint.getRestBaseUrl() + "/upload").openConnection();