Package org.grails.web.util

Source Code of org.grails.web.util.BoundedCharsAsEncodedBytesCounterTest

package org.grails.web.util;

import junit.framework.TestCase;
import org.grails.web.util.BoundedCharsAsEncodedBytesCounter;

public class BoundedCharsAsEncodedBytesCounterTest extends TestCase {

    private static final String TEST_STRING = "Hello \u00f6\u00e4\u00e5\u00d6\u00c4\u00c5!";

    public void testCalculation() throws Exception {
        BoundedCharsAsEncodedBytesCounter counter = new BoundedCharsAsEncodedBytesCounter(1024, "ISO-8859-1");
        counter.getCountingWriter();
        counter.update(TEST_STRING);
        assertEquals(13, counter.size());
        assertEquals(13, TEST_STRING.getBytes("ISO-8859-1").length);
        counter.update(TEST_STRING);
        assertEquals(26, counter.size());
    }
}
TOP

Related Classes of org.grails.web.util.BoundedCharsAsEncodedBytesCounterTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.