本文整理汇总了Java中tests.util.CallVerificationStack类的典型用法代码示例。如果您正苦于以下问题:Java CallVerificationStack类的具体用法?Java CallVerificationStack怎么用?Java CallVerificationStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallVerificationStack类属于tests.util包,在下文中一共展示了CallVerificationStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPublish_AfterResetSystemErr
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testPublish_AfterResetSystemErr() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
h.setFilter(new MockFilter());
System.setErr(new PrintStream(new ByteArrayOutputStream()));
LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter");
h.setLevel(Level.INFO);
h.publish(r);
assertNull(CallVerificationStack.getInstance().pop());
assertSame(r, CallVerificationStack.getInstance().pop());
assertEquals("", this.errSubstituteStream.toString());
}
示例2: testConstructor_NoParameter_InvalidProperties
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testConstructor_NoParameter_InvalidProperties()
throws Exception {
Properties p = new Properties();
p.put("java.util.logging.StreamHandler.level", INVALID_LEVEL);
p.put("java.util.logging.StreamHandler.filter", className + "");
p.put("java.util.logging.StreamHandler.formatter", className + "");
p.put("java.util.logging.StreamHandler.encoding", "XXXX");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
assertEquals(INVALID_LEVEL, LogManager.getLogManager().getProperty(
"java.util.logging.StreamHandler.level"));
assertEquals("XXXX", 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());
h.publish(new LogRecord(Level.SEVERE, "test"));
assertTrue(CallVerificationStack.getInstance().empty());
assertNull(h.getEncoding());
}
示例3: testIsLoggable_WithFilter
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testIsLoggable_WithFilter() {
StreamHandler h = new StreamHandler(new ByteArrayOutputStream(),
new SimpleFormatter());
LogRecord r = new LogRecord(Level.INFO, null);
h.setFilter(new MockFilter());
assertFalse(h.isLoggable(r));
assertSame(r, CallVerificationStack.getInstance().pop());
h.setLevel(Level.CONFIG);
assertFalse(h.isLoggable(r));
assertSame(r, CallVerificationStack.getInstance().pop());
h.setLevel(Level.WARNING);
assertFalse(h.isLoggable(r));
assertTrue(CallVerificationStack.getInstance().empty());
}
示例4: testSetOutputStream_Normal
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testSetOutputStream_Normal() {
ByteArrayOutputStream aos = new ByteArrayOutputStream();
MockStreamHandler h = new MockStreamHandler(aos, new MockFormatter());
LogRecord r = new LogRecord(Level.INFO, "testSetOutputStream_Normal");
h.publish(r);
assertSame(r, CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
h.flush();
assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal", aos
.toString());
ByteArrayOutputStream aos2 = new ByteArrayOutputStream();
h.setOutputStream(aos2);
assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal"
+ "MockFormatter_Tail", aos.toString());
r = new LogRecord(Level.INFO, "testSetOutputStream_Normal2");
h.publish(r);
assertSame(r, CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
h.flush();
assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal2", aos2
.toString());
assertEquals("MockFormatter_Head" + "testSetOutputStream_Normal"
+ "MockFormatter_Tail", aos.toString());
}
示例5: testClose_SufficientPrivilege_DirectClose
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testClose_SufficientPrivilege_DirectClose() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
h.close();
assertEquals("flush", CallVerificationStack.getInstance()
.getCurrentSourceMethod());
assertNull(CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
}
示例6: testPublish_WithFilter
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testPublish_WithFilter() throws Exception {
Properties p = new Properties();
p.put("java.util.logging.ConsoleHandler.formatter", className
+ "$MockFormatter");
LogManager.getLogManager().readConfiguration(
EnvironmentHelper.PropertiesToInputStream(p));
ConsoleHandler h = new ConsoleHandler();
h.setFilter(new MockFilter());
LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter");
h.setLevel(Level.INFO);
h.publish(r);
assertNull(CallVerificationStack.getInstance().pop());
assertSame(r, CallVerificationStack.getInstance().pop());
assertEquals("", this.errSubstituteStream.toString());
h.setLevel(Level.WARNING);
h.publish(r);
assertNull(CallVerificationStack.getInstance().pop());
assertTrue(CallVerificationStack.getInstance().empty());
assertEquals("", this.errSubstituteStream.toString());
h.setLevel(Level.CONFIG);
h.publish(r);
assertNull(CallVerificationStack.getInstance().pop());
assertSame(r, CallVerificationStack.getInstance().pop());
assertEquals("", this.errSubstituteStream.toString());
r.setLevel(Level.OFF);
h.setLevel(Level.OFF);
h.publish(r);
assertNull(CallVerificationStack.getInstance().pop());
assertEquals("", this.errSubstituteStream.toString());
assertTrue(CallVerificationStack.getInstance().empty());
}
示例7: testThrowing_Normal
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testThrowing_Normal() {
Throwable t = new Throwable();
this.sharedLogger.setLevel(Level.FINER);
this.sharedLogger.throwing("sourceClass", "sourceMethod", t);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "THROW");
assertSame(r.getResourceBundleName(), this.sharedLogger
.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.FINER);
assertSame(r.getParameters(), null);
assertSame(r.getThrown(), t);
this.sharedLogger.setLevel(Level.FINE);
this.sharedLogger.throwing("sourceClass", "sourceMethod", t);
assertTrue(CallVerificationStack.getInstance().empty());
}
示例8: testThrowing_Null
import tests.util.CallVerificationStack; //导入依赖的package包/类
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);
}
示例9: testEntering_StringString_Normal
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_StringString_Normal() {
this.sharedLogger.setLevel(Level.FINER);
this.sharedLogger.entering("sourceClass", "sourceMethod");
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "ENTRY");
assertSame(r.getResourceBundleName(), this.sharedLogger
.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.FINER);
assertSame(r.getParameters(), null);
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.FINE);
this.sharedLogger.entering("sourceClass", "sourceMethod");
assertTrue(CallVerificationStack.getInstance().empty());
}
示例10: testEntering_StringString_Null
import tests.util.CallVerificationStack; //导入依赖的package包/类
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);
}
示例11: testEntering_StringStringObject_Normal
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_StringStringObject_Normal() {
Object param = new Object();
this.sharedLogger.setLevel(Level.FINER);
this.sharedLogger.entering("sourceClass", "sourceMethod", param);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "ENTRY {0}");
assertSame(r.getResourceBundleName(), this.sharedLogger
.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.FINER);
assertSame(r.getParameters()[0], param);
assertEquals(1, r.getParameters().length);
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.FINE);
this.sharedLogger.entering("sourceClass", "sourceMethod", param);
assertTrue(CallVerificationStack.getInstance().empty());
}
示例12: testEntering_StringStringObject_Null
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_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.entering(null, null, (Object) null);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), child.getName());
assertEquals(r.getMessage(), "ENTRY {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);
}
示例13: testEntering_StringStringObjects_Normal
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_StringStringObjects_Normal() {
Object[] params = new Object[2];
params[0] = new Object();
params[1] = new Object();
this.sharedLogger.setLevel(Level.FINER);
this.sharedLogger.entering("sourceClass", "sourceMethod", params);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "ENTRY {0} {1}");
assertSame(r.getResourceBundleName(), this.sharedLogger
.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), "sourceClass");
assertSame(r.getSourceMethodName(), "sourceMethod");
assertSame(r.getLevel(), Level.FINER);
assertSame(r.getParameters()[0], params[0]);
assertSame(r.getParameters()[1], params[1]);
assertEquals(2, r.getParameters().length);
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.FINE);
this.sharedLogger.entering("sourceClass", "sourceMethod", params);
assertTrue(CallVerificationStack.getInstance().empty());
}
示例14: testEntering_StringStringObjects_NullEmpty
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_StringStringObjects_NullEmpty() {
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, new Object[0]);
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);
assertEquals(0, r.getParameters().length);
assertSame(r.getThrown(), null);
}
示例15: testEntering_StringStringObjects_Null
import tests.util.CallVerificationStack; //导入依赖的package包/类
public void testEntering_StringStringObjects_Null() {
sharedLogger.setLevel(Level.FINER);
sharedLogger.entering(null, null, (Object[]) null);
// regression test for Harmony-1265
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(sharedLogger.getName(), r.getLoggerName());
assertEquals("ENTRY", r.getMessage());
assertSame(sharedLogger.getResourceBundleName(), r
.getResourceBundleName());
assertSame(sharedLogger.getResourceBundle(), r.getResourceBundle());
assertNull(r.getSourceClassName());
assertNull(r.getSourceMethodName());
assertSame(Level.FINER, r.getLevel());
assertNull(r.getParameters());
assertNull(r.getThrown());
}