Blame SOURCES/CheckVendor.java

a8eab4
/* CheckVendor -- Check the vendor properties match specified values.
a8eab4
   Copyright (C) 2020 Red Hat, Inc.
a8eab4
a8eab4
This program is free software: you can redistribute it and/or modify
a8eab4
it under the terms of the GNU Affero General Public License as
a8eab4
published by the Free Software Foundation, either version 3 of the
a8eab4
License, or (at your option) any later version.
a8eab4
a8eab4
This program is distributed in the hope that it will be useful,
a8eab4
but WITHOUT ANY WARRANTY; without even the implied warranty of
a8eab4
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a8eab4
GNU Affero General Public License for more details.
a8eab4
a8eab4
You should have received a copy of the GNU Affero General Public License
a8eab4
along with this program.  If not, see <http://www.gnu.org/licenses/>.
a8eab4
*/
a8eab4
a8eab4
/**
a8eab4
 * @test
a8eab4
 */
a8eab4
public class CheckVendor {
a8eab4
a8eab4
    public static void main(String[] args) {
a8eab4
        if (args.length < 4) {
a8eab4
            System.err.println("CheckVendor <VENDOR> <VENDOR-URL> <VENDOR-BUG-URL> <VENDOR-VERSION-STRING>");
a8eab4
	    System.exit(1);
a8eab4
	}
a8eab4
a8eab4
	String vendor = System.getProperty("java.vendor");
a8eab4
	String expectedVendor = args[0];
a8eab4
	String vendorURL = System.getProperty("java.vendor.url");
a8eab4
	String expectedVendorURL = args[1];
a8eab4
	String vendorBugURL = System.getProperty("java.vendor.url.bug");
a8eab4
	String expectedVendorBugURL = args[2];
a8eab4
        String vendorVersionString = System.getProperty("java.vendor.version");
a8eab4
        String expectedVendorVersionString = args[3];
a8eab4
a8eab4
	if (!expectedVendor.equals(vendor)) {
a8eab4
	    System.err.printf("Invalid vendor %s, expected %s\n",
a8eab4
			      vendor, expectedVendor);
a8eab4
	    System.exit(2);
a8eab4
	}
a8eab4
a8eab4
	if (!expectedVendorURL.equals(vendorURL)) {
a8eab4
	    System.err.printf("Invalid vendor URL %s, expected %s\n",
a8eab4
			      vendorURL, expectedVendorURL);
a8eab4
	    System.exit(3);
a8eab4
	}
a8eab4
a8eab4
	if (!expectedVendorBugURL.equals(vendorBugURL)) {
a8eab4
            System.err.printf("Invalid vendor bug URL %s, expected %s\n",
a8eab4
			      vendorBugURL, expectedVendorBugURL);
a8eab4
	    System.exit(4);
a8eab4
	}
a8eab4
a8eab4
        if (!expectedVendorVersionString.equals(vendorVersionString)) {
a8eab4
            System.err.printf("Invalid vendor version string %s, expected %s\n",
a8eab4
                              vendorVersionString, expectedVendorVersionString);
a8eab4
	    System.exit(5);
a8eab4
        }
a8eab4
a8eab4
        System.err.printf("Vendor information verified as %s, %s, %s, %s\n",
a8eab4
                          vendor, vendorURL, vendorBugURL, vendorVersionString);
a8eab4
    }
a8eab4
}