Blame SOURCES/CheckVendor.java

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