[jboss-cvs] jboss-portal/common/src/main/org/jboss/portal/test/common ...

Julien Viet julien at jboss.com
Thu Jul 20 11:16:58 EDT 2006


  User: julien  
  Date: 06/07/20 11:16:58

  Added:       common/src/main/org/jboss/portal/test/common 
                        Application_XWWWFormURLEncodedFormatTestCase.java
  Log:
  added lookup based application/x-www-formurlencoded class for fast encoding
  
  Revision  Changes    Path
  1.1      date: 2006/07/20 15:16:58;  author: julien;  state: Exp;jboss-portal/common/src/main/org/jboss/portal/test/common/Application_XWWWFormURLEncodedFormatTestCase.java
  
  Index: Application_XWWWFormURLEncodedFormatTestCase.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portal.test.common;
  
  import junit.framework.TestCase;
  import org.jboss.portal.common.net.Application_XWWWFormURLEncodedFormat;
  
  import java.net.URLEncoder;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class Application_XWWWFormURLEncodedFormatTestCase extends TestCase
  {
  
     private Application_XWWWFormURLEncodedFormat format = Application_XWWWFormURLEncodedFormat.UTF_8;
  
     public Application_XWWWFormURLEncodedFormatTestCase(String name)
     {
        super(name);
     }
  
     private static final String INVARIANT_STRING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_*";
  
     public void testInvariant()
     {
        assertEquals(INVARIANT_STRING, format.encode(INVARIANT_STRING));
        for (int i = 0;i < INVARIANT_STRING.length();i++)
        {
           char c = INVARIANT_STRING.charAt(i);
           String s = format.encode(c);
           assertEquals(s + "!=" + c, s, "" + c);
        }
     }
  
     public void testSpace()
     {
        assertEquals("+", format.encode(' '));
     }
  
     public void testASCII() throws Exception
     {
        for (int i = 0;i < 50000 + 1;i++)
        {
           char c = (char)i;
           String expectedResult = URLEncoder.encode("" + c, "UTF-8");
           String result = format.encode(c);
           assertEquals("Comparing char=" + i + " was expecting " + expectedResult + " but got " + result, expectedResult, result);
        }
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list