changeset 10893:fffb29a53519

8228434: jdk/net/Sockets/Test.java fails after JDK-8227642 Summary: Move container constant to separate test lib class Reviewed-by: alanb, phh
author sgehwolf
date Mon, 22 Jul 2019 10:48:14 +0200
parents 6d9f5328694b
children 6b4a25ec5eaf
files test/testlibrary/com/oracle/java/testlibrary/Container.java test/testlibrary/com/oracle/java/testlibrary/DockerTestUtils.java test/testlibrary/com/oracle/java/testlibrary/Platform.java
diffstat 3 files changed, 37 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testlibrary/com/oracle/java/testlibrary/Container.java	Mon Jul 22 10:48:14 2019 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019, Red Hat Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.java.testlibrary;
+
+public class Container {
+    // Use this property to specify docker location on your system.
+    // E.g.: "/usr/local/bin/docker". We define this constant here so
+    // that it can be used in VMProps as well which checks docker support
+    // via this command
+    public static final String ENGINE_COMMAND =
+        System.getProperty("jdk.test.container.command", "docker");
+}
--- a/test/testlibrary/com/oracle/java/testlibrary/DockerTestUtils.java	Fri Jul 12 19:37:25 2019 +0200
+++ b/test/testlibrary/com/oracle/java/testlibrary/DockerTestUtils.java	Mon Jul 22 10:48:14 2019 +0200
@@ -38,7 +38,7 @@
 import java.util.List;
 
 import com.oracle.java.testlibrary.Utils;
-import com.oracle.java.testlibrary.Platform;
+import com.oracle.java.testlibrary.Container;
 import com.oracle.java.testlibrary.OutputAnalyzer;
 import com.oracle.java.testlibrary.ProcessTools;
 
@@ -106,7 +106,7 @@
      */
     private static boolean isDockerEngineAvailableCheck() throws Exception {
         try {
-            execute(Platform.DOCKER_COMMAND, "ps")
+            execute(Container.ENGINE_COMMAND, "ps")
                 .shouldHaveExitValue(0)
                 .shouldContain("CONTAINER")
                 .shouldContain("IMAGE");
@@ -167,7 +167,7 @@
                            DockerfileConfig.getBaseImageVersion());
 
         // Build the docker
-        execute(Platform.DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
+        execute(Container.ENGINE_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
             .shouldHaveExitValue(0);
     }
 
@@ -183,7 +183,7 @@
     public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
         ArrayList<String> cmd = new ArrayList<>();
 
-        cmd.add(Platform.DOCKER_COMMAND);
+        cmd.add(Container.ENGINE_COMMAND);
         cmd.add("run");
         if (opts.tty)
             cmd.add("--tty=true");
@@ -212,7 +212,7 @@
      * @throws Exception
      */
     public static void removeDockerImage(String imageNameAndTag) throws Exception {
-            execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag);
+            execute(Container.ENGINE_COMMAND, "rmi", "--force", imageNameAndTag);
     }
 
 
--- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Fri Jul 12 19:37:25 2019 +0200
+++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Mon Jul 22 10:48:14 2019 +0200
@@ -28,12 +28,6 @@
 import com.oracle.java.testlibrary.Utils;
 
 public class Platform {
-    // Use this property to specify docker location on your system.
-    // E.g.: "/usr/local/bin/docker". We define this constant here so
-    // that it can be used in VMProps as well which checks docker support
-    // via this command
-    public static final String DOCKER_COMMAND =
-        System.getProperty("jdk.test.docker.command", "docker");
     private static final String osName      = System.getProperty("os.name");
     private static final String dataModel   = System.getProperty("sun.arch.data.model");
     private static final String vmVersion   = System.getProperty("java.vm.version");