use of java.util.logging.SimpleFormatter in project j2objc by google.
the class HandlerTest method testGetSetFormatter_Normal.
/*
* Test setFilter with insufficient privilege.
*
public void testSetFilter_InsufficientPrivilege() throws Exception {
MockHandler h = new MockHandler();
SecurityManager oldMan = System.getSecurityManager();
System.setSecurityManager(new MockSecurityManager());
// set null
try {
h.setFilter(null);
fail("Should throw SecurityException!");
} catch (SecurityException e) {
} finally {
System.setSecurityManager(oldMan);
}
// set a normal value
System.setSecurityManager(new MockSecurityManager());
try {
h.setFilter(new MockFilter());
fail("Should throw SecurityException!");
} catch (SecurityException e) {
} finally {
System.setSecurityManager(oldMan);
}
}
*/
/*
* Test getFormatter & setFormatter methods with non-null value.
*/
public void testGetSetFormatter_Normal() throws Exception {
MockHandler h = new MockHandler();
Formatter f = new SimpleFormatter();
h.setFormatter(f);
assertSame(f, h.getFormatter());
}
use of java.util.logging.SimpleFormatter in project j2objc by google.
the class HandlerTest method testGetSetFormatter_Null.
/*
* Test getFormatter & setFormatter methods with null.
*/
public void testGetSetFormatter_Null() throws Exception {
MockHandler h = new MockHandler();
// test set null
try {
h.setFormatter(null);
fail("Should throw NullPointerException!");
} catch (NullPointerException e) {
}
// test reset null
try {
h.setFormatter(new SimpleFormatter());
h.setFormatter(null);
fail("Should throw NullPointerException!");
} catch (NullPointerException e) {
}
}
use of java.util.logging.SimpleFormatter in project j2objc by google.
the class ConsoleHandlerTest method testConstructor_NoProperties.
/*
* Test the constructor with no relevant log manager properties are set.
*/
public void testConstructor_NoProperties() {
assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.level"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.filter"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.formatter"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.ConsoleHandler.encoding"));
ConsoleHandler h = new ConsoleHandler();
assertSame(h.getLevel(), Level.INFO);
assertTrue(h.getFormatter() instanceof SimpleFormatter);
assertNull(h.getFilter());
assertSame(h.getEncoding(), null);
}
use of java.util.logging.SimpleFormatter in project j2objc by google.
the class StreamHandlerTest method testConstructor_NoParameter_NoProperties.
/*
* Test the constructor with no parameter, and no relevant log manager
* properties are set.
*/
public void testConstructor_NoParameter_NoProperties() {
assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.level"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.filter"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.formatter"));
assertNull(LogManager.getLogManager().getProperty("java.util.logging.StreamHandler.encoding"));
StreamHandler h = new StreamHandler();
assertSame(Level.INFO, h.getLevel());
assertTrue(h.getFormatter() instanceof SimpleFormatter);
assertNull(h.getFilter());
assertNull(h.getEncoding());
}
use of java.util.logging.SimpleFormatter in project malmo by Microsoft.
the class TCPSocketHelper method setLogging.
static void setLogging(boolean log) {
logging = log;
if (log == true && filehandler == null) {
try {
filehandler = new FileHandler("TCPLog.txt");
filehandler.setFormatter(new SimpleFormatter());
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.addHandler(filehandler);
}
}
Aggregations