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