< prev index next >

test/jdk/tools/jpackage/linux/base/LicenseBase.java

Print this page

        

@@ -48,12 +48,19 @@
 
     private static void verifyInstall() throws Exception {
         String app = JPackagePath.getLinuxInstalledApp(TEST_NAME);
         JPackageInstallerHelper.validateApp(app);
 
+        File licenseFile = null;
         if (EXT.equals("rpm")) {
-            verifyInstallRpm();
+            licenseFile = getRpmLicenseFileInstallLocation();
+        } else if (EXT.equals("deb")) {
+            licenseFile = getDebLicenseFileInstallLocation();
+        }
+        if (!licenseFile.exists()) {
+            throw new AssertionError(
+                    "Error: " + licenseFile.getAbsolutePath() + " not found");
         }
     }
 
     private static File getRpmLicenseFileInstallLocation() throws Exception {
         final String infoResult = "infoResult.txt";

@@ -65,28 +72,25 @@
 
         final String rootLicenseDir = Files.readString(Path.of(infoResult)).replaceAll(
                 "(\\r|\\n)", "");
 
         retVal = JPackageHelper.execute(new File(infoResult), "rpm",
-                "-qp", "--queryformat", "%{name}-%{version}",
-                OUTPUT.toLowerCase());
+                "-q", "--queryformat", "%{name}-%{version}",
+                TEST_NAME.toLowerCase());
         if (retVal != 0) {
             throw new AssertionError("rpm exited with error: " + retVal);
         }
 
         final String testPackageName = Files.readString(Path.of(infoResult));
 
         return Path.of(rootLicenseDir, testPackageName, new File(
                 JPackagePath.getLicenseFilePath()).getName()).toFile();
     }
 
-    private static void verifyInstallRpm() throws Exception {
-        final File licenseFile = getRpmLicenseFileInstallLocation();
-        if (!licenseFile.exists()) {
-            throw new AssertionError(
-                    "Error: " + licenseFile.getAbsolutePath() + " not found");
-        }
+    private static File getDebLicenseFileInstallLocation() throws Exception {
+        return Path.of("/usr", "share", "doc", TEST_NAME.toLowerCase(),
+                "copyright").toFile();
     }
 
     private static void verifyUnInstall() throws Exception {
         String folderPath = JPackagePath.getLinuxInstallFolder(TEST_NAME);
         File folder = new File(folderPath);

@@ -99,10 +103,16 @@
             final File licenseFileFolder = getRpmLicenseFileInstallLocation().getParentFile();
             if (folder.exists()) {
                 throw new AssertionError(
                         "Error: " + licenseFileFolder.getAbsolutePath() + " exist");
             }
+        } else if (EXT.equals("deb")) {
+            final File licenseFileFolder = getDebLicenseFileInstallLocation().getParentFile();
+            if (folder.exists()) {
+                throw new AssertionError(
+                        "Error: " + licenseFileFolder.getAbsolutePath() + " exist");
+            }
         }
     }
 
     private static void init(String name, String ext) throws Exception {
         TEST_NAME = name;
< prev index next >