test/java/util/logging/Logger/getGlobal/TestGetGlobal.java

Print this page




  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  */
  23 import java.util.Arrays;
  24 import java.util.List;
  25 import java.util.logging.Logger;
  26 
  27 /**
  28  * @test
  29  * @bug 7184195
  30  * @summary checks that java.util.logging.Logger.getGlobal().info() logs without configuration
  31  * @build TestGetGlobal testgetglobal.HandlerImpl testgetglobal.LogManagerImpl1 testgetglobal.LogManagerImpl2 testgetglobal.LogManagerImpl3 testgetglobal.BadLogManagerImpl testgetglobal.DummyLogManagerImpl
  32  * @run main/othervm/timeout=10 TestGetGlobal
  33  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager TestGetGlobal
  34  * @run main/othervm/timeout=10 -Djava.util.logging.manager=testgetglobal.LogManagerImpl1 TestGetGlobal
  35  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl1 TestGetGlobal
  36  * @run main/othervm/timeout=10 -Djava.util.logging.manager=testgetglobal.LogManagerImpl2 TestGetGlobal
  37  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl2 TestGetGlobal
  38  * @run main/othervm/timeout=10 -Djava.util.logging.manager=testgetglobal.LogManagerImpl3 TestGetGlobal
  39  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl3 TestGetGlobal
  40  * @run main/othervm/timeout=10 -Djava.util.logging.manager=testgetglobal.BadLogManagerImpl TestGetGlobal
  41  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.BadLogManagerImpl TestGetGlobal
  42  * @run main/othervm/timeout=10 -Djava.util.logging.manager=testgetglobal.DummyLogManagerImpl TestGetGlobal
  43  * @run main/othervm/timeout=10/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.DummyLogManagerImpl TestGetGlobal
  44  * @author danielfuchs
  45  */
  46 public class TestGetGlobal {
  47 
  48     final static String[] messages = {
  49         "1. This message should not appear on the console.",
  50         "2. This message should appear on the console.",
  51         "3. This message should now appear on the console too."
  52     };
  53 
  54     static {
  55         System.setProperty("java.util.logging.config.file",
  56             System.getProperty("test.src", ".") + java.io.File.separator + "logging.properties");
  57     }
  58 
  59     public static void main(String... args) {
  60         final String manager = System.getProperty("java.util.logging.manager", null);
  61 
  62         final String description = "TestGetGlobal"
  63             + (System.getSecurityManager() == null ? " " :


  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  */
  23 import java.util.Arrays;
  24 import java.util.List;
  25 import java.util.logging.Logger;
  26 
  27 /**
  28  * @test
  29  * @bug 7184195
  30  * @summary checks that java.util.logging.Logger.getGlobal().info() logs without configuration
  31  * @build TestGetGlobal testgetglobal.HandlerImpl testgetglobal.LogManagerImpl1 testgetglobal.LogManagerImpl2 testgetglobal.LogManagerImpl3 testgetglobal.BadLogManagerImpl testgetglobal.DummyLogManagerImpl
  32  * @run main/othervm TestGetGlobal
  33  * @run main/othervm/policy=policy -Djava.security.manager TestGetGlobal
  34  * @run main/othervm -Djava.util.logging.manager=testgetglobal.LogManagerImpl1 TestGetGlobal
  35  * @run main/othervm/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl1 TestGetGlobal
  36  * @run main/othervm -Djava.util.logging.manager=testgetglobal.LogManagerImpl2 TestGetGlobal
  37  * @run main/othervm/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl2 TestGetGlobal
  38  * @run main/othervm -Djava.util.logging.manager=testgetglobal.LogManagerImpl3 TestGetGlobal
  39  * @run main/othervm/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.LogManagerImpl3 TestGetGlobal
  40  * @run main/othervm -Djava.util.logging.manager=testgetglobal.BadLogManagerImpl TestGetGlobal
  41  * @run main/othervm/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.BadLogManagerImpl TestGetGlobal
  42  * @run main/othervm -Djava.util.logging.manager=testgetglobal.DummyLogManagerImpl TestGetGlobal
  43  * @run main/othervm/policy=policy -Djava.security.manager -Djava.util.logging.manager=testgetglobal.DummyLogManagerImpl TestGetGlobal
  44  * @author danielfuchs
  45  */
  46 public class TestGetGlobal {
  47 
  48     final static String[] messages = {
  49         "1. This message should not appear on the console.",
  50         "2. This message should appear on the console.",
  51         "3. This message should now appear on the console too."
  52     };
  53 
  54     static {
  55         System.setProperty("java.util.logging.config.file",
  56             System.getProperty("test.src", ".") + java.io.File.separator + "logging.properties");
  57     }
  58 
  59     public static void main(String... args) {
  60         final String manager = System.getProperty("java.util.logging.manager", null);
  61 
  62         final String description = "TestGetGlobal"
  63             + (System.getSecurityManager() == null ? " " :