Java Code Examples for java.beans.EventSetDescriptor#setInDefaultEventSet()

The following examples show how to use java.beans.EventSetDescriptor#setInDefaultEventSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetInDefaultEventSet() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    MockPropertyChangeEvent.class),
            listenerType.getMethod("mockPropertyChange2",
                    MockPropertyChangeEvent.class) };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener", listenerType);
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener", listenerType);

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    esd.setInDefaultEventSet(true);
    assertTrue(esd.isInDefaultEventSet());
}
 
Example 2
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetInDefaultEventSet_false() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    new Class[] { MockPropertyChangeEvent.class }),
            listenerType.getMethod("mockPropertyChange2",
                    new Class[] { MockPropertyChangeEvent.class }), };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener", new Class[] { listenerType });
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener",
            new Class[] { listenerType });

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    assertTrue(esd.isInDefaultEventSet());
    esd.setInDefaultEventSet(false);
    assertFalse(esd.isInDefaultEventSet());
}
 
Example 3
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetUnicast() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    new Class[] { MockPropertyChangeEvent.class }),
            listenerType.getMethod("mockPropertyChange2",
                    new Class[] { MockPropertyChangeEvent.class }), };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener", new Class[] { listenerType });
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener",
            new Class[] { listenerType });

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    assertFalse(esd.isUnicast());
    esd.setInDefaultEventSet(true);
    assertTrue(esd.isInDefaultEventSet());
}
 
Example 4
Source File: EventSetDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetUnicast_false() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String eventSetName = "MockPropertyChange";
    Class<?> listenerType = MockPropertyChangeListener.class;
    Method[] listenerMethods = {
            listenerType.getMethod("mockPropertyChange",
                    MockPropertyChangeEvent.class),
            listenerType.getMethod("mockPropertyChange2",
                    MockPropertyChangeEvent.class) };
    MethodDescriptor[] listenerMethodDescriptors = {
            new MethodDescriptor(listenerMethods[0]),
            new MethodDescriptor(listenerMethods[1]), };
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Method addMethod = sourceClass.getMethod(
            "addMockPropertyChangeListener",listenerType);
    Method removeMethod = sourceClass.getMethod(
            "removeMockPropertyChangeListener", listenerType);

    EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
            listenerType, listenerMethodDescriptors, addMethod,
            removeMethod);
    assertFalse(esd.isUnicast());
    esd.setInDefaultEventSet(false);
    assertFalse(esd.isInDefaultEventSet());
}