pkg://jakarta-commons-codec-1.2-1jpp.src.rpm:66318/commons-codec-1.2-src.tar.gz
info downloads
commons-codec-1.2/ 40755 0 0 0 7760562322 11125 5 ustar 0 0 commons-codec-1.2/src/ 40755 0 0 0 7760562322 11714 5 ustar 0 0 commons-codec-1.2/src/test/ 40755 0 0 0 7760562321 12672 5 ustar 0 0 commons-codec-1.2/src/test/org/ 40755 0 0 0 7760562321 13461 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/ 40755 0 0 0 7760562321 14702 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/ 40755 0 0 0 7760562321 16355 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/codec/ 40755 0 0 0 7760562322 17433 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/codec/binary/ 40755 0 0 0 7760562322 20717 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/codec/net/ 40755 0 0 0 7760562321 20220 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/codec/language/ 40755 0 0 0 7760562322 21216 5 ustar 0 0 commons-codec-1.2/src/test/org/apache/commons/codec/digest/ 40755 0 0 0 7760562322 20712 5 ustar 0 0 commons-codec-1.2/src/java/ 40755 0 0 0 7760562321 12634 5 ustar 0 0 commons-codec-1.2/src/java/org/ 40755 0 0 0 7760562321 13423 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/ 40755 0 0 0 7760562321 14644 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/ 40755 0 0 0 7760562321 16317 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/codec/ 40755 0 0 0 7760562322 17375 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/codec/digest/ 40755 0 0 0 7760562321 20653 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/codec/net/ 40755 0 0 0 7760562322 20163 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/codec/language/ 40755 0 0 0 7760562322 21160 5 ustar 0 0 commons-codec-1.2/src/java/org/apache/commons/codec/binary/ 40755 0 0 0 7760562322 20661 5 ustar 0 0 commons-codec-1.2/src/conf/ 40755 0 0 0 7760562322 12641 5 ustar 0 0 commons-codec-1.2/project.xml 100644 0 0 13627 7760562321 13442 0 ustar 0 0 <?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>../project.xml</extend>
<name>Codec</name>
<id>commons-codec</id>
<currentVersion>1.2</currentVersion>
<inceptionYear>2002</inceptionYear>
<shortDescription>Simple encoders and decoders</shortDescription>
<description>
The codec package contains simple encoder and decoders for
various formats such as Base64 and Hexadecimal. In addition to these
widely used encoders and decoders, the codec package also maintains a
collection of phonetic encoding utilities.
</description>
<versions>
<version>
<id>1.1-rc1</id>
<name>1.1-rc1</name>
<tag>CODEC_1_1_RC1</tag>
</version>
<version>
<id>1.1</id>
<name>1.1</name>
<tag>CODEC_1_1</tag>
</version>
<version>
<id>1.2-rc1</id>
<name>1.2-rc1</name>
<tag>CODEC_1_2_RC1</tag>
</version>
<version>
<id>1.2</id>
<name>1.2</name>
<tag>CODEC_1_2</tag>
</version>
</versions>
<branches>
</branches>
<developers>
<developer>
<name>Henri Yandell</name>
<id>bayard</id>
<email>bayard@generationjava.com</email>
</developer>
<developer>
<name>Tim OBrien</name>
<id>tobrien</id>
<email>tobrien@apache.org</email>
<timezone>-6</timezone>
</developer>
<developer>
<name>Scott Sanders</name>
<id>sanders</id>
<email>sanders@totalsync.com</email>
</developer>
<developer>
<name>Rodney Waldhoff</name>
<id>rwaldhoff</id>
<email>rwaldhoff@apache.org</email>
</developer>
<developer>
<name>Daniel Rall</name>
<id>dlr</id>
<email>dlr@finemaltcoding.com</email>
</developer>
<developer>
<name>Jon S. Stevens</name>
<id>jon</id>
<email>jon@collab.net</email>
</developer>
<developer>
<name>Gary D. Gregory</name>
<id>ggregory</id>
<email>ggregory@seagullsw.com</email>
<organization>SEAGULL Software</organization>
<roles>
<role>Java Developer</role>
</roles>
</developer>
<developer>
<name>David Graham</name>
<id>dgraham</id>
<email>dgraham@apache.org</email>
</developer>
</developers>
<contributors>
<contributor>
<name>Christopher O'Brien</name>
<email>siege@preoccupied.net</email>
<roles>hex, md5, architecture</roles>
</contributor>
<contributor>
<name>Martin Redington</name>
<roles>representing xml-rpc</roles>
</contributor>
<contributor>
<name>Jeffery Dever</name>
<roles>representing http-client</roles>
</contributor>
<contributor>
<name>Steve Zimmermann</name>
<email>steve.zimmermann@heii.com</email>
<roles>documentation</roles>
</contributor>
<contributor>
<name>Benjamin Walstrum</name>
<email>ben@walstrum.com</email>
</contributor>
<contributor>
<name>Oleg Kalnichevski</name>
<email>oleg@ural.ru</email>
<roles>representing http-client</roles>
</contributor>
<contributor>
<name>Dave Dribin</name>
<email>apache@dave.dribin.org</email>
<roles>digest util</roles>
</contributor>
</contributors>
<dependencies>
<!-- <dependency>
<id>junit</id>
<version>3.8</version>
</dependency> -->
</dependencies>
<issueTrackingUrl>http://nagoya.apache.org/bugzilla/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&email1=&emailtype1=substring&emailassigned_to1=1&email2=&emailtype2=substring&emailreporter2=1&bugidtype=include&bug_id=&changedin=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&product=Commons&component=Codec&short_desc=&short_desc_type=allwordssubstr&long_desc=&long_desc_type=allwordssubstr&bug_file_loc=&bug_file_loc_type=allwordssubstr&keywords=&keywords_type=anywords&field0-0-0=noop&type0-0-0=noop&value0-0-0=&cmdtype=doit&newqueryname=&order=Reuse+same+sort+as+last+time</issueTrackingUrl>
<build>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*AbstractTest.java</exclude>
</excludes>
<resources>
<resource>
<directory>${pom.build.unitTestSourceDirectory}</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</unitTest>
</build>
<reports>
<report>maven-changelog-plugin</report>
<!-- <report>maven-changes-plugin</report> -->
<report>maven-checkstyle-plugin</report>
<report>maven-clover-plugin</report>
<report>maven-developer-activity-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-javadoc-plugin</report>
<!-- <report>maven-jdepend-plugin</report> -->
<!-- <report>maven-jellydoc-plugin</report> -->
<report>maven-junit-report-plugin</report>
<report>maven-jxr-plugin</report>
<report>maven-license-plugin</report>
<!-- <report>maven-linkcheck-plugin</report> -->
<report>maven-statcvs-plugin</report>
<!-- <report>maven-tasklist-plugin</report> -->
</reports>
</project>
commons-codec-1.2/maven.xml 100644 0 0 1054 7760562321 13051 0 ustar 0 0 <project default="java:jar">
<preGoal name="dist:build-bin">
<copy todir="${maven.build.dir}/${maven.final.name}/bin/${maven.final.name}">
<fileset dir="${basedir}">
<include name="RELEASE-NOTES.txt"/>
</fileset>
</copy>
</preGoal>
<preGoal name="dist:build-src">
<copy todir="${maven.build.dir}/${maven.final.name}/src/${maven.final.name}">
<fileset dir="${basedir}">
<include name="RELEASE-NOTES.txt"/>
</fileset>
</copy>
</preGoal>
</project>
commons-codec-1.2/LICENSE.txt 100644 0 0 5215 7760562321 13047 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
commons-codec-1.2/project.properties 100644 0 0 1120 7760562321 14777 0 ustar 0 0 ##
# Properties that override Maven build defaults
#
# $Id: project.properties,v 1.7 2003/11/23 22:16:46 tobrien Exp $
##
maven.checkstyle.properties=${basedir}/checkstyle.xml
maven.test.failure = false
maven.junit.fork=true
maven.linkcheck.enable=false
maven.xdoc.date=left
maven.xdoc.version=${pom.currentVersion}
maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html
maven.javadoc.links=http://java.sun.com/j2se/1.3/docs/api/
maven.javadoc.overview=${basedir}/src/java/org/apache/commons/codec/overview.html
maven.jar.manifest=${basedir}/src/conf/MANIFEST.MF commons-codec-1.2/build.xml 100644 0 0 22651 7760562321 13070 0 ustar 0 0 <project name="Codec" default="compile" basedir=".">
<!--
"Codec" component of the Jakarta Commons Subproject
$Id: build.xml,v 1.11 2003/11/14 01:43:38 ggregory Exp $
-->
<!-- ========== Initialize Properties ===================================== -->
<property file="${user.home}/${component.name}.build.properties"/>
<property file="${user.home}/build.properties"/>
<property file="${basedir}/build.properties"/>
<property file="${basedir}/default.properties"/>
<!-- ========== Construct compile classpath =============================== -->
<path id="compile.classpath">
<pathelement location="${build.home}/classes"/>
</path>
<!-- ========== Construct unit test classpath ============================= -->
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/tests"/>
<pathelement location="${junit.jar}"/>
</path>
<!-- ========== Executable Targets ======================================== -->
<target name="init" description="Initialize and evaluate conditionals">
<echo message="-------- ${component.name} ${component.version} --------"/>
<filter token="name" value="${component.name}"/>
<filter token="package" value="${component.package}"/>
<filter token="version" value="${component.version}"/>
</target>
<target name="prepare" depends="init" description="Prepare build directory">
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}/classes"/>
<mkdir dir="${build.home}/conf"/>
<mkdir dir="${build.home}/tests"/>
<mkdir dir="${build.home}/test-reports"/>
</target>
<target name="static" depends="prepare" description="Copy static files to build directory">
<tstamp/>
<copy todir="${build.home}/conf" filtering="on">
<fileset dir="${conf.home}" includes="*.MF"/>
</copy>
</target>
<target name="compile" depends="static" description="Compile shareable components">
<javac srcdir="${source.home}" destdir="${build.home}/classes" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${build.home}/classes" filtering="on">
<fileset dir="${source.home}" excludes="**/*.java"/>
</copy>
</target>
<target name="clean" description="Clean build and distribution directories">
<delete dir="${build.home}"/>
<delete dir="${dist.home}"/>
<delete dir="${pub.home}"/>
</target>
<target name="all" depends="clean,compile" description="Clean and compile all components"/>
<target name="javadoc" depends="compile" description="Create component Javadoc documentation">
<mkdir dir="${dist.home}"/>
<mkdir dir="${dist.home}/docs"/>
<mkdir dir="${dist.home}/docs/api"/>
<!-- The Sun 1.2 docs are no-longer on-line, point to 1.3. -->
<javadoc
sourcepath="${source.home}"
destdir="${dist.home}/docs/api"
packagenames="org.apache.commons.*"
overview="${source.home}/org/apache/commons/codec/overview.html"
author="true"
private="true"
version="true"
doctitle="<h1>${component.title}</h1>"
windowtitle="${component.title} (Version ${component.version})"
bottom="${component.name} version ${component.version} - Copyright &copy; 2003 - Apache Software Foundation"
use="true"
link="http://java.sun.com/products/jdk/1.3/docs/api/">
<classpath refid="compile.classpath"/>
</javadoc>
</target>
<target name="dist" depends="compile,javadoc" description="Create binary distribution">
<mkdir dir="${dist.home}"/>
<copy file="../LICENSE" todir="${dist.home}"/>
<copy file="${basedir}/RELEASE-NOTES.txt" todir="${dist.home}"/>
<antcall target="jar"/>
</target>
<target name="jar" depends="compile" description="Create jar">
<mkdir dir="${dist.home}"/>
<mkdir dir="${build.home}/classes/META-INF"/>
<copy file="../LICENSE" tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
<jar jarfile="${dist.home}/${final.name}.jar" basedir="${build.home}/classes" manifest="${build.home}/conf/MANIFEST.MF"/>
</target>
<target name="install-jar" depends="jar" description="--> Installs jar file in ${lib.repo}">
<copy todir="${lib.repo}" filtering="no">
<fileset dir="${dist.home}">
<include name="${final.name}.jar"/>
</fileset>
</copy>
</target>
<target name="pub-bin" depends="dist" description="Create binary distribution (compressed) ready for publication">
<mkdir dir="${pub.home}"/>
<!-- Binary properties -->
<property name="final.path" value="${pub.home}/${final.name}"/>
<property name="zip.path" value="${final.path}.zip"/>
<property name="tar.path" value="${final.path}.tar"/>
<property name="gz.path" value="${tar.path}.gz"/>
<!-- Zip binary dist -->
<zip destfile="${zip.path}">
<zipfileset dir="${dist.home}" prefix="${final.name}/"/>
</zip>
<checksum algorithm="md5" file="${zip.path}" fileext=".md5"/>
<checksum algorithm="sha" file="${zip.path}" fileext=".sha"/>
<!-- Tar & gzip binary dist -->
<tar tarfile="${tar.path}" basedir="${dist.home}"/>
<gzip zipfile="${gz.path}" src="${tar.path}"/>
<checksum algorithm="md5" file="${gz.path}" fileext=".md5"/>
<checksum algorithm="sha" file="${gz.path}" fileext=".sha"/>
<delete file="${tar.path}"/>
<!-- Delete old signatures -->
<delete file="${zip.path}.asc"/>
<delete file="${gz.path}.asc"/>
</target>
<target name="pub-src" depends="dist" description="Create source distribution (compressed) ready for publication based on your LOCAL CVS sources">
<mkdir dir="${pub.home}"/>
<echo>Warning: The source files used to create this source distribution come from your local copy of the source files.</echo>
<!-- Source properties -->
<property name="final-src.path" value="${pub.home}/${final.name}-src"/>
<property name="zip-src.path" value="${final-src.path}.zip"/>
<property name="tar-src.path" value="${final-src.path}.tar"/>
<property name="gz-src.path" value="${tar-src.path}.gz"/>
<property name="excludes" value="${pub.home}/**, ${dist.home}/**, target/**, xdocs/**"/>
<!-- Zip source dist -->
<zip destfile="${zip-src.path}">
<zipfileset dir="src" prefix="${final.name}/src/"/>
<zipfileset dir="." includes="build.xml" prefix="${final.name}/"/>
<zipfileset dir="." includes="checkstyle.xml" prefix="${final.name}/"/>
<zipfileset dir="." includes="default.properties" prefix="${final.name}/"/>
<zipfileset dir="." includes="LICENSE.TXT" prefix="${final.name}/"/>
<zipfileset dir="." includes="maven.xml" prefix="${final.name}/"/>
<zipfileset dir="." includes="project.properties" prefix="${final.name}/"/>
<zipfileset dir="." includes="project.xml" prefix="${final.name}/"/>
<zipfileset dir="." includes="RELEASE-NOTES.txt" prefix="${final.name}/"/>
</zip>
<checksum algorithm="md5" file="${zip-src.path}" fileext=".md5"/>
<checksum algorithm="sha" file="${zip-src.path}" fileext=".sha"/>
<!-- Tar & gzip source dist -->
<tar tarfile="${tar-src.path}" basedir="." excludes="${excludes}" excludesfile=".cvsignore"/>
<gzip zipfile="${gz-src.path}" src="${tar-src.path}"/>
<checksum algorithm="md5" file="${gz-src.path}" fileext=".md5"/>
<checksum algorithm="sha" file="${gz-src.path}" fileext=".sha"/>
<delete file="${tar-src.path}"/>
<!-- Delete old signatures -->
<delete file="${zip-src.path}.asc"/>
<delete file="${gz-src.path}.asc"/>
</target>
<target name="pub" depends="pub-bin, pub-src" description="Create binary and source distribution (compressed) ready for publication">
</target>
<!-- ========== Unit Test Targets ========================================= -->
<target name="compile.tests" depends="compile" description="Compile unit test cases">
<javac srcdir="${test.home}" destdir="${build.home}/tests" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
<classpath refid="test.classpath"/>
</javac>
<copy todir="${build.home}/tests" filtering="on">
<fileset dir="${test.home}" excludes="**/*.java"/>
</copy>
</target>
<!-- Run all the JUnit Tests -->
<target name="test" depends="compile.tests" description="Compiles and runs unit test cases">
<record name="${build.home}/test-output.txt" append="no" action="start"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<batchtest fork="yes" todir="${build.home}/test-reports">
<fileset dir="${test.home}">
<include name="**/*Test.java"/>
<exclude name="**/*AbstractTest.java"/>
</fileset>
</batchtest>
</junit>
<record name="${build.home}/test-output.txt" action="stop"/>
</target>
</project>
commons-codec-1.2/src/test/org/apache/commons/codec/binary/Base64Test.java 100644 0 0 71254 7760562321 23573 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.codec.binary;
import java.util.Arrays;
import java.util.Random;
import junit.framework.TestCase;
/**
* @version $Revision: 1.10 $ $Date: 2003/11/03 17:58:57 $
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:rwaldhoff@apache.org">Rodney Waldhoff</a>
* @author Tim O'Brien
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
*/
public class Base64Test extends TestCase {
/**
* Construct a new instance of this test case.
*
* @param name Name of the test case
*/
public Base64Test(String name) {
super(name);
}
/**
* Test the Base64 implementation
*/
public void testBase64() {
String content = "Hello World";
String encodedContent;
encodedContent = new String(Base64.encodeBase64(content.getBytes()));
assertTrue("encoding hello world", encodedContent.equals("SGVsbG8gV29ybGQ="));
}
/**
* Tests conditional true branch for "marker0" test.
*/
public void testDecodePadMarkerIndex2() {
assertEquals("A", new String(Base64.decodeBase64("QQ==".getBytes())));
}
/**
* Tests conditional branches for "marker1" test.
*/
public void testDecodePadMarkerIndex3() {
assertEquals("AA", new String(Base64.decodeBase64("QUE=".getBytes())));
assertEquals("AAA", new String(Base64.decodeBase64("QUFB".getBytes())));
}
public void testDecodePadOnly() {
assertTrue(Base64.decodeBase64("====".getBytes()).length == 0);
assertEquals("", new String(Base64.decodeBase64("====".getBytes())));
}
// encode/decode random arrays from size 0 to size 11
public void testEncodeDecodeSmall() {
for(int i=0;i<12;i++) {
byte[] data = new byte[i];
this.getRandom().nextBytes(data);
byte[] enc = Base64.encodeBase64(data);
assertTrue("\"" + (new String(enc)) + "\" is Base64 data.",Base64.isArrayByteBase64(enc) );
byte[] data2 = Base64.decodeBase64(enc);
assertTrue(toString(data) + " equals " + toString(data2), Arrays.equals(data,data2));
}
}
// encode/decode a large random array
public void testEncodeDecodeRandom() {
for(int i=1;i<5;i++) {
byte[] data = new byte[this.getRandom().nextInt(10000)+1];
this.getRandom().nextBytes(data);
byte[] enc = Base64.encodeBase64(data);
assertTrue(Base64.isArrayByteBase64(enc));
byte[] data2 = Base64.decodeBase64(enc);
assertTrue(Arrays.equals(data,data2));
}
}
public void testSingletons() {
assertEquals("AA==",new String(Base64.encodeBase64(new byte[] { (byte)0 })));
assertEquals("AQ==",new String(Base64.encodeBase64(new byte[] { (byte)1 })));
assertEquals("Ag==",new String(Base64.encodeBase64(new byte[] { (byte)2 })));
assertEquals("Aw==",new String(Base64.encodeBase64(new byte[] { (byte)3 })));
assertEquals("BA==",new String(Base64.encodeBase64(new byte[] { (byte)4 })));
assertEquals("BQ==",new String(Base64.encodeBase64(new byte[] { (byte)5 })));
assertEquals("Bg==",new String(Base64.encodeBase64(new byte[] { (byte)6 })));
assertEquals("Bw==",new String(Base64.encodeBase64(new byte[] { (byte)7 })));
assertEquals("CA==",new String(Base64.encodeBase64(new byte[] { (byte)8 })));
assertEquals("CQ==",new String(Base64.encodeBase64(new byte[] { (byte)9 })));
assertEquals("Cg==",new String(Base64.encodeBase64(new byte[] { (byte)10 })));
assertEquals("Cw==",new String(Base64.encodeBase64(new byte[] { (byte)11 })));
assertEquals("DA==",new String(Base64.encodeBase64(new byte[] { (byte)12 })));
assertEquals("DQ==",new String(Base64.encodeBase64(new byte[] { (byte)13 })));
assertEquals("Dg==",new String(Base64.encodeBase64(new byte[] { (byte)14 })));
assertEquals("Dw==",new String(Base64.encodeBase64(new byte[] { (byte)15 })));
assertEquals("EA==",new String(Base64.encodeBase64(new byte[] { (byte)16 })));
assertEquals("EQ==",new String(Base64.encodeBase64(new byte[] { (byte)17 })));
assertEquals("Eg==",new String(Base64.encodeBase64(new byte[] { (byte)18 })));
assertEquals("Ew==",new String(Base64.encodeBase64(new byte[] { (byte)19 })));
assertEquals("FA==",new String(Base64.encodeBase64(new byte[] { (byte)20 })));
assertEquals("FQ==",new String(Base64.encodeBase64(new byte[] { (byte)21 })));
assertEquals("Fg==",new String(Base64.encodeBase64(new byte[] { (byte)22 })));
assertEquals("Fw==",new String(Base64.encodeBase64(new byte[] { (byte)23 })));
assertEquals("GA==",new String(Base64.encodeBase64(new byte[] { (byte)24 })));
assertEquals("GQ==",new String(Base64.encodeBase64(new byte[] { (byte)25 })));
assertEquals("Gg==",new String(Base64.encodeBase64(new byte[] { (byte)26 })));
assertEquals("Gw==",new String(Base64.encodeBase64(new byte[] { (byte)27 })));
assertEquals("HA==",new String(Base64.encodeBase64(new byte[] { (byte)28 })));
assertEquals("HQ==",new String(Base64.encodeBase64(new byte[] { (byte)29 })));
assertEquals("Hg==",new String(Base64.encodeBase64(new byte[] { (byte)30 })));
assertEquals("Hw==",new String(Base64.encodeBase64(new byte[] { (byte)31 })));
assertEquals("IA==",new String(Base64.encodeBase64(new byte[] { (byte)32 })));
assertEquals("IQ==",new String(Base64.encodeBase64(new byte[] { (byte)33 })));
assertEquals("Ig==",new String(Base64.encodeBase64(new byte[] { (byte)34 })));
assertEquals("Iw==",new String(Base64.encodeBase64(new byte[] { (byte)35 })));
assertEquals("JA==",new String(Base64.encodeBase64(new byte[] { (byte)36 })));
assertEquals("JQ==",new String(Base64.encodeBase64(new byte[] { (byte)37 })));
assertEquals("Jg==",new String(Base64.encodeBase64(new byte[] { (byte)38 })));
assertEquals("Jw==",new String(Base64.encodeBase64(new byte[] { (byte)39 })));
assertEquals("KA==",new String(Base64.encodeBase64(new byte[] { (byte)40 })));
assertEquals("KQ==",new String(Base64.encodeBase64(new byte[] { (byte)41 })));
assertEquals("Kg==",new String(Base64.encodeBase64(new byte[] { (byte)42 })));
assertEquals("Kw==",new String(Base64.encodeBase64(new byte[] { (byte)43 })));
assertEquals("LA==",new String(Base64.encodeBase64(new byte[] { (byte)44 })));
assertEquals("LQ==",new String(Base64.encodeBase64(new byte[] { (byte)45 })));
assertEquals("Lg==",new String(Base64.encodeBase64(new byte[] { (byte)46 })));
assertEquals("Lw==",new String(Base64.encodeBase64(new byte[] { (byte)47 })));
assertEquals("MA==",new String(Base64.encodeBase64(new byte[] { (byte)48 })));
assertEquals("MQ==",new String(Base64.encodeBase64(new byte[] { (byte)49 })));
assertEquals("Mg==",new String(Base64.encodeBase64(new byte[] { (byte)50 })));
assertEquals("Mw==",new String(Base64.encodeBase64(new byte[] { (byte)51 })));
assertEquals("NA==",new String(Base64.encodeBase64(new byte[] { (byte)52 })));
assertEquals("NQ==",new String(Base64.encodeBase64(new byte[] { (byte)53 })));
assertEquals("Ng==",new String(Base64.encodeBase64(new byte[] { (byte)54 })));
assertEquals("Nw==",new String(Base64.encodeBase64(new byte[] { (byte)55 })));
assertEquals("OA==",new String(Base64.encodeBase64(new byte[] { (byte)56 })));
assertEquals("OQ==",new String(Base64.encodeBase64(new byte[] { (byte)57 })));
assertEquals("Og==",new String(Base64.encodeBase64(new byte[] { (byte)58 })));
assertEquals("Ow==",new String(Base64.encodeBase64(new byte[] { (byte)59 })));
assertEquals("PA==",new String(Base64.encodeBase64(new byte[] { (byte)60 })));
assertEquals("PQ==",new String(Base64.encodeBase64(new byte[] { (byte)61 })));
assertEquals("Pg==",new String(Base64.encodeBase64(new byte[] { (byte)62 })));
assertEquals("Pw==",new String(Base64.encodeBase64(new byte[] { (byte)63 })));
assertEquals("QA==",new String(Base64.encodeBase64(new byte[] { (byte)64 })));
assertEquals("QQ==",new String(Base64.encodeBase64(new byte[] { (byte)65 })));
assertEquals("Qg==",new String(Base64.encodeBase64(new byte[] { (byte)66 })));
assertEquals("Qw==",new String(Base64.encodeBase64(new byte[] { (byte)67 })));
assertEquals("RA==",new String(Base64.encodeBase64(new byte[] { (byte)68 })));
assertEquals("RQ==",new String(Base64.encodeBase64(new byte[] { (byte)69 })));
assertEquals("Rg==",new String(Base64.encodeBase64(new byte[] { (byte)70 })));
assertEquals("Rw==",new String(Base64.encodeBase64(new byte[] { (byte)71 })));
assertEquals("SA==",new String(Base64.encodeBase64(new byte[] { (byte)72 })));
assertEquals("SQ==",new String(Base64.encodeBase64(new byte[] { (byte)73 })));
assertEquals("Sg==",new String(Base64.encodeBase64(new byte[] { (byte)74 })));
assertEquals("Sw==",new String(Base64.encodeBase64(new byte[] { (byte)75 })));
assertEquals("TA==",new String(Base64.encodeBase64(new byte[] { (byte)76 })));
assertEquals("TQ==",new String(Base64.encodeBase64(new byte[] { (byte)77 })));
assertEquals("Tg==",new String(Base64.encodeBase64(new byte[] { (byte)78 })));
assertEquals("Tw==",new String(Base64.encodeBase64(new byte[] { (byte)79 })));
assertEquals("UA==",new String(Base64.encodeBase64(new byte[] { (byte)80 })));
assertEquals("UQ==",new String(Base64.encodeBase64(new byte[] { (byte)81 })));
assertEquals("Ug==",new String(Base64.encodeBase64(new byte[] { (byte)82 })));
assertEquals("Uw==",new String(Base64.encodeBase64(new byte[] { (byte)83 })));
assertEquals("VA==",new String(Base64.encodeBase64(new byte[] { (byte)84 })));
assertEquals("VQ==",new String(Base64.encodeBase64(new byte[] { (byte)85 })));
assertEquals("Vg==",new String(Base64.encodeBase64(new byte[] { (byte)86 })));
assertEquals("Vw==",new String(Base64.encodeBase64(new byte[] { (byte)87 })));
assertEquals("WA==",new String(Base64.encodeBase64(new byte[] { (byte)88 })));
assertEquals("WQ==",new String(Base64.encodeBase64(new byte[] { (byte)89 })));
assertEquals("Wg==",new String(Base64.encodeBase64(new byte[] { (byte)90 })));
assertEquals("Ww==",new String(Base64.encodeBase64(new byte[] { (byte)91 })));
assertEquals("XA==",new String(Base64.encodeBase64(new byte[] { (byte)92 })));
assertEquals("XQ==",new String(Base64.encodeBase64(new byte[] { (byte)93 })));
assertEquals("Xg==",new String(Base64.encodeBase64(new byte[] { (byte)94 })));
assertEquals("Xw==",new String(Base64.encodeBase64(new byte[] { (byte)95 })));
assertEquals("YA==",new String(Base64.encodeBase64(new byte[] { (byte)96 })));
assertEquals("YQ==",new String(Base64.encodeBase64(new byte[] { (byte)97 })));
assertEquals("Yg==",new String(Base64.encodeBase64(new byte[] { (byte)98 })));
assertEquals("Yw==",new String(Base64.encodeBase64(new byte[] { (byte)99 })));
assertEquals("ZA==",new String(Base64.encodeBase64(new byte[] { (byte)100 })));
assertEquals("ZQ==",new String(Base64.encodeBase64(new byte[] { (byte)101 })));
assertEquals("Zg==",new String(Base64.encodeBase64(new byte[] { (byte)102 })));
assertEquals("Zw==",new String(Base64.encodeBase64(new byte[] { (byte)103 })));
assertEquals("aA==",new String(Base64.encodeBase64(new byte[] { (byte)104 })));
}
public void testTriplets() {
assertEquals("AAAA",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)0 })));
assertEquals("AAAB",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)1 })));
assertEquals("AAAC",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)2 })));
assertEquals("AAAD",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)3 })));
assertEquals("AAAE",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)4 })));
assertEquals("AAAF",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)5 })));
assertEquals("AAAG",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)6 })));
assertEquals("AAAH",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)7 })));
assertEquals("AAAI",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)8 })));
assertEquals("AAAJ",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)9 })));
assertEquals("AAAK",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)10 })));
assertEquals("AAAL",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)11 })));
assertEquals("AAAM",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)12 })));
assertEquals("AAAN",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)13 })));
assertEquals("AAAO",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)14 })));
assertEquals("AAAP",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)15 })));
assertEquals("AAAQ",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)16 })));
assertEquals("AAAR",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)17 })));
assertEquals("AAAS",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)18 })));
assertEquals("AAAT",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)19 })));
assertEquals("AAAU",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)20 })));
assertEquals("AAAV",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)21 })));
assertEquals("AAAW",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)22 })));
assertEquals("AAAX",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)23 })));
assertEquals("AAAY",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)24 })));
assertEquals("AAAZ",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)25 })));
assertEquals("AAAa",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)26 })));
assertEquals("AAAb",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)27 })));
assertEquals("AAAc",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)28 })));
assertEquals("AAAd",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)29 })));
assertEquals("AAAe",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)30 })));
assertEquals("AAAf",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)31 })));
assertEquals("AAAg",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)32 })));
assertEquals("AAAh",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)33 })));
assertEquals("AAAi",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)34 })));
assertEquals("AAAj",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)35 })));
assertEquals("AAAk",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)36 })));
assertEquals("AAAl",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)37 })));
assertEquals("AAAm",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)38 })));
assertEquals("AAAn",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)39 })));
assertEquals("AAAo",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)40 })));
assertEquals("AAAp",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)41 })));
assertEquals("AAAq",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)42 })));
assertEquals("AAAr",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)43 })));
assertEquals("AAAs",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)44 })));
assertEquals("AAAt",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)45 })));
assertEquals("AAAu",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)46 })));
assertEquals("AAAv",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)47 })));
assertEquals("AAAw",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)48 })));
assertEquals("AAAx",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)49 })));
assertEquals("AAAy",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)50 })));
assertEquals("AAAz",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)51 })));
assertEquals("AAA0",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)52 })));
assertEquals("AAA1",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)53 })));
assertEquals("AAA2",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)54 })));
assertEquals("AAA3",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)55 })));
assertEquals("AAA4",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)56 })));
assertEquals("AAA5",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)57 })));
assertEquals("AAA6",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)58 })));
assertEquals("AAA7",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)59 })));
assertEquals("AAA8",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)60 })));
assertEquals("AAA9",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)61 })));
assertEquals("AAA+",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)62 })));
assertEquals("AAA/",new String(Base64.encodeBase64(new byte[] { (byte)0, (byte)0, (byte)63 })));
}
public void testKnownEncodings() {
assertEquals("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==",new String(Base64.encodeBase64("The quick brown fox jumped over the lazy dogs.".getBytes())));
assertEquals("YmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJs\nYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFo\nIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBi\nbGFoIGJsYWg=\n",new String(Base64.encodeBase64Chunked("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah".getBytes())));
assertEquals("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==",new String(Base64.encodeBase64("It was the best of times, it was the worst of times.".getBytes())));
assertEquals("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==",new String(Base64.encodeBase64("http://jakarta.apache.org/commmons".getBytes())));
assertEquals("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==",new String(Base64.encodeBase64("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz".getBytes())));
assertEquals("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0=",new String(Base64.encodeBase64("{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }".getBytes())));
assertEquals("eHl6enkh",new String(Base64.encodeBase64("xyzzy!".getBytes())));
}
public void testKnownDecodings() {
assertEquals("The quick brown fox jumped over the lazy dogs.",new String(Base64.decodeBase64("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes())));
assertEquals("It was the best of times, it was the worst of times.",new String(Base64.decodeBase64("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==".getBytes())));
assertEquals("http://jakarta.apache.org/commmons",new String(Base64.decodeBase64("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==".getBytes())));
assertEquals("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",new String(Base64.decodeBase64("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==".getBytes())));
assertEquals("{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }",new String(Base64.decodeBase64("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0=".getBytes())));
assertEquals("xyzzy!",new String(Base64.decodeBase64("eHl6enkh".getBytes())));
}
public void testNonBase64Test() throws Exception {
byte[] bArray = { '%' };
assertFalse( "Invalid Base64 array was incorrectly validated as " +
"an array of Base64 encoded data",
Base64.isArrayByteBase64( bArray ) );
boolean exceptionThrown = false;
try {
Base64 b64 = new Base64();
byte[] result = b64.decode( bArray );
assertTrue( "The result should be empty as the test encoded content did " +
"not contain any valid base 64 characters", result.length == 0);
}
catch( Exception e ) {
exceptionThrown = true;
}
assertFalse( "Exception was thrown when trying to decode " +
"invalid base64 encoded data - RFC 2045 requires that all " +
"non base64 character be discarded, an exception should not" +
" have been thrown", exceptionThrown );
}
public void testIgnoringNonBase64InDecode() throws Exception {
assertEquals("The quick brown fox jumped over the lazy dogs.",new String(Base64.decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes())));
}
public void testObjectDecodeWithInvalidParameter() throws Exception {
boolean exceptionThrown = false;
Base64 b64 = new Base64();
try {
Object o = new String( "Yadayadayada" );
b64.decode( o );
} catch( Exception e ) {
exceptionThrown = true;
}
assertTrue( "decode(Object) didn't throw an exception when passed a " +
"String object", exceptionThrown );
}
public void testObjectDecodeWithValidParameter() throws Exception {
String original = "Hello World!";
byte[] bArray =
Base64.encodeBase64( (new String(original)).getBytes() );
Object o = bArray;
Base64 b64 = new Base64();
Object oDecoded = b64.decode( o );
byte[] baDecoded = (byte[]) oDecoded;
String dest = new String( baDecoded );
assertTrue( "dest string down not equal original",
dest.equals( original ) );
}
public void testObjectEncodeWithInvalidParameter() throws Exception {
boolean exceptionThrown = false;
Base64 b64 = new Base64();
try {
Object o = new String( "Yadayadayada" );
b64.encode( o );
} catch( Exception e ) {
exceptionThrown = true;
}
assertTrue( "encode(Object) didn't throw an exception when passed a " +
"String object", exceptionThrown );
}
public void testObjectEncodeWithValidParameter() throws Exception {
String original = "Hello World!";
byte[] origBytes = original.getBytes();
Object origObj = origBytes;
Base64 b64 = new Base64();
Object oEncoded = b64.encode( origObj );
byte[] bArray =
Base64.decodeBase64( (byte[]) oEncoded );
String dest = new String( bArray );
assertTrue( "dest string down not equal original",
dest.equals( original ) );
}
public void testDecodeWithWhitespace() throws Exception {
String orig = "I am a late night coder.";
byte[] encodedArray = Base64.encodeBase64( orig.getBytes() );
StringBuffer intermediate =
new StringBuffer( new String(encodedArray) );
intermediate.insert( 2, ' ' );
intermediate.insert( 5, '\t' );
intermediate.insert( 10, '\r' );
intermediate.insert( 15, '\n' );
byte[] encodedWithWS = intermediate.toString().getBytes();
byte[] decodedWithWS = Base64.decodeBase64( encodedWithWS );
String dest = new String( decodedWithWS );
assertTrue( "Dest string doesn't eausl original",
dest.equals( orig ) );
}
public void testDiscardWhitespace() throws Exception {
String orig = "I am a late night coder.";
byte[] encodedArray = Base64.encodeBase64( orig.getBytes() );
StringBuffer intermediate =
new StringBuffer( new String(encodedArray) );
intermediate.insert( 2, ' ' );
intermediate.insert( 5, '\t' );
intermediate.insert( 10, '\r' );
intermediate.insert( 15, '\n' );
byte[] encodedWithWS = intermediate.toString().getBytes();
byte[] encodedNoWS = Base64.discardWhitespace( encodedWithWS );
byte[] decodedWithWS = Base64.decodeBase64( encodedWithWS );
byte[] decodedNoWS = Base64.decodeBase64( encodedNoWS );
String destFromWS = new String( decodedWithWS );
String destFromNoWS = new String( decodedNoWS );
assertTrue( "Dest string doesn't eausl original",
destFromWS.equals( orig ) );
assertTrue( "Dest string doesn't eausl original",
destFromNoWS.equals( orig ) );
}
// -------------------------------------------------------- Private Methods
private String toString(byte[] data) {
StringBuffer buf = new StringBuffer();
for(int i=0;i<data.length;i++) {
buf.append(data[i]);
if(i != data.length-1) {
buf.append(",");
}
}
return buf.toString();
}
// ------------------------------------------------------------------------
private Random _random = new Random();
/**
* @return Returns the _random.
*/
public Random getRandom() {
return this._random;
}
}
commons-codec-1.2/src/test/org/apache/commons/codec/binary/jakarta-logo.gif.btoa.bak 100644 0 0 25521 7760562322 25563 0 ustar 0 0 xbtoa5 78 jakarta-logo.gif Begin
7nH003FV^a0EC89!!33''GD3B2*+r=/;JR?hZc-JX%pD89(C#-UBW$R)_RBY,LJSPA.pQaf3F(9.e=
cn-R5I_.iE^m>-K\5upO#Sf1.?$`*MF3$khoq<md@Ma3_g09aH:XQ#pOOP3a<.dP))]4VIE115*f/C
2kK[P`'h.ieMHa@n_R=0%MNppD-BSmRCHOJaZ!5r8ffBm@AhI5rGYg"E/Rp89mK57e&i-/H=^jiUIm
31rPp@d;X6?[$$R#GW?#ugPm;5,U2[]X?e*ZrJALtjO\bG9gZk%^WB8Ql[M=Z\gD[(9j\A>L5+DgRV
,Q4^!7S2Tc7nma>_DqYEl11k/D?5!D/?-=GOQ6#.$MPAjBsRUt;8=EZT$HZ)C4iSZ?q8^;L:LIX]jK
,Vl#\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CF*o%k?'%h5=.hRVU"P;:KH.9m#V_p,P'\.sgbqjI$@"YpZ$5ro?DPYXn=]E$j3q.AVWj$KW>Wh&1*
e8qD9Hh'[@+Q\(EF@`c9kC_Ca9>PF5,`]-aD@iQQ:'cV(TZms-4<_&oGVK@-d/jZRiXjdVE@:*<Jjh
Vet!g"PFV(?Qk:2t"N,d;t@oDst@1nk7E!(RlZgkeDjTFV-DHR-6X6(@mliVY0[oL)Rc!GbpGJ>dhh
Qa*LV!(VWbeR&W1iSqr+?hXM?a9ImuqMRmDn#fOME(?e!gG51&<FkFJ_@UY3b1gD44]6HaLN6r+Qa5
Iigc(!-heJWH_6r:.G1];&i@P^%HN,75-mm;G4:1_\dA,+0!r[)(lm(kUA[LOSSod>A/Ec"OtT^>k:
XMpks&Tqo<(4pVF$6%JUti!<E0^$
xbtoa End N 8584 2188 E 43 S c2e73 R 523c8e83
commons-codec-1.2/src/test/org/apache/commons/codec/binary/HexTest.java 100644 0 0 16063 7760562322 23271 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.codec.binary;
import java.util.Arrays;
import java.util.Random;
import junit.framework.TestCase;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;
/**
* Tests {@link org.apache.commons.codec.binary.Hex}.
*
* @author <a href="mailto:siege@preoccupied.net">Christopher O'Brien</a>
* @author Tim O'Brien
* @author Gary Gregory
* @version $Id: HexTest.java,v 1.6 2003/11/03 19:04:34 ggregory Exp $
*/
public class HexTest extends TestCase {
public HexTest(String name) {
super(name);
}
public void testDecodeArrayOddCharacters() {
try {
new Hex().decode(new byte[] { 65 });
fail("An exception wasn't thrown when trying to decode an odd number of characters");
}
catch (DecoderException e) {
// Expected exception
}
}
public void testDecodeClassCastException() {
try {
new Hex().decode(new int[] { 65 });
fail("An exception wasn't thrown when trying to decode.");
}
catch (DecoderException e) {
// Expected exception
}
}
public void testDecodeHexOddCharacters() {
try {
Hex.decodeHex(new char[] { 'A' });
fail("An exception wasn't thrown when trying to decode an odd number of characters");
}
catch (DecoderException e) {
// Expected exception
}
}
public void testDecodeStringOddCharacters() {
try {
new Hex().decode("6");
fail("An exception wasn't thrown when trying to decode an odd number of characters");
}
catch (DecoderException e) {
// Expected exception
}
}
public void testDencodeEmpty() throws DecoderException {
assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0])));
assertTrue(Arrays.equals(new byte[0], new Hex().decode(new byte[0])));
assertTrue(Arrays.equals(new byte[0], (byte[])new Hex().decode("")));
}
public void testEncodeClassCastException() {
try {
new Hex().encode(new int[] { 65 });
fail("An exception wasn't thrown when trying to encode.");
}
catch (EncoderException e) {
// Expected exception
}
}
public void testEncodeDecodeRandom() throws DecoderException, EncoderException {
Random random = new Random();
Hex hex = new Hex();
for (int i = 5; i > 0; i--) {
byte[] data = new byte[random.nextInt(10000) + 1];
random.nextBytes(data);
// static API
char[] encodedChars = Hex.encodeHex(data);
byte[] decodedBytes = Hex.decodeHex(encodedChars);
assertTrue(Arrays.equals(data, decodedBytes));
// instance API with array parameter
byte[] encodedStringBytes = hex.encode(data);
decodedBytes = hex.decode(encodedStringBytes);
assertTrue(Arrays.equals(data, decodedBytes));
// instance API with char[] (Object) parameter
String dataString = new String(encodedChars);
char[] encodedStringChars = (char[])hex.encode(dataString);
decodedBytes = (byte[])hex.decode(encodedStringChars);
assertTrue(Arrays.equals(dataString.getBytes(), decodedBytes));
// instance API with String (Object) parameter
dataString = new String(encodedChars);
encodedStringChars = (char[])hex.encode(dataString);
decodedBytes = (byte[])hex.decode(new String(encodedStringChars));
assertTrue(Arrays.equals(dataString.getBytes(), decodedBytes));
}
}
public void testEncodeEmpty() throws EncoderException {
assertTrue(Arrays.equals(new char[0], Hex.encodeHex(new byte[0])));
assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0])));
assertTrue(Arrays.equals(new char[0], (char[])new Hex().encode("")));
}
public void testEncodeZeroes() {
char[] c = Hex.encodeHex(new byte[36]);
assertEquals(
"000000000000000000000000000000000000"
+ "000000000000000000000000000000000000",
new String(c));
}
public void testHelloWorld() {
byte[] b = "Hello World".getBytes();
char[] c = Hex.encodeHex(b);
assertEquals("48656c6c6f20576f726c64", new String(c));
}
}
commons-codec-1.2/src/test/org/apache/commons/codec/StringEncoderComparatorTest.java 100644 0 0 11541 7760562321 26052 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.codec;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
import org.apache.commons.codec.language.DoubleMetaphone;
import org.apache.commons.codec.language.Soundex;
/**
* Test cases for the StingEncoderComparator.
*
* @version $Revision: 1.6 $ $Date: 2003/10/12 01:35:17 $
* @author Tim O'Brien
*/
public class StringEncoderComparatorTest extends TestCase {
public StringEncoderComparatorTest(String name) {
super(name);
}
public void testComparatorNoArgCon() throws Exception {
new StringEncoderComparator();
}
public void testComparatorWithSoundex() throws Exception {
StringEncoderComparator sCompare =
new StringEncoderComparator( new Soundex() );
assertTrue( "O'Brien and O'Brian didn't come out with " +
"the same Soundex, something must be wrong here",
0 == sCompare.compare( "O'Brien", "O'Brian" ) );
}
public void testComparatorWithDoubleMetaphone() throws Exception {
StringEncoderComparator sCompare =
new StringEncoderComparator( new DoubleMetaphone() );
String[] testArray = { "Jordan", "Sosa", "Prior", "Pryor" };
List testList = Arrays.asList( testArray );
String[] controlArray = { "Jordan", "Prior", "Pryor", "Sosa" };
Collections.sort( testList, sCompare);
String[] resultArray = (String[]) testList.toArray(new String[0]);
for( int i = 0; i < resultArray.length; i++) {
assertEquals( "Result Array not Equal to Control Array at index: " + i, controlArray[i], resultArray[i] );
}
}
public void testComparatorWithDoubleMetaphoneAndInvalidInput() throws Exception {
StringEncoderComparator sCompare =
new StringEncoderComparator( new DoubleMetaphone() );
int compare = sCompare.compare(new Double(3.0), new Long(3));
assertEquals( "Trying to compare objects that make no sense to the underlying encoder should return a zero compare code",
0, compare);
}
}
commons-codec-1.2/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java 100644 0 0 7700 7760562321 25470 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.codec;
import junit.framework.TestCase;
/**
* @version $Revision: 1.5 $ $Date: 2003/10/05 21:45:49 $
* @author Rodney Waldhoff
* @author Tim O'Brien
*/
public abstract class StringEncoderAbstractTest extends TestCase {
public StringEncoderAbstractTest(String name) {
super(name);
}
protected abstract StringEncoder makeEncoder();
// ------------------------------------------------------------------------
public void testEncodeEmpty() throws Exception {
Encoder encoder = makeEncoder();
encoder.encode("");
encoder.encode(" ");
encoder.encode("\t");
}
public void testEncodeNull() throws Exception {
StringEncoder encoder = makeEncoder();
try {
encoder.encode(null);
} catch( EncoderException ee ) {
// An exception should be thrown
}
}
public void testEncodeWithInvalidObject() throws Exception {
boolean exceptionThrown = false;
try {
StringEncoder encoder = makeEncoder();
encoder.encode( new Float( 3.4 ) );
} catch( Exception e ) {
exceptionThrown = true;
}
assertTrue( "An exception was not thrown when we tried to encode " +
"a Float object", exceptionThrown );
}
}
commons-codec-1.2/src/test/org/apache/commons/codec/net/URLCodecTest.java 100644 0 0 24446 7760562321 23452 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.codec.net;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;
import junit.framework.TestCase;
/**
* URL codec test cases
*
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
*/
public class URLCodecTest extends TestCase {
static final int SWISS_GERMAN_STUFF_UNICODE [] = {
0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4
};
static final int RUSSIAN_STUFF_UNICODE [] = {
0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438,
0x432, 0x435, 0x442
};
public URLCodecTest(String name) {
super(name);
}
private String constructString(int [] unicodeChars) {
StringBuffer buffer = new StringBuffer();
if (unicodeChars != null) {
for (int i = 0; i < unicodeChars.length; i++) {
buffer.append((char)unicodeChars[i]);
}
}
return buffer.toString();
}
public void testUTF8RoundTrip() throws Exception {
String ru_msg = constructString(RUSSIAN_STUFF_UNICODE);
String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
URLCodec codec = new URLCodec();
assertEquals(
"%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82",
codec.encode(ru_msg, "UTF-8")
);
assertEquals("Gr%C3%BCezi_z%C3%A4m%C3%A4", codec.encode(ch_msg, "UTF-8"));
assertEquals(ru_msg, codec.decode(codec.encode(ru_msg, "UTF-8"), "UTF-8"));
assertEquals(ch_msg, codec.decode(codec.encode(ch_msg, "UTF-8"), "UTF-8"));
}
public void testBasicEncodeDecode() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "Hello there!";
String encoded = urlcodec.encode(plain);
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);
assertEquals("Basic URL decoding test",
plain, urlcodec.decode(encoded));
}
public void testSafeCharEncodeDecode() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "abc123_-.*";
String encoded = urlcodec.encode(plain);
assertEquals("Safe chars URL encoding test",
plain, encoded);
assertEquals("Safe chars URL decoding test",
plain, urlcodec.decode(encoded));
}
public void testUnsafeEncodeDecode() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "~!@#$%^&()+{}\"\\;:`,/[]";
String encoded = urlcodec.encode(plain);
assertEquals("Unsafe chars URL encoding test",
"%7E%21%40%23%24%25%5E%26%28%29%2B%7B%7D%22%5C%3B%3A%60%2C%2F%5B%5D", encoded);
assertEquals("Unsafe chars URL decoding test",
plain, urlcodec.decode(encoded));
}
public void testEncodeDecodeNull() throws Exception {
URLCodec urlcodec = new URLCodec();
assertNull("Null string URL encoding test",
urlcodec.encode((String)null));
assertNull("Null string URL decoding test",
urlcodec.decode((String)null));
}
public void testDecodeInvalid() throws Exception {
URLCodec urlcodec = new URLCodec();
try {
urlcodec.decode("%");
fail("DecoderException should have been thrown");
} catch(DecoderException e) {
// Expected. Move on
}
try {
urlcodec.decode("%A");
fail("DecoderException should have been thrown");
} catch(DecoderException e) {
// Expected. Move on
}
try {
urlcodec.decode("%WW");
fail("DecoderException should have been thrown");
} catch(DecoderException e) {
// Expected. Move on
}
}
public void testEncodeNull() throws Exception {
URLCodec urlcodec = new URLCodec();
byte[] plain = null;
byte[] encoded = urlcodec.encode(plain);
assertEquals("Encoding a null string should return null",
null, encoded);
}
public void testEncodeUrlWithNullBitSet() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "Hello there!";
String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes()));
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);
assertEquals("Basic URL decoding test",
plain, urlcodec.decode(encoded));
}
public void testDecodeWithNullArray() throws Exception {
byte[] plain = null;
byte[] result = URLCodec.decodeUrl( plain );
assertEquals("Result should be null", null, result);
}
public void testEncodeStringWithNull() throws Exception {
URLCodec urlcodec = new URLCodec();
String test = null;
String result = urlcodec.encode( test, "charset" );
assertEquals("Result should be null", null, result);
}
public void testDecodeStringWithNull() throws Exception {
URLCodec urlcodec = new URLCodec();
String test = null;
String result = urlcodec.decode( test, "charset" );
assertEquals("Result should be null", null, result);
}
public void testEncodeObjects() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "Hello there!";
String encoded = (String) urlcodec.encode((Object) plain);
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);
byte[] plainBA = plain.getBytes();
byte[] encodedBA = (byte[]) urlcodec.encode((Object) plainBA);
encoded = new String(encodedBA);
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);
Object result = urlcodec.encode((Object) null);
assertEquals( "Encoding a null Object should return null", null, result);
try {
Object dObj = new Double(3.0);
urlcodec.encode( dObj );
fail( "Trying to url encode a Double object should cause an exception.");
} catch( EncoderException ee ) {
}
}
public void testInvalidEncoding() {
URLCodec urlcodec = new URLCodec("NONSENSE");
String plain = "Hello there!";
try {
String encoded = urlcodec.encode(plain);
fail( "We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
} catch( EncoderException ee ) {
}
try {
String decoded = urlcodec.decode(plain);
fail( "We set the encoding to a bogus NONSENSE vlaue, this shouldn't have worked.");
} catch( DecoderException ee ) {
}
}
public void testDecodeObjects() throws Exception {
URLCodec urlcodec = new URLCodec();
String plain = "Hello+there%21";
String decoded = (String) urlcodec.decode((Object) plain);
assertEquals("Basic URL decoding test",
"Hello there!", decoded);
byte[] plainBA = plain.getBytes();
byte[] decodedBA = (byte[]) urlcodec.decode((Object) plainBA);
decoded = new String(decodedBA);
assertEquals("Basic URL decoding test",
"Hello there!", decoded);
Object result = urlcodec.decode((Object) null);
assertEquals( "Decoding a null Object should return null", null, result);
try {
Object dObj = new Double(3.0);
urlcodec.decode( dObj );
fail( "Trying to url encode a Double object should cause an exception.");
} catch( DecoderException ee ) {
}
}
}
commons-codec-1.2/src/test/org/apache/commons/codec/language/SoundexTest.java 100644 0 0 26354 7760562321 24474 0 ustar 0 0 /*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache" nor may "Apache" appear in their name without prior
* written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
// (FYI: Formatted and sorted with Eclipse)
package org.apache.commons.codec.language;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.codec.StringEncoder;
import org.apache.commons.codec.StringEncoderAbstractTest;
/**
* Tests {@link Soundex}
*
* @version $Revision: 1.8 $ $Date: 2003/11/12 19:32:52 $
* @author Rodney Waldhoff
* @author Gary Gregory
*/
public class SoundexTest extends StringEncoderAbstractTest {
public static Test suite() {
return (new TestSuite(SoundexTest.class));
}
private Soundex encoder = null;
public SoundexTest(String name) {
super(name);
}
/**
* @return Returns the _encoder.
*/
public Soundex getEncoder() {
return this.encoder;
}
protected StringEncoder makeEncoder() {
return new Soundex();
}
/**
* @param encoder
* The encoder to set.
*/
public void setEncoder(Soundex encoder) {
this.encoder = encoder;
}
public void setUp() throws Exception {
super.setUp();
this.setEncoder(new Soundex());
}
public void tearDown() throws Exception {
super.tearDown();
this.setEncoder(null);
}
void encodeAll(String[] strings, String expectedEncoding) {
for (int i = 0; i < strings.length; i++) {
assertEquals(expectedEncoding, this.getEncoder().encode(strings[i]));
}
}
public void testB650() {
this.encodeAll(
new String[] {
"BARHAM",
"BARONE",
"BARRON",
"BERNA",
"BIRNEY",
"BIRNIE",
"BOOROM",
"BOREN",
"BORN",
"BOURN",
"BOURNE",
"BOWRON",
"BRAIN",
"BRAME",
"BRANN",
"BRAUN",
"BREEN",
"BRIEN",
"BRIM",
"BRIMM",
"BRINN",
"BRION",
"BROOM",
"BROOME",
"BROWN",
"BROWNE",
"BRUEN",
"BRUHN",
"BRUIN",
"BRUMM",
"BRUN",
"BRUNO",
"BRYAN",
"BURIAN",
"BURN",
"BURNEY",
"BYRAM",
"BYRNE",
"BYRON",
"BYRUM" },