"Nathan Bubna" <[EMAIL PROTECTED]> writes:

>Henning,  this seems wrong to me.  How could a null or empty property
>be represented in a template?  Are we just testing bizarre manual use
>of the Uberspect here?

Yes I am. I'm trying to trick this bugger into corner cases to make
sure that no malicious attacker can.

        Best regards
                Henning


>On 9/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Author: henning
>> Date: Wed Sep  6 07:28:19 2006
>> New Revision: 440723
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=440723
>> Log:
>> Let's start slow. Just check for empty and null properties. Where does
>> that get mapped to?
>>
>>
>> Added:
>>     
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>>    (with props)
>> Modified:
>>     
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
>>
>> Modified: 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
>> URL: 
>> http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java?view=diff&rev=440723&r1=440722&r2=440723
>> ==============================================================================
>> --- 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
>>  (original)
>> +++ 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/UberspectorTestCase.java
>>  Wed Sep  6 07:28:19 2006
>> @@ -7,7 +7,10 @@
>>  import junit.framework.TestSuite;
>>
>>  import org.apache.velocity.runtime.RuntimeInstance;
>> +import org.apache.velocity.test.misc.GetPutObject;
>>  import org.apache.velocity.util.introspection.Uberspect;
>> +import org.apache.velocity.util.introspection.VelPropertyGet;
>> +import org.apache.velocity.util.introspection.VelPropertySet;
>>
>>  /*
>>   * Copyright 2006 The Apache Software Foundation.
>> @@ -47,28 +50,57 @@
>>          ri.init();
>>      }
>>
>> -    public void testEmptyProperties()
>> +    public void testEmptyPropertyGetter()
>>              throws Exception
>>      {
>>          Uberspect u = ri.getUberspect();
>>          Map map = new HashMap();
>>
>> -        // Don't screw up on empty propeties. That should map to 
>> get(Object) and put(Object, Object) on a Map
>> -        assertNotNull(u.getPropertyGet(map, "", null));
>> -        assertNotNull(u.getPropertySet(map, "", Object.class, null));
>> +        VelPropertyGet getter = u.getPropertyGet(map, "", null);
>> +
>> +        // Don't screw up on empty properties. That should map to 
>> get(Object)
>> +        assertNotNull(getter);
>> +        assertEquals("Found wrong method", "get", getter.getMethodName());
>>      }
>> -
>> -    public void testNullProperties()
>> -        throws Exception
>> +
>> +    public void testEmptyPropertySetter()
>> +            throws Exception
>>      {
>>          Uberspect u = ri.getUberspect();
>>          Map map = new HashMap();
>>
>> -        // Don't screw up on null propeties. That should map to get(Object) 
>> and put(Object, Object) on a Map, too?
>> -        assertNotNull(u.getPropertyGet(map, null, null));
>> -        assertNotNull(u.getPropertySet(map, null, Object.class, null));
>> +        VelPropertySet setter = u.getPropertySet(map, "", Object.class, 
>> null);
>> +
>> +        // Don't screw up on empty properties. That should map to 
>> put(Object, Object)
>> +        assertNotNull(setter);
>> +        assertEquals("Found wrong method", "put", setter.getMethodName());
>>      }
>>
>> +    public void testNullPropertyGetter()
>> +        throws Exception
>> +    {
>> +        Uberspect u = ri.getUberspect();
>> +        GetPutObject gpo = new GetPutObject();
>> +
>> +        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());
>> +    }
>> +
>> +    public void testNullPropertySetter()
>> +        throws Exception
>> +    {
>> +        Uberspect u = ri.getUberspect();
>> +        GetPutObject gpo = new GetPutObject();
>> +
>> +        // Don't screw up on null properties. That should map to put() on 
>> the GPO.
>> +        VelPropertySet setter = u.getPropertySet(gpo, null, Object.class, 
>> null);
>> +        assertNotNull(setter);
>> +        assertEquals("Found wrong method", "put", setter.getMethodName());
>> +    }
>> +
>>      /*
>>
>>      public void testMapGetSet()
>>
>> Added: 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>> URL: 
>> http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java?view=auto&rev=440723
>> ==============================================================================
>> --- 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>>  (added)
>> +++ 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>>  Wed Sep  6 07:28:19 2006
>> @@ -0,0 +1,16 @@
>> +package org.apache.velocity.test.misc;
>> +
>> +public class GetPutObject
>> +{
>> +    private Object value;
>> +
>> +    public Object get()
>> +    {
>> +        return value;
>> +    }
>> +
>> +    public void put(final Object value)
>> +    {
>> +        this.value = value;
>> +    }
>> +}
>> \ No newline at end of file
>>
>> Propchange: 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>> ------------------------------------------------------------------------------
>>     svn:eol-style = native
>>
>> Propchange: 
>> jakarta/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/GetPutObject.java
>> ------------------------------------------------------------------------------
>>     svn:keywords = Id Author Date Revision
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>

>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

Social behaviour: Bavarians can be extremely egalitarian and folksy.
                                    -- http://en.wikipedia.org/wiki/Bavaria
Most Franconians do not like to be called Bavarians.
                                    -- http://en.wikipedia.org/wiki/Franconia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to