Search in sources :

Example 51 with Logger

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

the class LoggerTest method testThrowing_Null.

/*
	 * Test throwing(String, String, Throwable) with null values.
	 */
public void testThrowing_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.FINER);
    child.throwing(null, null, null);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), child.getName());
    assertEquals(r.getMessage(), "THROW");
    assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
    assertSame(r.getResourceBundle(), parent.getResourceBundle());
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.FINER);
    assertSame(r.getParameters(), null);
    assertSame(r.getThrown(), null);
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Example 52 with Logger

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

the class LoggerTest method testExiting_StringStringObject_Null.

/*
	 * Test exiting(String, String, Object) with null values.
	 */
public void testExiting_StringStringObject_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.FINER);
    child.exiting(null, null, (Object) null);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), child.getName());
    assertEquals(r.getMessage(), "RETURN {0}");
    assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
    assertSame(r.getResourceBundle(), parent.getResourceBundle());
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.FINER);
    assertEquals(r.getParameters().length, 1);
    assertNull(r.getParameters()[0]);
    assertSame(r.getThrown(), null);
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Example 53 with Logger

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

the class LoggerTest method testLog_LevelStringThrowable_Null.

/*
	 * Test log(Level, String, Throwable) with null message and throwable.
	 */
public void testLog_LevelStringThrowable_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.INFO);
    child.log(Level.INFO, null, (Throwable) 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.INFO);
    assertNull(r.getParameters());
    assertSame(r.getThrown(), null);
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Example 54 with Logger

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

the class LoggerTest method testEntering_StringString_Null.

/*
	 * Test entering(String, String) with null values.
	 */
public void testEntering_StringString_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.FINER);
    child.entering(null, null);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), child.getName());
    assertEquals(r.getMessage(), "ENTRY");
    assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
    assertSame(r.getResourceBundle(), parent.getResourceBundle());
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.FINER);
    assertSame(r.getParameters(), null);
    assertSame(r.getThrown(), null);
}
Also used : LogRecord(java.util.logging.LogRecord) Logger(java.util.logging.Logger)

Example 55 with Logger

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

the class LoggerTest method testRemoveHandler_NamedLoggerSufficientPrivilegeNotExisting.

/*
	 * Test removeHandler(Handler) for a named logger with sufficient privilege,
	 * remove a non-existing handler.
	 */
public void testRemoveHandler_NamedLoggerSufficientPrivilegeNotExisting() {
    Logger log = Logger.getLogger("testRemoveHandler_NamedLoggerSufficientPrivilegeNotExisting");
    MockHandler h = new MockHandler();
    assertEquals(log.getHandlers().length, 0);
    log.removeHandler(h);
    assertEquals(log.getHandlers().length, 0);
}
Also used : 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