### Question:
ClassHelper { public static Class<?> getRealClassFromClass(Class<?> cls) { return getRealClassFromClass(null, cls); } protected  ClassHelper(); static Class<?> getRealClass(Object o); static Class<?> getRealClassFromClass(Class<?> cls); static Class<?> getRealClassFromClass(Bus bus, Class<?> cls); static Object getRealObject(Object o); static Class<?> getRealClass(Bus bus, Object o); static final String USE_DEFAULT_CLASS_HELPER; }### Answer:
@Test public void getRealClassFromClassPropertyWasSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(true); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(proxiedObject.getClass(), ClassHelper.getRealClassFromClass(proxiedObject.getClass())); EasyMock.verify(bus); }
@Test public void getRealClassFromClassPropertyWasNotSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(false); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(realObjectInternalSpring.getClass(), ClassHelper.getRealClassFromClass(springAopObject.getClass())); EasyMock.verify(bus); }
@Test public void getRealLambdaClassFromClassPropertyWasSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(true); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(fn.getClass(), ClassHelper.getRealClassFromClass(fn.getClass())); EasyMock.verify(bus); }
@Test public void getRealLambdaClassFromClassPropertyWasNotSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(false); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(fn.getClass(), ClassHelper.getRealClassFromClass(fn.getClass())); EasyMock.verify(bus); }
@Test public void getRealCglibClassFromClassPropertyWasNotSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(false); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(Object.class, ClassHelper.getRealClassFromClass(cglibProxyObject.getClass())); EasyMock.verify(bus); }
@Test public void getRealCglibClassFromClassPropertyWasSetInBus() { EasyMock.expect(bus.getProperty(ClassHelper.USE_DEFAULT_CLASS_HELPER)).andReturn(true); EasyMock.expect(bus.getProperty(ClassUnwrapper.class.getName())).andReturn(null); EasyMock.replay(bus); assertSame(cglibProxyObject.getClass(), ClassHelper.getRealClassFromClass(cglibProxyObject.getClass())); EasyMock.verify(bus); }