test/sun/util/logging/PlatformLoggerTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff test/sun/util/logging

test/sun/util/logging/PlatformLoggerTest.java

Print this page
rev 14189 : 8142464: PlatformLoggerTest.java throws java.lang.RuntimeException: Logger test.logger.bar does not exist
Summary: Test doesn't keep strong references to loggers
Reviewed-by:


  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 
  24 /*
  25  * @test
  26  * @bug     6882376 6985460 8010309 8011638
  27  * @summary Test if java.util.logging.Logger is created before and after
  28  *          logging is enabled.  Also validate some basic PlatformLogger
  29  *          operations.  othervm mode to make sure java.util.logging
  30  *          is not initialized.
  31  *
  32  * @modules java.base/sun.util.logging
  33  *          java.logging/sun.util.logging.internal
  34  * @compile -XDignore.symbol.file PlatformLoggerTest.java
  35  * @run main/othervm PlatformLoggerTest
  36  */
  37 
  38 import java.lang.reflect.Field;
  39 import java.lang.reflect.Modifier;
  40 import java.util.logging.*;
  41 import sun.util.logging.PlatformLogger;
  42 import static sun.util.logging.PlatformLogger.Level.*;
  43 
  44 public class PlatformLoggerTest {






  45     public static void main(String[] args) throws Exception {
  46         final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
  47         final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
  48         final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
  49         final String BAR_LOGGER = "test.logger.bar";
  50         PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
  51         // test the PlatformLogger methods
  52         testLogMethods(goo);
  53 
  54         // Create a platform logger using the default
  55         PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
  56         checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
  57 
  58         // create a java.util.logging.Logger
  59         // now java.util.logging.Logger should be created for each platform logger
  60         Logger logger = Logger.getLogger(BAR_LOGGER);
  61         logger.setLevel(Level.WARNING);
  62 
  63         PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
  64         checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
  65 
  66         // test the PlatformLogger methods
  67         testLogMethods(goo);
  68         testLogMethods(bar);
  69 
  70         checkLogger(FOO_PLATFORM_LOGGER, Level.FINER);
  71         checkLogger(BAR_PLATFORM_LOGGER, Level.FINER);
  72 
  73         checkLogger(GOO_PLATFORM_LOGGER, null);
  74         checkLogger(BAR_LOGGER, Level.WARNING);
  75 
  76         foo.setLevel(PlatformLogger.Level.SEVERE);
  77         checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE);
  78 
  79         checkPlatformLoggerLevels(foo, bar);
  80     }
  81 
  82     // don't use java.util.logging here to prevent it from initialized
  83     private static void checkPlatformLogger(PlatformLogger logger, String name) {




  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 
  24 /*
  25  * @test
  26  * @bug     6882376 6985460 8010309 8011638
  27  * @summary Test if java.util.logging.Logger is created before and after
  28  *          logging is enabled.  Also validate some basic PlatformLogger
  29  *          operations.  othervm mode to make sure java.util.logging
  30  *          is not initialized.
  31  *
  32  * @modules java.base/sun.util.logging
  33  *          java.logging/sun.util.logging.internal

  34  * @run main/othervm PlatformLoggerTest
  35  */
  36 
  37 import java.lang.reflect.Field;
  38 import java.lang.reflect.Modifier;
  39 import java.util.logging.*;
  40 import sun.util.logging.PlatformLogger;
  41 import static sun.util.logging.PlatformLogger.Level.*;
  42 
  43 public class PlatformLoggerTest {
  44     
  45     static Logger logger;
  46     static PlatformLogger bar;
  47     static PlatformLogger goo;
  48     static PlatformLogger foo;
  49     
  50     public static void main(String[] args) throws Exception {
  51         final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
  52         final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
  53         final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
  54         final String BAR_LOGGER = "test.logger.bar";
  55         goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
  56         // test the PlatformLogger methods
  57         testLogMethods(goo);
  58 
  59         // Create a platform logger using the default
  60         foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
  61         checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
  62 
  63         // create a java.util.logging.Logger
  64         // now java.util.logging.Logger should be created for each platform logger
  65         logger = Logger.getLogger(BAR_LOGGER);
  66         logger.setLevel(Level.WARNING);
  67 
  68         bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
  69         checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
  70 
  71         // test the PlatformLogger methods
  72         testLogMethods(goo);
  73         testLogMethods(bar);
  74 
  75         checkLogger(FOO_PLATFORM_LOGGER, Level.FINER);
  76         checkLogger(BAR_PLATFORM_LOGGER, Level.FINER);
  77 
  78         checkLogger(GOO_PLATFORM_LOGGER, null);
  79         checkLogger(BAR_LOGGER, Level.WARNING);
  80 
  81         foo.setLevel(PlatformLogger.Level.SEVERE);
  82         checkLogger(FOO_PLATFORM_LOGGER, Level.SEVERE);
  83 
  84         checkPlatformLoggerLevels(foo, bar);
  85     }
  86 
  87     // don't use java.util.logging here to prevent it from initialized
  88     private static void checkPlatformLogger(PlatformLogger logger, String name) {


test/sun/util/logging/PlatformLoggerTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File