Blame SOURCES/CheckVendor.java

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