<commit_before><commit_msg>add some explicit tests for the Uberspector to find out its behaviour in corner cases...<commit_after>package org.apache.velocity.test;

import java.util.HashMap;
import java.util.Map;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.apache.velocity.runtime.RuntimeInstance;
import org.apache.velocity.util.introspection.Uberspect;

/*
 * Copyright 2006 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class UberspectorTestCase
        extends BaseTestCase
{
    private RuntimeInstance ri;

    public UberspectorTestCase(String name)
    {
        super(name);
    }
    
    public static Test suite()
    {
        return new TestSuite(UberspectorTestCase.class);
    }
    
    public void setUp()
            throws Exception
    {
        ri = new RuntimeInstance();
        ri.init();
    }

    public void testEmptyProperties()
            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));
    }
    
    public void testNullProperties()
        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));
    }
    
    /*
    
    public void testMapGetSet()
        throws Exception
    {
        Uberspect u = ri.getUberspect();
        Map map = new HashMap();

        VelPropertyGet getter = u.getPropertyGet(map, "", null);
        VelPropertySet setter = u.getPropertySet(map, "", Object.class, null);

        assertNotNull("Got a null getter", getter);
        assertNotNull("Got a null setter", setter);

        assertEquals("Got wrong getter", "foo", getter.getMethodName());
        assertEquals("Got wrong setter", "bar", setter.getMethodName());
    }
    */
}    
        



{'fraction_non_alphanumeric': 0.09578682030968672, 'fraction_numerical': 0.0028808066258552397, 'mean_word_length': 2.7591339648173205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3747854', 'n_tokens_mistral': 770, 'n_tokens_neox': 748, 'n_words': 252}