assertNotNull("ClassLoader is null", loader);
assertNotNull("BeanClass is null", beanClass);
assertNotSame("ClassLoaders should be different..", getClass().getClassLoader(), beanClass.getClassLoader());
assertSame("BeanClass ClassLoader incorrect", beanClass.getClassLoader(), loader);
MappedPropertyDescriptor descriptor = new MappedPropertyDescriptor("mappedProperty", beanClass);
assertNotNull("1-Read Method null", descriptor.getMappedReadMethod());
assertNotNull("1-Write Method null", descriptor.getMappedWriteMethod());
assertEquals("1-Read Method name", "getMappedProperty", descriptor.getMappedReadMethod().getName());
assertEquals("1-Read Write name", "setMappedProperty", descriptor.getMappedWriteMethod().getName());
// this should make the reference go away.
loader = null;
beanClass = null;
bean = null;
forceGarbageCollection(); /* Try to force the garbage collector to run by filling up memory */
// The aim of this test is to check the functinality in MappedPropertyDescriptor which
// re-creates the Method references after they have been garbage collected. However theres no
// way of knowing the method references were garbage collected and that code was run, except by
// un-commeting the System.out statement in MappedPropertyDescriptor's MappedMethodReference's
// get() method.
assertNotNull("1-Read Method null", descriptor.getMappedReadMethod());
assertNotNull("1-Write Method null", descriptor.getMappedWriteMethod());
assertEquals("1-Read Method name", "getMappedProperty", descriptor.getMappedReadMethod().getName());
assertEquals("1-Read Write name", "setMappedProperty", descriptor.getMappedWriteMethod().getName());
// Clear All BeanUtils caches after the test
clearAllBeanUtilsCaches();
}