1 /*
2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
715 (String[])null);
716 tr = doExec(javaCmd, "-Xdiag", "-jar", "some.jar");
717 tr.contains("Error: Could not find or load main class MIA");
718 tr.contains("java.lang.ClassNotFoundException: MIA");
719 if (!tr.testStatus)
720 System.out.println(tr);
721
722 // use classpath to check
723 tr = doExec(javaCmd, "-Xdiag", "-cp", "some.jar", "MIA");
724 tr.contains("Error: Could not find or load main class MIA");
725 tr.contains("java.lang.ClassNotFoundException: MIA");
726 if (!tr.testStatus)
727 System.out.println(tr);
728
729 // a missing class on the classpath
730 tr = doExec(javaCmd, "-Xdiag", "NonExistentClass");
731 tr.contains("Error: Could not find or load main class NonExistentClass");
732 tr.contains("java.lang.ClassNotFoundException: NonExistentClass");
733 if (!tr.testStatus)
734 System.out.println(tr);
735 }
736
737 @Test
738 static void testJreRestrictSearchFlag() {
739 // test both arguments to ensure they exist
740 TestResult tr = null;
741 tr = doExec(javaCmd,
742 "-no-jre-restrict-search", "-version");
743 tr.checkPositive();
744 if (!tr.testStatus)
745 System.out.println(tr);
746
747 tr = doExec(javaCmd,
748 "-jre-restrict-search", "-version");
749 tr.checkPositive();
750 if (!tr.testStatus)
751 System.out.println(tr);
752 }
753
754 /**
755 * @param args the command line arguments
756 * @throws java.io.FileNotFoundException
757 */
758 public static void main(String[] args) throws Exception {
759 if (debug) {
760 System.out.println("Starting Arrrghs tests");
761 }
762 Arrrghs a = new Arrrghs();
763 a.run(args);
764 if (testExitValue > 0) {
765 System.out.println("Total of " + testExitValue + " failed");
766 System.exit(1);
767 } else {
768 System.out.println("All tests pass");
769 }
770 }
771 }
|
1 /*
2 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
715 (String[])null);
716 tr = doExec(javaCmd, "-Xdiag", "-jar", "some.jar");
717 tr.contains("Error: Could not find or load main class MIA");
718 tr.contains("java.lang.ClassNotFoundException: MIA");
719 if (!tr.testStatus)
720 System.out.println(tr);
721
722 // use classpath to check
723 tr = doExec(javaCmd, "-Xdiag", "-cp", "some.jar", "MIA");
724 tr.contains("Error: Could not find or load main class MIA");
725 tr.contains("java.lang.ClassNotFoundException: MIA");
726 if (!tr.testStatus)
727 System.out.println(tr);
728
729 // a missing class on the classpath
730 tr = doExec(javaCmd, "-Xdiag", "NonExistentClass");
731 tr.contains("Error: Could not find or load main class NonExistentClass");
732 tr.contains("java.lang.ClassNotFoundException: NonExistentClass");
733 if (!tr.testStatus)
734 System.out.println(tr);
735 }
736
737 /**
738 * @param args the command line arguments
739 * @throws java.io.FileNotFoundException
740 */
741 public static void main(String[] args) throws Exception {
742 if (debug) {
743 System.out.println("Starting Arrrghs tests");
744 }
745 Arrrghs a = new Arrrghs();
746 a.run(args);
747 if (testExitValue > 0) {
748 System.out.println("Total of " + testExitValue + " failed");
749 System.exit(1);
750 } else {
751 System.out.println("All tests pass");
752 }
753 }
754 }
|