Search in sources :

Example 61 with LogRecord

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

the class LoggerTest method testLog_LevelStringObjects_Normal.

/*
	 * Test log(Level, String, Object[]) with normal values.
	 */
public void testLog_LevelStringObjects_Normal() {
    Object[] params = new Object[2];
    params[0] = new Object();
    params[1] = new Object();
    this.sharedLogger.setLevel(Level.INFO);
    this.sharedLogger.log(Level.INFO, "log(Level, String, Object[]) msg", params);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), this.sharedLogger.getName());
    assertEquals(r.getMessage(), "log(Level, String, Object[]) msg");
    assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
    assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
    assertSame(r.getSourceClassName(), null);
    assertSame(r.getSourceMethodName(), null);
    assertSame(r.getLevel(), Level.INFO);
    assertEquals(2, r.getParameters().length);
    assertSame(params[0], r.getParameters()[0]);
    assertSame(params[1], r.getParameters()[1]);
    assertSame(r.getThrown(), null);
    this.sharedLogger.log(Level.CONFIG, "log(Level, String, Object[]) msg", params);
    assertTrue(CallVerificationStack.getInstance().empty());
    this.sharedLogger.setLevel(Level.OFF);
    this.sharedLogger.log(Level.OFF, "log(Level, String, Object[]) msg", params);
    assertTrue(CallVerificationStack.getInstance().empty());
}
Also used : LogRecord(java.util.logging.LogRecord)

Example 62 with LogRecord

use of java.util.logging.LogRecord 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 63 with LogRecord

use of java.util.logging.LogRecord 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 64 with LogRecord

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

the class LoggerTest method testLogrb_LevelStringStringStringObjects_InvalidRes.

/*
	 * Test logrb(Level, String, String, String, String, Object[]) with invalid
	 * resource bundle.
	 */
public void testLogrb_LevelStringStringStringObjects_InvalidRes() {
    Object[] params = new Object[2];
    params[0] = new Object();
    params[1] = new Object();
    this.sharedLogger.setLevel(Level.ALL);
    this.sharedLogger.logrb(Level.ALL, "sourceClass", "sourceMethod", INVALID_RESOURCE_BUNDLE, "logrb(Level, String, String, String, String) msg", params);
    LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
    assertTrue(CallVerificationStack.getInstance().empty());
    assertSame(r.getLoggerName(), this.sharedLogger.getName());
    assertEquals(r.getMessage(), "logrb(Level, String, String, String, String) msg");
    assertSame(r.getResourceBundleName(), INVALID_RESOURCE_BUNDLE);
    assertSame(r.getResourceBundle(), null);
    assertSame(r.getSourceClassName(), "sourceClass");
    assertSame(r.getSourceMethodName(), "sourceMethod");
    assertSame(r.getLevel(), Level.ALL);
    assertEquals(2, r.getParameters().length);
    assertSame(params[0], r.getParameters()[0]);
    assertSame(params[1], r.getParameters()[1]);
    assertSame(r.getThrown(), null);
}
Also used : LogRecord(java.util.logging.LogRecord)

Example 65 with LogRecord

use of java.util.logging.LogRecord 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)

Aggregations

LogRecord (java.util.logging.LogRecord)370 Logger (java.util.logging.Logger)62 Test (org.junit.Test)61 Handler (java.util.logging.Handler)24 File (java.io.File)21 IOException (java.io.IOException)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)16 Level (java.util.logging.Level)16 StreamHandler (java.util.logging.StreamHandler)14 ConsoleHandler (java.util.logging.ConsoleHandler)13 ArrayList (java.util.ArrayList)12 Properties (java.util.Properties)11 Config (com.sun.enterprise.config.serverbeans.Config)10 Formatter (java.util.logging.Formatter)10 SimpleFormatter (java.util.logging.SimpleFormatter)10 LogRecordCollectingLogger (alma.acs.testsupport.LogRecordCollectingLogger)9 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)9 ActionReport (org.glassfish.api.ActionReport)9 HashMap (java.util.HashMap)7 Subscribe (com.google.common.eventbus.Subscribe)6