本文整理汇总了Java中java.beans.beancontext.BeanContextMembershipEvent类的典型用法代码示例。如果您正苦于以下问题:Java BeanContextMembershipEvent类的具体用法?Java BeanContextMembershipEvent怎么用?Java BeanContextMembershipEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeanContextMembershipEvent类属于java.beans.beancontext包,在下文中一共展示了BeanContextMembershipEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertEqualsSerially
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
private void assertEqualsSerially(BeanContextMembershipEvent orig,
BeanContextMembershipEvent ser) {
assertNull(ser.getSource());
// check propagatedFrom
if (orig.getPropagatedFrom() instanceof Serializable) {
BeanContext origFrom = orig.getPropagatedFrom();
BeanContext serFrom = ser.getPropagatedFrom();
assertEquals(origFrom.getClass(), serFrom.getClass());
if (origFrom instanceof MockBeanContextDelegateS) {
assertEquals(((MockBeanContextDelegateS) origFrom).id,
((MockBeanContextDelegateS) serFrom).id);
}
}
// check children
Collection origChildren = (Collection) Utils.getField(orig, "children");
Collection serChildren = (Collection) Utils.getField(ser, "children");
assertEquals(origChildren, serChildren);
}
示例2: assertMembershipEvent
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
private void assertMembershipEvent(BeanContextMembershipEvent evt,
BeanContext ctx, BeanContext pFrom, Object changes) {
assertSame(ctx, evt.getSource());
assertSame(ctx, evt.getBeanContext());
assertSame(pFrom, evt.getPropagatedFrom());
if (changes instanceof Collection) {
Collection changeCollection = (Collection) changes;
assertEquals(changeCollection.size(), evt.size());
for (Iterator iter = changeCollection.iterator(); iter.hasNext();) {
assertTrue(evt.contains(iter.next()));
}
} else {
assertEquals(1, evt.size());
assertTrue(evt.contains(changes));
}
}
示例3: testNullPointerException1
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* @see java.beans.beancontext.BeanContextMembershipEvent
*/
public Result testNullPointerException1() throws Exception {
context = new BeanContextSupport();
bean = new BeanContextChildSupport();
// Adding the component
context.add(bean);
Object[] array = null;
try {
event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
} catch (java.lang.NullPointerException e) {
return passed();
}
return failed("testNullPointerException1");
}
示例4: testNullPointerException2
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* @see java.beans.beancontext.BeanContextMembershipEvent
*/
public Result testNullPointerException2() throws Exception {
context = new BeanContextSupport();
bean = new BeanContextChildSupport();
// Adding the component
context.add(bean);
Collection[] array = null;
try {
event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
} catch (java.lang.NullPointerException e) {
return passed();
}
return failed("testNullPointerException2");
}
示例5: testContainsBeanContextMembershipEvent
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* @see java.beans.beancontext.BeanContextMembershipEvent#contains()
*/
public Result testContainsBeanContextMembershipEvent() throws Exception {
context = new BeanContextSupport();
bean = new BeanContextChildSupport();
sBean = new ServiceBean();
// Adding the component
context.add(bean);
context.add(sBean);
event = new BeanContextMembershipEvent(bean.getBeanContext(), context
.toArray());
if ((event.contains(sBean)) || !(event.contains(context)))
return passed();
else
return failed("testContainsBeanContextMembershipEvent");
}
示例6: testIteratorBeanContextMembershipEvent
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* @see java.beans.beancontext.BeanContextSupport#iterator()
*/
public Result testIteratorBeanContextMembershipEvent() throws Exception {
context = new BeanContextSupport();
bean = new BeanContextChildSupport();
sBean = new ServiceBean();
// Adding the component
context.add(bean);
context.add(sBean);
event = new BeanContextMembershipEvent(bean.getBeanContext(), context
.toArray());
if ((event.iterator() instanceof java.util.Iterator))
return passed();
else
return failed("testIteratorBeanContextMembershipEvent");
}
示例7: testSizeBeanContextMembershipEvent
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* @see java.beans.beancontext.BeanContextSupport#size()
*/
public Result testSizeBeanContextMembershipEvent() throws Exception {
context = new BeanContextSupport();
bean = new BeanContextChildSupport();
sBean = new ServiceBean();
// Adding the component
context.add(bean);
context.add(sBean);
event = new BeanContextMembershipEvent(bean.getBeanContext(), context
.toArray());
// System.out.println(event.size());
if (event.size() == 2)
return passed();
else
return failed("testSizeBeanContextMembershipEvent");
}
示例8: childrenAdded
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/** Listener method that is called when a bean is added to
* the bean context.
* @param bcme event describing the action
*/
public void childrenAdded (BeanContextMembershipEvent bcme) {
InstanceChildren bc = ref.get ();
if (bc != null) {
bc.updateKeys();
}
}
示例9: childrenRemoved
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/** Listener method that is called when a bean is removed to
* the bean context.
* @param bcme event describing the action
*/
public void childrenRemoved (BeanContextMembershipEvent bcme) {
InstanceChildren bc = ref.get ();
if (bc != null) {
bc.updateKeys ();
}
}
示例10: childrenRemoved
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/** Method for BeanContextMembership interface */
public void childrenRemoved(BeanContextMembershipEvent bcme) {
Iterator it = bcme.iterator();
while (it.hasNext()) {
findAndUndo(it.next());
}
}
示例11: childrenRemoved
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/**
* BeanContextMembershipListener method. Called when objects have been
* removed from the parent BeanContext. If the ToolPanel finds a Tool in the
* list, it removes it from the ToolPanel.
*
* @param bcme the event containing the iterator with removed objects.
*/
public void childrenRemoved(BeanContextMembershipEvent bcme) {
Iterator<Object> it = bcme.iterator();
Object someObj;
while (it.hasNext()) {
someObj = it.next();
if (someObj instanceof Tool) {
// do the initializing that need to be done here
Debug.message("toolpanel", "ToolPanel removing tool Object");
remove(((Tool) someObj).getKey());
}
}
}
示例12: testSerialization
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
public void testSerialization() throws IOException, ClassNotFoundException {
ArrayList<String> things = new ArrayList<String>();
things.add("1");
things.add("2");
things.add("3");
BeanContextMembershipEvent event = new BeanContextMembershipEvent(
new MockBeanContext(), things);
event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
assertEqualsSerially(event,
(BeanContextMembershipEvent) SerializationTester
.getDeserilizedObject(event));
}
示例13: testSerialization_Compatibility
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
ArrayList<String> things = new ArrayList<String>();
things.add("1");
things.add("2");
things.add("3");
BeanContextMembershipEvent event = new BeanContextMembershipEvent(
new MockBeanContext(), things);
event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
SerializationTest.verifyGolden(this, event, new SerializableAssert(){
public void assertDeserialized(Serializable orig, Serializable ser) {
assertEqualsSerially((BeanContextMembershipEvent) orig,
(BeanContextMembershipEvent) ser);
}
});
}
示例14: childrenAdded
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/** Listener method that is called when a bean is added to
* the bean context.
* @param bcme event describing the action
*/
public void childrenAdded (BeanContextMembershipEvent bcme) {
InstanceChildren bc = (InstanceChildren)ref.get ();
if (bc != null) {
bc.updateKeys();
}
}
示例15: childrenRemoved
import java.beans.beancontext.BeanContextMembershipEvent; //导入依赖的package包/类
/** Listener method that is called when a bean is removed to
* the bean context.
* @param bcme event describing the action
*/
public void childrenRemoved (BeanContextMembershipEvent bcme) {
InstanceChildren bc = (InstanceChildren)ref.get ();
if (bc != null) {
bc.updateKeys ();
}
}