test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java
branchJDK-8200758-branch
changeset 58648 3bf53ffa9ae7
parent 58434 b00cbf427368
child 58696 61c44899b4eb
equal deleted inserted replaced
58647:2c43b89b1679 58648:3bf53ffa9ae7
   160     }
   160     }
   161 
   161 
   162     public PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa,
   162     public PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa,
   163             String... faLauncherDefaultArgs) {
   163             String... faLauncherDefaultArgs) {
   164 
   164 
   165         addInitializer(cmd -> HelloApp.addTo(cmd, null), "HelloApp");
   165         addInitializer(cmd -> new HelloApp(null).addTo(cmd), "HelloApp");
   166         addInstallVerifier(cmd -> {
   166         addInstallVerifier(cmd -> {
   167             if (cmd.isFakeRuntimeInstalled(
   167             if (cmd.isFakeRuntime("Not running file associations test")) {
   168                     "Not running file associations test")) {
       
   169                 return;
   168                 return;
   170             }
   169             }
   171 
   170 
   172             withTestFileAssociationsFile(fa, testFile -> {
   171             withTestFileAssociationsFile(fa, testFile -> {
   173                 testFile = testFile.toAbsolutePath().normalize();
   172                 testFile = testFile.toAbsolutePath().normalize();
   217     public PackageTest configureHelloApp() {
   216     public PackageTest configureHelloApp() {
   218         return configureHelloApp(null);
   217         return configureHelloApp(null);
   219     }
   218     }
   220 
   219 
   221     public PackageTest configureHelloApp(String encodedName) {
   220     public PackageTest configureHelloApp(String encodedName) {
   222         addInitializer(cmd -> HelloApp.addTo(cmd, encodedName));
   221         addInitializer(
       
   222                 cmd -> new HelloApp(JavaAppDesc.parse(encodedName)).addTo(cmd));
   223         addInstallVerifier(HelloApp::executeLauncherAndVerifyOutput);
   223         addInstallVerifier(HelloApp::executeLauncherAndVerifyOutput);
   224         return this;
   224         return this;
   225     }
   225     }
   226 
   226 
   227     public void run() {
   227     public void run() {
   295         @Override
   295         @Override
   296         public void accept(JPackageCommand cmd) {
   296         public void accept(JPackageCommand cmd) {
   297             type.applyTo(cmd);
   297             type.applyTo(cmd);
   298 
   298 
   299             initializers.stream().forEach(v -> v.accept(cmd));
   299             initializers.stream().forEach(v -> v.accept(cmd));
       
   300             cmd.executePrerequisiteActions();
       
   301 
   300             switch (action) {
   302             switch (action) {
   301                 case CREATE:
   303                 case CREATE:
   302                     Executor.Result result = cmd.execute();
   304                     Executor.Result result = cmd.execute();
   303                     result.assertExitCodeIs(expectedJPackageExitCode);
   305                     result.assertExitCodeIs(expectedJPackageExitCode);
   304                     if (expectedJPackageExitCode == 0) {
   306                     if (expectedJPackageExitCode == 0) {
   334         }
   336         }
   335 
   337 
   336         private void verifyPackageInstalled(JPackageCommand cmd) {
   338         private void verifyPackageInstalled(JPackageCommand cmd) {
   337             TKit.trace(String.format("Verify installed: %s",
   339             TKit.trace(String.format("Verify installed: %s",
   338                     cmd.getPrintableCommandLine()));
   340                     cmd.getPrintableCommandLine()));
   339             if (cmd.isRuntime()) {
   341             TKit.assertDirectoryExists(cmd.appRuntimeDirectory());
   340                 TKit.assertPathExists(
   342             if (!cmd.isRuntime()) {
   341                         cmd.appRuntimeInstallationDirectory(), false);
   343                 TKit.assertExecutableFileExists(cmd.appLauncherPath());
   342             } else {
   344 
   343                 TKit.assertExecutableFileExists(cmd.launcherInstallationPath());
   345                 if (PackageType.WINDOWS.contains(cmd.packageType())) {
   344             }
   346                     new WindowsHelper.AppVerifier(cmd);
   345 
   347                 }
   346             if (PackageType.WINDOWS.contains(cmd.packageType())) {
       
   347                 new WindowsHelper.AppVerifier(cmd);
       
   348             }
   348             }
   349 
   349 
   350             installVerifiers.stream().forEach(v -> v.accept(cmd));
   350             installVerifiers.stream().forEach(v -> v.accept(cmd));
   351         }
   351         }
   352 
   352 
   353         private void verifyPackageUninstalled(JPackageCommand cmd) {
   353         private void verifyPackageUninstalled(JPackageCommand cmd) {
   354             TKit.trace(String.format("Verify uninstalled: %s",
   354             TKit.trace(String.format("Verify uninstalled: %s",
   355                     cmd.getPrintableCommandLine()));
   355                     cmd.getPrintableCommandLine()));
   356             if (!cmd.isRuntime()) {
   356             if (!cmd.isRuntime()) {
   357                 TKit.assertPathExists(cmd.launcherInstallationPath(), false);
   357                 TKit.assertPathExists(cmd.appLauncherPath(), false);
   358                 TKit.assertPathExists(cmd.appInstallationDirectory(), false);
   358 
   359             }
   359                 if (PackageType.WINDOWS.contains(cmd.packageType())) {
   360 
   360                     new WindowsHelper.AppVerifier(cmd);
   361             if (PackageType.WINDOWS.contains(cmd.packageType())) {
   361                 }
   362                 new WindowsHelper.AppVerifier(cmd);
   362             }
   363             }
   363 
       
   364             TKit.assertPathExists(cmd.appInstallationDirectory(), false);
   364 
   365 
   365             uninstallVerifiers.stream().forEach(v -> v.accept(cmd));
   366             uninstallVerifiers.stream().forEach(v -> v.accept(cmd));
   366         }
   367         }
   367 
   368 
   368         private final PackageType type;
   369         private final PackageType type;