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