<commit_before>//
// Tapestry Web Application Framework
// Copyright (c) 2000-2002 by <NAME>
//
// <NAME>
// http://sf.net/projects/tapestry
// mailto:<EMAIL>
//
// This library is free software.
//
// You may redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License as published by the Free Software Foundation.
//
// Version 2.1 of the license should be included with this distribution in
// the file LICENSE, as well as License.html. If the license is not
// included with this distribution, you may find a copy at the FSF web
// site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
// Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied waranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//

package net.sf.tapestry.junit.utils;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;

import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import net.sf.tapestry.IResourceResolver;
import net.sf.tapestry.engine.ResourceResolver;
import net.sf.tapestry.spec.BeanLifecycle;
import net.sf.tapestry.util.io.DataSqueezer;
import net.sf.tapestry.util.io.ISqueezeAdaptor;
import net.sf.tapestry.util.prop.OgnlUtils;

/**
 *  A series of tests for {@link DataSqueezer} and friends.
 *
 *  @author <NAME>
 *  @version $Id$
 *
 **/

public class TestDataSqueezer extends TestCase
{
    private DataSqueezer s = new DataSqueezer(new ResourceResolver(this));

    public TestDataSqueezer(String name)
    {
        super(name);
    }

    private void attempt(Object input, String expectedEncoding) throws IOException
    {
        attempt(input, expectedEncoding, s);
    }

    private void attempt(Object input, String expectedEncoding, DataSqueezer ds) throws IOException
    {
        String encoding = ds.squeeze(input);

        assertEquals("String encoding.", expectedEncoding, encoding);

        Object output = ds.unsqueeze(encoding);

        assertEquals("Decoded object.", input, output);
    }

    public void testBoolean() throws IOException
    {
        attempt(Boolean.TRUE, "T");
        attempt(Boolean.FALSE, "F");
    }

    public void testNull() throws IOException
    {
        attempt(null, "X");
    }

    public void testByte() throws IOException
    {
        attempt(new Byte((byte) 0), "b0");
        attempt(new Byte((byte) - 5), "b-5");
        attempt(new Byte((byte) 72), "b72");
    }

    public void testFloat() throws IOException
    {
        attempt(new Float(0), "f0.0");
        attempt(new Float(3.1459), "f3.1459");
        attempt(new Float(-37.23), "f-37.23");
    }

    public void testDouble() throws IOException
    {
        attempt(new Double(0), "d0.0");
        attempt(new Double(3.1459), "d3.1459");
        attempt(new Double(-37.23), "d-37.23");
    }

    public void testInteger() throws IOException
    {
        attempt(new Integer(0), "0");
        attempt(new Integer(205), "205");
        attempt(new Integer(-173), "-173");
    }

    public void testLong() throws IOException
    {
        attempt(new Long(0), "l0");
        attempt(new Long(800400300l), "l800400300");
        attempt(new Long(-987654321l), "l-987654321");
    }

    public void testShort() throws IOException
    {
        attempt(new Short((short) 0), "s0");
        attempt(new Short((short) - 10), "s-10");
        attempt(new Short((short) 57), "s57");
    }

    /** @since 2.2 **/

    public void testCharacter() throws IOException
    {
        attempt(new Character('a'), "ca");
        attempt(new Character('Z'), "cZ");
    }

    public void testString() throws IOException
    {
        attempt("Now is the time for all good men ...", "Now is the time for all good men ...");
        attempt("X marks the spot!", "SX marks the spot!");
        attempt("So long, sucker!", "SSo long, sucker!");
    }<commit_msg>added ComponentAddress unit test<commit_after>//
// Tapestry Web Application Framework
// Copyright (c) 2000-2002 by <NAME>
//
// <NAME>
// http://sf.net/projects/tapestry
// mailto:<EMAIL>
//
// This library is free software.
//
// You may redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License as published by the Free Software Foundation.
//
// Version 2.1 of the license should be included with this distribution in
// the file LICENSE, as well as License.html. If the license is not
// included with this distribution, you may find a copy at the FSF web
// site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
// Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied waranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//

package net.sf.tapestry.junit.utils;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;

import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import net.sf.tapestry.ComponentAddress;
import net.sf.tapestry.IResourceResolver;
import net.sf.tapestry.engine.ResourceResolver;
import net.sf.tapestry.spec.BeanLifecycle;
import net.sf.tapestry.util.io.DataSqueezer;
import net.sf.tapestry.util.io.ISqueezeAdaptor;
import net.sf.tapestry.util.prop.OgnlUtils;

/**
 *  A series of tests for {@link DataSqueezer} and friends.
 *
 *  @author <NAME>
 *  @version $Id$
 *
 **/

public class TestDataSqueezer extends TestCase
{
    private DataSqueezer s = new DataSqueezer(new ResourceResolver(this));

    public TestDataSqueezer(String name)
    {
        super(name);
    }

    private void attempt(Object input, String expectedEncoding) throws IOException
    {
        attempt(input, expectedEncoding, s);
    }

    private void attempt(Object input, String expectedEncoding, DataSqueezer ds) throws IOException
    {
        String encoding = ds.squeeze(input);

        assertEquals("String encoding.", expectedEncoding, encoding);

        Object output = ds.unsqueeze(encoding);

        assertEquals("Decoded object.", input, output);
    }

    public void testBoolean() throws IOException
    {
        attempt(Boolean.TRUE, "T");
        attempt(Boolean.FALSE, "F");
    }

    public void testNull() throws IOException
    {
        attempt(null, "X");
    }

    public void testByte() throws IOException
    {
        attempt(new Byte((byte) 0), "b0");
        attempt(new Byte((byte) - 5), "b-5");
        attempt(new Byte((byte) 72), "b72");
    }

    public void testFloat() throws IOException
    {
        attempt(new Float(0), "f0.0");
        attempt(new Float(3.1459), "f3.1459");
        attempt(new Float(-37.23), "f-37.23");
    }

    public void testDouble() throws IOException
    {
        attempt(new Double(0), "d0.0");
        attempt(new Double(3.1459), "d3.1459");
        attempt(new Double(-37.23), "d-37.23");
    }

    public void testInteger() throws IOException
    {
        attempt(new Integer(0), "0");
        attempt(new Integer(205), "205");
        attempt(new Integer(-173), "-173");
    }

    public void testLong() throws IOException
    {
        attempt(new Long(0), "l0");
        attempt(new Long(800400300l), "l800400300");
        attempt(new Long(-987654321l), "l-987654321");
    }

    public void testShort() throws IOException
    {
        attempt(new Short((short) 0), "s0");
        attempt(new Short((short) - 10), "s-10");
        attempt(new Short((short) 57), "s57");
    }

    /** @since 2.2 **/

    public void testCharacter() throws IOException
    {
        attempt(new Character('a'), "ca");
        attempt(new Character('Z'), "cZ");
    }

    public void testString() throws IOException
    {
        attempt("Now is the time for all good men ...", "Now is the time for all good men ...");
        attempt("X marks the spot!", "SX marks the spot!");
        attempt("So long, sucker!", "SSo long, sucker!");
    }

    public void testComponentAddress() throws IOException 
    {
        ComponentAddress objAddress = new ComponentAddress("framework:DirectLink", "component.subcomponent");
        attempt(objAddress, "Aframework:DirectLink/component.subcomponent");
    }
{'fraction_non_alphanumeric': 0.12659098727210183, 'fraction_numerical': 0.03027175782593739, 'mean_word_length': 2.991762013729977, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '414980', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2538, 'n_words': 797}