oglueck 2004/01/29 10:39:34 Modified: httpclient/src/java/org/apache/commons/httpclient HttpsURL.java HttpURL.java httpclient/src/test/org/apache/commons/httpclient TestURI.java Log: fixed: getScheme() and getPort() were returning wrong defaults for HttpsURL added: testcase PR: 26328 Revision Changes Path 1.7 +34 -3 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpsURL.java Index: HttpsURL.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpsURL.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- HttpsURL.java 13 Feb 2003 05:08:18 -0000 1.6 +++ HttpsURL.java 29 Jan 2004 18:39:34 -0000 1.7 @@ -440,6 +440,37 @@ */ static final long serialVersionUID = 887844277028676648L; + // ------------------------------------------------------------- The scheme + + /** + * Get the scheme. You can get the scheme explicitly. + * + * @return the scheme + */ + public char[] getRawScheme() { + return (_scheme == null) ? null : HttpsURL.DEFAULT_SCHEME; + } + + + /** + * Get the scheme. You can get the scheme explicitly. + * + * @return the scheme null if empty or undefined + */ + public String getScheme() { + return (_scheme == null) ? null : new String(HttpsURL.DEFAULT_SCHEME); + } + + // --------------------------------------------------------------- The port + + /** + * Get the port number. + * @return the port number + */ + public int getPort() { + return (_port == -1) ? HttpsURL.DEFAULT_PORT : _port; + } + // ---------------------------------------------------------------- Utility /** 1.13 +6 -6 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpURL.java Index: HttpURL.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpURL.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- HttpURL.java 4 Apr 2003 02:37:02 -0000 1.12 +++ HttpURL.java 29 Jan 2004 18:39:34 -0000 1.13 @@ -444,7 +444,7 @@ * @return the scheme */ public char[] getRawScheme() { - return (_scheme == null) ? null : DEFAULT_SCHEME; + return (_scheme == null) ? null : HttpURL.DEFAULT_SCHEME; } @@ -454,7 +454,7 @@ * @return the scheme null if empty or undefined */ public String getScheme() { - return (_scheme == null) ? null : new String(DEFAULT_SCHEME); + return (_scheme == null) ? null : new String(HttpURL.DEFAULT_SCHEME); } // --------------------------------------------------------------- The port @@ -464,7 +464,7 @@ * @return the port number */ public int getPort() { - return (_port == -1) ? DEFAULT_PORT : _port; + return (_port == -1) ? HttpURL.DEFAULT_PORT : _port; } // ----------------------------------------------------------- The userinfo 1.7 +13 -3 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java Index: TestURI.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TestURI.java 23 Sep 2003 13:08:42 -0000 1.6 +++ TestURI.java 29 Jan 2004 18:39:34 -0000 1.7 @@ -112,6 +112,16 @@ } + public void testUrl() throws URIException { + URI url = new HttpURL("http://jakarta.apache.org"); + assertEquals(80, url.getPort()); + assertEquals("http", url.getScheme()); + + url = new HttpsURL("https://jakarta.apache.org"); + assertEquals(443, url.getPort()); + assertEquals("https", url.getScheme()); + } + /** * Tests the URI(URI, String) constructor. This tests URIs ability to * resolve relative URIs.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]