26 import java.util.ArrayList; 27 import java.util.List; 28 29 public class LicenseTypeBase { 30 31 private static String TEST_NAME; 32 private static String EXT; 33 private static String JP_LICENSE_TYPE; 34 private static String OUTPUT; 35 private static String[] CMD; 36 37 private static void copyResults() throws Exception { 38 List<String> files = new ArrayList<>(); 39 files.add(OUTPUT.toLowerCase()); 40 JPackageInstallerHelper.copyTestResults(files); 41 } 42 43 private static final String infoResult = "infoResult.txt"; 44 private static void validatePackage() throws Exception { 45 int retVal = JPackageHelper.execute(new File(infoResult),"rpm", 46 "--query", "--package", "--info", OUTPUT.toLowerCase()); 47 if (retVal != 0) { 48 throw new AssertionError("rpm exited with error: " + retVal); 49 } 50 51 File outfile = new File(infoResult); 52 if (!outfile.exists()) { 53 throw new AssertionError(infoResult + " was not created"); 54 } 55 56 String output = Files.readString(outfile.toPath()); 57 if (!output.contains(JP_LICENSE_TYPE)) { 58 throw new AssertionError("Unexpected result: " + output); 59 } 60 } 61 62 private static void testCreateInstaller() throws Exception { 63 JPackageHelper.executeCLI(true, CMD); 64 JPackageInstallerHelper.validateOutput(OUTPUT); 65 validatePackage(); 66 copyResults(); 67 } 68 69 private static void verifyInstall() throws Exception { 70 String app = JPackagePath.getLinuxInstalledApp(TEST_NAME); 71 JPackageInstallerHelper.validateApp(app); 72 } 73 74 private static void verifyUnInstall() throws Exception { 75 String folderPath = JPackagePath.getLinuxInstallFolder(TEST_NAME); 76 File folder = new File(folderPath); 77 if (folder.exists()) { | 26 import java.util.ArrayList; 27 import java.util.List; 28 29 public class LicenseTypeBase { 30 31 private static String TEST_NAME; 32 private static String EXT; 33 private static String JP_LICENSE_TYPE; 34 private static String OUTPUT; 35 private static String[] CMD; 36 37 private static void copyResults() throws Exception { 38 List<String> files = new ArrayList<>(); 39 files.add(OUTPUT.toLowerCase()); 40 JPackageInstallerHelper.copyTestResults(files); 41 } 42 43 private static final String infoResult = "infoResult.txt"; 44 private static void validatePackage() throws Exception { 45 int retVal = JPackageHelper.execute(new File(infoResult),"rpm", 46 "-qp", "--queryformat", "%{license}", OUTPUT.toLowerCase()); 47 if (retVal != 0) { 48 throw new AssertionError("rpm exited with error: " + retVal); 49 } 50 51 File outfile = new File(infoResult); 52 if (!outfile.exists()) { 53 throw new AssertionError(infoResult + " was not created"); 54 } 55 56 String output = Files.readString(outfile.toPath()); 57 if (!output.equals(JP_LICENSE_TYPE)) { 58 throw new AssertionError("Unexpected result: " + output); 59 } 60 } 61 62 private static void testCreateInstaller() throws Exception { 63 JPackageHelper.executeCLI(true, CMD); 64 JPackageInstallerHelper.validateOutput(OUTPUT); 65 validatePackage(); 66 copyResults(); 67 } 68 69 private static void verifyInstall() throws Exception { 70 String app = JPackagePath.getLinuxInstalledApp(TEST_NAME); 71 JPackageInstallerHelper.validateApp(app); 72 } 73 74 private static void verifyUnInstall() throws Exception { 75 String folderPath = JPackagePath.getLinuxInstallFolder(TEST_NAME); 76 File folder = new File(folderPath); 77 if (folder.exists()) { |