You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2002/09/11 00:42:40 UTC
cvs commit: jakarta-slide/src/tests/uri HttpsURLTest.java URITestSuite.java
jericho 2002/09/10 15:42:39
Modified: src/tests/uri URITestSuite.java
Added: src/tests/uri HttpsURLTest.java
Log:
- Add the basic HTTPS URL test case and include it as one of the URI test suite.
Revision Changes Path
1.4 +2 -1 jakarta-slide/src/tests/uri/URITestSuite.java
Index: URITestSuite.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/tests/uri/URITestSuite.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- URITestSuite.java 4 Sep 2002 00:21:42 -0000 1.3
+++ URITestSuite.java 10 Sep 2002 22:42:39 -0000 1.4
@@ -103,6 +103,7 @@
suite.addTest(KoreanURITest.suite());
suite.addTest(URIUtilTest.suite());
suite.addTest(HttpURLTest.suite());
+ suite.addTest(HttpsURLTest.suite());
// TODO: add other all URI suites
return suite;
}
1.1 jakarta-slide/src/tests/uri/HttpsURLTest.java
Index: HttpsURLTest.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 apache@apache.org.
*
* 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 org.apache.util.HttpsURL;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
* The HttpsURL testcases {@link org.apache.util.HttpsURL}.
*
* @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
* @version $Id: HttpsURLTest.java,v 1.1 2002/09/10 22:42:39 jericho Exp $
*/
public class HttpsURLTest extends URITestBase {
// ----------------------------------------------------------- constructors
/**
* The constructor.
*
* @param name the name
*/
public HttpsURLTest(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(HttpsURLTest.class);
suite.setName("HttpsURL tests");
return suite;
}
// ----------------------------------------------------------- test methods
/**
* Test the example 01, HttpsURL constructor.
*/
public void testExample01() throws URIException {
String result = "https://host/path?query#fragment";
HttpsURL https = new HttpsURL(result);
assertEquals(result, https.getURI());
}
/**
* Test the example 02, HttpsURL constructor.
*/
public void testExample02() throws URIException {
String result = "https://host/path";
HttpsURL https = new HttpsURL("host", "/path");
assertEquals(result, https.getURI());
}
/**
* Test the example 03, HttpsURL constructor.
*/
public void testExample03() throws URIException {
String result = "https://host/path";
HttpsURL https = new HttpsURL("host", -1, "/path");
assertEquals(result, https.getURI());
result = "https://host:8080/path";
https = new HttpsURL("host", 8080, "/path");
assertEquals(result, https.getURI());
}
/**
* Test the example 04, HttpsURL constructor.
*/
public void testExample04() throws URIException {
String result = "https://host/path?query";
HttpsURL https = new HttpsURL("host", -1, "/path", "query");
assertEquals(result, https.getURI());
result = "https://host:8080/path?query";
https = new HttpsURL("host", 8080, "/path", "query");
assertEquals(result, https.getURI());
}
/**
* Test the example 05, HttpsURL constructor.
*/
public void testExample05() throws URIException {
String uri = "https://user:password@host";
HttpsURL https = new HttpsURL("user", "password", "host");
String result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host";
assertEquals(result, https.getURI());
uri = "https://user@host";
https = new HttpsURL("user", null, "host");
result = "user";
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getPassword());
result = "https://host";
assertEquals(result, https.getURI());
}
/**
* Test the example 06, HttpsURL constructor.
*/
public void testExample06() throws URIException {
String result = "https://user:password@host:8080";
HttpsURL https = new HttpsURL("user", "password", "host", 8080);
result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://user:password@host:80";
https = new HttpsURL("user", "password", "host", 80);
result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host:80";
assertEquals(result, https.getURI());
result = "https://user@host";
https = new HttpsURL("user", null, "host", -1);
result = "user";
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getPassword());
result = "https://host";
assertEquals(result, https.getURI());
}
/**
* Test the example 07, HttpsURL constructor.
*/
public void testExample07() throws URIException {
String uri = "https://user:password@host:8080/path";
HttpsURL https = new HttpsURL("user", "password", "host", 8080, "/path");
String result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host:8080/path";
assertEquals(result, https.getURI());
result = "https://user:password@host:80/path";
https = new HttpsURL("user", "password", "host", 80, "/path");
result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host:80/path";
assertEquals(result, https.getURI());
result = "https://user@host/path";
https = new HttpsURL("user", null, "host", -1, "/path");
result = "user";
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getPassword());
result = "https://host/path";
assertEquals(result, https.getURI());
}
/**
* Test the example 08, HttpsURL constructor.
*/
public void testExample08() throws URIException {
String uri = "https://user:password@host:8080/path?query";
HttpsURL https = new HttpsURL("user", "password", "host", 8080, "/path",
"query");
String result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host:8080/path?query";
assertEquals(result, https.getURI());
uri = "https://user:password@host:80/path?query";
https = new HttpsURL("user", "password", "host", 80, "/path", "query");
result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host:80/path?query";
assertEquals(result, https.getURI());
uri = "https://user@host/path?query";
https = new HttpsURL("user", null, "host", -1, "/path", "query");
result = "user";
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getPassword());
result = "https://host/path?query";
assertEquals(result, https.getURI());
uri = "https://user@host/path";
https = new HttpsURL("user", null, "host", -1, "/path", null);
result = "user";
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getPassword());
result = "https://host/path";
assertEquals(result, https.getURI());
uri = "https://host/";
https = new HttpsURL(null, null, "host", -1, "/", null);
result = "https://host/";
assertEquals(result, https.getURI());
}
/**
* Test the example 09, HttpsURL constructor.
*/
public void testExample09() throws URIException {
String result = "https://host/path?query";
HttpsURL https = new HttpsURL("host", "/path", "query", null);
assertEquals(result, https.getURI());
result = "https://host/path";
https = new HttpsURL("host", "/path", null, null);
assertEquals(result, https.getURI());
}
/**
* Test the example 10, HttpsURL constructor.
*/
public void testExample10() throws URIException {
String uri = "https://user:password@host:8080/path?query#fragment";
HttpsURL https = new HttpsURL("user:password", "host", 8080, "/path",
"query", "fragment");
String result = "https://host:8080/path?query#fragment";
assertEquals(result, https.getURI());
result = "/path?query#fragment";
https = new HttpsURL(null, null, -1, "/path", "query", "fragment");
assertEquals(result, https.getURI());
}
/**
* Test the example 11, HttpsURL constructor.
*/
public void testExample11() throws URIException {
String uri = "https://user:password@host/path?query#fragment";
HttpsURL https = new HttpsURL("user:password", "host", "/path", "query",
"fragment");
String result = "user";
assertEquals(result, https.getUser());
result = "password";
assertEquals(result, https.getPassword());
result = "https://host/path?query#fragment";
assertEquals(result, https.getURI());
result = "/path?query#fragment";
https = new HttpsURL(null, null, "/path", "query", "fragment");
result = null;
assertEquals(result, https.getUser());
result = null;
assertEquals(result, https.getUser());
result = "/path?query#fragment";
assertEquals(result, https.getURI());
}
/**
* Test the example 12, HttpsURL constructor.
*/
public void testExample12() throws URIException {
String uri = "/ns1/ns2/ns3/";
HttpsURL https = new HttpsURL(uri);
String result = "/ns1/ns2/ns3/";
assertEquals(result, https.getPath());
result = "/ns1/ns2/ns3";
assertEquals(result, https.getCurrentHierPath());
result = "/ns1/ns2";
assertEquals(result, https.getAboveHierPath());
uri = "/ns1/ns2/ns3";
https = new HttpsURL(uri);
result = "/ns1/ns2/ns3";
assertEquals(result, https.getPath());
result = "/ns1/ns2";
assertEquals(result, https.getCurrentHierPath());
result = "/ns1";
assertEquals(result, https.getAboveHierPath());
uri = "/ns1/ns2/";
https = new HttpsURL(uri);
result = "/ns1/ns2/";
assertEquals(result, https.getPath());
result = "/ns1/ns2";
assertEquals(result, https.getCurrentHierPath());
result = "/ns1";
assertEquals(result, https.getAboveHierPath());
uri = "/ns1/ns2";
https = new HttpsURL(uri);
result = "/ns1/ns2";
assertEquals(result, https.getPath());
result = "/ns1";
assertEquals(result, https.getCurrentHierPath());
result = "/";
assertEquals(result, https.getAboveHierPath());
uri = "/ns1/";
https = new HttpsURL(uri);
result = "/ns1/";
assertEquals(result, https.getPath());
result = "/ns1";
assertEquals(result, https.getCurrentHierPath());
result = "/";
assertEquals(result, https.getAboveHierPath());
uri = "/ns1";
https = new HttpsURL(uri);
result = "/ns1";
assertEquals(result, https.getPath());
result = "/";
assertEquals(result, https.getCurrentHierPath());
result = "/";
assertEquals(result, https.getAboveHierPath());
uri = "/";
https = new HttpsURL(uri);
result = "/";
assertEquals(result, https.getPath());
result = "/";
assertEquals(result, https.getCurrentHierPath());
result = "/";
assertEquals(result, https.getAboveHierPath());
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>