< prev index next >

test/jdk/tools/jpackage/helpers/JPackageInstallerHelper.java

Print this page




 127 
 128         if (!result[0].trim().equals("jpackage test application")) {
 129             throw new AssertionError("Unexpected result[0]: " + result[0]);
 130         }
 131 
 132         if (!result[1].trim().equals("args.length: 0")) {
 133             throw new AssertionError("Unexpected result[1]: " + result[1]);
 134         }
 135     }
 136 
 137     public static void validateOutput(String output) throws Exception {
 138         File file = new File(output);
 139         if (!file.exists()) {
 140             // Try lower case in case of OS is case sensitive
 141             file = new File(output.toLowerCase());
 142             if (!file.exists()) {
 143                 throw new AssertionError("Cannot find " + file.getAbsolutePath());
 144             }
 145         }
 146     }
 147 
 148     public static void validateStartMenu(String menuGroup, String menu, boolean exist)
 149             throws Exception {
 150         String startMenuLink = JPackagePath.getWinStartMenu() +
 151                 File.separator + menuGroup + File.separator +
 152                 menu + ".lnk";
 153 
 154         File link = new File(startMenuLink);
 155         if (exist) {
 156             if (!link.exists()) {
 157                 throw new AssertionError("Cannot find " + link.getAbsolutePath());
 158             }
 159         } else {
 160             if (link.exists()) {
 161                 throw new AssertionError("Error: " + link.getAbsolutePath() + " exist");
 162             }
 163         }
 164     }
 165 
 166     public static void validateDesktopShortcut(String name, boolean exist)
 167             throws Exception {
 168         String shortcutLink = JPackagePath.getWinPublicDesktop() +
 169                 File.separator + name + ".lnk";
 170 
 171         File link = new File(shortcutLink);
 172         if (exist) {
 173             if (!link.exists()) {
 174                 throw new AssertionError("Cannot find " + link.getAbsolutePath());
 175             }
 176         } else {
 177             if (link.exists()) {
 178                 throw new AssertionError("Error: " + link.getAbsolutePath() + " exist");
 179             }
 180         }
 181     }
 182 
 183     public static void validateUserLocalStartMenu(String menuGroup, String menu, boolean exist)
 184             throws Exception {
 185         String startMenuLink = JPackagePath.getWinUserLocalStartMenu() +
 186                 File.separator + menuGroup + File.separator +
 187                 menu + ".lnk";
 188 
 189         File link = new File(startMenuLink);
 190         if (exist) {
 191             if (!link.exists()) {
 192                 throw new AssertionError("Cannot find " + link.getAbsolutePath());
 193             }
 194         } else {
 195             if (link.exists()) {
 196                 throw new AssertionError("Error: " + link.getAbsolutePath() + " exist");
 197             }
 198         }
 199     }
 200 
 201     public static void validateWinRegistry(String key, String [] values, boolean retValZero)
 202             throws Exception {
 203         File outFile = new File("regOutput.txt");
 204         if (outFile.exists()) {
 205             outFile.delete();
 206         }
 207 
 208         int retVal = JPackageHelper.execute(outFile, "reg.exe", "query", key);
 209         if (retValZero) {
 210             if (retVal != 0) {
 211                 System.out.println("validateWinRegistry() key=" + key);
 212                 if (outFile.exists()) {
 213                     System.err.println(Files.readString(outFile.toPath()));
 214                 }
 215                 throw new AssertionError(
 216                        "Reg.exe application exited with error: " + retVal);
 217             }
 218         } else {
 219             if (retVal == 0) {
 220                 System.out.println("validateWinRegistry() key=" + key);
 221                 if (outFile.exists()) {
 222                     System.err.println(Files.readString(outFile.toPath()));
 223                 }
 224                 throw new AssertionError(
 225                        "Reg.exe application exited without error: " + retVal);
 226             } else {
 227                 return; // Done
 228             }
 229         }
 230 
 231         if (!outFile.exists()) {
 232             throw new AssertionError(outFile.getAbsolutePath() + " was not created");
 233         }
 234 
 235         String output = Files.readString(outFile.toPath());
 236         for (String value : values) {
 237             if (!output.contains(value)) {
 238                 System.err.println(output);
 239                 throw new AssertionError("Cannot find in registry: " + value);
 240             }
 241         }
 242     }
 243 }


 127 
 128         if (!result[0].trim().equals("jpackage test application")) {
 129             throw new AssertionError("Unexpected result[0]: " + result[0]);
 130         }
 131 
 132         if (!result[1].trim().equals("args.length: 0")) {
 133             throw new AssertionError("Unexpected result[1]: " + result[1]);
 134         }
 135     }
 136 
 137     public static void validateOutput(String output) throws Exception {
 138         File file = new File(output);
 139         if (!file.exists()) {
 140             // Try lower case in case of OS is case sensitive
 141             file = new File(output.toLowerCase());
 142             if (!file.exists()) {
 143                 throw new AssertionError("Cannot find " + file.getAbsolutePath());
 144             }
 145         }
 146     }
































































































 147 }
< prev index next >