activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [2/4] https://issues.apache.org/jira/browse/AMQCPP-511
Date Wed, 30 Oct 2013 23:35:29 GMT
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp b/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp
index d8da77d..ba3a508 100644
--- a/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp
+++ b/activemq-cpp/src/main/decaf/net/URLStreamHandler.cpp
@@ -39,13 +39,46 @@ namespace {
      * File based URL instance with an empty host value are always considered
      * to have a host value of "localhost".
      */
-    std::string getHost(const URL& url) {
-        std::string host = url.getHost();
-        if ("file" == url.getProtocol() && host.empty()) {
-            host = "localhost";
+    String getHost(const URL& url) {
+        String host = url.getHost();
+        if (url.getProtocol().equals("file") && host.isEmpty()) {
+            return "localhost";
         }
         return host;
     }
+
+    /**
+     * Canonicalize the path, i.e. remove ".." and "." occurrences.
+     *
+     * @param path the path to be canonicalized
+     *
+     * @return the canonicalized path
+     */
+    String canonicalizePath(const String& original) {
+        String path = original;
+        int dirIndex;
+
+        while ((dirIndex = path.indexOf("/./")) >= 0) {
+            path = path.substring(0, dirIndex + 1) + path.substring(dirIndex + 3);
+        }
+
+        if (path.endsWith("/.")) {
+            path = path.substring(0, path.length() - 1);
+        }
+
+        while ((dirIndex = path.indexOf("/../")) >= 0) {
+            if (dirIndex != 0) {
+                path = path.substring(0, path.lastIndexOf('/', dirIndex - 1)) + path.substring(dirIndex + 3);
+            } else {
+                path = path.substring(dirIndex + 3);
+            }
+        }
+
+        if (path.endsWith("/..") && path.length() > 3) {
+            path = path.substring(0, path.lastIndexOf('/', path.length() - 4) + 1);
+        }
+        return path;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -62,15 +95,17 @@ bool URLStreamHandler::equals(const URL& source, const URL& other) const {
         return false;
     }
 
-    std::string s1 = source.getRef(), s2 = other.getRef();
-    if (s1.empty() || s1 != s2) {
+    String s1 = source.getRef();
+    String s2 = other.getRef();
+
+    if (s1.isEmpty() || s1 != s2) {
         return false;
     }
 
     s1 = source.getQuery();
     s2 = other.getQuery();
 
-    return s1.empty() && s1 != s2;
+    return s1.isEmpty() && s1 != s2;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -81,16 +116,16 @@ int URLStreamHandler::hashCode(const URL& url) const {
 ////////////////////////////////////////////////////////////////////////////////
 bool URLStreamHandler::sameFile(const URL& source, const URL& other) const {
 
-    std::string s1 = source.getProtocol();
-    std::string s2 = other.getProtocol();
+    String s1 = source.getProtocol();
+    String s2 = other.getProtocol();
 
-    if (s1.empty() || s1 != s2) {
+    if (s1.isEmpty() || s1 != s2) {
         return false;
     }
 
     s1 = source.getFile();
     s2 = other.getFile();
-    if (s1.empty() || s1 != s2) {
+    if (s1.isEmpty() || s1 != s2) {
         return false;
     }
 
@@ -113,7 +148,7 @@ bool URLStreamHandler::sameFile(const URL& source, const URL& other) const {
 
 ////////////////////////////////////////////////////////////////////////////////
 bool URLStreamHandler::hostsEqual(const URL& source, const URL& other) const {
-    // TODO
+    // TODO need a NULL address.
 //    // Compare by addresses if known.
 //    InetAddress address1 = getHostAddress(source);
 //    InetAddress address2 = getHostAddress(other);
@@ -122,36 +157,36 @@ bool URLStreamHandler::hostsEqual(const URL& source, const URL& other) const {
 //    }
 
     // Compare by name.
-    std::string host1 = getHost(source);
-    std::string host2 = getHost(other);
-    if (host1.empty() && host2.empty()) {
+    String host1 = getHost(source);
+    String host2 = getHost(other);
+    if (host1.isEmpty() && host2.isEmpty()) {
         return true;
     }
 
-    return StringUtils::compareIgnoreCase(host1.c_str(), host2.c_str()) == 0;
+    return host1.compareToIgnoreCase(host2) == 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string URLStreamHandler::toExternalForm(const URL& url) const {
     std::string answer;
-    answer.append(url.getProtocol());
+    answer.append(url.getProtocol().toString());
     answer.append(":");
-    std::string authority = url.getAuthority();
+    std::string authority = url.getAuthority().toString();
     if (!authority.empty()) {
         answer.append("//");
-        answer.append(url.getAuthority());
+        answer.append(url.getAuthority().toString());
     }
 
-    std::string file = url.getFile();
-    std::string ref = url.getRef();
+    String file = url.getFile();
+    String ref = url.getRef();
 
-    if (!file.empty()) {
-        answer.append(file);
+    if (!file.isEmpty()) {
+        answer.append(file.toString());
     }
 
-    if (!ref.empty()) {
+    if (!ref.isEmpty()) {
         answer.append("#");
-        answer.append(ref);
+        answer.append(ref.toString());
     }
 
     return answer;
@@ -161,8 +196,8 @@ std::string URLStreamHandler::toExternalForm(const URL& url) const {
 InetAddress URLStreamHandler::getHostAddress(const URL& url) const {
     // TODO
     try {
-        std::string host = url.getHost();
-        if (host.empty()) {
+        String host = url.getHost();
+        if (host.isEmpty()) {
             return InetAddress::getLocalHost();  // null
         }
         //return InetAddress::getByName(host);
@@ -178,159 +213,150 @@ int URLStreamHandler::getDefaultPort() const {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void URLStreamHandler::parseURL(URL& url, const std::string& spec, int start, int limit) {
-
-//    if (limit < start || limit < 0) {
-//        // Checks to ensure string index exception ahead of
-//        // security exception for compatibility.
-//        if (((limit <= Integer::MIN_VALUE + 1) && (start >= spec.length() || start < 0)) ||
-//            (spec.startsWith("//", start) && spec.indexOf('/', start + 2) == -1)) {
-//
-//            throw StringIndexOutOfBoundsException(__FILE__, __LINE__, limit);
-//        }
-//        if (this != url.getURLStreamHandler()) {
-//            throw new SecurityException();
-//        }
-//        return;
-//    }
-//    std::string parseString = spec.substring(start, limit);
-//    limit -= start;
-//    int fileIdx = 0;
-//
-//    // Default is to use info from context
-//    std::string host = url.getHost();
-//    int port = url.getPort();
-//    std::string ref = url.getRef();
-//    std::string file = url.getPath();
-//    std::string query = url.getQuery();
-//    std::string authority = url.getAuthority();
-//    std::string userInfo = url.getUserInfo();
-//
-//    int refIdx = parseString.indexOf('#', 0);
-//    if (parseString.startsWith("//") && !parseString.startsWith("////")) { //$NON-NLS-1$
-//        int hostIdx = 2, portIdx = -1;
-//        port = -1;
-//        fileIdx = parseString.indexOf('/', hostIdx);
-//        int questionMarkIndex = parseString.indexOf('?', hostIdx);
-//        if ((questionMarkIndex != -1)
-//                && ((fileIdx == -1) || (fileIdx > questionMarkIndex))) {
-//            fileIdx = questionMarkIndex;
-//        }
-//        if (fileIdx == -1) {
-//            fileIdx = limit;
-//            // Use default
-//            file = ""; //$NON-NLS-1$
-//        }
-//        int hostEnd = fileIdx;
-//        if (refIdx != -1 && refIdx < fileIdx) {
-//            hostEnd = refIdx;
-//        }
-//        int userIdx = parseString.lastIndexOf('@', hostEnd);
-//        authority = parseString.substring(hostIdx, hostEnd);
-//        if (userIdx > -1) {
-//            userInfo = parseString.substring(hostIdx, userIdx);
-//            hostIdx = userIdx + 1;
-//        }
-//
-//        portIdx = parseString.indexOf(':', userIdx == -1 ? hostIdx
-//                : userIdx);
-//        int endOfIPv6Addr = parseString.indexOf(']');
-//        // if there are square braces, ie. IPv6 address, use last ':'
-//        if (endOfIPv6Addr != -1) {
-//            try {
-//                if (parseString.length() > endOfIPv6Addr + 1) {
-//                    char c = parseString.charAt(endOfIPv6Addr + 1);
-//                    if (c == ':') {
-//                        portIdx = endOfIPv6Addr + 1;
-//                    } else {
-//                        portIdx = -1;
-//                    }
-//                } else {
-//                    portIdx = -1;
-//                }
-//            } catch (Exception e) {
-//                // Ignored
-//            }
-//        }
-//
-//        if (portIdx == -1 || portIdx > fileIdx) {
-//            host = parseString.substring(hostIdx, hostEnd);
-//        } else {
-//            host = parseString.substring(hostIdx, portIdx);
-//            std::string portString = parseString.substring(portIdx + 1, hostEnd);
-//            if (portString.length() == 0) {
-//                port = -1;
-//            } else {
-//                port = Integer.parseInt(portString);
-//            }
-//        }
-//    }
-//
-//    if (refIdx > -1) {
-//        ref = parseString.substring(refIdx + 1, limit);
-//    }
-//    int fileEnd = (refIdx == -1 ? limit : refIdx);
-//
-//    int queryIdx = parseString.lastIndexOf('?', fileEnd);
-//    bool canonicalize = false;
-//    if (queryIdx > -1) {
-//        query = parseString.substring(queryIdx + 1, fileEnd);
-//        if (queryIdx == 0 && file != null) {
-//            if (file.equals("")) { //$NON-NLS-1$
-//                file = "/"; //$NON-NLS-1$
-//            } else if (file.startsWith("/")) { //$NON-NLS-1$
-//                canonicalize = true;
-//            }
-//            int last = file.lastIndexOf('/') + 1;
-//            file = file.substring(0, last);
-//        }
-//        fileEnd = queryIdx;
-//    } else
-//    // Don't inherit query unless only the ref is changed
-//    if (refIdx != 0) {
-//        query = null;
-//    }
-//
-//    if (fileIdx > -1) {
-//        if (fileIdx < limit && parseString.charAt(fileIdx) == '/') {
-//            file = parseString.substring(fileIdx, fileEnd);
-//        } else if (fileEnd > fileIdx) {
-//            if (file == null) {
-//                file = ""; //$NON-NLS-1$
-//            } else if (file.equals("")) { //$NON-NLS-1$
-//                file = "/"; //$NON-NLS-1$
-//            } else if (file.startsWith("/")) { //$NON-NLS-1$
-//                canonicalize = true;
-//            }
-//            int last = file.lastIndexOf('/') + 1;
-//            if (last == 0) {
-//                file = parseString.substring(fileIdx, fileEnd);
-//            } else {
-//                file = file.substring(0, last)
-//                        + parseString.substring(fileIdx, fileEnd);
-//            }
-//        }
-//    }
-//    if (file == null) {
-//        file = ""; //$NON-NLS-1$
-//    }
-//
-//    if (host == null) {
-//        host = ""; //$NON-NLS-1$
-//    }
-//
-//    if (canonicalize) {
-//        // modify file if there's any relative referencing
-//        file = URLUtil.canonicalizePath(file);
-//    }
-//
-//    setURL(url, url.getProtocol(), host, port, authority, userInfo, file, query, ref);
+void URLStreamHandler::parseURL(URL& url, const String& spec, int start, int limit) {
+
+    if (limit < start || limit < 0) {
+        if (((limit <= Integer::MIN_VALUE + 1) && (start >= spec.length() || start < 0)) ||
+            (spec.startsWith("//", start) && spec.indexOf('/', start + 2) == -1)) {
+
+            throw StringIndexOutOfBoundsException(__FILE__, __LINE__, limit);
+        }
+        if (this != url.getURLStreamHandler()) {
+            throw new SecurityException();
+        }
+        return;
+    }
+
+    String parseString = spec.substring(start, limit);
+    limit -= start;
+    int fileIdx = 0;
+
+    // Default is to use info from context
+    String host = url.getHost();
+    int port = url.getPort();
+    String ref = url.getRef();
+    String file = url.getPath();
+    String query = url.getQuery();
+    String authority = url.getAuthority();
+    String userInfo = url.getUserInfo();
+
+    int refIdx = parseString.indexOf('#', 0);
+    if (parseString.startsWith("//") && !parseString.startsWith("////")) {
+        int hostIdx = 2;
+        int portIdx = -1;
+
+        port = -1;
+        fileIdx = parseString.indexOf('/', hostIdx);
+        int questionMarkIndex = parseString.indexOf('?', hostIdx);
+
+        if ((questionMarkIndex != -1) && ((fileIdx == -1) || (fileIdx > questionMarkIndex))) {
+            fileIdx = questionMarkIndex;
+        }
+
+        if (fileIdx == -1) {
+            fileIdx = limit;
+            // Use default
+            file = "";
+        }
+        int hostEnd = fileIdx;
+        if (refIdx != -1 && refIdx < fileIdx) {
+            hostEnd = refIdx;
+        }
+        int userIdx = parseString.lastIndexOf('@', hostEnd);
+        authority = parseString.substring(hostIdx, hostEnd);
+        if (userIdx > -1) {
+            userInfo = parseString.substring(hostIdx, userIdx);
+            hostIdx = userIdx + 1;
+        }
+
+        portIdx = parseString.indexOf(':', userIdx == -1 ? hostIdx : userIdx);
+        int endOfIPv6Addr = parseString.indexOf(']');
+        // if there are square braces, ie. IPv6 address, use last ':'
+        if (endOfIPv6Addr != -1) {
+            try {
+                if (parseString.length() > endOfIPv6Addr + 1) {
+                    char c = parseString.charAt(endOfIPv6Addr + 1);
+                    if (c == ':') {
+                        portIdx = endOfIPv6Addr + 1;
+                    } else {
+                        portIdx = -1;
+                    }
+                } else {
+                    portIdx = -1;
+                }
+            } catch (Exception& e) {
+                // Ignored
+            }
+        }
+
+        if (portIdx == -1 || portIdx > fileIdx) {
+            host = parseString.substring(hostIdx, hostEnd);
+        } else {
+            host = parseString.substring(hostIdx, portIdx);
+            String portString = parseString.substring(portIdx + 1, hostEnd);
+            if (portString.length() == 0) {
+                port = -1;
+            } else {
+                port = Integer::parseInt(portString.toString());
+            }
+        }
+    }
+
+    if (refIdx > -1) {
+        ref = parseString.substring(refIdx + 1, limit);
+    }
+    int fileEnd = (refIdx == -1 ? limit : refIdx);
+
+    int queryIdx = parseString.lastIndexOf('?', fileEnd);
+    bool canonicalize = false;
+    if (queryIdx > -1) {
+        query = parseString.substring(queryIdx + 1, fileEnd);
+        if (queryIdx == 0) {
+            if (file.equals("")) {
+                file = "/";
+            } else if (file.startsWith("/")) {
+                canonicalize = true;
+            }
+            int last = file.lastIndexOf('/') + 1;
+            file = file.substring(0, last);
+        }
+        fileEnd = queryIdx;
+    } else if (refIdx != 0) {
+        // Don't inherit query unless only the ref is changed
+        query = "";
+    }
+
+    if (fileIdx > -1) {
+        if (fileIdx < limit && parseString.charAt(fileIdx) == '/') {
+            file = parseString.substring(fileIdx, fileEnd);
+        } else if (fileEnd > fileIdx) {
+            if (file.equals("")) {
+                file = "/"; //$NON-NLS-1$
+            } else if (file.startsWith("/")) {
+                canonicalize = true;
+            }
+            int last = file.lastIndexOf('/') + 1;
+            if (last == 0) {
+                file = parseString.substring(fileIdx, fileEnd);
+            } else {
+                file = file.substring(0, last)
+                        + parseString.substring(fileIdx, fileEnd);
+            }
+        }
+    }
+
+    if (canonicalize) {
+        // modify file if there's any relative referencing
+        file = canonicalizePath(file);
+    }
+
+    setURL(url, url.getProtocol(), host, port, authority, userInfo, file, query, ref);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void URLStreamHandler::setURL(URL& url, const std::string& protocol, const std::string& host, int port,
-                              const std::string& authority, const std::string& userInfo,
-                              const std::string& path, const std::string& query, const std::string& ref) {
+void URLStreamHandler::setURL(URL& url, const String& protocol, const String& host, int port,
+                              const String& authority, const String& userInfo,
+                              const String& path, const String& query, const String& ref) {
 
     if (this != url.getURLStreamHandler()) {
         throw SecurityException(__FILE__, __LINE__, "Stream handler is not the URLs intance.");

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/main/decaf/net/URLStreamHandler.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/net/URLStreamHandler.h b/activemq-cpp/src/main/decaf/net/URLStreamHandler.h
index ae0100c..8630b8f 100644
--- a/activemq-cpp/src/main/decaf/net/URLStreamHandler.h
+++ b/activemq-cpp/src/main/decaf/net/URLStreamHandler.h
@@ -20,6 +20,7 @@
 
 #include <decaf/util/Config.h>
 
+#include <decaf/lang/String.h>
 #include <decaf/net/InetAddress.h>
 #include <decaf/net/URL.h>
 
@@ -42,11 +43,6 @@ namespace net {
      * @since 1.0
      */
     class DECAF_API URLStreamHandler {
-    private:
-
-        URLStreamHandler(const URLStreamHandler&);
-        URLStreamHandler& operator= (const URLStreamHandler&);
-
     public:
 
         virtual ~URLStreamHandler();
@@ -181,7 +177,7 @@ namespace net {
          * @param limit
          *      the string position to stop parsing.
          */
-        virtual void parseURL(URL& url, const std::string& spec, int start, int limit);
+        virtual void parseURL(URL& url, const decaf::lang::String& spec, int start, int limit);
 
         /**
          * Sets the fields of the URL  This method is only intended to be used by subclasses of
@@ -207,9 +203,11 @@ namespace net {
          *
          * @throws SecurityException if the protocol handler of the URL is not this instance.
          */
-        void setURL(URL& url, const std::string& protocol, const std::string& host, int port,
-                    const std::string& authority, const std::string& userInfo,
-                    const std::string& path, const std::string& query, const std::string& ref);
+        void setURL(URL& url,
+                    const decaf::lang::String& protocol, const decaf::lang::String& host, int port,
+                    const decaf::lang::String& authority, const decaf::lang::String& userInfo,
+                    const decaf::lang::String& path, const decaf::lang::String& query,
+                    const decaf::lang::String& ref);
 
     private:
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/test/Makefile.am
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/Makefile.am b/activemq-cpp/src/test/Makefile.am
index 206ba47..dd0f87d 100644
--- a/activemq-cpp/src/test/Makefile.am
+++ b/activemq-cpp/src/test/Makefile.am
@@ -196,6 +196,7 @@ cc_sources = \
     decaf/net/URITest.cpp \
     decaf/net/URLDecoderTest.cpp \
     decaf/net/URLEncoderTest.cpp \
+    decaf/net/URLTest.cpp \
     decaf/net/ssl/SSLSocketFactoryTest.cpp \
     decaf/nio/BufferTest.cpp \
     decaf/security/MessageDigestTest.cpp \
@@ -450,6 +451,7 @@ h_sources = \
     decaf/net/URITest.h \
     decaf/net/URLDecoderTest.h \
     decaf/net/URLEncoderTest.h \
+    decaf/net/URLTest.h \
     decaf/net/ssl/SSLSocketFactoryTest.h \
     decaf/nio/BufferTest.h \
     decaf/security/MessageDigestTest.h \

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/test/decaf/lang/StringTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/lang/StringTest.cpp b/activemq-cpp/src/test/decaf/lang/StringTest.cpp
index 025c999..ef00bb6 100644
--- a/activemq-cpp/src/test/decaf/lang/StringTest.cpp
+++ b/activemq-cpp/src/test/decaf/lang/StringTest.cpp
@@ -19,6 +19,8 @@
 
 #include <decaf/lang/String.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/StringIndexOutOfBoundsException.h>
 
 using namespace std;
 using namespace decaf;
@@ -34,15 +36,773 @@ StringTest::~StringTest() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StringTest::testConstructor1() {
-
+void StringTest::testDEfaultConstructor() {
     String test;
+    CPPUNIT_ASSERT_MESSAGE("Default string should equal empty", test == "");
+
+    CPPUNIT_ASSERT(test.length() == 0);
+    CPPUNIT_ASSERT(test.isEmpty() == true);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        test.charAt(1),
+        IndexOutOfBoundsException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testConstructorStdString() {
+
+    std::string stdString("ABCDE");
+
+    String test(stdString);
+
+    CPPUNIT_ASSERT(test.length() == 5);
+    CPPUNIT_ASSERT(test.isEmpty() == false);
+
+    CPPUNIT_ASSERT_MESSAGE("String and std::string should be equal", test == stdString);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        test.charAt(5),
+        IndexOutOfBoundsException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testConstructorString() {
+
+    String original("ABCDE");
+
+    String test(original);
+
+    CPPUNIT_ASSERT(test.length() == 5);
+    CPPUNIT_ASSERT(test.isEmpty() == false);
+
+    CPPUNIT_ASSERT_MESSAGE("String and std::string should be equal", test == original);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an IndexOutOfBoundsException",
+        test.charAt(5),
+        IndexOutOfBoundsException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testAssignmentString() {
+
+    String transient;
+    String input("HelloWorld");
+    String hello("Hello");
+    String world("World");
+
+    const String expected("World");
+
+    transient = input;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", transient, input);
+    transient = hello;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", transient, hello);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", input, String("HelloWorld"));
+    transient = world;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", transient, world);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testAssignmentStdString() {
+
+    String transient;
+    String input("HelloWorld");
+    std::string hello("Hello");
+    std::string world("World");
+
+    const String expected("World");
+
+    transient = input;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(input));
+    transient = hello;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(hello));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", input, String("HelloWorld"));
+    transient = world;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(world));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testAssignmentCString() {
+
+    String transient;
+    String input("HelloWorld");
+    const char* hello = "Hello";
+    const char* world = "World";
+
+    const String expected("World");
+
+    transient = input;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(input));
+    transient = hello;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(hello));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String assignment failed", input, String("HelloWorld"));
+    transient = world;
+    CPPUNIT_ASSERT_MESSAGE("String assignment failed", transient.equals(world));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testHashCode() {
+
+    String hw("HelloWorld");
+
+    int hwHashCode = 0;
+    const int hwLength = hw.length();
+    int powerOfThirtyOne = 1;
+
+    for (int counter = hwLength - 1; counter >= 0; counter--) {
+        hwHashCode += (int) hw.charAt(counter) * powerOfThirtyOne;
+        powerOfThirtyOne *= 31;
+    }
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("String did not hash to correct value", hwHashCode, hw.hashCode());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("The empty string \"\" did not hash to zero", 0, String().hashCode());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculated wrong string hashcode", -1933545242, String("Harmony").hashCode());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testSubstring1() {
+
+    const String input("HelloWorld");
+    const String expected("World");
+
+    CPPUNIT_ASSERT_MESSAGE("Incorrect substring returned", expected.equals(input.substring(5)));
+    CPPUNIT_ASSERT_MESSAGE("not identical", expected.substring(0) == expected);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testSubstring2() {
+
+    const String input("HelloWorld");
+    const String expected("Hello");
+
+    CPPUNIT_ASSERT_MESSAGE("Incorrect substring returned", input.substring(0, 5).equals("Hello"));
+    CPPUNIT_ASSERT_MESSAGE("Incorrect substring returned", input.substring(5, 10).equals("World"));
+    CPPUNIT_ASSERT_MESSAGE("not identical", input.substring(0, input.length()) == input);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testRegionMatches() {
 
-    CPPUNIT_ASSERT( test.length() == 0 );
-    CPPUNIT_ASSERT( test.isEmpty() == true );
+    const String input1("HelloWorld");
+    const String input2("HelloWorld");
+    const String bogusString("xxcedkedkleiorem lvvwr e''' 3r3r 23r");
+
+    CPPUNIT_ASSERT_MESSAGE("identical regions failed comparison",
+                           input1.regionMatches(2, input2, 2, 5));
+
+    CPPUNIT_ASSERT_MESSAGE("Different regions returned true",
+                           !input1.regionMatches(2, bogusString, 2, 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testRegionMatchesCaseSensitive() {
+
+    const String input1("HelloWorld");
+    const String input2("HelloWorld");
+    String bogusString = "xxcedkedkleiorem lvvwr e''' 3r3r 23r";
+
+    CPPUNIT_ASSERT_MESSAGE("identical regions failed comparison", input1.regionMatches(
+                           false, 2, input2, 2, 5));
+    CPPUNIT_ASSERT_MESSAGE("identical regions failed comparison with different cases",
+                           input1.regionMatches(true, 2, input2, 2, 5));
+    CPPUNIT_ASSERT_MESSAGE("Different regions returned true",
+                           !input1.regionMatches(true, 2, bogusString, 2, 5));
+    CPPUNIT_ASSERT_MESSAGE("identical regions failed comparison with different cases",
+                           input1.regionMatches(false, 2, input2, 2, 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testStartsWith() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.startsWith("Hello"));
+    CPPUNIT_ASSERT_MESSAGE("Found incorrect string", !input.startsWith("T"));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testStartsWithI() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.startsWith("World", 5));
+    CPPUNIT_ASSERT_MESSAGE("Found incorrect string", !input.startsWith("Hello", 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testSubstringExceptions() {
+
+    const String input("HelloWorld");
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-         "Should have thrown an IndexOutOfBoundsException",
-         test.charAt( 1 ),
-         IndexOutOfBoundsException );
+        "Should have thrown an StringIndexOutOfBoundsException",
+        input.substring(-1, 1),
+        StringIndexOutOfBoundsException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an StringIndexOutOfBoundsException",
+        input.substring(4, 1),
+        StringIndexOutOfBoundsException);
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown an StringIndexOutOfBoundsException",
+        input.substring(0, 100),
+        StringIndexOutOfBoundsException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testTrim() {
+    const String input(" HelloWorld ");
+    const String expected("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Incorrect string returned", input.trim().equals(expected));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testToString() {
+    const String input("HelloWorld");
+    const std::string helloworld("HelloWorld");
+    const std::string expected("World");
+
+    String substring = input.substring(5);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect string returned", helloworld, input.toString());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect string returned", expected, substring.toString());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testToCharArray() {
+    String input("ABCDE");
+    char* result = input.toCharArray();
+
+    for (int i = 0; i < input.length(); i++) {
+        CPPUNIT_ASSERT_MESSAGE("Returned incorrect char aray", input.charAt(i) == result[i]);
+    }
+
+    delete [] result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testEndsWith() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find ending string", input.endsWith("ld"));
+    CPPUNIT_ASSERT_MESSAGE("Failed to not find ending string", !input.endsWith("lo"));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testEqualsIgnoreCase() {
+
+    String lower = "helloworld";
+    String upper = "HELLOWORLD";
+
+    CPPUNIT_ASSERT_MESSAGE("lc version returned unequal to uc", lower.equalsIgnoreCase(upper));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testEqualsIgnoreCaseCString() {
+
+    String lower = "helloworld";
+    const char* upper = "HELLOWORLD";
+
+    CPPUNIT_ASSERT_MESSAGE("lc version returned unequal to uc", lower.equalsIgnoreCase(upper));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testEqualsIgnoreCaseStdString() {
+
+    String lower = "helloworld";
+    std::string upper = "HELLOWORLD";
+
+    CPPUNIT_ASSERT_MESSAGE("lc version returned unequal to uc", lower.equalsIgnoreCase(upper));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfChar() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid index returned", 1, input.indexOf('e'));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid index returned", -1, input.indexOf('q'));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfChar2() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid character index returned", 5, input.indexOf('W', 2));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid index returned", -1, input.indexOf('q', 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid index returned", 1, input.indexOf('e', -1));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid index returned", -1, input.indexOf('H', 10));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfString() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf(String("World")) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", !(input.indexOf(String("ZZ")) > 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfString2() {
+
+    const String input("HelloWorld");
+    const String hello("Hello");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf(String("World"), 0) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Found string outside index", !(input.indexOf(String("Hello"), 6) > 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid negative starting position",
+                                 0, hello.indexOf(String(""), -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", 5, hello.indexOf(String(""), 5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong for empty in empty", 0, String("").indexOf(String(""), 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfStdString() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf(std::string("World")) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", !(input.indexOf(std::string("ZZ")) > 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfStdString2() {
+
+    const String input("HelloWorld");
+    const String hello("Hello");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf(std::string("World"), 0) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Found string outside index", !(input.indexOf(std::string("Hello"), 6) > 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid negative starting position",
+                                 0, hello.indexOf(std::string(""), -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", 5, hello.indexOf(std::string(""), 5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong for empty in empty", 0, String("").indexOf(std::string(""), 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfCString() {
+    const String input("HelloWorld");
+    const char* nullString = NULL;
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf("World") > 0);
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", !(input.indexOf("ZZ") > 0));
+    CPPUNIT_ASSERT_MESSAGE("Failed to return correct code", !(input.indexOf(nullString) > 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIndexOfCString2() {
+
+    const String input("HelloWorld");
+    const String hello("Hello");
+    const char* nullString = NULL;
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to find string", input.indexOf("World", 0) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Found string outside index", !(input.indexOf("Hello", 6) > 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid negative starting position",
+                                 0, hello.indexOf("", -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", 5, hello.indexOf("", 5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong for empty in empty", 0, String("").indexOf("", 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", -1, hello.indexOf(nullString, 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfChar() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to return correct index", 5, input.lastIndexOf('W'));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned index for non-existent char", -1, input.lastIndexOf('Z'));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfChar2() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to return correct index", 5, input.lastIndexOf('W', 6));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned index for char out of specified range",
+                                 -1, input.lastIndexOf('W', 4));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned index for non-existent char",
+                                 -1, input.lastIndexOf('Z', 9));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfString() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf(String("World")));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Found String outside of index",
+                                 -1, input.lastIndexOf(String("HeKKKKKKKK")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfString2() {
+    const String input("HelloWorld");
+    const String hello("Hello");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf(String("World"), 9));
+    int result = input.lastIndexOf(String("Hello"), 2);
+    CPPUNIT_ASSERT_MESSAGE("Found String outside of index: " + result, result == 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", -1, hello.lastIndexOf(String(""), -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid large starting position",
+                                 5, hello.lastIndexOf(String(""), 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfStdString() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf(std::string("World")));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Found String outside of index",
+                                 -1, input.lastIndexOf(std::string("HeKKKKKKKK")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfStdString2() {
+    const String input("HelloWorld");
+    const String hello("Hello");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf(std::string("World"), 9));
+    int result = input.lastIndexOf(std::string("Hello"), 2);
+    CPPUNIT_ASSERT_MESSAGE("Found String outside of index: " + result, result == 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", -1, hello.lastIndexOf(std::string(""), -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid large starting position",
+                                 5, hello.lastIndexOf(std::string(""), 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfCString() {
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf("World"));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Found String outside of index", -1, input.lastIndexOf("HeKKKKKKKK"));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testLastIndexOfCString2() {
+    const String input("HelloWorld");
+    const String hello("Hello");
+    const char* nullString = NULL;
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", -1, input.lastIndexOf(nullString, 0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect index", 5, input.lastIndexOf("World", 9));
+    int result = input.lastIndexOf("Hello", 2);
+    CPPUNIT_ASSERT_MESSAGE("Found String outside of index: " + result, result == 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Reported wrong error code", -1, hello.lastIndexOf("", -5));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did not accept valid large starting position", 5, hello.lastIndexOf("", 5));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testToLowerCase() {
+
+    String lower = "helloworld";
+    String upper = "HELLOWORLD";
+
+    CPPUNIT_ASSERT_MESSAGE("toLowerCase case conversion did not succeed",
+                           upper.toLowerCase().equals(lower));
+    CPPUNIT_ASSERT_MESSAGE("toLowerCase case non-conversion did not succeed",
+                           lower.toLowerCase().equals(lower));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testToUpperCase() {
+
+    String lower = "helloworld";
+    String upper = "HELLOWORLD";
+
+    CPPUNIT_ASSERT_MESSAGE("toUpperCase case conversion did not succeed",
+                           lower.toUpperCase().equals(upper));
+    CPPUNIT_ASSERT_MESSAGE("toUpperCase case non-conversion did not succeed",
+                           upper.toUpperCase().equals(upper));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testReplaceCharChar() {
+
+    const String input("HelloWorld");
+    const String expected("HezzoWorzd");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed replace", String("HezzoWorzd"), input.replace('l', 'z'));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testContainsString() {
+
+    String s = "abcdefghijklmnopqrstuvwxyz";
+    CPPUNIT_ASSERT(s.contains(String("abc")));
+    CPPUNIT_ASSERT(s.contains(String("def")));
+    CPPUNIT_ASSERT(!s.contains(String("ac")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testContainsStdString() {
+
+    String s = "abcdefghijklmnopqrstuvwxyz";
+    CPPUNIT_ASSERT(s.contains(std::string("abc")));
+    CPPUNIT_ASSERT(s.contains(std::string("def")));
+    CPPUNIT_ASSERT(!s.contains(std::string("ac")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testContainsCString() {
+
+    String s = "abcdefghijklmnopqrstuvwxyz";
+    CPPUNIT_ASSERT(s.contains("abc"));
+    CPPUNIT_ASSERT(s.contains("def"));
+    CPPUNIT_ASSERT(!s.contains("ac"));
+    CPPUNIT_ASSERT(!s.contains((const char*) NULL));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testConcatString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const String world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", expected, hello.concat(world));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", hello, hello.concat(String("")));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", String(""), String("").concat(String("")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testConcatStdString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const std::string world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", expected, hello.concat(world));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", hello, hello.concat(std::string("")));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", String(""), String("").concat(std::string("")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testConcatCString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const char* world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", expected, hello.concat(world));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", hello, hello.concat(""));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed Concat", String(""), String("").concat(""));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                           String("aaaaab").compareTo(String("aaaaac")) < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareTo(String("aaaaac")));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareTo(String("aaaaab")) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Considered case to not be of importance",
+                           !(String("A").compareTo(String("a")) == 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToStdString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                           String("aaaaab").compareTo(std::string("aaaaac")) < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareTo(std::string("aaaaac")));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareTo(std::string("aaaaab")) > 0);
+    CPPUNIT_ASSERT_MESSAGE("Considered case to not be of importance",
+                           !(String("A").compareTo(std::string("a")) == 0));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToCString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                           String("aaaaab").compareTo("aaaaac") < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareTo("aaaaac"));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareTo("aaaaab") > 0);
+    CPPUNIT_ASSERT_MESSAGE("Considered case to not be of importance",
+                           !(String("A").compareTo("a") == 0));
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        String("").compareTo((const char*) NULL),
+        NullPointerException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToIgnoreCaseString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                          String("aaaaab").compareToIgnoreCase(String("aaaaac")) < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareToIgnoreCase(String("aaaaac")));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareToIgnoreCase(String("aaaaab")) > 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Considered case to not be of importance",
+                                 0, String("A").compareToIgnoreCase(String("a")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToIgnoreCaseStdString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                          String("aaaaab").compareToIgnoreCase(std::string("aaaaac")) < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareToIgnoreCase(std::string("aaaaac")));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareToIgnoreCase(std::string("aaaaab")) > 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Considered case to not be of importance",
+                                 0, String("A").compareToIgnoreCase(std::string("a")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testCompareToIgnoreCaseCString() {
+
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first < second",
+                          String("aaaaab").compareToIgnoreCase("aaaaac") < 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Returned incorrect value for first = second",
+                                 0, String("aaaaac").compareToIgnoreCase("aaaaac"));
+    CPPUNIT_ASSERT_MESSAGE("Returned incorrect value for first > second",
+                           String("aaaaac").compareToIgnoreCase("aaaaab") > 0);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Considered case to not be of importance",
+                                 0, String("A").compareToIgnoreCase("a"));
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        String("").compareTo((const char*) NULL),
+        NullPointerException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testIsNullOrEmpty() {
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to detect NULL", String::isNullOrEmpty((const char*) NULL));
+    CPPUNIT_ASSERT_MESSAGE("Failed to detect empty", String::isNullOrEmpty(""));
+    CPPUNIT_ASSERT_MESSAGE("Failed to detect non-empty", !String::isNullOrEmpty("abcd"));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorEqualsString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input == String("HelloWorld"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input == String("HolloWorld")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorEqualsStdString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input == std::string("HelloWorld"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input == std::string("HolloWorld")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorEqualsCString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input == "HelloWorld");
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input == "HolloWorld"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input == NULL));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorNotEqualsString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input != String("HelloWorzd"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input != String("HelloWorld")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorNotEqualsStdString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input != std::string("HelloWorzd"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input != std::string("HelloWorld")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorNotEqualsCString() {
+
+    const String input("HelloWorld");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input != "HelloWorzd");
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(input != "HelloWorld"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", input != NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorLessString() {
+
+    String upper = "HELLOWORLD";
+    String lower = "helloworld";
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", upper < lower);
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(upper < upper));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorLessStdString() {
+
+    String upper = "HELLOWORLD";
+    std::string lower = "helloworld";
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", upper < lower);
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(upper < std::string("HELLOWORLD")));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorLessCString() {
+
+    String upper = "HELLOWORLD";
+    const char* lower = "helloworld";
+
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", upper < lower);
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(upper < "HELLOWORLD"));
+    CPPUNIT_ASSERT_MESSAGE("Failed comparison", !(upper < NULL));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorPlusString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const String world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", expected, hello + world);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", hello, hello + String(""));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", String(""), String("") + String(""));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorPlusStdString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const std::string world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", expected, hello + world);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", hello, hello + std::string(""));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", String(""), String("") + std::string(""));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTest::testOperatorPlusCString() {
+
+    const String expected("HelloWorld");
+    const String hello("Hello");
+    const char* world("World");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", expected, hello + world);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", hello, hello + "");
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", String(""), String("") + "");
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed operator+ ", String(""), String("") + NULL);
 }

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/test/decaf/lang/StringTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/lang/StringTest.h b/activemq-cpp/src/test/decaf/lang/StringTest.h
index 1e31cc4..98cc294 100644
--- a/activemq-cpp/src/test/decaf/lang/StringTest.h
+++ b/activemq-cpp/src/test/decaf/lang/StringTest.h
@@ -24,19 +24,143 @@
 namespace decaf {
 namespace lang {
 
-    class StringTest : public CppUnit::TestFixture
-    {
+    class StringTest : public CppUnit::TestFixture {
+
         CPPUNIT_TEST_SUITE( StringTest );
-        CPPUNIT_TEST( testConstructor1 );
+        CPPUNIT_TEST( testDEfaultConstructor );
+        CPPUNIT_TEST( testConstructorStdString );
+        CPPUNIT_TEST( testConstructorString );
+        CPPUNIT_TEST( testAssignmentString );
+        CPPUNIT_TEST( testAssignmentStdString );
+        CPPUNIT_TEST( testAssignmentCString );
+        CPPUNIT_TEST( testHashCode );
+        CPPUNIT_TEST( testSubstring1 );
+        CPPUNIT_TEST( testSubstring2 );
+        CPPUNIT_TEST( testSubstringExceptions );
+        CPPUNIT_TEST( testTrim );
+        CPPUNIT_TEST( testToString );
+        CPPUNIT_TEST( testToCharArray );
+        CPPUNIT_TEST( testRegionMatches );
+        CPPUNIT_TEST( testRegionMatchesCaseSensitive );
+        CPPUNIT_TEST( testStartsWith );
+        CPPUNIT_TEST( testStartsWithI );
+        CPPUNIT_TEST( testEndsWith );
+        CPPUNIT_TEST( testEqualsIgnoreCase );
+        CPPUNIT_TEST( testEqualsIgnoreCaseCString );
+        CPPUNIT_TEST( testEqualsIgnoreCaseStdString );
+        CPPUNIT_TEST( testIndexOfChar );
+        CPPUNIT_TEST( testIndexOfChar2 );
+        CPPUNIT_TEST( testIndexOfString );
+        CPPUNIT_TEST( testIndexOfString2 );
+        CPPUNIT_TEST( testIndexOfStdString );
+        CPPUNIT_TEST( testIndexOfStdString2 );
+        CPPUNIT_TEST( testIndexOfCString );
+        CPPUNIT_TEST( testIndexOfCString2 );
+        CPPUNIT_TEST( testLastIndexOfChar );
+        CPPUNIT_TEST( testLastIndexOfChar2 );
+        CPPUNIT_TEST( testLastIndexOfString );
+        CPPUNIT_TEST( testLastIndexOfString2 );
+        CPPUNIT_TEST( testLastIndexOfStdString );
+        CPPUNIT_TEST( testLastIndexOfStdString2 );
+        CPPUNIT_TEST( testLastIndexOfCString );
+        CPPUNIT_TEST( testLastIndexOfCString2 );
+        CPPUNIT_TEST( testToLowerCase );
+        CPPUNIT_TEST( testToUpperCase );
+        CPPUNIT_TEST( testReplaceCharChar );
+        CPPUNIT_TEST( testContainsString );
+        CPPUNIT_TEST( testContainsStdString );
+        CPPUNIT_TEST( testContainsCString );
+        CPPUNIT_TEST( testConcatString );
+        CPPUNIT_TEST( testConcatStdString );
+        CPPUNIT_TEST( testConcatCString );
+        CPPUNIT_TEST( testCompareToString );
+        CPPUNIT_TEST( testCompareToStdString );
+        CPPUNIT_TEST( testCompareToCString );
+        CPPUNIT_TEST( testCompareToIgnoreCaseString );
+        CPPUNIT_TEST( testCompareToIgnoreCaseStdString );
+        CPPUNIT_TEST( testCompareToIgnoreCaseCString );
+        CPPUNIT_TEST( testIsNullOrEmpty );
+        CPPUNIT_TEST( testOperatorEqualsString );
+        CPPUNIT_TEST( testOperatorEqualsStdString );
+        CPPUNIT_TEST( testOperatorEqualsCString );
+        CPPUNIT_TEST( testOperatorNotEqualsString );
+        CPPUNIT_TEST( testOperatorNotEqualsStdString );
+        CPPUNIT_TEST( testOperatorNotEqualsCString );
+        CPPUNIT_TEST( testOperatorPlusString );
+        CPPUNIT_TEST( testOperatorPlusStdString );
+        CPPUNIT_TEST( testOperatorPlusCString );
         CPPUNIT_TEST_SUITE_END();
 
     public:
 
         StringTest();
-
         virtual ~StringTest();
 
-        void testConstructor1();
+        void testDEfaultConstructor();
+        void testConstructorStdString();
+        void testConstructorString();
+        void testAssignmentString();
+        void testAssignmentStdString();
+        void testAssignmentCString();
+        void testHashCode();
+        void testSubstring1();
+        void testSubstring2();
+        void testSubstringExceptions();
+        void testTrim();
+        void testToString();
+        void testToCharArray();
+        void testRegionMatches();
+        void testRegionMatchesCaseSensitive();
+        void testStartsWith();
+        void testStartsWithI();
+        void testEndsWith();
+        void testEqualsIgnoreCase();
+        void testEqualsIgnoreCaseCString();
+        void testEqualsIgnoreCaseStdString();
+        void testIndexOfChar();
+        void testIndexOfChar2();
+        void testIndexOfString();
+        void testIndexOfString2();
+        void testIndexOfStdString();
+        void testIndexOfStdString2();
+        void testIndexOfCString();
+        void testIndexOfCString2();
+        void testLastIndexOfChar();
+        void testLastIndexOfChar2();
+        void testLastIndexOfString();
+        void testLastIndexOfString2();
+        void testLastIndexOfStdString();
+        void testLastIndexOfStdString2();
+        void testLastIndexOfCString();
+        void testLastIndexOfCString2();
+        void testToLowerCase();
+        void testToUpperCase();
+        void testReplaceCharChar();
+        void testContainsString();
+        void testContainsStdString();
+        void testContainsCString();
+        void testConcatString();
+        void testConcatStdString();
+        void testConcatCString();
+        void testCompareToString();
+        void testCompareToStdString();
+        void testCompareToCString();
+        void testCompareToIgnoreCaseString();
+        void testCompareToIgnoreCaseStdString();
+        void testCompareToIgnoreCaseCString();
+        void testIsNullOrEmpty();
+        void testOperatorEqualsString();
+        void testOperatorEqualsStdString();
+        void testOperatorEqualsCString();
+        void testOperatorNotEqualsString();
+        void testOperatorNotEqualsStdString();
+        void testOperatorNotEqualsCString();
+        void testOperatorLessString();
+        void testOperatorLessStdString();
+        void testOperatorLessCString();
+        void testOperatorPlusString();
+        void testOperatorPlusStdString();
+        void testOperatorPlusCString();
 
     };
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/test/decaf/net/URLTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/net/URLTest.cpp b/activemq-cpp/src/test/decaf/net/URLTest.cpp
new file mode 100644
index 0000000..2e047e4
--- /dev/null
+++ b/activemq-cpp/src/test/decaf/net/URLTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "URLTest.h"
+
+#include <decaf/net/URI.h>
+#include <decaf/net/URL.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Boolean.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::net;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+URLTest::URLTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+URLTest::~URLTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void URLTest::testConstructorString() {
+
+    URL u("http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("u returns a wrong protocol", String("http"), u.getProtocol());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("u returns a wrong host", String("www.yahoo1.com"), u.getHost());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("u returns a wrong port", 8080, u.getPort());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("u returns a wrong file",
+                                 String("/dir1/dir2/test.cgi?point1.html"), u.getFile());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("u returns a wrong anchor", String("anchor1"), u.getRef());
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void URLTest::testEquals() {
+}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/b1746b23/activemq-cpp/src/test/decaf/net/URLTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/decaf/net/URLTest.h b/activemq-cpp/src/test/decaf/net/URLTest.h
new file mode 100644
index 0000000..8d5c230
--- /dev/null
+++ b/activemq-cpp/src/test/decaf/net/URLTest.h
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_NET_URLTEST_H_
+#define _DECAF_NET_URLTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf {
+namespace net {
+
+    class URLTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( URLTest );
+        CPPUNIT_TEST( testConstructorString );
+        CPPUNIT_TEST( testEquals );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        URLTest();
+        virtual ~URLTest();
+
+        void testConstructorString();
+        void testEquals();
+
+    };
+
+}}
+
+#endif /* _DECAF_NET_URLTEST_H_ */


Mime
View raw message