How to finish the java constructor throw Exception test?
nuohe 2009-08-19 11:27:32
Test case:
Verify Instance Creation through Constructor DeviceBeanInfo is failed
Summary: Verify Instance Creation through Constructor DeviceBeanInfo is failed
Preconditions: No Preconditions .
Steps:Invoke constructor DeviceBeanInfo .
Expected Results:on invalid operation it should throw IntrospectionException
The testing class:
import java.awt.Image;
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.MethodDescriptor;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.ziptie.addressing.IPAddress;
import com.alterpoint.aof.util.AofBeanInfo;
import com.alterpoint.aof.util.AofPropertyDescriptor;
import com.alterpoint.server.BootActiveStatus;
import com.alterpoint.server.plugin.compliance.status.ComplianceStatus;
/**
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DeviceBeanInfo extends AofBeanInfo
{
protected BeanDescriptor bd = new BeanDescriptor(com.alterpoint.aof.objects.cm.Device.class);
/** Constructor for the CardBeanInfo object */
public DeviceBeanInfo() throws java.beans.IntrospectionException
{
// setup bean descriptor in constructor.
BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass());
String order = info.getBeanDescriptor().getValue("propertyorder") == null ? "" : (String) info.getBeanDescriptor().getValue("propertyorder");
PropertyDescriptor[] pd = getPropertyDescriptors();
for (int i = 0; i != pd.length; i++)
{
if (order.indexOf(pd[i].getName()) == -1)
{
order = order + (order.length() == 0 ? "" : ":") + pd[i].getName();
}
}
getBeanDescriptor().setValue("propertyorder", order);
}
public BeanDescriptor getBeanDescriptor()
{
return this.bd;
}
}
when i attempted to code the test-case, i found that only the block of code "Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass());" would throw the excepted Exception. How do i finish the test case without changing the construtor's code?