Search in sources :

Example 1 with ParameterDescriptor

use of java.beans.ParameterDescriptor in project j2objc by google.

the class MethodDescriptorTest method testMethodDescriptorMethodParameterDescriptorArray_MethodNull.

public void testMethodDescriptorMethodParameterDescriptorArray_MethodNull() {
    Method method = null;
    ParameterDescriptor[] pds = new ParameterDescriptor[1];
    pds[0] = new ParameterDescriptor();
    try {
        new MethodDescriptor(method, pds);
        fail("Should throw NullPointerException.");
    } catch (NullPointerException e) {
    }
}
Also used : ParameterDescriptor(java.beans.ParameterDescriptor) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor)

Example 2 with ParameterDescriptor

use of java.beans.ParameterDescriptor in project jdk8u_jdk by JetBrains.

the class Test8005065 method testMethodDescriptor.

private static void testMethodDescriptor() {
    try {
        ParameterDescriptor[] array = { new ParameterDescriptor() };
        MethodDescriptor descriptor = new MethodDescriptor(MyDPD.class.getMethod("getArray"), array);
        test(descriptor.getParameterDescriptors());
        array[0] = null;
        test(descriptor.getParameterDescriptors());
        descriptor.getParameterDescriptors()[0] = null;
        test(descriptor.getParameterDescriptors());
    } catch (Exception exception) {
        throw new Error("unexpected error", exception);
    }
}
Also used : ParameterDescriptor(java.beans.ParameterDescriptor) MethodDescriptor(java.beans.MethodDescriptor)

Example 3 with ParameterDescriptor

use of java.beans.ParameterDescriptor in project j2objc by google.

the class MethodDescriptorTest method testMethodDescriptorMethodParameterDescriptorArray.

/*
     * Class under test for void MethodDescriptor(Method, ParameterDescriptor[])
     */
public void testMethodDescriptorMethodParameterDescriptorArray() throws SecurityException, NoSuchMethodException {
    String beanName = "MethodDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Method method = bean.getClass().getMethod("setPropertyOne", new Class[] { String.class });
    ParameterDescriptor[] pds = new ParameterDescriptor[1];
    pds[0] = new ParameterDescriptor();
    pds[0].setValue(method.getName(), method.getReturnType());
    MethodDescriptor md = new MethodDescriptor(method, pds);
    assertSame(method, md.getMethod());
    assertSame(pds, md.getParameterDescriptors());
    assertEquals(pds[0].getValue(method.getName()), md.getParameterDescriptors()[0].getValue(method.getName()));
    assertEquals(method.getName(), md.getDisplayName());
    assertEquals(method.getName(), md.getName());
    assertEquals(method.getName(), md.getShortDescription());
    assertNotNull(md.attributeNames());
    assertFalse(md.isExpert());
    assertFalse(md.isHidden());
    assertFalse(md.isPreferred());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) ParameterDescriptor(java.beans.ParameterDescriptor) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor)

Example 4 with ParameterDescriptor

use of java.beans.ParameterDescriptor in project j2objc by google.

the class ParameterDescriptorTest method testParameterDescriptor.

public void testParameterDescriptor() {
    ParameterDescriptor pd = new ParameterDescriptor();
    assertNull(pd.getDisplayName());
    assertNull(pd.getName());
    assertNull(pd.getShortDescription());
    assertNotNull(pd.attributeNames());
    assertFalse(pd.isExpert());
    assertFalse(pd.isHidden());
    assertFalse(pd.isPreferred());
}
Also used : ParameterDescriptor(java.beans.ParameterDescriptor)

Example 5 with ParameterDescriptor

use of java.beans.ParameterDescriptor in project jdk8u_jdk by JetBrains.

the class Test4498236 method main.

public static void main(String[] args) throws Exception {
    PropertyChangeEvent event = new PropertyChangeEvent("source", null, null, null);
    event.setPropagationId("id");
    test("[propertyName=null; oldValue=null; newValue=null; propagationId=id; source=source]", event);
    test("[propertyName=name; oldValue=old; newValue=new; propagationId=null; source=source]", new PropertyChangeEvent("source", "name", "old", "new"));
    test("[propertyName=array; index=5; oldValue=old; newValue=new; propagationId=null; source=source]", new IndexedPropertyChangeEvent("source", "array", "old", "new", 5));
    FeatureDescriptor fd = new FeatureDescriptor();
    fd.setName("n");
    fd.setDisplayName("dn");
    fd.setShortDescription("sd");
    fd.setPreferred(true);
    fd.setHidden(true);
    fd.setExpert(true);
    fd.setValue("first", "value");
    test("[name=n; displayName=dn; shortDescription=sd; preferred; hidden; expert; values={first=value}]", fd);
    test("[name=String; beanClass=class java.lang.String]", new BeanDescriptor(String.class));
    test("[name=Object; beanClass=class java.lang.Object; customizerClass=class java.lang.String]", new BeanDescriptor(Object.class, String.class));
    test("[name=Object; beanClass=class java.lang.Object; customizerClass=class java.lang.String]", new BeanDescriptor(Object.class, String.class));
    test("[name=equals; method=public boolean java.lang.Object.equals(java.lang.Object)]", new MethodDescriptor(Object.class.getMethod("equals", Object.class)));
    test("[name=equals; method=public boolean java.lang.Object.equals(java.lang.Object); parameterDescriptors={java.beans.ParameterDescriptor[name=null]}]", new MethodDescriptor(Object.class.getMethod("equals", Object.class), new ParameterDescriptor[] { new ParameterDescriptor() }));
    Class type = KeyListener.class;
    String[] names = { "keyTyped", "keyPressed", "keyReleased" };
    Method[] methods = new Method[names.length];
    for (int i = 0; i < names.length; i++) {
        methods[i] = type.getMethod(names[i], KeyEvent.class);
    }
    test("[name=key; inDefaultEventSet; listenerType=interface java.awt.event.KeyListener; getListenerMethod=public java.awt.event.KeyListener Test4498236.getKeyListeners(); addListenerMethod=public void Test4498236.addKeyListener(java.awt.event.KeyListener); removeListenerMethod=public void Test4498236.removeKeyListener(java.awt.event.KeyListener)]", new EventSetDescriptor(Test4498236.class, "key", type, names[0]));
    test("[name=$$$; inDefaultEventSet; listenerType=interface java.awt.event.KeyListener; addListenerMethod=public void Test4498236.add(java.awt.event.KeyListener); removeListenerMethod=public void Test4498236.remove(java.awt.event.KeyListener)]", new EventSetDescriptor(Test4498236.class, "$$$", type, names, "add", "remove"));
    test("[name=$$$; inDefaultEventSet; listenerType=interface java.awt.event.KeyListener; getListenerMethod=public java.awt.event.KeyListener Test4498236.get(); addListenerMethod=public void Test4498236.add(java.awt.event.KeyListener); removeListenerMethod=public void Test4498236.remove(java.awt.event.KeyListener)]", new EventSetDescriptor(Test4498236.class, "$$$", type, names, "add", "remove", "get"));
    test("[name=$$$; inDefaultEventSet; listenerType=interface java.awt.event.KeyListener; addListenerMethod=public void Test4498236.add(java.awt.event.KeyListener); removeListenerMethod=public void Test4498236.remove(java.awt.event.KeyListener)]", new EventSetDescriptor("$$$", type, methods, Test4498236.class.getMethod("add", type), Test4498236.class.getMethod("remove", type)));
    test("[name=$$$; inDefaultEventSet; listenerType=interface java.awt.event.KeyListener; getListenerMethod=public java.awt.event.KeyListener Test4498236.get(); addListenerMethod=public void Test4498236.add(java.awt.event.KeyListener); removeListenerMethod=public void Test4498236.remove(java.awt.event.KeyListener)]", new EventSetDescriptor("$$$", type, methods, Test4498236.class.getMethod("add", type), Test4498236.class.getMethod("remove", type), Test4498236.class.getMethod("get")));
    test("[name=value; propertyType=boolean; readMethod=public boolean Test4498236.isValue(); writeMethod=public void Test4498236.setValue(boolean)]", new PropertyDescriptor("value", Test4498236.class));
    test("[name=$$$]", new PropertyDescriptor("$$$", Test4498236.class, null, null));
    test("[name=$$$; propertyType=boolean; readMethod=public boolean Test4498236.getValue()]", new PropertyDescriptor("$$$", Test4498236.class, "getValue", null));
    test("[name=$$$; propertyType=boolean; readMethod=public boolean Test4498236.getValue(); writeMethod=public void Test4498236.setValue(boolean)]", new PropertyDescriptor("$$$", Test4498236.class, "getValue", "setValue"));
    test("[name=$$$]", new PropertyDescriptor("$$$", null, null));
    test("[name=$$$; propertyType=boolean; readMethod=public boolean Test4498236.getValue()]", new PropertyDescriptor("$$$", Test4498236.class.getMethod("getValue"), null));
    test("[name=$$$; propertyType=boolean; readMethod=public boolean Test4498236.getValue(); writeMethod=public void Test4498236.setValue(boolean)]", new PropertyDescriptor("$$$", Test4498236.class.getMethod("getValue"), Test4498236.class.getMethod("setValue", boolean.class)));
    test("[name=index; propertyType=class [I; readMethod=public int[] Test4498236.getIndex(); writeMethod=public void Test4498236.setIndex(int[]); indexedPropertyType=int; indexedReadMethod=public int Test4498236.getIndex(int); indexedWriteMethod=public void Test4498236.setIndex(int,int)]", new IndexedPropertyDescriptor("index", Test4498236.class));
    test("[name=$$$; propertyType=class [I; readMethod=public int[] Test4498236.getIndex(); writeMethod=public void Test4498236.setIndex(int[]); indexedPropertyType=int; indexedReadMethod=public int Test4498236.getIndex(int); indexedWriteMethod=public void Test4498236.setIndex(int,int)]", new IndexedPropertyDescriptor("$$$", Test4498236.class, "getIndex", "setIndex", "getIndex", "setIndex"));
    test("[name=$$$; propertyType=class [I; readMethod=public int[] Test4498236.getIndex(); writeMethod=public void Test4498236.setIndex(int[]); indexedPropertyType=int; indexedReadMethod=public int Test4498236.getIndex(int); indexedWriteMethod=public void Test4498236.setIndex(int,int)]", new IndexedPropertyDescriptor("$$$", Test4498236.class.getMethod("getIndex"), Test4498236.class.getMethod("setIndex", new int[0].getClass()), Test4498236.class.getMethod("getIndex", int.class), Test4498236.class.getMethod("setIndex", int.class, int.class)));
}
Also used : IndexedPropertyChangeEvent(java.beans.IndexedPropertyChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyDescriptor(java.beans.PropertyDescriptor) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) ParameterDescriptor(java.beans.ParameterDescriptor) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor) EventSetDescriptor(java.beans.EventSetDescriptor) KeyEvent(java.awt.event.KeyEvent) FeatureDescriptor(java.beans.FeatureDescriptor) BeanDescriptor(java.beans.BeanDescriptor) IndexedPropertyChangeEvent(java.beans.IndexedPropertyChangeEvent) KeyListener(java.awt.event.KeyListener) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor)

Aggregations

ParameterDescriptor (java.beans.ParameterDescriptor)5 MethodDescriptor (java.beans.MethodDescriptor)4 Method (java.lang.reflect.Method)3 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 BeanDescriptor (java.beans.BeanDescriptor)1 EventSetDescriptor (java.beans.EventSetDescriptor)1 FeatureDescriptor (java.beans.FeatureDescriptor)1 IndexedPropertyChangeEvent (java.beans.IndexedPropertyChangeEvent)1 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)1