Search in sources :

Example 36 with Logger

use of java.util.logging.Logger in project j2objc by google.

the class LoggerTest method testGetResourceBundleName_Normal.

/*
	 * Test getResourceBundleName() when it it not null.
	 */
public void testGetResourceBundleName_Normal() {
    Logger log = Logger.getLogger("testGetResourceBundleName_Normal", VALID_RESOURCE_BUNDLE);
    assertEquals(VALID_RESOURCE_BUNDLE, log.getResourceBundleName());
    Logger mlog = new MockLogger(null, null);
    assertNull(mlog.getResourceBundleName());
}
Also used : Logger(java.util.logging.Logger)

Example 37 with Logger

use of java.util.logging.Logger in project j2objc by google.

the class LoggerTest method testSevere_Null.

/*
	 * Test severe(String) with null values.
	 */
public void testSevere_Null() {
    Logger child = new MockLogger("childLogger", null);
    Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
    child.addHandler(new MockHandler());
    child.setParent(parent);
    child.setLevel(Level.SEVERE);
    child.severe(null);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), child.getName());
    assertNull(r.getMessage());
    assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
    assertSame(r.getResourceBundle(), parent.getResourceBundle());
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.SEVERE);
    assertNull(r.getParameters());
    assertSame(r.getThrown(), null);
    this.sharedLogger.setLevel(Level.OFF);
    this.sharedLogger.severe(null);
    assertTrue(CallVerificationStack.getInstance().empty());
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Example 38 with Logger

use of java.util.logging.Logger in project j2objc by google.

the class LoggerTest method testGetSetFilter_NamedLoggerSufficientPrivilege.

/*
	 * Test getFilter & setFilter with normal value for a named logger, having
	 * sufficient privilege.
	 */
public void testGetSetFilter_NamedLoggerSufficientPrivilege() {
    Logger log = Logger.getLogger("testGetSetFilter_NamedLoggerSufficientPrivilege");
    Filter f = new MockFilter();
    assertNull(log.getFilter());
    log.setFilter(f);
    assertSame(f, log.getFilter());
}
Also used : Filter(java.util.logging.Filter) Logger(java.util.logging.Logger)

Example 39 with Logger

use of java.util.logging.Logger in project j2objc by google.

the class LoggerTest method testGetName_Null.

/*
	 * Test getName() for null name.
	 */
public void testGetName_Null() {
    Logger log = Logger.getAnonymousLogger();
    assertNull(log.getName());
    Logger mlog = new MockLogger(null, null);
    assertNull(mlog.getName());
}
Also used : Logger(java.util.logging.Logger)

Example 40 with Logger

use of java.util.logging.Logger in project j2objc by google.

the class LoggerTest method testLog_ParentInformed.

/*
	 * Test that the parent's handler is notified for a new log record when
	 * getUseParentHandlers() is true.
	 */
public void testLog_ParentInformed() {
    Logger child = new MockLogger("childLogger", VALID_RESOURCE_BUNDLE);
    Logger parent = new MockParentLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
    child.setParent(parent);
    child.setLevel(Level.INFO);
    parent.setLevel(Level.INFO);
    parent.addHandler(new MockHandler());
    LogRecord r = new LogRecord(Level.INFO, "testLog_ParentInformed");
    child.log(r);
    assertTrue(child.getUseParentHandlers());
    // pop only once, pushed by the parent logger's handler, not by the
    // parent itself!
    assertSame(r, CallVerificationStack.getInstance().pop());
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), null);
    assertEquals(r.getMessage(), "testLog_ParentInformed");
    assertSame(r.getResourceBundleName(), null);
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.INFO);
    assertNull(r.getParameters());
    assertSame(r.getThrown(), null);
    // set the child logger to disabling level
    child.setLevel(Level.SEVERE);
    child.log(r);
    assertTrue(CallVerificationStack.getInstance().empty());
    // set the parent logger to disabling level
    child.setLevel(Level.INFO);
    parent.setLevel(Level.SEVERE);
    child.log(r);
    assertSame(r, CallVerificationStack.getInstance().pop());
    assertTrue(CallVerificationStack.getInstance().empty());
    // set the child logger off
    child.setLevel(Level.OFF);
    child.log(r);
    assertTrue(CallVerificationStack.getInstance().empty());
    // set the record off
    r.setLevel(Level.OFF);
    child.log(r);
    assertTrue(CallVerificationStack.getInstance().empty());
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Aggregations

Logger (java.util.logging.Logger)499 Test (org.junit.Test)70 LogRecord (java.util.logging.LogRecord)60 ActionReport (org.glassfish.api.ActionReport)56 Handler (java.util.logging.Handler)52 IOException (java.io.IOException)37 File (java.io.File)36 Level (java.util.logging.Level)25 ArrayList (java.util.ArrayList)22 ConsoleHandler (java.util.logging.ConsoleHandler)19 Properties (java.util.Properties)15 SimpleFormatter (java.util.logging.SimpleFormatter)15 Config (com.sun.enterprise.config.serverbeans.Config)14 HashMap (java.util.HashMap)14 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ResourceBundle (java.util.ResourceBundle)11 LogManager (java.util.logging.LogManager)11 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)10