Search in sources :

Example 1 with ErrorManager

use of java.util.logging.ErrorManager in project robovm by robovm.

the class OldErrorManagerTest method test_errorCheck.

public void test_errorCheck() {
    ErrorManager em = new ErrorManager();
    MockStream aos = new MockStream();
    PrintStream st = new PrintStream(aos);
    System.setErr(st);
    System.setOut(st);
    em.error("supertest", null, ErrorManager.GENERIC_FAILURE);
    st.flush();
    assertTrue("message appears (supertest)", aos.getWrittenData().indexOf("supertest") != -1);
}
Also used : PrintStream(java.io.PrintStream) ErrorManager(java.util.logging.ErrorManager)

Example 2 with ErrorManager

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

the class HandlerTest method testGetSetErrorManager_Normal.

/*
	 * Test setEncoding with insufficient privilege.
	 *
	public void testSetEncoding_InsufficientPrivilege() throws Exception {
		MockHandler h = new MockHandler();
		SecurityManager oldMan = System.getSecurityManager();
		System.setSecurityManager(new MockSecurityManager());
		// set a normal value
		try {
			h.setEncoding("iso-8859-1");
			fail("Should throw SecurityException!");
		} catch (SecurityException e) {
		} finally {
			System.setSecurityManager(oldMan);
		}
		assertNull(h.getEncoding());
		System.setSecurityManager(new MockSecurityManager());
		// set an invalid value
		try {

			h.setEncoding("impossible");
			fail("Should throw SecurityException!");
		} catch (SecurityException e) {
		} finally {
			System.setSecurityManager(oldMan);
		}
		assertNull(h.getEncoding());
	}
	*/
/*
	 * Test getErrorManager & setErrorManager methods with non-null value.
	 */
public void testGetSetErrorManager_Normal() throws Exception {
    MockHandler h = new MockHandler();
    ErrorManager man = new ErrorManager();
    h.setErrorManager(man);
    assertSame(man, h.getErrorManager());
}
Also used : ErrorManager(java.util.logging.ErrorManager)

Example 3 with ErrorManager

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

the class HandlerTest method testGetSetErrorManager_Null.

/*
	 * Test getErrorManager & setErrorManager methods with null.
	 */
public void testGetSetErrorManager_Null() throws Exception {
    MockHandler h = new MockHandler();
    // test set null
    try {
        h.setErrorManager(null);
        fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
    }
    // test reset null
    try {
        h.setErrorManager(new ErrorManager());
        h.setErrorManager(null);
        fail("Should throw NullPointerException!");
    } catch (NullPointerException e) {
    }
}
Also used : ErrorManager(java.util.logging.ErrorManager)

Example 4 with ErrorManager

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

the class ErrorManagerTest method test_errorStringStringint.

public void test_errorStringStringint() {
    ErrorManager em = new ErrorManager();
    em.error(null, new NullPointerException(), ErrorManager.GENERIC_FAILURE);
    em.error("An error message.", null, ErrorManager.GENERIC_FAILURE);
    em.error(null, null, ErrorManager.GENERIC_FAILURE);
}
Also used : ErrorManager(java.util.logging.ErrorManager)

Example 5 with ErrorManager

use of java.util.logging.ErrorManager in project google-cloud-java by GoogleCloudPlatform.

the class LoggingHandlerTest method testReportWriteError.

@Test
public void testReportWriteError() {
    expect(options.getProjectId()).andReturn(PROJECT).anyTimes();
    expect(options.getService()).andReturn(logging);
    RuntimeException ex = new RuntimeException();
    logging.setFlushSeverity(Severity.ERROR);
    expectLastCall().once();
    logging.setWriteSynchronicity(Synchronicity.ASYNC);
    expectLastCall().once();
    logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS);
    expectLastCall().andStubThrow(ex);
    replay(options, logging);
    ErrorManager errorManager = EasyMock.createStrictMock(ErrorManager.class);
    errorManager.error(null, ex, ErrorManager.WRITE_FAILURE);
    expectLastCall().once();
    replay(errorManager);
    Handler handler = new LoggingHandler(LOG_NAME, options);
    handler.setLevel(Level.ALL);
    handler.setErrorManager(errorManager);
    handler.setFormatter(new TestFormatter());
    handler.publish(newLogRecord(Level.FINEST, MESSAGE));
    verify(errorManager);
}
Also used : ErrorManager(java.util.logging.ErrorManager) Handler(java.util.logging.Handler) Test(org.junit.Test)

Aggregations

ErrorManager (java.util.logging.ErrorManager)11 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Handler (java.util.logging.Handler)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 Formatter (java.util.logging.Formatter)2 LogRecord (java.util.logging.LogRecord)2 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 PrintStream (java.io.PrintStream)1 Properties (java.util.Properties)1 Filter (java.util.logging.Filter)1 SimpleFormatter (java.util.logging.SimpleFormatter)1