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);
}
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());
}
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) {
}
}
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);
}
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);
}
Aggregations