Blame SOURCES/CheckVendor.java

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