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