本文整理汇总了Java中java.beans.Encoder.setExceptionListener方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.setExceptionListener方法的具体用法?Java Encoder.setExceptionListener怎么用?Java Encoder.setExceptionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.Encoder
的用法示例。
在下文中一共展示了Encoder.setExceptionListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInitialize_NullClass
import java.beans.Encoder; //导入方法依赖的package包/类
public void testInitialize_NullClass() {
MockPersistenceDelegate pd = new MockPersistenceDelegate();
Encoder enc = new Encoder();
Object o1 = new Object();
Object o2 = new Object();
// enc.setPersistenceDelegate(MockFooStop.class,
// new MockPersistenceDelegate());
try {
enc.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e) {
CallVerificationStack.getInstance().push(e);
}
});
pd.initialize(null, o1, o2, enc);
fail("Should throw NullPointerException!");
} catch (NullPointerException ex) {
// expected
}
assertTrue(CallVerificationStack.getInstance().empty());
}
示例2: testInitialize_NullInstances
import java.beans.Encoder; //导入方法依赖的package包/类
public void testInitialize_NullInstances() {
MockPersistenceDelegate pd = new MockPersistenceDelegate();
Encoder enc = new Encoder();
MockFoo b = new MockFoo();
b.setName("myName");
// enc.setPersistenceDelegate(MockFooStop.class,
// new MockPersistenceDelegate());
enc.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e) {
CallVerificationStack.getInstance().push(e);
}
});
try {
pd.initialize(MockFoo.class, null, b, enc);
fail("Should throw NullPointerException!");
} catch (NullPointerException ex) {
// expected
}
assertTrue(CallVerificationStack.getInstance().empty());
pd.initialize(MockFoo.class, b, null, enc);
assertFalse(CallVerificationStack.getInstance().empty());
}
示例3: main
import java.beans.Encoder; //导入方法依赖的package包/类
public static void main(String[] args) {
TestBean bean = new TestBean(true, 11);
Encoder encoder = new Encoder();
encoder.setExceptionListener(bean);
new TestDPD().instantiate(bean, encoder);
}
示例4: instantiate
import java.beans.Encoder; //导入方法依赖的package包/类
public Expression instantiate(Object instance, Encoder encoder) {
encoder.setExceptionListener(this);
return super.instantiate(instance, encoder);
}