}
public void testIntrospector() throws Exception {
//SimpleLog log = new SimpleLog("testIntrospector:introspector");
//log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
XMLIntrospector introspector = new XMLIntrospector();
//introspector.setLog(log);
introspector.setAttributesForPrimitives(true);
Object bean = createBean();
XMLBeanInfo info = introspector.introspect( bean );
assertTrue( "Found XMLBeanInfo", info != null );
ElementDescriptor descriptor = info.getElementDescriptor();
assertTrue( "Found root element descriptor", descriptor != null );
AttributeDescriptor[] attributes = descriptor.getAttributeDescriptors();
assertTrue( "Found attributes", attributes != null && attributes.length > 0 );
// test second introspection with caching on
info = introspector.introspect( bean );
assertTrue( "Found XMLBeanInfo", info != null );
descriptor = info.getElementDescriptor();
assertTrue( "Found root element descriptor", descriptor != null );
attributes = descriptor.getAttributeDescriptors();
assertTrue( "Found attributes", attributes != null && attributes.length > 0 );
// test introspection with caching off
//introspector.setCachingEnabled(false);
introspector.setRegistry(new NoCacheRegistry());
info = introspector.introspect( bean );
assertTrue( "Found XMLBeanInfo", info != null );
descriptor = info.getElementDescriptor();
assertTrue( "Found root element descriptor", descriptor != null );
attributes = descriptor.getAttributeDescriptors();
assertTrue( "Found attributes", attributes != null && attributes.length > 0 );
// test introspection after flushing cache
// introspector.setCachingEnabled(true);
introspector.setRegistry(new DefaultXMLBeanInfoRegistry());
//introspector.flushCache();
info = introspector.introspect( bean );
assertTrue( "Found XMLBeanInfo", info != null );
descriptor = info.getElementDescriptor();