< prev index next >

test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageVersionTest.java

Print this page




  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 
  28 /*
  29  * @test
  30  * @summary jpackage create image --app-version test
  31  * @library ../helpers
  32  * @build JPackageHelper
  33  * @build JPackagePath
  34  * @modules jdk.jpackage
  35  * @run main/othervm -Xmx512m JPackageCreateImageVersionTest
  36  */
  37 public class JPackageCreateImageVersionTest {
  38     private static final String OUTPUT = "output";
  39     private static final String appCfg = JPackagePath.getAppCfg();
  40     private static final String VERSION = "2.3";
  41     private static final String VERSION_DEFAULT = "1.0";
  42 
  43     private static final String[] CMD = {
  44         "create-image",
  45         "--input", "input",
  46         "--output", OUTPUT,
  47         "--name", "test",
  48         "--main-jar", "hello.jar",
  49         "--main-class", "Hello",
  50         "--files", "hello.jar"};
  51 
  52     private static final String[] CMD_VERSION = {
  53         "create-image",
  54         "--input", "input",
  55         "--output", OUTPUT,
  56         "--name", "test",
  57         "--main-jar", "hello.jar",
  58         "--main-class", "Hello",
  59         "--files", "hello.jar",
  60         "--app-version", VERSION};
  61 
  62     private static void validate(String version)
  63             throws Exception {
  64         File outfile = new File(appCfg);
  65         if (!outfile.exists()) {
  66             throw new AssertionError(appCfg + " was not created");
  67         }
  68 
  69         String output = Files.readString(outfile.toPath());
  70         if (version == null) {
  71             version = VERSION_DEFAULT;
  72         }
  73 
  74         String expected = "app.version=" + version;
  75         if (!output.contains(expected)) {
  76             System.err.println("Expected: " + expected);
  77             throw new AssertionError("Cannot find expected entry in config file");
  78         }
  79     }




  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 
  28 /*
  29  * @test
  30  * @summary jpackage create image --app-version test
  31  * @library ../helpers
  32  * @build JPackageHelper
  33  * @build JPackagePath
  34  * @modules jdk.jpackage
  35  * @run main/othervm -Xmx512m JPackageCreateAppImageVersionTest
  36  */
  37 public class JPackageCreateAppImageVersionTest {
  38     private static final String OUTPUT = "output";
  39     private static final String appCfg = JPackagePath.getAppCfg();
  40     private static final String VERSION = "2.3";
  41     private static final String VERSION_DEFAULT = "1.0";
  42 
  43     private static final String[] CMD = {
  44         "create-app-image",
  45         "--input", "input",
  46         "--output", OUTPUT,
  47         "--name", "test",
  48         "--main-jar", "hello.jar",
  49         "--main-class", "Hello",
  50    };
  51 
  52     private static final String[] CMD_VERSION = {
  53         "create-app-image",
  54         "--input", "input",
  55         "--output", OUTPUT,
  56         "--name", "test",
  57         "--main-jar", "hello.jar",
  58         "--main-class", "Hello",

  59         "--app-version", VERSION};
  60 
  61     private static void validate(String version)
  62             throws Exception {
  63         File outfile = new File(appCfg);
  64         if (!outfile.exists()) {
  65             throw new AssertionError(appCfg + " was not created");
  66         }
  67 
  68         String output = Files.readString(outfile.toPath());
  69         if (version == null) {
  70             version = VERSION_DEFAULT;
  71         }
  72 
  73         String expected = "app.version=" + version;
  74         if (!output.contains(expected)) {
  75             System.err.println("Expected: " + expected);
  76             throw new AssertionError("Cannot find expected entry in config file");
  77         }
  78     }


< prev index next >