Java Code Examples for org.apache.velocity.util.introspection.Uberspect#getPropertyGet()

The following examples show how to use org.apache.velocity.util.introspection.Uberspect#getPropertyGet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UberspectorTestCase.java    From velocity-engine with Apache License 2.0 6 votes vote down vote up
public void testNullPropertyGetter()
    throws Exception
{
    Uberspect u = ri.getUberspect();
    GetPutObject gpo = new GetPutObject();
    Map map = new HashMap();

    VelPropertyGet getter = u.getPropertyGet(gpo, null, null);

    // Don't screw up on null properties. That should map to get() on the GPO.
    assertNotNull(getter);
    assertEquals("Found wrong method", "get", getter.getMethodName());

    // And should be null on a Map which does not have a get()
    getter = u.getPropertyGet(map, null, null);
    assertNull(getter);

}
 
Example 2
Source File: UberspectorTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void testNullObjects()
        throws Exception
{
    // How about some null objects... Gee, I'm mean. ;-)
    Uberspect u = ri.getUberspect();

    VelPropertyGet getter = u.getPropertyGet(null, "foo", null);
    assertNull(getter);

    VelPropertySet setter = u.getPropertySet(null, "foo", Object.class, null);
    assertNull(setter);
}
 
Example 3
Source File: UberspectorTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void testEmptyPropertyGetter()
        throws Exception
{
    Uberspect u = ri.getUberspect();
    Map map = new HashMap();

    VelPropertyGet getter = u.getPropertyGet(map, "", null);

    // Don't screw up on empty properties. That should map to get("")
    assertNotNull(getter);
    assertEquals("Found wrong method", "get", getter.getMethodName());
}
 
Example 4
Source File: UberspectorTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void testRegularGetters()
        throws Exception
{
    VelPropertyGet getter;

    Uberspect u = ri.getUberspect();
    UberspectorTestObject uto = new UberspectorTestObject();

    // getRegular()
    getter = u.getPropertyGet(uto, "Regular", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "getRegular", getter.getMethodName());

    // Lowercase regular
    getter = u.getPropertyGet(uto, "regular", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "getRegular", getter.getMethodName());

    // lowercase: getpremium()
    getter = u.getPropertyGet(uto, "premium", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "getpremium", getter.getMethodName());

    // test uppercase: getpremium()
    getter = u.getPropertyGet(uto, "Premium", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "getpremium", getter.getMethodName());
}
 
Example 5
Source File: UberspectorTestCase.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
public void testBooleanGetters()
        throws Exception
{
    VelPropertyGet getter;

    Uberspect u = ri.getUberspect();
    UberspectorTestObject uto = new UberspectorTestObject();

    // getRegular()
    getter = u.getPropertyGet(uto, "RegularBool", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "isRegularBool", getter.getMethodName());

    // Lowercase regular
    getter = u.getPropertyGet(uto, "regularBool", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "isRegularBool", getter.getMethodName());

    // lowercase: getpremiumBool()
    getter = u.getPropertyGet(uto, "premiumBool", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "ispremiumBool", getter.getMethodName());

    // test uppercase: ()
    getter = u.getPropertyGet(uto, "PremiumBool", null);
    assertNotNull(getter);
    assertEquals("Found wrong method", "ispremiumBool", getter.getMethodName());
}