jericho 2002/08/17 16:31:04 Added: src/tests/uri URITestSuite.java KoreanURITest.java Log: - Add the Korean multi-bytes test cases - Add the test suite to test all.... Revision Changes Path 1.1 jakarta-slide/src/tests/uri/URITestSuite.java Index: URITestSuite.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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 acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Slide", 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 [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names 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 uri; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * The test suite for URI {@link org.apache.util.URI}. * * @author <a href="mailto:jericho at apache.org">Sung-Gu</a> * @version $Id: URITestSuite.java,v 1.1 2002/08/17 23:31:04 jericho Exp $ */ public class URITestSuite extends TestCase { // ----------------------------------------------------------- constructors /** * The constructor. * * @param name the name */ public URITestSuite(String name) { super(name); } // ------------------------------------------------------------------- main /** * The command line interface with java compiler. * * @param args arguments */ public static void main(String[] args) { TestRunner.run(suite()); } // ---------------------------------------------------------- suite methods /** * Return the suite. * * @return Test */ public static Test suite() { TestSuite suite = new TestSuite(URITestSuite.class); suite.setName("All URI tests"); suite.addTest(BasicURITest.suite()); suite.addTest(KoreanURITest.suite()); // TODO: add other all URI suites return suite; } } 1.1 jakarta-slide/src/tests/uri/KoreanURITest.java Index: KoreanURITest.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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 acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Slide", 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 [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names 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 uri; import org.apache.util.URI; import org.apache.util.URIException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * The korean characters testcases for URI {@link org.apache.util.URI}. * * @author <a href="mailto:jericho at apache.org">Sung-Gu</a> * @version $Id: KoreanURITest.java,v 1.1 2002/08/17 23:31:04 jericho Exp $ */ public class KoreanURITest extends URITestBase { // ----------------------------------------------------------- constructors /** * The constructor. * * @param name the name */ public KoreanURITest(String name) { super(name); } // ------------------------------------------------------------- properties /** * The URI example 1. */ protected String uri01; /** * The URI example 2. */ protected String uri02; /** * The URI example 3. */ protected String uri03; /** * The URI example 4. */ protected String uri04; /** * The URI example 5. */ protected String uri05; /** * The URI example 6. */ protected String uri06; /** * The URI example 7. */ protected String uri07; /** * The URI example 8. */ protected String uri08; // ------------------------------------------------------------------- main /** * The command line interface with java compiler. * * @param args arguments */ public static void main(String[] args) { TestRunner.run(suite()); } // ---------------------------------------------------------- suite methods /** * Return the suite. * * @return Test */ public static Test suite() { TestSuite suite = new TestSuite(KoreanURITest.class); suite.setName("Korean characters URI tests"); return suite; } /** * Set up. */ protected void setUp() throws Exception { uri01 = "http://HanGul/���?����#����"; uri02 = "http://HanGul/���?����"; uri03 = "http://HanGul/���"; uri04 = "https://Corean:81/���ѹα�/�ѱ�/"; uri05 = "https://Korean:82/��ī��Ÿ/�����̵�_������Ʈ"; uri06 = "http://HanJa/����?����#߳��"; uri07 = "http://HanJa/����?����"; uri08 = "http://HanJa/����"; } /** * Tear down. */ protected void tearDown() throws Exception { super.tearDown(); } // ----------------------------------------------------------- test methods /** * Test the example 01. */ public void testExample01() throws URIException { URI uri = new URI(this.uri01); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanGul"; char[] rawHost = { 'H', 'a', 'n', 'G', 'u', 'l' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/���?����"; String escapedPathQuery = "/%EA%B2%BD%EB%A1%9C?%EC%A7%88%EC%9D%98"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/���"; String escapedPath = "/%EA%B2%BD%EB%A1%9C"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = "����"; String escapedQuery = "%EC%A7%88%EC%9D%98"; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = "����"; String escapedFragment = "%EC%B0%B8%EC%A1%B0"; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanGul/���?����#����"; String escapedUriReference = "http://HanGul/%EA%B2%BD%EB%A1%9C?%EC%A7" + "%88%EC%9D%98#%EC%B0%B8%EC%A1%B0"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 02. */ public void testExample02() throws URIException { URI uri = new URI(this.uri02); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanGul"; char[] rawHost = { 'H', 'a', 'n', 'G', 'u', 'l' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/���?����"; String escapedPathQuery = "/%EA%B2%BD%EB%A1%9C?%EC%A7%88%EC%9D%98"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/���"; String escapedPath = "/%EA%B2%BD%EB%A1%9C"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = "����"; String escapedQuery = "%EC%A7%88%EC%9D%98"; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanGul/���?����"; String escapedUriReference = "http://HanGul/%EA%B2%BD%EB%A1%9C?%EC%A7" + "%88%EC%9D%98"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 03. */ public void testExample03() throws URIException { URI uri = new URI(this.uri03); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanGul"; char[] rawHost = { 'H', 'a', 'n', 'G', 'u', 'l' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/���"; String escapedPathQuery = "/%EA%B2%BD%EB%A1%9C"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/���"; String escapedPath = "/%EA%B2%BD%EB%A1%9C"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = null; String escapedQuery = null; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanGul/���"; String escapedUriReference = "http://HanGul/%EA%B2%BD%EB%A1%9C"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 04. */ public void testExample04() throws URIException { URI uri = new URI(this.uri04); String scheme = "https"; char[] rawScheme = { 'h', 't', 't', 'p', 's' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "Corean"; assertEquals(host, uri.getHost()); int port = 81; assertEquals(port, uri.getPort()); String pathQuery = "/���ѹα�/�ѱ�/"; String escapedPathQuery = "/%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD/%ED" + "%95%9C%EA%B8%80/"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/���ѹα�/�ѱ�/"; String escapedPath = "/%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD/%ED" + "%95%9C%EA%B8%80/"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = null; String escapedQuery = null; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "https://Corean:81/���ѹα�/�ѱ�/"; String escapedUriReference = "https://Corean:81/%EB%8C%80%ED%95%9C" + "%EB%AF%BC%EA%B5%AD/%ED%95%9C%EA%B8%80/"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 05. */ public void testExample05() throws URIException { URI uri = new URI(this.uri05); String scheme = "https"; char[] rawScheme = { 'h', 't', 't', 'p', 's' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "Korean"; assertEquals(host, uri.getHost()); int port = 82; assertEquals(port, uri.getPort()); String pathQuery = "/��ī��Ÿ/�����̵�_������Ʈ"; String escapedPathQuery = "/%EC%9E%90%EC%B9%B4%EB%A5%B4%ED%83%80/%EC" + "%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C_%ED%94%84%EB%A1%9C%EC%A0%9D" + "%ED%8A%B8"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/��ī��Ÿ/�����̵�_������Ʈ"; String escapedPath = "/%EC%9E%90%EC%B9%B4%EB%A5%B4%ED%83%80/%EC%8A" + "%AC%EB%9D%BC%EC%9D%B4%EB%93%9C_%ED%94%84%EB%A1%9C%EC%A0%9D%ED" + "%8A%B8"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = null; String escapedQuery = null; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "https://Korean:82/��ī��Ÿ/�����̵�_������Ʈ"; String escapedUriReference = "https://Korean:82/%EC%9E%90%EC%B9%B4" + "%EB%A5%B4%ED%83%80/%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C_%ED%94" + "%84%EB%A1%9C%EC%A0%9D%ED%8A%B8"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 06. */ public void testExample06() throws URIException { URI uri = new URI(this.uri06); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanJa"; char[] rawHost = { 'H', 'a', 'n', 'J', 'a' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/����?����"; String escapedPathQuery = "/%E7%B6%93%E8%B7%AF?%E8%B3%AA%E7%96%91"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/����"; String escapedPath = "/%E7%B6%93%E8%B7%AF"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = "����"; String escapedQuery = "%E8%B3%AA%E7%96%91"; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = "߳��"; String escapedFragment = "%EF%A5%AB%E7%85%A7"; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanJa/����?����#߳��"; String escapedUriReference = "http://HanJa/%E7%B6%93%E8%B7%AF?%E8%B3" + "%AA%E7%96%91#%EF%A5%AB%E7%85%A7"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 07. */ public void testExample07() throws URIException { URI uri = new URI(this.uri07); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanJa"; char[] rawHost = { 'H', 'a', 'n', 'J', 'a' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/����?����"; String escapedPathQuery = "/%E7%B6%93%E8%B7%AF?%E8%B3%AA%E7%96%91"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/����"; String escapedPath = "/%E7%B6%93%E8%B7%AF"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = "����"; String escapedQuery = "%E8%B3%AA%E7%96%91"; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanJa/����?����"; String escapedUriReference = "http://HanJa/%E7%B6%93%E8%B7%AF?%E8%B3" + "%AA%E7%96%91"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } /** * Test the example 08. */ public void testExample08() throws URIException { URI uri = new URI(this.uri08); String scheme = "http"; char[] rawScheme = { 'h', 't', 't', 'p' }; assertEquals(scheme, uri.getScheme()); assertEquals(rawScheme, uri.getRawScheme()); String host = "HanJa"; char[] rawHost = { 'H', 'a', 'n', 'J', 'a' }; assertEquals(host, uri.getHost()); assertEquals(rawHost, uri.getRawHost()); int port = -1; assertEquals(port, uri.getPort()); String pathQuery = "/����"; String escapedPathQuery = "/%E7%B6%93%E8%B7%AF"; assertEquals(pathQuery, uri.getPathQuery()); assertEquals(escapedPathQuery, uri.getEscapedPathQuery()); String path = "/����"; String escapedPath = "/%E7%B6%93%E8%B7%AF"; assertEquals(path, uri.getPath()); assertEquals(escapedPath, uri.getEscapedPath()); String query = null; String escapedQuery = null; assertEquals(query, uri.getQuery()); assertEquals(escapedQuery, uri.getEscapedQuery()); String fragment = null; String escapedFragment = null; assertEquals(fragment, uri.getFragment()); assertEquals(escapedFragment, uri.getEscapedFragment()); String uriReference = "http://HanJa/����"; String escapedUriReference = "http://HanJa/%E7%B6%93%E8%B7%AF"; assertEquals(uriReference, uri.getURI()); assertEquals(escapedUriReference, uri.getEscapedURI()); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
