Index: modules/beans/src/test/java/org/apache/harmony/tests/beans/PropertyDescriptorTest.java =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ modules/beans/src/test/java/org/apache/harmony/tests/beans/PropertyDescriptorTest.java 2006-03-22 19:45:39.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.tests.beans; + +import junit.framework.TestCase; +import java.beans.PropertyDescriptor; +import java.beans.IntrospectionException; + +public class PropertyDescriptorTest extends TestCase { + + public void testIntrospectionExpections() { + try { + PropertyDescriptor pd = new PropertyDescriptor(null,null); + fail("Constructor PropertyDescriptor(null,null) should "+ + "throw IntrospectionException"); + } catch (IntrospectionException e) { + assertEquals("Target Bean class is null", e.getMessage()); + } + try { + PropertyDescriptor pd = new PropertyDescriptor(null,String.class); + fail("Constructor PropertyDescriptor(null,String.class) should "+ + "throw IntrospectionException"); + } catch (IntrospectionException e) { + assertEquals("bad property name", e.getMessage()); + } + try { + PropertyDescriptor pd = new PropertyDescriptor(null,null,null,null); + fail("Constructor PropertyDescriptor(null,null,null,null) should "+ + "throw IntrospectionException"); + } catch (IntrospectionException e) { + assertEquals("Target Bean class is null", e.getMessage()); + } + try { + PropertyDescriptor pd = + new PropertyDescriptor(null,String.class,null,null); + fail("Constructor "+ + "PropertyDescriptor(null,String.class,null,null) should "+ + "throw IntrospectionException"); + } catch (IntrospectionException e) { + assertEquals("bad property name", e.getMessage()); + } + try { + PropertyDescriptor pd = new PropertyDescriptor(null,null,null); + fail("Constructor PropertyDescriptor(null,null,null) should "+ + "throw IntrospectionException"); + } catch (IntrospectionException e) { + assertEquals("bad property name", e.getMessage()); + } + } + +} Index: modules/beans/src/main/java/java/beans/PropertyDescriptor.java =================================================================== --- modules/beans/src/main/java/java/beans/PropertyDescriptor.java.orig 2006-03-22 18:10:23.000000000 +0000 +++ modules/beans/src/main/java/java/beans/PropertyDescriptor.java 2006-03-22 19:37:02.000000000 +0000 @@ -51,6 +51,10 @@ String getterName, String setterName) throws IntrospectionException { super(); + if (beanClass == null) + throw new IntrospectionException("Target Bean class is null"); + if (propertyName == null) + throw new IntrospectionException("bad property name"); this.beanClass = beanClass; this.propertyName = propertyName; @@ -67,6 +71,8 @@ public PropertyDescriptor(String propertyName, Method getter, Method setter) throws IntrospectionException { super(); + if (propertyName == null) + throw new IntrospectionException("bad property name"); this.propertyName = propertyName; this.setName(propertyName); @@ -82,6 +88,10 @@ public PropertyDescriptor(String propertyName, Class beanClass) throws IntrospectionException { super(); + if (beanClass == null) + throw new IntrospectionException("Target Bean class is null"); + if (propertyName == null) + throw new IntrospectionException("bad property name"); this.propertyName = propertyName; this.setName(propertyName);