Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 58523 invoked from network); 23 Dec 2008 22:52:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Dec 2008 22:52:37 -0000 Received: (qmail 69454 invoked by uid 500); 23 Dec 2008 22:52:37 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 69430 invoked by uid 500); 23 Dec 2008 22:52:37 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 69420 invoked by uid 99); 23 Dec 2008 22:52:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Dec 2008 14:52:37 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Dec 2008 22:52:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 17167238896C; Tue, 23 Dec 2008 14:52:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r729164 - in /activemq/activemq-cpp/trunk/src: main/decaf/net/URI.cpp test/decaf/net/URITest.cpp test/decaf/net/URITest.h Date: Tue, 23 Dec 2008 22:52:04 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081223225205.17167238896C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Tue Dec 23 14:52:04 2008 New Revision: 729164 URL: http://svn.apache.org/viewvc?rev=729164&view=rev Log: Completed URI class and Unit tests. Modified: activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.cpp activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.h Modified: activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp?rev=729164&r1=729163&r2=729164&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp Tue Dec 23 14:52:04 2008 @@ -837,6 +837,8 @@ // except that it has the fragment from the relative URI. result = *this; result.uri.setFragment( relative.uri.getFragment() ); + result.uriString = ""; + // no need to re-calculate the scheme specific part, // since fragment is not part of scheme specific part. return result; @@ -908,13 +910,6 @@ result.append( this->uri.getAuthority() ); } - if( this->uri.getScheme() != "" && - this->uri.getAuthority() == "" && - this->uri.getPath() != "" ) { - - result.append( "//" ); - } - if( this->uri.getPath() != "" ) { result.append( this->uri.getPath() ); } Modified: activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.cpp?rev=729164&r1=729163&r2=729164&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.cpp Tue Dec 23 14:52:04 2008 @@ -443,7 +443,7 @@ CPPUNIT_ASSERT_MESSAGE( string( "incorrect toString()" ) + uri.toString(), - uri.toString() == "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#fragment" ); + uri.toString() == "ht12-3+tp:/p%23a%25E2%2582%25ACth?q%5Eu%2525ery#fragment" ); } //////////////////////////////////////////////////////////////////////////////// @@ -735,7 +735,7 @@ CPPUNIT_ASSERT_MESSAGE( string( "Host not null for URI " ) + uri.toString(), uri.getHost() == "" ); CPPUNIT_ASSERT_MESSAGE( string( "testB, toString() returned incorrect value:" ) + uri.toString(), - string( "file:///tmp#frag" ) == uri.toString() ); + string( "file:/tmp#frag" ) == uri.toString() ); } { URI uri( "file", "", "/tmp", "query", "frag" ); @@ -744,21 +744,21 @@ CPPUNIT_ASSERT_MESSAGE( "Host not null for URI " + uri.toString(), uri.getHost() == "" ); CPPUNIT_ASSERT_MESSAGE( "test C, toString() returned incorrect value", - string( "file:///tmp?query#frag" ) == uri.toString() ); + string( "file:/tmp?query#frag" ) == uri.toString() ); } // after normalization the host string info may be lost since the // uri string is reconstructed - URI uri( "file", "", "/tmp/a/../b/c", "query", "frag" ); + URI uri( "file", "www.google.com", "/tmp/a/../b/c", "query", "frag" ); URI uri2 = uri.normalize(); CPPUNIT_ASSERT_MESSAGE( string( "Authority not null for URI: " ) + uri2.toString(), - uri.getAuthority() == "" ); + uri.getAuthority() == "www.google.com" ); CPPUNIT_ASSERT_MESSAGE( string( "Host not null for URI " ) + uri2.toString(), - uri.getHost() == "" ); + uri.getHost() == "www.google.com" ); CPPUNIT_ASSERT_MESSAGE( "test D, toString() returned incorrect value: " + uri.toString(), - string( "file:///tmp/a/../b/c?query#frag" ) == uri.toString() ); + string( "file://www.google.com/tmp/a/../b/c?query#frag" ) == uri.toString() ); CPPUNIT_ASSERT_MESSAGE( "test E, toString() returned incorrect value: " + uri2.toString(), - string( "file:/tmp/b/c?query#frag" ) == uri2.toString() ); + string( "file://www.google.com/tmp/b/c?query#frag" ) == uri2.toString() ); // the empty string host will give URISyntaxException // for the 7 arg constructor @@ -1585,7 +1585,7 @@ "http://www.oogle.com", }; - for( unsigned int i = 0; i < 0; i++ ) { + for( unsigned int i = 0; i < 12; i++ ) { try { @@ -1643,33 +1643,40 @@ } } -/* //////////////////////////////////////////////////////////////////////////////// -void URITest::test_toURL() { - String absoluteuris[] = new const char* { "mailto:noreply@apache.org", - "urn:isbn:123498989h", "news:software.ibm.com", - "http://www.apache.org", "file:///d:/temp/results.txt", - "scheme:ssp", }; - - String relativeuris[] = new const char* { "calculate.pl?isbn=123498989h", - "?isbn=123498989h", "//www.apache.org", "a.html", "#top", - "//pc1/", "//user@host/path/file" }; +void URITest::testToURL() { - for (int i = 0; i < absoluteuris.length; i++) { + const char* absoluteuris[] = { + "mailto:noreply@apache.org", + "urn:isbn:123498989h", + "news:software.ibm.com", + "http://www.apache.org", + "file:///d:/temp/results.txt", + "scheme:ssp", }; + + const char* relativeuris[] = { + "calculate.pl?isbn=123498989h", + "?isbn=123498989h", + "//www.apache.org", + "a.html", + "#top", + "//pc1/", + "//user@host/path/file" }; + + for( int i = 0; i < 6; i++ ) { try { - new URI(absoluteuris[i]).toURL(); - } catch (MalformedURLException e) { + URI( absoluteuris[i] ).toURL(); + } catch( MalformedURLException& e ) { // not all the URIs can be translated into valid URLs } } - for (int i = 0; i < relativeuris.length; i++) { + for( int i = 0; i < 7; i++ ) { try { - new URI(relativeuris[i]).toURL(); - fail("Expected IllegalArgumentException not thrown"); - } catch (IllegalArgumentException e) { + URI( relativeuris[i] ).toURL(); + CPPUNIT_FAIL( "Expected IllegalArgumentException not thrown" ); + } catch( IllegalArgumentException& e ) { // Expected } } } - */ Modified: activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.h?rev=729164&r1=729163&r2=729164&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.h (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/net/URITest.h Tue Dec 23 14:52:04 2008 @@ -67,6 +67,7 @@ CPPUNIT_TEST( testResolveURI ); CPPUNIT_TEST( testResolve ); CPPUNIT_TEST( testToString ); + CPPUNIT_TEST( testToURL ); CPPUNIT_TEST_SUITE_END(); public: @@ -114,6 +115,7 @@ void testResolveURI(); void testResolve(); void testToString(); + void testToURL(); };