activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r729142 - in /activemq/activemq-cpp/trunk/src: main/decaf/internal/net/URIHelper.cpp main/decaf/internal/net/URIType.h main/decaf/net/URI.cpp test/decaf/net/URITest.cpp test/decaf/net/URITest.h
Date Tue, 23 Dec 2008 22:15:00 GMT
Author: tabish
Date: Tue Dec 23 14:15:00 2008
New Revision: 729142

URL: http://svn.apache.org/viewvc?rev=729142&view=rev
Log:
Partially working URI class, updates for bugs found in testing.

Modified:
    activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp
    activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIType.h
    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/internal/net/URIHelper.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp?rev=729142&r1=729141&r2=729142&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp Tue Dec 23 14:15:00 2008
@@ -127,7 +127,7 @@
         }
 
         // Authority and Path
-        if( temp != "" && temp.at(0) == '/' && temp.at(1) == '/' ) {
+        if( temp.size() >= 2 && temp.at(0) == '/' && temp.at(1) == '/' ) {
 
             index = temp.find( '/', 2 );
             if( index != std::string::npos ) {

Modified: activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIType.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIType.h?rev=729142&r1=729141&r2=729142&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIType.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIType.h Tue Dec 23 14:15:00 2008
@@ -49,16 +49,16 @@
 
         URIType( const std::string& source ) : source( source ) {
             this->port = -1;
-            this->opaque = true;
-            this->absolute = true;
+            this->opaque = false;
+            this->absolute = false;
             this->serverAuthority = false;
             this->valid = false;
         }
 
         URIType() {
             this->port = -1;
-            this->opaque = true;
-            this->absolute = true;
+            this->opaque = false;
+            this->absolute = false;
             this->serverAuthority = false;
             this->valid = false;
         }

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=729142&r1=729141&r2=729142&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:15:00 2008
@@ -172,7 +172,9 @@
         uri.append( ":" );
     }
 
-    uri.append( "//" );
+    if( host != "" ) {
+        uri.append( "//" );
+    }
 
     if( host != "" ) {
         std::string newHost = host;
@@ -605,6 +607,10 @@
 ////////////////////////////////////////////////////////////////////////////////
 std::string URI::normalize( const std::string& path ) const {
 
+    if( path == "" ) {
+        return path;
+    }
+
     // count the number of '/'s, to determine number of segments
     unsigned int index = -1;
     unsigned int pathlen = path.length();
@@ -681,7 +687,7 @@
     // if we used at least one segment and the path previously ended with
     // a slash and the last segment is still used, then delete the extra
     // trailing '/'
-    if( !path.at( path.length() - 1 ) == '/' && seglist.size() > 0 &&
+    if( path.at( path.length() - 1 ) != '/' && seglist.size() > 0 &&
         include[seglist.size() - 1] ) {
 
         newpath.erase( newpath.length() - 1, 1 );
@@ -791,7 +797,7 @@
     if( thisPath != relativePath ) {
 
         // if this URI's path doesn't end in a '/', add one
-        if( thisPath.at( thisPath.length() ) != '/' ) {
+        if( thisPath.empty() || thisPath.at( thisPath.length() - 1 ) != '/' ) {
             thisPath = thisPath + '/';
         }
 
@@ -841,9 +847,10 @@
         // if the relative URI has authority,
         // the resolved URI is almost the same as the relative URI,
         // except that it has the scheme of this URI.
-        result = *this;
+        result = relative;
         result.uri.setScheme( this->uri.getScheme() );
         result.uri.setAbsolute( this->uri.isAbsolute() );
+        result.uriString = "";
 
     } else {
 
@@ -854,6 +861,7 @@
         result = *this;
         result.uri.setFragment( relative.uri.getFragment() );
         result.uri.setQuery( relative.uri.getQuery() );
+        result.uriString = "";
 
         if( relative.uri.getPath().at(0) == '/' ) {
             result.uri.setPath( relative.uri.getPath() );
@@ -895,11 +903,18 @@
             result.append( this->uri.getSchemeSpecificPart() );
         } else {
 
-            result.append( "//" );
             if( this->uri.getAuthority() != "" ) {
+                result.append( "//" );
                 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=729142&r1=729141&r2=729142&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:15:00 2008
@@ -215,8 +215,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 void URITest::testURIString() {
 
+    CPPUNIT_ASSERT_NO_THROW_MESSAGE(
+        "Should Not Throw an Exception URI( \"\\\" )",
+        URI uri( "/" )
+    );
+
     try {
-        URI myUri(":abc@mymail.com");
+        URI myUri( ":abc@mymail.com" );
         CPPUNIT_FAIL("TestA, URISyntaxException expected, but not received.");
     } catch( URISyntaxException& e ) {
         CPPUNIT_ASSERT_MESSAGE(
@@ -224,7 +229,7 @@
     }
 
     try {
-        URI uri("path[one");
+        URI uri( "path[one" );
         CPPUNIT_FAIL("TestB, URISyntaxException expected, but not received.");
     } catch( URISyntaxException& e1 ) {
         CPPUNIT_ASSERT_MESSAGE(
@@ -232,7 +237,7 @@
     }
 
     try {
-        URI uri(" ");
+        URI uri( " " );
         CPPUNIT_FAIL("TestC, URISyntaxException expected, but not received.");
     } catch( URISyntaxException& e2 ) {
         CPPUNIT_ASSERT_MESSAGE(
@@ -428,13 +433,16 @@
     CPPUNIT_ASSERT_MESSAGE( "wrong query", uri.getQuery() == "q^u%25ery" );
     CPPUNIT_ASSERT_MESSAGE( "wrong fragment", uri.getFragment() == "fragment" );
 
-    CPPUNIT_ASSERT_MESSAGE( "wrong SchemeSpecificPart",
+    CPPUNIT_ASSERT_MESSAGE(
+        string( "wrong SchemeSpecificPart: " ) + uri.getSchemeSpecificPart(),
         uri.getSchemeSpecificPart() == "///p#a%E2%82%ACth?q^u%25ery" );
 
-    CPPUNIT_ASSERT_MESSAGE( "wrong RawSchemeSpecificPart",
+    CPPUNIT_ASSERT_MESSAGE(
+        string( "wrong RawSchemeSpecificPart" ) + uri.getRawSchemeSpecificPart(),
         uri.getRawSchemeSpecificPart() == "///p%23a%25E2%2582%25ACth?q%5Eu%2525ery" );
 
-    CPPUNIT_ASSERT_MESSAGE( "incorrect toString()",
+    CPPUNIT_ASSERT_MESSAGE(
+        string( "incorrect toString()" ) + uri.toString(),
         uri.toString() == "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#fragment" );
 }
 
@@ -826,7 +834,7 @@
         string result = uris[i].getPath();
         if( getPathResults[i] != result ) {
             CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
-                          string( "\", getHost() returned: " ) + result +
+                          string( "\", getPath() returned: " ) + result +
                           string( ", expected: " ) + getPathResults[i] );
         }
     }
@@ -851,337 +859,351 @@
     }
 }
 
-/*
-public void test_getPort2() throws Exception {
-    // if port value is negative, the authority should be
-    // consider registry based.
-
-    URI uri = new URI("http://myhost:-8096/site/index.html");
-    assertEquals("TestA, returned wrong port value,", -1, uri.getPort());
-    assertNull("TestA, returned wrong host value,", uri.getHost());
-    try {
-        uri.parseServerAuthority();
-        fail("TestA, Expected URISyntaxException");
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetPort2() {
 
-    uri = new URI("http", "//myhost:-8096", null);
-    assertEquals("TestB returned wrong port value,", -1, uri.getPort());
-    assertNull("TestB returned wrong host value,", uri.getHost());
-    try {
-        uri.parseServerAuthority();
-        fail("TestB, Expected URISyntaxException");
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+    // if port value is negative, the authority should be considered registry based.
+
+    URI uri( "http://myhost:-8096/site/index.html" );
+    CPPUNIT_ASSERT_MESSAGE( "TestA, returned wrong port value,", -1 == uri.getPort() );
+    CPPUNIT_ASSERT_MESSAGE( "TestA, returned wrong host value,", uri.getHost() == "" );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "TestA - URISyntaxException expected but not received.",
+        uri.parseServerAuthority(),
+        URISyntaxException );
+
+    URI uri2( "http", "//myhost:-8096", "" );
+    CPPUNIT_ASSERT_MESSAGE( "TestB returned wrong port value,", -1 == uri2.getPort() );
+    CPPUNIT_ASSERT_MESSAGE( "TestB returned wrong host value,", uri2.getHost() == "" );
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "TestB - URISyntaxException expected but not received.",
+        uri2.parseServerAuthority(),
+        URISyntaxException );
 }
 
-/*
-public void test_getQuery() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetQuery() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getQueryResults = { "qu` ery", "qu\u00A9\u00AEery", // =
-            // "qu\u00a9\u00aeery",
-            "qu\u00A9\u00AEery", // = "qu\u00a9\u00aeery",
-            "qu%60%20ery", "qu%C2%A9%C2%AEery", "qu\u00A9\u00AEery", // =
-            // "qu\u00a9\u00aeery",
-            "qu` ery", "que%ry", null, null, null, null, null, "query", "" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getQuery();
-        if (getQueryResults[i] != result
-                && !getQueryResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getQuery() returned: " + result + ", expected: "
-                    + getQueryResults[i]);
+    const char* getQueryResults[] = {
+        "qu` ery",
+        "qu%60%20ery",
+        "qu%C2%A9%C2%AEery",
+        "qu` ery",
+        "que%ry",
+        "", "", "", "", "",
+        "query",
+        ""
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getQuery();
+        if( getQueryResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
+                          string( "\", getQuery() returned: " ) + result +
+                          string( ", expected: " ) + getQueryResults[i] );
         }
     }
 }
 
-/*
-public void test_getRawAuthority() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawAuthority() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawAuthorityResults = {
+    const char* getRawAuthorityResults[] = {
             "user%60%20info@host",
-            "user%C3%9F%C2%A3info@host:80",
-            "user\u00DF\u00A3info@host:0", // =
-            // "user\u00df\u00a3info@host:0",
             "user%2560%2520info@host:80",
             "user%25C3%259F%25C2%25A3info@host",
-            "user\u00DF\u00A3info@host:80", // =
-            // "user\u00df\u00a3info@host:80",
-            "user%60%20info@host:81", "user%25info@host:0", null, null,
-            null, null, "server.org", "reg:istry", null };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawAuthority();
-        if (getRawAuthorityResults[i] != result
-                && !getRawAuthorityResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawAuthority() returned: " + result
-                    + ", expected: " + getRawAuthorityResults[i]);
+            "user%60%20info@host:81",
+            "user%25info@host:0",
+            "", "", "", "",
+            "server.org",
+            "reg:istry",
+            "" };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawAuthority();
+        if( getRawAuthorityResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
+                          string( "\", getRawAuthority() returned: " ) + result +
+                          string( ", expected: " ) + getRawAuthorityResults[i] );
         }
     }
 }
 
-/*
-public void test_getRawFragment() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawFragment() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawFragmentResults = { "fr%5E%20ag",
-            "fr%C3%A4%C3%A8g",
-            "fr\u00E4\u00E8g", // = "fr\u00e4\u00e8g",
-            "fr%255E%2520ag", "fr%25C3%25A4%25C3%25A8g",
-            "fr\u00E4\u00E8g", // =
-            // "fr\u00e4\u00e8g",
-            "fr%5E%20ag", "f%25rag", null, "", null, "fragment", null,
-            null, null };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawFragment();
-        if (getRawFragmentResults[i] != result
-                && !getRawFragmentResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawFragment() returned: " + result
-                    + ", expected: " + getRawFragmentResults[i]);
+    const char* getRawFragmentResults[] = {
+        "fr%5E%20ag",
+        "fr%255E%2520ag",
+        "fr%25C3%25A4%25C3%25A8g",
+        "fr%5E%20ag", "f%25rag",
+        "", "", "",
+        "fragment",
+        "", "", ""
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawFragment();
+        if( getRawFragmentResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
+                          string( "\", getRawFragment() returned: " ) + result +
+                          string( ", expected: " ) + getRawFragmentResults[i] );
         }
     }
 }
 
-/*
-public void test_getRawPath() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawPath() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawPathResults = { "/a%20path",
-            "/a%E2%82%ACpath",
-            "/a\u20ACpath", // = "/a\u0080path",
-            "/a%2520path", "/a%25E2%2582%25ACpath",
-            "/a\u20ACpath", // =
-            // "/a\u0080path",
-            "/a%20path", "/a%25path", null, "../adirectory/file.html",
-            null, "", "", "", "/c:/temp/calculate.pl" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawPath();
-        if (getRawPathResults[i] != result
-                && !getRawPathResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawPath() returned: " + result
-                    + ", expected: " + getRawPathResults[i]);
+    const char* getRawPathResults[] = {
+        "/a%20path",
+        "/a%2520path", "/a%25E2%2582%25ACpath",
+        "/a%20path", "/a%25path", "",
+        "../adirectory/file.html",
+        "", "", "", "",
+        "/c:/temp/calculate.pl" };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawPath();
+        if( getRawPathResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
+                          string( "\", getRawPath() returned: " ) + result +
+                          string( ", expected: " ) + getRawPathResults[i] );
         }
     }
 }
 
-/*
-public void test_getRawQuery() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawQuery() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawQueryResults = {
-            "qu%60%20ery",
-            "qu%C2%A9%C2%AEery",
-            "qu\u00A9\u00AEery", // = "qu\u00a9\u00aeery",
-            "qu%2560%2520ery",
-            "qu%25C2%25A9%25C2%25AEery",
-            "qu\u00A9\u00AEery", // = "qu\u00a9\u00aeery",
-            "qu%60%20ery", "que%25ry", null, null, null, null, null,
-            "query", "" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawQuery();
-        if (getRawQueryResults[i] != result
-                && !getRawQueryResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawQuery() returned: " + result
-                    + ", expected: " + getRawQueryResults[i]);
+    const char* getRawQueryResults[] = {
+        "qu%60%20ery",
+        "qu%2560%2520ery",
+        "qu%25C2%25A9%25C2%25AEery",
+        "qu%60%20ery", "que%25ry",
+        "", "", "", "", "",
+        "query", ""
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawQuery();
+        if( getRawQueryResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI \"" ) + uris[i].toString() +
+                          string( "\", getRawQuery() returned: " ) + result +
+                          string( ", expected: " ) + getRawQueryResults[i] );
         }
     }
-
 }
 
-/*
-public void test_getRawSchemeSpecificPart() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawSchemeSpecificPart() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawSspResults = {
-            "//user%60%20info@host/a%20path?qu%60%20ery",
-            "//user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery",
-            "//user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery", // =
-            // "//user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery"
-            "//user%2560%2520info@host:80/a%2520path?qu%2560%2520ery",
-            "//user%25C3%259F%25C2%25A3info@host/a%25E2%2582%25ACpath?qu%25C2%25A9%25C2%25AEery",
-            "//user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery", // =
-            // "//user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery"
-            "//user%60%20info@host:81/a%20path?qu%60%20ery",
-            "//user%25info@host:0/a%25path?que%25ry", "user@domain.com",
-            "../adirectory/file.html", "comp.infosystems.www.servers.unix",
-            "", "//server.org", "//reg:istry?query",
-            "///c:/temp/calculate.pl?" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawSchemeSpecificPart();
-        if (!getRawSspResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawSchemeSpecificPart() returned: " + result
-                    + ", expected: " + getRawSspResults[i]);
+    const char* getRawSspResults[] = {
+        "//user%60%20info@host/a%20path?qu%60%20ery",
+        "//user%2560%2520info@host:80/a%2520path?qu%2560%2520ery",
+        "//user%25C3%259F%25C2%25A3info@host/a%25E2%2582%25ACpath?qu%25C2%25A9%25C2%25AEery",
+        "//user%60%20info@host:81/a%20path?qu%60%20ery",
+        "//user%25info@host:0/a%25path?que%25ry",
+        "user@domain.com",
+        "../adirectory/file.html",
+        "comp.infosystems.www.servers.unix",
+        "",
+        "//server.org",
+        "//reg:istry?query",
+        "///c:/temp/calculate.pl?"
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawSchemeSpecificPart();
+        if( getRawSspResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI[" ) +
+                          Integer::toString( i ) + string( "] \"" ) + uris[i].toString() +
+                          string( "\", getRawSchemeSpecificPart() returned: " ) + result +
+                          string( ", expected: " ) + getRawSspResults[i] );
         }
     }
 }
 
-/*
-public void test_getRawUserInfo() throws URISyntaxException {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetRawUserInfo() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getRawUserInfoResults = {
-            "user%60%20info",
-            "user%C3%9F%C2%A3info",
-            "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
-            "user%2560%2520info",
-            "user%25C3%259F%25C2%25A3info",
-            "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
-            "user%60%20info", "user%25info", null, null, null, null, null,
-            null, null };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getRawUserInfo();
-        if (getRawUserInfoResults[i] != result
-                && !getRawUserInfoResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getRawUserInfo() returned: " + result
-                    + ", expected: " + getRawUserInfoResults[i]);
+    const char* getRawUserInfoResults[] = {
+        "user%60%20info",
+        "user%2560%2520info",
+        "user%25C3%259F%25C2%25A3info",
+        "user%60%20info", "user%25info",
+        "", "", "", "", "", "", "" };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getRawUserInfo();
+        if( getRawUserInfoResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI[" ) +
+                          Integer::toString( i ) + string( "] \"" ) + uris[i].toString() +
+                          string( "\", getRawUserInfo() returned: " ) + result +
+                          string( ", expected: " ) + getRawUserInfoResults[i] );
         }
     }
 }
 
-/*
-public void test_getScheme() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetScheme() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getSchemeResults = { "http", "http", "ascheme", "http",
-            "http", "ascheme", "http", "http", "mailto", null, "news",
-            null, "telnet", "http", "file" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getScheme();
-        if (getSchemeResults[i] != result
-                && !getSchemeResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getScheme() returned: " + result
-                    + ", expected: " + getSchemeResults[i]);
+    const char* getSchemeResults[] = {
+        "http", "http",
+        "http", "http",
+        "http", "mailto",
+        "", "news",
+        "", "telnet",
+        "http", "file"
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getScheme();
+        if( getSchemeResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI[" ) +
+                          Integer::toString( i ) + string( "] \"" ) + uris[i].toString() +
+                          string( "\", getScheme() returned: " ) + result +
+                          string( ", expected: " ) + getSchemeResults[i] );
         }
     }
 }
 
-/*
-public void test_getSchemeSpecificPart() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetSchemeSpecificPart() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getSspResults = {
-            "//user` info@host/a path?qu` ery",
-            "//user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery", // =
-            // "//user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery",
-            "//user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery", // =
-            // "//user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery",
-            "//user%60%20info@host:80/a%20path?qu%60%20ery",
-            "//user%C3%9F%C2%A3info@host/a%E2%82%ACpath?qu%C2%A9%C2%AEery",
-            "//user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery", // =
-            // "//user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery",
-            "//user` info@host:81/a path?qu` ery",
-            "//user%info@host:0/a%path?que%ry", "user@domain.com",
-            "../adirectory/file.html", "comp.infosystems.www.servers.unix",
-            "", "//server.org", "//reg:istry?query",
-            "///c:/temp/calculate.pl?" };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getSchemeSpecificPart();
-        if (!getSspResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getSchemeSpecificPart() returned: " + result
-                    + ", expected: " + getSspResults[i]);
+    const char* getSspResults[] = {
+        "//user` info@host/a path?qu` ery",
+        "//user%60%20info@host:80/a%20path?qu%60%20ery",
+        "//user%C3%9F%C2%A3info@host/a%E2%82%ACpath?qu%C2%A9%C2%AEery",
+        "//user` info@host:81/a path?qu` ery",
+        "//user%info@host:0/a%path?que%ry",
+        "user@domain.com",
+        "../adirectory/file.html",
+        "comp.infosystems.www.servers.unix",
+        "",
+        "//server.org",
+        "//reg:istry?query",
+        "///c:/temp/calculate.pl?"
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getSchemeSpecificPart();
+        if( getSspResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI[" ) +
+                          Integer::toString( i ) + string( "] \"" ) + uris[i].toString() +
+                          string( "\", getSchemeSpecificPart() returned: " ) + result +
+                          string( ", expected: " ) + getSspResults[i] );
         }
     }
-
 }
 
-/*
-public void test_getUserInfo() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testGetUserInfo() {
 
     std::vector<URI> uris = getUris();
 
-    String[] getUserInfoResults = {
-            "user` info",
-            "user\u00DF\u00A3info", // =
-            // "user\u00df\u00a3info",
-            "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
-            "user%60%20info",
-            "user%C3%9F%C2%A3info",
-            "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
-            "user` info", "user%info", null, null, null, null, null, null,
-            null };
-
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].getUserInfo();
-        if (getUserInfoResults[i] != result
-                && !getUserInfoResults[i].equals(result)) {
-            fail("Error: For URI \"" + uris[i].toString()
-                    + "\", getUserInfo() returned: " + result
-                    + ", expected: " + getUserInfoResults[i]);
+    const char* getUserInfoResults[] = {
+        "user` info",
+        "user%60%20info",
+        "user%C3%9F%C2%A3info",
+        "user` info",
+        "user%info",
+        "", "", "", "", "", "", ""
+    };
+
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        string result = uris[i].getUserInfo();
+        if( getUserInfoResults[i] != result ) {
+            CPPUNIT_FAIL( string( "Error: For URI[" ) +
+                          Integer::toString( i ) + string( "] \"" ) + uris[i].toString() +
+                          string( "\", getUserInfo() returned: " ) + result +
+                          string( ", expected: " ) + getUserInfoResults[i] );
         }
     }
 }
 
-/*
-public void test_isAbsolute() throws URISyntaxException {
-    String[] isAbsoluteData = new String[] { "mailto:user@ca.ibm.com",
-            "urn:isbn:123498989h", "news:software.ibm.com",
-            "http://www.amazon.ca", "file:///d:/temp/results.txt",
-            "scheme:ssp", "calculate.pl?isbn=123498989h",
-            "?isbn=123498989h", "//www.amazon.ca", "a.html", "#top",
-            "//pc1/", "//user@host/path/file" };
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testIsAbsolute() {
 
-    boolean results[] = new boolean[] { true, true, true, true, true, true,
-            false, false, false, false, false, false, false };
+    const char* isAbsoluteData[] = {
+        "mailto:user@ca.ibm.com",
+        "urn:isbn:123498989h",
+        "news:software.ibm.com",
+        "http://www.amazon.ca",
+        "file:///d:/temp/results.txt",
+        "scheme:ssp",
+        "calculate.pl?isbn=123498989h",
+        "?isbn=123498989h",
+        "//www.amazon.ca",
+        "a.html",
+        "#top",
+        "//pc1/",
+        "//user@host/path/file"
+    };
+
+    bool results[] = {
+        true, true, true, true, true, true,
+        false, false, false, false, false, false, false
+    };
 
-    for (int i = 0; i < isAbsoluteData.length; i++) {
-        boolean result = new URI(isAbsoluteData[i]).isAbsolute();
-        assertEquals("new URI(" + isAbsoluteData[i] + ").isAbsolute()",
-                results[i], result);
+    for( unsigned int i = 0; i < 13; i++) {
+        bool result = URI( isAbsoluteData[i] ).isAbsolute();
+        CPPUNIT_ASSERT_MESSAGE( string( "URI(" ) + isAbsoluteData[i] +
+                                string( ").isAbsolute() = " ) + Boolean::toString( result ),
+                                results[i] == result );
     }
 }
 
-/*
-public void test_isOpaque() throws URISyntaxException {
-    String[] isOpaqueData = new String[] { "mailto:user@ca.ibm.com",
-            "urn:isbn:123498989h", "news:software.ibm.com",
-            "http://www.amazon.ca", "file:///d:/temp/results.txt",
-            "scheme:ssp", "calculate.pl?isbn=123498989h",
-            "?isbn=123498989h", "//www.amazon.ca", "a.html", "#top",
-            "//pc1/", "//user@host/path/file" };
-
-    boolean results[] = new boolean[] { true, true, true, false, false,
-            true, false, false, false, false, false, false, false };
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testIsOpaque() {
 
-    for (int i = 0; i < isOpaqueData.length; i++) {
-        boolean result = new URI(isOpaqueData[i]).isOpaque();
-        assertEquals("new URI(" + isOpaqueData[i] + ").isOpaque()",
-                results[i], result);
+    const char* isOpaqueData[] = {
+        "mailto:user@ca.ibm.com",
+        "urn:isbn:123498989h",
+        "news:software.ibm.com",
+        "http://www.amazon.ca",
+        "file:///d:/temp/results.txt",
+        "scheme:ssp",
+        "calculate.pl?isbn=123498989h",
+        "?isbn=123498989h",
+        "//www.amazon.ca", "a.html", "#top",
+        "//pc1/", "//user@host/path/file" };
+
+    bool results[] = {
+        true, true, true, false, false,
+        true, false, false, false, false,
+        false, false, false };
+
+    for( unsigned int i = 0; i < 13; i++) {
+        bool result = URI( isOpaqueData[i] ).isOpaque();
+        CPPUNIT_ASSERT_MESSAGE( string( "URI(" ) + isOpaqueData[i] +
+                                string( ").isOpaque() = " ) + Boolean::toString( result ),
+                                results[i] == result );
     }
 }
 
-/*
-public void test_normalize() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testNormalize() {
 
-    String[] normalizeData = new String[] {
+    const char* normalizeData[] = {
             // normal
             "/",
             "/a",
@@ -1220,388 +1242,416 @@
             "g/a/../../b/c/./g", "a/b/.././../../c/./d/../e",
             "a/../../.c././../././c/d/../g/..", };
 
-    String[] normalizeResults = new String[] { "/", "/a", "/a/b", "/a/b/c",
-            "/", "/", "/", "/", "/a", "/a/", "/a", "/a/", "/a/", "/a/",
-            "/a/", "/a/b", "/", "/", "/b", "/", "/", "/c", "/..", "/../",
-            "/../..", "/../../", "/../a", "/../a/", "/../../a",
-            "/../../a/", "/c", "/", "/", "/c", "/d", "/a/", "/a/", "/a/c",
-            "/../c/e", "/../c/", "/a./b", "/.a/b", "/a.b/c", "/a/b../c",
-            "/a/..b/c", "/a/b..c/d", "", "a", "a/b", "a/b/c", "../", "",
-            "..", "../g", "b/c/g", "../c/e", "../c/", };
-
-    for (int i = 0; i < normalizeData.length; i++) {
-        URI test = new URI(normalizeData[i]);
-        String result = test.normalize().toString();
-        assertEquals("Normalized incorrectly, ", normalizeResults[i],
-                result.toString());
-    }
-}
-
-/*
-public void test_normalize2() throws URISyntaxException {
-    URI uri1 = null, uri2 = null;
-    uri1 = new URI("file:/D:/one/two/../../three");
-    uri2 = uri1.normalize();
-
-    assertEquals("Normalized to incorrect URI", "file:/D:/three", uri2
-            .toString());
-    assertTrue("Resolved URI is not absolute", uri2.isAbsolute());
-    assertFalse("Resolved URI is opaque", uri2.isOpaque());
-    assertEquals("Resolved URI has incorrect scheme  specific part",
-            "/D:/three", uri2.getRawSchemeSpecificPart());
-}
-
-/*
-public void test_normalize3() throws URISyntaxException {
-    // return same URI if it has a normalized path already
-    URI uri1 = null, uri2 = null;
-    uri1 = new URI("http://host/D:/one/two/three");
-    uri2 = uri1.normalize();
-    assertSame("Failed to return same URI after normalization", uri1, uri2);
+    const char* normalizeResults[] = {
+        "/", "/a", "/a/b", "/a/b/c",
+        "/", "/", "/", "/", "/a", "/a/", "/a", "/a/", "/a/", "/a/",
+        "/a/", "/a/b", "/", "/", "/b", "/", "/", "/c", "/..", "/../",
+        "/../..", "/../../", "/../a", "/../a/", "/../../a",
+        "/../../a/", "/c", "/", "/", "/c", "/d", "/a/", "/a/", "/a/c",
+        "/../c/e", "/../c/", "/a./b", "/.a/b", "/a.b/c", "/a/b../c",
+        "/a/..b/c", "/a/b..c/d", "", "a", "a/b", "a/b/c", "../", "",
+        "..", "../g", "b/c/g", "../c/e", "../c/",
+    };
 
-    // try with empty path
-    uri1 = new URI("http", "host", null, "fragment");
-    uri2 = uri1.normalize();
-    assertSame("Failed to return same URI after normalization", uri1, uri2);
+    for( unsigned int i = 0; i < 57; i++) {
+        URI test( normalizeData[i] );
+        std::string result = test.normalize().toString();
+        CPPUNIT_ASSERT_MESSAGE( string( "URI(" ) + normalizeData[i] +
+                                string( ") normalized incorrectly to := " ) + result,
+                                result == normalizeResults[i] );
+    }
 }
 
-/*
-public void test_parseServerAuthority() throws URISyntaxException {
-    // registry based uris
-    URI[] uris = null;
-    uris = new URI[] {
-            // port number not digits
-            new URI("http://foo:bar/file#fragment"),
-            new URI("http", "//foo:bar/file", "fragment"),
-
-            // unicode char in the hostname = new
-            // URI("http://host\u00dfname/")
-            new URI("http://host\u00DFname/"),
-
-            new URI("http", "//host\u00DFname/", null),
-            // = new URI("http://host\u00dfname/", null),
 
-            // escaped octets in host name
-            new URI("http://host%20name/"),
-            new URI("http", "//host%20name/", null),
-
-            // missing host name, port number
-            new URI("http://joe@:80"),
-
-            // missing host name, no port number
-            new URI("http://user@/file?query#fragment"),
-
-            new URI("//host.com:80err"), // malformed port number
-            new URI("//host.com:81e%Abrr"),
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testNormalize2() {
 
-            // malformed ipv4 address
-            new URI("telnet", "//256.197.221.200", null),
+    URI uri1( "file:/D:/one/two/../../three" );
+    URI uri2 = uri1.normalize();
 
-            new URI("telnet://198.256.221.200"),
-            new URI("//te%ae.com"), // misc ..
-            new URI("//:port"), new URI("//:80"),
+    CPPUNIT_ASSERT_MESSAGE( "Normalized to incorrect URI: " + uri2.toString(),
+                            string( "file:/D:/three" ) == uri2.toString() );
+    CPPUNIT_ASSERT_MESSAGE( "Resolved URI is not absolute",  uri2.isAbsolute() );
+    CPPUNIT_ASSERT_MESSAGE( "Resolved URI is opaque", !uri2.isOpaque() );
+    CPPUNIT_ASSERT_MESSAGE( "Resolved URI has incorrect scheme specific part",
+                            string( "/D:/three" ) == uri2.getRawSchemeSpecificPart() );
+}
 
-            // last label has to start with alpha char
-            new URI("//fgj234fkgj.jhj.123."),
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testNormalize3() {
 
-            new URI("//fgj234fkgj.jhj.123"),
+    // return same URI if it has a normalized path already
+    URI uri1( "http://host/D:/one/two/three" );
+    URI uri2 = uri1.normalize();
+    CPPUNIT_ASSERT_MESSAGE( "Failed to return same URI after normalization",
+                            uri1.toString() == uri2.toString() );
 
-            // '-' cannot be first or last character in a label
-            new URI("//-domain.name"), new URI("//domain.name-"),
-            new URI("//domain-"),
+    // try with empty path
+    URI uri3( "http", "host", "", "fragment" );
+    URI uri4 = uri3.normalize();
+    CPPUNIT_ASSERT_MESSAGE( "Failed to return same URI after normalization",
+                            uri3.toString() == uri4.toString() );
+}
 
-            // illegal char in host name
-            new URI("//doma*in"),
 
-            // host expected
-            new URI("http://:80/"), new URI("http://user@/"),
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testParseServerAuthority() {
 
-            // ipv6 address not enclosed in "[]"
-            new URI("http://3ffe:2a00:100:7031:22:1:80:89/"),
+    // registry based uris
+    std::vector<URI> uris;
 
-            // expected ipv6 addresses to be enclosed in "[]"
-            new URI("http", "34::56:78", "/path", "query", "fragment"),
+    // port number not digits
+    uris.push_back( URI( "http://foo:bar/file#fragment" ) );
+    uris.push_back( URI( "http", "//foo:bar/file", "fragment" ) );
+    // escaped octets in host name
+    uris.push_back( URI( "http://host%20name/" ) );
+    uris.push_back( URI( "http", "//host%20name/", "" ) );
+    // missing host name, port number
+    uris.push_back( URI( "http://joe@:80" ) );
+    // missing host name, no port number
+    uris.push_back( URI( "http://user@/file?query#fragment" ) );
+    uris.push_back( URI( "//host.com:80err") ); // malformed port number
+    uris.push_back( URI( "//host.com:81e%Abrr") );
+    // malformed ipv4 address
+    uris.push_back( URI( "telnet", "//256.197.221.200", "" ) );
+    uris.push_back( URI( "telnet://198.256.221.200") );
+    uris.push_back( URI( "//te%ae.com") ); // misc ..
+    uris.push_back( URI( "//:port") );
+    uris.push_back( URI( "//:80" ) );
+    // last label has to start with alpha char
+    uris.push_back( URI( "//fgj234fkgj.jhj.123.") );
+    uris.push_back( URI( "//fgj234fkgj.jhj.123") );
+    // '-' cannot be first or last character in a label
+    uris.push_back( URI( "//-domain.name" ) );
+    uris.push_back( URI( "//domain.name-" ) );
+    uris.push_back( URI( "//domain-") );
+    // illegal char in host name
+    uris.push_back( URI( "//doma*in") );
+    // host expected
+    uris.push_back( URI( "http://:80/") );
+    uris.push_back( URI( "http://user@/" ) );
+    // ipv6 address not enclosed in "[]"
+    uris.push_back( URI( "http://3ffe:2a00:100:7031:22:1:80:89/" ) );
+    // expected ipv6 addresses to be enclosed in "[]"
+    uris.push_back( URI( "http", "34::56:78", "/path", "query", "fragment" ) );
+    // expected host
+    uris.push_back( URI( "http", "user@", "/path", "query", "fragment" ) );
 
-            // expected host
-            new URI("http", "user@", "/path", "query", "fragment") };
     // these URIs do not have valid server based authorities,
     // but single arg, 3 and 5 arg constructors
     // parse them as valid registry based authorities
 
     // exception should occur when parseServerAuthority is
     // requested on these uris
-    for (int i = 0; i < uris.length; i++) {
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
         try {
             URI uri = uris[i].parseServerAuthority();
-            fail("URISyntaxException expected but not received for URI: "
-                    + uris[i].toString());
-        } catch (URISyntaxException e) {
+            CPPUNIT_FAIL( string( "URISyntaxException expected but not received for URI: " ) +
+                          uris[i].toString());
+        } catch( URISyntaxException& e ) {
             // Expected
         }
     }
 
     // valid Server based authorities
-    new URI("http", "3ffe:2a00:100:7031:2e:1:80:80", "/path", "fragment")
-            .parseServerAuthority();
-    new URI("http", "host:80", "/path", "query", "fragment")
-            .parseServerAuthority();
-    new URI("http://[::3abc:4abc]:80/").parseServerAuthority();
-    new URI("http", "34::56:78", "/path", "fragment")
-            .parseServerAuthority();
-    new URI("http", "[34:56::78]:80", "/path", "fragment")
-            .parseServerAuthority();
+    URI( "http", "3ffe:2a00:100:7031:2e:1:80:80", "/path", "fragment" ).parseServerAuthority();
+    URI( "http", "host:80", "/path", "query", "fragment" ).parseServerAuthority();
+    URI( "http://[::3abc:4abc]:80/" ).parseServerAuthority();
+    URI( "http", "34::56:78", "/path", "fragment" ).parseServerAuthority();
+    URI( "http", "[34:56::78]:80", "/path", "fragment" ).parseServerAuthority();
 
     // invalid authorities (neither server nor registry)
-    try {
-        URI uri = new URI("http://us[er@host:80/");
-        fail("Expected URISyntaxException for URI " + uri.toString());
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Expected URISyntaxException for URI ",
+        URI( "http://us[er@host:80/" ),
+        URISyntaxException );
 
-    try {
-        URI uri = new URI("http://[ddd::hgghh]/");
-        fail("Expected URISyntaxException for URI " + uri.toString());
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Expected URISyntaxException for URI ",
+        URI( "http://[ddd::hgghh]/" ),
+        URISyntaxException );
 
-    try {
-        URI uri = new URI("http", "[3ffe:2a00:100:7031:2e:1:80:80]a:80",
-                "/path", "fragment");
-        fail("Expected URISyntaxException for URI " + uri.toString());
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Expected URISyntaxException for URI ",
+        URI( "http", "[3ffe:2a00:100:7031:2e:1:80:80]a:80", "/path", "fragment" ),
+        URISyntaxException );
 
-    try {
-        URI uri = new URI("http", "host:80", "/path", "fragment");
-        fail("Expected URISyntaxException for URI " + uri.toString());
-    } catch (URISyntaxException e) {
-        // Expected
-    }
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Expected URISyntaxException for URI ",
+        URI( "http", "host:80", "/path", "fragment" ),
+        URISyntaxException );
 
-    // regression test for HARMONY-1126
-    assertNotNull(URI.create("file://C:/1.txt").parseServerAuthority());
+    CPPUNIT_ASSERT_NO_THROW( URI::create("file://C:/1.txt").parseServerAuthority() );
 }
 
-/*
-public void test_relativizeLjava_net_URI() throws URISyntaxException {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testRelativizeLURI() {
+
     // relativization tests
-    String[][] relativizeData = new String[][] {
-            // first is base, second is the one to relativize
-            { "http://www.google.com/dir1/dir2", "mailto:test" }, // rel =
-            // opaque
-            { "mailto:test", "http://www.google.com" }, // base = opaque
-
-            // different authority
-            { "http://www.eclipse.org/dir1",
-                    "http://www.google.com/dir1/dir2" },
-
-            // different scheme
-            { "http://www.google.com", "ftp://www.google.com" },
-
-            { "http://www.google.com/dir1/dir2/",
-                    "http://www.google.com/dir3/dir4/file.txt" },
-            { "http://www.google.com/dir1/",
-                    "http://www.google.com/dir1/dir2/file.txt" },
-            { "./dir1/", "./dir1/hi" },
-            { "/dir1/./dir2", "/dir1/./dir2/hi" },
-            { "/dir1/dir2/..", "/dir1/dir2/../hi" },
-            { "/dir1/dir2/..", "/dir1/dir2/hi" },
-            { "/dir1/dir2/", "/dir1/dir3/../dir2/text" },
-            { "//www.google.com", "//www.google.com/dir1/file" },
-            { "/dir1", "/dir1/hi" }, { "/dir1/", "/dir1/hi" }, };
+    const char* relativizeData[][2] = {
+        // first is base, second is the one to relativize
+        { "http://www.google.com/dir1/dir2", "mailto:test" }, // rel = opaque
+        { "mailto:test", "http://www.google.com" }, // base = opaque
+        // different authority
+        { "http://www.eclipse.org/dir1",
+          "http://www.google.com/dir1/dir2" },
+        // different scheme
+        { "http://www.google.com", "ftp://www.google.com" },
+
+        { "http://www.google.com/dir1/dir2/",
+          "http://www.google.com/dir3/dir4/file.txt" },
+        { "http://www.google.com/dir1/",
+          "http://www.google.com/dir1/dir2/file.txt" },
+        { "./dir1/", "./dir1/hi" },
+        { "/dir1/./dir2", "/dir1/./dir2/hi" },
+        { "/dir1/dir2/..", "/dir1/dir2/../hi" },
+        { "/dir1/dir2/..", "/dir1/dir2/hi" },
+        { "/dir1/dir2/", "/dir1/dir3/../dir2/text" },
+        { "//www.google.com", "//www.google.com/dir1/file" },
+        { "/dir1", "/dir1/hi" }, { "/dir1/", "/dir1/hi" },
+    };
 
     // expected results
-    String[] relativizeResults = new String[] { "mailto:test",
-            "http://www.google.com", "http://www.google.com/dir1/dir2",
-            "ftp://www.google.com",
-            "http://www.google.com/dir3/dir4/file.txt", "dir2/file.txt",
-            "hi", "hi", "hi", "dir2/hi", "text", "dir1/file", "hi", "hi", };
+    const char* relativizeResults[] = {
+        "mailto:test",
+        "http://www.google.com",
+        "http://www.google.com/dir1/dir2",
+        "ftp://www.google.com",
+        "http://www.google.com/dir3/dir4/file.txt",
+        "dir2/file.txt",
+        "hi",
+        "hi",
+        "hi",
+        "dir2/hi",
+        "text",
+        "dir1/file",
+        "hi",
+        "hi",
+    };
+
+    for( unsigned int i = 0; i < 14; i++ ) {
 
-    for (int i = 0; i < relativizeData.length; i++) {
         try {
-            URI b = new URI(relativizeData[i][0]);
-            URI r = new URI(relativizeData[i][1]);
-            if (!b.relativize(r).toString().equals(relativizeResults[i])) {
-                fail("Error: relativize, " + relativizeData[i][0] + ", "
-                        + relativizeData[i][1] + " returned: "
-                        + b.relativize(r) + ", expected:"
-                        + relativizeResults[i]);
+
+            URI b( relativizeData[i][0] );
+            URI r( relativizeData[i][1] );
+
+            if( ( b.relativize( r ) ).toString() != relativizeResults[i] ) {
+                CPPUNIT_FAIL( string( "Error: relativize, " ) + relativizeData[i][0] +
+                              string( ", " ) + relativizeData[i][1] + " returned: " +
+                              b.relativize( r ).toString() + ", expected:" +
+                              relativizeResults[i] );
             }
-        } catch (URISyntaxException e) {
-            fail("Exception on relativize test on data "
-                    + relativizeData[i][0] + ", " + relativizeData[i][1]
-                    + ": " + e);
+
+        } catch( URISyntaxException& e ) {
+            CPPUNIT_FAIL( string( "Exception on relativize test on data " ) +
+                          relativizeData[i][0] + ", " + relativizeData[i][1] +
+                          string( ": " ) + e.getMessage() );
         }
     }
 
-    URI a = new URI("http://host/dir");
-    URI b = new URI("http://host/dir/file?query");
-    assertEquals("Assert 0: URI relativized incorrectly,", new URI(
-            "file?query"), a.relativize(b));
-
-    // One URI with empty host
-    a = new URI("file:///~/first");
-    b = new URI("file://tools/~/first");
-    assertEquals("Assert 1: URI relativized incorrectly,", new URI(
-            "file://tools/~/first"), a.relativize(b));
-    assertEquals("Assert 2: URI relativized incorrectly,", new URI(
-            "file:///~/first"), b.relativize(a));
-
-    // Both URIs with empty hosts
-    b = new URI("file:///~/second");
-    assertEquals("Assert 3: URI relativized incorrectly,", new URI(
-            "file:///~/second"), a.relativize(b));
-    assertEquals("Assert 4: URI relativized incorrectly,", new URI(
-            "file:///~/first"), b.relativize(a));
+    {
+        URI a( "http://host/dir" );
+        URI b( "http://host/dir/file?query" );
+        CPPUNIT_ASSERT_MESSAGE(
+            string( "Assert 0: URI relativized incorrectly: " ) + a.relativize( b ).toString(),
+            URI( "file?query" ).equals( a.relativize( b ) ) );
+    }
+    {
+        // One URI with empty host
+        URI a( "file:///~/first" );
+        URI b( "file://tools/~/first" );
+        CPPUNIT_ASSERT_MESSAGE("Assert 1: URI relativized incorrectly,",
+            URI( "file://tools/~/first" ).equals( a.relativize( b ) ) );
+        CPPUNIT_ASSERT_MESSAGE("Assert 2: URI relativized incorrectly,",
+            URI( "file:///~/first" ).equals( b.relativize( a ) ) );
+    }
+    {
+        // Both URIs with empty hosts
+        URI a( "file:///~/first" );
+        URI b( "file:///~/second" );
+        CPPUNIT_ASSERT_MESSAGE( "Assert 3: URI relativized incorrectly,",
+                      URI( "file:///~/second").equals( a.relativize( b ) ) );
+        CPPUNIT_ASSERT_MESSAGE("Assert 4: URI relativized incorrectly,",
+            URI( "file:///~/first").equals( b.relativize( a ) ) );
+    }
 }
 
-/*
-public void test_relativize2() throws URISyntaxException {
-    URI a = new URI("http://host/dir");
-    URI b = new URI("http://host/dir/file?query");
-    assertEquals("relativized incorrectly,", new URI("file?query"), a
-            .relativize(b));
-
-    // one URI with empty host
-    a = new URI("file:///~/dictionary");
-    b = new URI("file://tools/~/dictionary");
-    assertEquals("relativized incorrectly,", new URI(
-            "file://tools/~/dictionary"), a.relativize(b));
-    assertEquals("relativized incorrectly,",
-            new URI("file:///~/dictionary"), b.relativize(a));
-
-    // two URIs with empty hosts
-    b = new URI("file:///~/therasus");
-    assertEquals("relativized incorrectly,", new URI("file:///~/therasus"),
-            a.relativize(b));
-    assertEquals("relativized incorrectly,",
-            new URI("file:///~/dictionary"), b.relativize(a));
-
-    URI one = new URI("file:/C:/test/ws");
-    URI two = new URI("file:/C:/test/ws");
-
-    URI empty = new URI("");
-    assertEquals(empty, one.relativize(two));
-
-    one = new URI("file:/C:/test/ws");
-    two = new URI("file:/C:/test/ws/p1");
-    URI result = new URI("p1");
-    assertEquals(result, one.relativize(two));
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testRelativize2() {
+
+    {
+        URI a( "http://host/dir" );
+        URI b( "http://host/dir/file?query" );
+        CPPUNIT_ASSERT_MESSAGE( "relativized incorrectly,",
+            URI( "file?query" ).equals( a.relativize( b ) ) );
+    }
+    {
+        // one URI with empty host
+        URI a( "file:///~/dictionary" );
+        URI b( "file://tools/~/dictionary" );
+        CPPUNIT_ASSERT_MESSAGE( "relativized incorrectly,",
+            URI( "file://tools/~/dictionary" ).equals( a.relativize( b ) ) );
+        CPPUNIT_ASSERT_MESSAGE("relativized incorrectly,",
+            URI( "file:///~/dictionary" ).equals( b.relativize( a ) ) );
+    }
+    {
+        // two URIs with empty hosts
+        URI a( "file:///~/dictionary" );
+        URI b( "file:///~/therasus" );
+        CPPUNIT_ASSERT_MESSAGE( "relativized incorrectly,",
+            URI( "file:///~/therasus" ).equals( a.relativize( b ) ) );
+        CPPUNIT_ASSERT_MESSAGE( "relativized incorrectly,",
+            URI( "file:///~/dictionary").equals( b.relativize( a ) ) );
+    }
 
-    one = new URI("file:/C:/test/ws/");
-    assertEquals(result, one.relativize(two));
+    {
+        URI one( "file:/C:/test/ws" );
+        URI two( "file:/C:/test/ws" );
+        URI empty("");
+        CPPUNIT_ASSERT( empty.equals( one.relativize( two ) ) );
+    }
+    {
+        URI one( "file:/C:/test/ws" );
+        URI two( "file:/C:/test/ws/p1" );
+        URI result( "p1" );
+        CPPUNIT_ASSERT( result.equals( one.relativize( two ) ) );
+    }
+    {
+        URI one( "file:/C:/test/ws/" );
+        URI two( "file:/C:/test/ws/p1" );
+        URI result( "p1" );
+        CPPUNIT_ASSERT( result.equals( one.relativize( two ) ) );
+    }
 }
 
-/*
-public void test_resolve() throws URISyntaxException {
-    URI uri1 = null, uri2 = null;
-    uri1 = new URI("file:/D:/one/two/three");
-    uri2 = uri1.resolve(new URI(".."));
-
-    assertEquals("Resolved to incorrect URI", "file:/D:/one/", uri2
-            .toString());
-    assertTrue("Resolved URI is not absolute", uri2.isAbsolute());
-    assertFalse("Resolved URI is opaque", uri2.isOpaque());
-    assertEquals("Resolved URI has incorrect scheme  specific part",
-            "/D:/one/", uri2.getRawSchemeSpecificPart());
+
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testResolve() {
+
+    URI uri1( "file:/D:/one/two/three" );
+    URI uri2 = uri1.resolve( URI( ".." ) );
+
+    CPPUNIT_ASSERT_MESSAGE(
+        string( "Resolved to incorrect URI: " ) + uri2.toString(),
+        string( "file:/D:/one/" ) == uri2.toString() );
+    CPPUNIT_ASSERT_MESSAGE( "Resolved URI is not absolute", uri2.isAbsolute());
+    CPPUNIT_ASSERT_MESSAGE( "Resolved URI is opaque", !uri2.isOpaque() );
+    CPPUNIT_ASSERT_MESSAGE(
+        string( "Resolved URI has incorrect scheme specific part" ) +
+        uri2.getRawSchemeSpecificPart(),
+        string( "/D:/one/" ) == uri2.getRawSchemeSpecificPart() );
 }
 
-/*
-public void test_resolveLjava_net_URI() {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testResolveURI() {
+
     // resolution tests
-    String[][] resolveData = new String[][] {
-            // authority in given URI
-            { "http://www.test.com/dir",
-                    "//www.test.com/hello?query#fragment" },
-            // no authority, absolute path
-            { "http://www.test.com/dir", "/abspath/file.txt" },
-            // no authority, relative paths
-            { "/", "dir1/file.txt" }, { "/dir1", "dir2/file.txt" },
-            { "/dir1/", "dir2/file.txt" }, { "", "dir1/file.txt" },
-            { "dir1", "dir2/file.txt" }, { "dir1/", "dir2/file.txt" },
-            // normalization required
-            { "/dir1/dir2/../dir3/./", "dir4/./file.txt" },
-            // allow a standalone fragment to be resolved
-            { "http://www.google.com/hey/joe?query#fragment", "#frag2" },
-            // return given when base is opaque
-            { "mailto:idontexist@uk.ibm.com", "dir1/dir2" },
-            // return given when given is absolute
-            { "http://www.google.com/hi/joe", "http://www.oogle.com" }, };
+    const char* resolveData[12][2] = {
+        // authority in given URI
+        { "http://www.test.com/dir", "//www.test.com/hello?query#fragment" },
+        // no authority, absolute path
+        { "http://www.test.com/dir", "/abspath/file.txt" },
+        // no authority, relative paths
+        { "/", "dir1/file.txt" },
+        { "/dir1", "dir2/file.txt" },
+        { "/dir1/", "dir2/file.txt" },
+        { "", "dir1/file.txt" },
+        { "dir1", "dir2/file.txt" },
+        { "dir1/", "dir2/file.txt" },
+        // normalization required
+        { "/dir1/dir2/../dir3/./", "dir4/./file.txt" },
+        // allow a standalone fragment to be resolved
+        { "http://www.google.com/hey/joe?query#fragment", "#frag2" },
+        // return given when base is opaque
+        { "mailto:idontexist@uk.ibm.com", "dir1/dir2" },
+        // return given when given is absolute
+        { "http://www.google.com/hi/joe", "http://www.oogle.com" },
+    };
 
     // expected results
-    String[] resolveResults = new String[] {
-            "http://www.test.com/hello?query#fragment",
-            "http://www.test.com/abspath/file.txt", "/dir1/file.txt",
-            "/dir2/file.txt", "/dir1/dir2/file.txt", "dir1/file.txt",
-            "dir2/file.txt", "dir1/dir2/file.txt",
-            "/dir1/dir3/dir4/file.txt",
-            "http://www.google.com/hey/joe?query#frag2", "dir1/dir2",
-            "http://www.oogle.com", };
+    const char* resolveResults[] = {
+        "http://www.test.com/hello?query#fragment",
+        "http://www.test.com/abspath/file.txt",
+        "/dir1/file.txt",
+        "/dir2/file.txt",
+        "/dir1/dir2/file.txt",
+        "dir1/file.txt",
+        "dir2/file.txt",
+        "dir1/dir2/file.txt",
+        "/dir1/dir3/dir4/file.txt",
+        "http://www.google.com/hey/joe?query#frag2",
+        "dir1/dir2",
+        "http://www.oogle.com",
+    };
+
+    for( unsigned int i = 0; i < 0; i++ ) {
 
-    for (int i = 0; i < resolveResults.length; i++) {
         try {
-            URI b = new URI(resolveData[i][0]);
-            URI r = new URI(resolveData[i][1]);
-            URI result = b.resolve(r);
-            if (!result.toString().equals(resolveResults[i])) {
-                fail("Error: resolve, " + resolveData[i][0] + ", "
-                        + resolveData[i][1] + " returned: " + b.resolve(r)
-                        + ", expected:" + resolveResults[i]);
+
+            URI b( resolveData[i][0] );
+            URI r( resolveData[i][1] );
+            URI result = b.resolve( r );
+
+            if( result.toString() != resolveResults[i] ) {
+                CPPUNIT_FAIL( string( "Error: resolve at iteration: " ) +
+                              Integer::toString( i ) + ": \n" +
+                              resolveData[i][0] + ", " + resolveData[i][1] +
+                              string( "\nreturned: " ) + b.resolve( r ).toString() +
+                              string( "\nexpected: " ) + resolveResults[i] );
             }
-            if (!b.isOpaque()) {
-                assertEquals(b + " and " + result
-                        + " incorrectly differ in absoluteness", b
-                        .isAbsolute(), result.isAbsolute());
+
+            if( !b.isOpaque() ) {
+                CPPUNIT_ASSERT_MESSAGE( b.toString() + " and " + result.toString() +
+                                        " incorrectly differ in absoluteness",
+                                        b.isAbsolute() == result.isAbsolute() );
             }
-        } catch (URISyntaxException e) {
-            fail("Exception on resolve test on data " + resolveData[i][0]
-                    + ", " + resolveData[i][1] + ": " + e);
+
+        } catch( URISyntaxException& e ) {
+            CPPUNIT_FAIL( string( "Exception on resolve test on data " ) +
+                          resolveData[i][0] + ", " + resolveData[i][1] +
+                          ": " + e.getMessage() );
         }
     }
 }
 
-/*
-public void test_toString() throws Exception {
+////////////////////////////////////////////////////////////////////////////////
+void URITest::testToString() {
 
     std::vector<URI> uris = getUris();
 
-    String[] toStringResults = {
+    const char* toStringResults[] = {
             "http://user%60%20info@host/a%20path?qu%60%20ery#fr%5E%20ag",
-            "http://user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g",
-            "ascheme://user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g",
-            // =
-            // "ascheme://user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery#fr\u00e4\u00e8g",
             "http://user%2560%2520info@host:80/a%2520path?qu%2560%2520ery#fr%255E%2520ag",
             "http://user%25C3%259F%25C2%25A3info@host/a%25E2%2582%25ACpath?qu%25C2%25A9%25C2%25AEery#fr%25C3%25A4%25C3%25A8g",
-            "ascheme://user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g",
-            // =
-            // "ascheme://user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery#fr\u00e4\u00e8g",
             "http://user%60%20info@host:81/a%20path?qu%60%20ery#fr%5E%20ag",
             "http://user%25info@host:0/a%25path?que%25ry#f%25rag",
-            "mailto:user@domain.com", "../adirectory/file.html#",
-            "news:comp.infosystems.www.servers.unix", "#fragment",
-            "telnet://server.org", "http://reg:istry?query",
+            "mailto:user@domain.com",
+            "../adirectory/file.html#",
+            "news:comp.infosystems.www.servers.unix",
+            "#fragment",
+            "telnet://server.org",
+            "http://reg:istry?query",
             "file:///c:/temp/calculate.pl?" };
 
-    for (int i = 0; i < uris.length; i++) {
-        String result = uris[i].toString();
-        assertTrue("Error: For URI \"" + uris[i].toString()
-                + "\", toString() returned: " + result + ", expected: "
-                + toStringResults[i], result.equals(toStringResults[i]));
+    for( unsigned int i = 0; i < uris.size(); i++ ) {
+        std::string result = uris[i].toString();
+        CPPUNIT_ASSERT_MESSAGE( string( "Error: For URI \"" ) + uris[i].toString() +
+                                string( "\", toString() returned: \n" ) + result +
+                                string( "\n, expected: \n" ) + toStringResults[i],
+                                result == toStringResults[i] );
     }
 }
 
 /*
-public void test_toURL() throws Exception {
-    String absoluteuris[] = new String[] { "mailto:noreply@apache.org",
+////////////////////////////////////////////////////////////////////////////////
+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 String[] { "calculate.pl?isbn=123498989h",
+    String relativeuris[] = new const char* { "calculate.pl?isbn=123498989h",
             "?isbn=123498989h", "//www.apache.org", "a.html", "#top",
             "//pc1/", "//user@host/path/file" };
 
@@ -1622,5 +1672,4 @@
         }
     }
 }
-
  */

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=729142&r1=729141&r2=729142&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:15:00 2008
@@ -45,6 +45,28 @@
         CPPUNIT_TEST( testGetHost );
         CPPUNIT_TEST( testGetPath );
         CPPUNIT_TEST( testGetPort );
+        CPPUNIT_TEST( testGetPort2 );
+        CPPUNIT_TEST( testGetQuery );
+        CPPUNIT_TEST( testGetRawAuthority );
+        CPPUNIT_TEST( testGetRawFragment );
+        CPPUNIT_TEST( testGetRawPath );
+        CPPUNIT_TEST( testGetRawQuery );
+        CPPUNIT_TEST( testGetRawSchemeSpecificPart );
+        CPPUNIT_TEST( testGetRawUserInfo );
+        CPPUNIT_TEST( testGetScheme );
+        CPPUNIT_TEST( testGetSchemeSpecificPart );
+        CPPUNIT_TEST( testGetUserInfo );
+        CPPUNIT_TEST( testIsAbsolute );
+        CPPUNIT_TEST( testIsOpaque );
+        CPPUNIT_TEST( testNormalize );
+        CPPUNIT_TEST( testNormalize2 );
+        CPPUNIT_TEST( testNormalize3 );
+        CPPUNIT_TEST( testParseServerAuthority );
+        CPPUNIT_TEST( testRelativizeLURI );
+        CPPUNIT_TEST( testRelativize2 );
+        CPPUNIT_TEST( testResolveURI );
+        CPPUNIT_TEST( testResolve );
+        CPPUNIT_TEST( testToString );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -70,6 +92,28 @@
         void testGetHost();
         void testGetPath();
         void testGetPort();
+        void testGetPort2();
+        void testGetQuery();
+        void testGetRawAuthority();
+        void testGetRawFragment();
+        void testGetRawPath();
+        void testGetRawQuery();
+        void testGetRawSchemeSpecificPart();
+        void testGetRawUserInfo();
+        void testGetScheme();
+        void testGetSchemeSpecificPart();
+        void testGetUserInfo();
+        void testIsAbsolute();
+        void testIsOpaque();
+        void testNormalize();
+        void testNormalize2();
+        void testNormalize3();
+        void testParseServerAuthority();
+        void testRelativizeLURI();
+        void testRelativize2();
+        void testResolveURI();
+        void testResolve();
+        void testToString();
 
     };
 



Mime
View raw message