### Question:
ReflectionHelper { public static PropertyAccessor getAccessor(Class<?> clazz, String propertyName) throws ReflectiveOperationException { if (propertyName == null || propertyName.length() == 0) { throw new IllegalArgumentException("Property name cannot be null or empty"); } if (propertyName.indexOf('.') != -1) { throw new IllegalArgumentException("The argument cannot be a nested property name"); } String propertyNameSuffix = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); Class<?> c = clazz; while (c != null) { PropertyAccessor m = getAccessor(c, propertyName, propertyNameSuffix); if (m != null) { return m; } c = c.getSuperclass(); } throw new ReflectiveOperationException("Property not found: " + propertyName); } private  ReflectionHelper(); static PropertyAccessor getAccessor(Class<?> clazz, String propertyName);  }### Answer:
@Test public void testGetSimpleProperty() throws Exception { assertEquals(int.class, ReflectionHelper.getAccessor(Base.class, "prop1").getPropertyType()); assertEquals(float.class, ReflectionHelper.getAccessor(Base.class, "prop2").getPropertyType()); }
@Test public void testPropertyNotFound() throws Exception { expectedException.expect(ReflectiveOperationException.class); expectedException.expectMessage("Property not found: unknown"); ReflectionHelper.getAccessor(Base.class, "unknown"); }
@Test public void testGetNestedProperty() throws Exception { ReflectionHelper.PropertyAccessor prop3 = ReflectionHelper.getAccessor(Base.class, "prop3"); assertEquals(Base.class, prop3.getPropertyType()); assertEquals(int.class, prop3.getAccessor("prop1").getPropertyType()); }
@Test public void testGetMultipleProperty() throws Exception { assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "array").getPropertyType()); assertEquals(Float.class, ReflectionHelper.getAccessor(A.class, "array2").getPropertyType()); assertEquals(float.class, ReflectionHelper.getAccessor(A.class, "array3").getPropertyType()); assertEquals(Collection.class, ReflectionHelper.getAccessor(A.class, "array4").getPropertyType()); assertEquals(Integer.class, ReflectionHelper.getAccessor(A.class, "list").getPropertyType()); assertEquals(List.class, ReflectionHelper.getAccessor(A.class, "list2").getPropertyType()); assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "list3").getPropertyType()); assertEquals(Integer.class, ReflectionHelper.getAccessor(A.class, "map").getPropertyType()); assertEquals(Base.class, ReflectionHelper.getAccessor(A.class, "map2").getPropertyType()); assertEquals(Long.class, ReflectionHelper.getAccessor(A.class, "y").getPropertyType()); assertEquals(Long.class, ReflectionHelper.getAccessor(A.class, "z").getPropertyType()); assertEquals(Double.class, ReflectionHelper.getAccessor(A.class, "q").getPropertyType()); assertEquals(Double.class, ReflectionHelper.getAccessor(A.class, "w").getPropertyType()); }