You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/12/23 23:52:04 UTC
svn commit: r729164 - in /activemq/activemq-cpp/trunk/src:
main/decaf/net/URI.cpp test/decaf/net/URITest.cpp test/decaf/net/URITest.h
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();
};