use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedWriteMethod_InvalidIndexType.
public void testSetIndexedWriteMethod_InvalidIndexType() throws IntrospectionException, NoSuchMethodException, NoSuchMethodException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String[].class });
Method indexedReadMethod = beanClass.getMethod("get" + propertyName, new Class[] { Integer.TYPE });
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, null);
assertNull(ipd.getIndexedWriteMethod());
Method badArgType = beanClass.getMethod("setPropertyFourInvalid2", new Class[] { String.class, String.class });
try {
ipd.setIndexedWriteMethod(badArgType);
fail("Should throw IntrospectionException");
} catch (IntrospectionException e) {
}
ipd = new IndexedPropertyDescriptor("data", NormalBean.class);
ipd.setIndexedReadMethod(null);
try {
ipd.setIndexedWriteMethod(NormalBean.class.getMethod("setData", Integer.TYPE, Integer.TYPE));
fail("should throw IntrospectionException");
} catch (IntrospectionException e) {
// expected
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidReturn.
/*
* indexed read method with void return.
*/
public void testSetIndexedReadMethod_RInvalidReturn() throws SecurityException, NoSuchMethodException, IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String[].class });
Method indexedReadMethod = beanClass.getMethod("get" + propertyName, new Class[] { Integer.TYPE });
Method indexedWriteMethod = beanClass.getMethod("set" + propertyName, new Class[] { Integer.TYPE, String.class });
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
Method voidMethod = beanClass.getMethod("getPropertyFourInvalid", new Class[] { Integer.TYPE });
try {
ipd.setIndexedReadMethod(voidMethod);
fail("Should throw IntrospectionException.");
} catch (IntrospectionException e) {
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IntrospectionExceptionTest method testIntrospectionExceptionMessage.
public void testIntrospectionExceptionMessage() {
// Regression for HARMONY-235
IntrospectionException e = new IntrospectionException("test message");
assertEquals("test message", e.getMessage());
}
use of java.beans.IntrospectionException in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringStringString.
/*
* Class under test for void EventSetDescriptor(Class, String, Class,
* String[], String, String, String)
*/
public void testEventSetDescriptorClassStringClassStringArrayStringStringString() throws IntrospectionException {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2" };
String addMethod = "addMockPropertyChangeListener";
String removeMethod = "removeMockPropertyChangeListener";
String getMethod = "getMockPropertyChangeListener";
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod, getMethod);
assertEquals(addMethod, esd.getAddListenerMethod().getName());
assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
assertNull(esd.getGetListenerMethod());
assertEquals(2, esd.getListenerMethods().length);
assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0].getName());
assertEquals(listenerMethodNames[1], esd.getListenerMethods()[1].getName());
assertEquals(2, esd.getListenerMethodDescriptors().length);
assertEquals(listenerMethodNames[0], esd.getListenerMethodDescriptors()[0].getMethod().getName());
assertEquals(listenerMethodNames[1], esd.getListenerMethodDescriptors()[1].getMethod().getName());
assertEquals(listenerType, esd.getListenerType());
assertTrue(esd.isInDefaultEventSet());
assertFalse(esd.isUnicast());
// Regression for HARMONY-1237
try {
new EventSetDescriptor(Thread.class, "0xABCD", Thread.class, new String[] {}, "aaa", null, "bbb");
fail("IntrospectionException expected");
} catch (IntrospectionException e) {
// expected
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString.
/*
* Class under test for void IndexedPropertyDescriptor(String, Class,
* String, String, String, String)
*/
public void testIndexedPropertyDescriptorStringClassStringStringStringString() throws IntrospectionException, SecurityException, NoSuchMethodException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "set" + propertyName);
Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String[].class });
Method indexedReadMethod = beanClass.getMethod("get" + propertyName, new Class[] { Integer.TYPE });
Method indexedWriteMethod = beanClass.getMethod("set" + propertyName, new Class[] { Integer.TYPE, String.class });
assertEquals(readMethod, ipd.getReadMethod());
assertEquals(writeMethod, ipd.getWriteMethod());
assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
assertEquals(String[].class, ipd.getPropertyType());
assertEquals(String.class, ipd.getIndexedPropertyType());
assertFalse(ipd.isBound());
assertFalse(ipd.isConstrained());
assertEquals(propertyName, ipd.getDisplayName());
assertEquals(propertyName, ipd.getName());
assertEquals(propertyName, ipd.getShortDescription());
assertNotNull(ipd.attributeNames());
assertFalse(ipd.isExpert());
assertFalse(ipd.isHidden());
assertFalse(ipd.isPreferred());
//empty method name
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "", "set" + propertyName);
try {
new IndexedPropertyDescriptor("a", MyClass.class, "getA", "setA", "", "setA");
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "", "set" + propertyName, "get" + propertyName, "set" + propertyName);
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "", "get" + propertyName, "set" + propertyName);
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "");
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
//null method name
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, null, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, null, "set" + propertyName, "get" + propertyName, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, null, "get" + propertyName, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, null);
}
Aggregations