activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] https://issues.apache.org/jira/browse/AMQCPP-519
Date Mon, 14 Oct 2013 21:36:26 GMT
Updated Branches:
  refs/heads/trunk e78c28336 -> ba624ea97


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/main/decaf/util/Properties.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/Properties.cpp b/activemq-cpp/src/main/decaf/util/Properties.cpp
index 72c871d..71b38b9 100644
--- a/activemq-cpp/src/main/decaf/util/Properties.cpp
+++ b/activemq-cpp/src/main/decaf/util/Properties.cpp
@@ -63,15 +63,15 @@ namespace {
         PARSE_MODE_IGNORE = 4
     };
 
-    void dumpString( std::ostringstream& buffer, const std::string& string, bool key ) {
+    void dumpString(std::ostringstream& buffer, const std::string& string, bool key) {
 
         std::size_t i = 0;
-        if( !key && i < string.length() && string.at(i) == ' ' ) {
+        if (!key && i < string.length() && string.at(i) == ' ') {
             buffer << "\\ ";
             i++;
         }
 
-        for( ; i < string.length(); i++ ) {
+        for (; i < string.length(); i++) {
 
             char ch = string.at(i);
 
@@ -89,17 +89,17 @@ namespace {
                     buffer << "\\r";
                     break;
                 default:
-                    if( std::string( "\\#!=:" ).find( ch ) != std::string::npos || ( key && ch == ' ' ) ) {
+                    if (std::string("\\#!=:").find(ch) != std::string::npos || (key && ch == ' ')) {
                         buffer << '\\';
                     }
 
-                    if( ch >= ' ' && ch <= '~' ) {
+                    if (ch >= ' ' && ch <= '~') {
                         buffer << ch;
                     } else {
 
-                        std::string hex = Integer::toHexString( ch );
+                        std::string hex = Integer::toHexString(ch);
                         buffer << "\\u";
-                        for( std::size_t j = 0; j < 4 - hex.length(); j++ ) {
+                        for (std::size_t j = 0; j < 4 - hex.length(); j++) {
                             buffer << "0";
                         }
                         buffer << hex;
@@ -112,36 +112,36 @@ namespace {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Properties::Properties() : internal( new PropertiesInternal() ), defaults() {
+Properties::Properties() : internal(new PropertiesInternal()), defaults() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Properties::Properties( const Properties& src ) : internal( new PropertiesInternal() ), defaults() {
+Properties::Properties(const Properties& src) : internal(new PropertiesInternal()), defaults() {
 
-    this->internal->properties.copy( src.internal->properties );
+    this->internal->properties.copy(src.internal->properties);
 
-    if( src.defaults.get() != NULL ) {
-        this->defaults.reset( src.defaults->clone() );
+    if (src.defaults.get() != NULL) {
+        this->defaults.reset(src.defaults->clone());
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Properties::~Properties() {
-    try{
+    try {
         delete this->internal;
     }
-    DECAF_CATCH_NOTHROW( Exception )
+    DECAF_CATCH_NOTHROW(Exception)
     DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Properties& Properties::operator= ( const Properties& source ) {
+Properties& Properties::operator=(const Properties& source) {
 
-    if( this == &source ) {
+    if (this == &source) {
         return *this;
     }
 
-    this->copy( source );
+    this->copy(source);
 
     return *this;
 }
@@ -159,20 +159,20 @@ bool Properties::isEmpty() const {
 int Properties::size() const {
 
     synchronized( &( internal->properties ) ) {
-        return (int)internal->properties.size();
+        return (int) internal->properties.size();
     }
 
     return 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-const char* Properties::getProperty( const std::string& name ) const{
+const char* Properties::getProperty(const std::string& name) const {
 
     synchronized( &( internal->properties ) ) {
-        if( this->internal->properties.containsKey( name ) ) {
-            return this->internal->properties.get( name ).c_str();
-        } else if( this->defaults != NULL && this->defaults->hasProperty( name ) ) {
-            return this->defaults->getProperty( name );
+        if (this->internal->properties.containsKey(name)) {
+            return this->internal->properties.get(name).c_str();
+        } else if (this->defaults != NULL && this->defaults->hasProperty(name)) {
+            return this->defaults->getProperty(name);
         }
     }
 
@@ -180,14 +180,13 @@ const char* Properties::getProperty( const std::string& name ) const{
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Properties::getProperty( const std::string& name,
-                                     const std::string& defaultValue ) const {
+std::string Properties::getProperty(const std::string& name, const std::string& defaultValue) const {
 
-    synchronized( &( internal->properties ) ) {
-        if( this->internal->properties.containsKey( name ) ) {
-            return this->internal->properties.get( name );
-        } else if( this->defaults != NULL && this->defaults->hasProperty( name ) ) {
-            return this->defaults->getProperty( name );
+    synchronized(&(internal->properties)) {
+        if (this->internal->properties.containsKey(name)) {
+            return this->internal->properties.get(name);
+        } else if (this->defaults != NULL && this->defaults->hasProperty(name)) {
+            return this->defaults->getProperty(name);
         }
     }
 
@@ -195,41 +194,40 @@ std::string Properties::getProperty( const std::string& name,
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Properties::setProperty( const std::string& name, const std::string& value ){
+std::string Properties::setProperty(const std::string& name, const std::string& value) {
 
     std::string oldValue;
+    synchronized(&(internal->properties)) {
 
-    synchronized( &( internal->properties ) ) {
-
-        if( internal->properties.containsKey( name ) ) {
-            oldValue = internal->properties.get( name );
+        if (internal->properties.containsKey(name)) {
+            oldValue = internal->properties.get(name);
         }
 
-        internal->properties.put( name, value );
+        internal->properties.put(name, value);
     }
 
     return oldValue;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool Properties::hasProperty( const std::string& name ) const {
+bool Properties::hasProperty(const std::string& name) const {
 
     synchronized( &( internal->properties ) ) {
-        return this->internal->properties.containsKey( name );
+        return this->internal->properties.containsKey(name);
     }
 
     return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Properties::remove( const std::string& name ){
+std::string Properties::remove(const std::string& name) {
 
     std::string oldValue;
 
     synchronized( &( internal->properties ) ) {
-        if( this->internal->properties.containsKey( name ) ) {
-            oldValue = this->internal->properties.get( name );
-            this->internal->properties.remove( name );
+        if (this->internal->properties.containsKey(name)) {
+            oldValue = this->internal->properties.get(name);
+            this->internal->properties.remove(name);
         }
     }
 
@@ -237,12 +235,12 @@ std::string Properties::remove( const std::string& name ){
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::vector< std::pair< std::string, std::string > > Properties::toArray() const{
+std::vector<std::pair<std::string, std::string> > Properties::toArray() const {
 
-    std::vector< std::pair<std::string, std::string> > result;
+    std::vector<std::pair<std::string, std::string> > result;
 
     synchronized( &( internal->properties ) ) {
-        Pointer< Iterator< MapEntry<std::string, std::string> > > entries(
+        Pointer<Iterator<MapEntry<std::string, std::string> > > entries(
                 this->internal->properties.entrySet().iterator());
         while (entries->hasNext()) {
             MapEntry<std::string, std::string> entry = entries->next();
@@ -256,32 +254,32 @@ std::vector< std::pair< std::string, std::string > > Properties::toArray() const
 ////////////////////////////////////////////////////////////////////////////////
 void Properties::copy( const Properties& source ){
 
-    if( &source == this ) {
+    if (&source == this) {
         return;
     }
 
     synchronized( &( this->internal->properties ) ) {
 
         synchronized( &( source.internal->properties ) ) {
-            this->internal->properties.copy( source.internal->properties );
+            this->internal->properties.copy(source.internal->properties);
 
-            if( source.defaults.get() != NULL ) {
-                this->defaults.reset( source.defaults->clone() );
+            if (source.defaults.get() != NULL) {
+                this->defaults.reset(source.defaults->clone());
             }
         }
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Properties* Properties::clone() const{
+Properties* Properties::clone() const {
 
     Properties* props = new Properties();
-    props->internal->properties.copy( this->internal->properties );
+    props->internal->properties.copy(this->internal->properties);
     return props;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::clear(){
+void Properties::clear() {
 
     synchronized( &( internal->properties ) ) {
         this->internal->properties.clear();
@@ -289,20 +287,20 @@ void Properties::clear(){
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool Properties::equals( const Properties& source ) const {
-    return this->internal->properties.equals( source.internal->properties );
+bool Properties::equals(const Properties& source) const {
+    return this->internal->properties.equals(source.internal->properties);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string Properties::toString() const {
 
     std::ostringstream stream;
-    std::map< std::string, std::string >::const_iterator iter;
+    std::map<std::string, std::string>::const_iterator iter;
 
     stream << "Begin Class decaf::util::Properties:" << std::endl;
 
-    synchronized( &( internal->properties ) ) {
-        Pointer< Iterator< MapEntry<std::string, std::string> > > entries(
+    synchronized(&(internal->properties)) {
+        Pointer<Iterator<MapEntry<std::string, std::string> > > entries(
                 this->internal->properties.entrySet().iterator());
         while (entries->hasNext()) {
             MapEntry<std::string, std::string> entry = entries->next();
@@ -318,19 +316,19 @@ std::string Properties::toString() const {
 ////////////////////////////////////////////////////////////////////////////////
 std::vector<std::string> Properties::propertyNames() const {
     StlMap<std::string, std::string> selectedProperties;
-    this->selectProperties( selectedProperties );
+    this->selectProperties(selectedProperties);
     return selectedProperties.keySet().toArray();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::selectProperties( StlMap<std::string, std::string>& selectProperties ) const {
+void Properties::selectProperties(StlMap<std::string, std::string>& selectProperties) const {
 
-    if( this->defaults != NULL ) {
-        this->defaults->selectProperties( selectProperties );
+    if (this->defaults != NULL) {
+        this->defaults->selectProperties(selectProperties);
     }
 
-    Pointer< Iterator< MapEntry<std::string, std::string> > > entries(
-            this->internal->properties.entrySet().iterator());
+    Pointer<Iterator<MapEntry<std::string, std::string> > > entries(
+        this->internal->properties.entrySet().iterator());
     while (entries->hasNext()) {
         MapEntry<std::string, std::string> entry = entries->next();
         selectProperties.put(entry.getKey(), entry.getValue());
@@ -338,14 +336,13 @@ void Properties::selectProperties( StlMap<std::string, std::string>& selectPrope
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::load( decaf::io::InputStream* stream ) {
+void Properties::load(decaf::io::InputStream* stream) {
 
     try{
 
-        if( stream == NULL ) {
+        if (stream == NULL) {
             throw NullPointerException(
-                __FILE__, __LINE__,
-                "The Stream instance passed was Null" );
+                __FILE__, __LINE__, "The Stream instance passed was Null");
         }
 
         int mode = PARSE_MODE_NONE;
@@ -355,19 +352,19 @@ void Properties::load( decaf::io::InputStream* stream ) {
         int keyLength = -1;
         int intVal;
         bool firstChar = true;
-        BufferedInputStream bis( stream );
+        BufferedInputStream bis(stream);
 
-        while(true) {
+        while (true) {
 
             intVal = bis.read();
 
-            if( intVal == -1 ) {
+            if (intVal == -1) {
                 break;
             }
 
-            nextChar = (char) ( intVal & 0xFF );
+            nextChar = (char) (intVal & 0xFF);
 
-            if( mode == PARSE_MODE_SLASH ) {
+            if (mode == PARSE_MODE_SLASH) {
 
                 mode = PARSE_MODE_NONE;
                 switch( nextChar ) {
@@ -399,16 +396,16 @@ void Properties::load( decaf::io::InputStream* stream ) {
                 switch( nextChar ) {
                     case '#':
                     case '!':
-                        if( firstChar ) {
-                            while( true ) {
+                        if (firstChar) {
+                            while (true) {
                                 intVal = bis.read();
-                                if( intVal == -1 ) {
+                                if (intVal == -1) {
                                     break;
                                 }
 
-                                nextChar = (char)( intVal & 0xFF );
+                                nextChar = (char) (intVal & 0xFF);
 
-                                if( nextChar == '\r' || nextChar == '\n' ) {
+                                if (nextChar == '\r' || nextChar == '\n') {
                                     break;
                                 }
                             }
@@ -416,23 +413,23 @@ void Properties::load( decaf::io::InputStream* stream ) {
                         }
                         break;
                     case '\n':
-                        if( mode == PARSE_MODE_CONTINUE) { // Part of a \r\n sequence
+                        if (mode == PARSE_MODE_CONTINUE) { // Part of a \r\n sequence
                             mode = PARSE_MODE_IGNORE; // Ignore whitespace on the next line
                             continue;
                         }
-                        // fall into the next case
+                        // Intentional fall into the next case
                     case '\r':
                         mode = PARSE_MODE_NONE;
                         firstChar = true;
-                        if( offset > 0 || ( offset == 0 && keyLength == 0 ) ) {
+                        if (offset > 0 || (offset == 0 && keyLength == 0)) {
 
-                            if( keyLength == -1 ) {
+                            if (keyLength == -1) {
                                 keyLength = offset;
                             }
-                            std::string temp( buf.begin(), buf.begin() + offset );
+                            std::string temp(buf.begin(), buf.begin() + offset);
 
-                            this->internal->properties.put( temp.substr( 0, keyLength ),
-                                                            temp.substr( keyLength ) );
+                            this->internal->properties.put(temp.substr(
+                                0, keyLength), temp.substr(keyLength));
                         }
 
                         keyLength = -1;
@@ -440,14 +437,14 @@ void Properties::load( decaf::io::InputStream* stream ) {
                         buf.clear();
                         continue;
                     case '\\':
-                        if( mode == PARSE_MODE_KEY_DONE ) {
+                        if (mode == PARSE_MODE_KEY_DONE) {
                             keyLength = offset;
                         }
                         mode = PARSE_MODE_SLASH;
                         continue;
                     case ':':
                     case '=':
-                        if( keyLength == -1 ) { // if parsing the key
+                        if (keyLength == -1) { // if parsing the key
                             mode = PARSE_MODE_NONE;
                             keyLength = offset;
                             continue;
@@ -455,87 +452,84 @@ void Properties::load( decaf::io::InputStream* stream ) {
                         break;
                 }
                 if( Character::isWhitespace( nextChar ) ) {
-                    if( mode == PARSE_MODE_CONTINUE ) {
+                    if (mode == PARSE_MODE_CONTINUE) {
                         mode = PARSE_MODE_IGNORE;
                     }
                     // if key length == 0 or value length == 0
-                    if( offset == 0 || offset == keyLength || mode == PARSE_MODE_IGNORE ) {
+                    if (offset == 0 || offset == keyLength || mode == PARSE_MODE_IGNORE) {
                         continue;
                     }
-                    if( keyLength == -1 ) { // if parsing the key
+                    if (keyLength == -1) { // if parsing the key
                         mode = PARSE_MODE_KEY_DONE;
                         continue;
                     }
                 }
 
-                if( mode == PARSE_MODE_IGNORE || mode == PARSE_MODE_CONTINUE ) {
+                if (mode == PARSE_MODE_IGNORE || mode == PARSE_MODE_CONTINUE) {
                     mode = PARSE_MODE_NONE;
                 }
             }
 
             firstChar = false;
-            if( mode == PARSE_MODE_KEY_DONE ) {
+            if (mode == PARSE_MODE_KEY_DONE) {
                 keyLength = offset;
                 mode = PARSE_MODE_NONE;
             }
 
             offset += 1;
-            buf.push_back( nextChar );
+            buf.push_back(nextChar);
         }
 
-        if( keyLength == -1 && offset > 0 ) {
+        if (keyLength == -1 && offset > 0) {
             keyLength = offset;
         }
 
-        if( keyLength >= 0 ) {
-            std::string temp( buf.begin(), buf.begin() + offset );
-            this->internal->properties.put( temp.substr( 0, keyLength ), temp.substr( keyLength ) );
+        if (keyLength >= 0) {
+            std::string temp(buf.begin(), buf.begin() + offset);
+            this->internal->properties.put(temp.substr(0, keyLength), temp.substr(keyLength));
         }
     }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCH_RETHROW( IllegalArgumentException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
-    DECAF_CATCHALL_THROW( IOException )
+    DECAF_CATCH_RETHROW(IOException)
+    DECAF_CATCH_RETHROW(IllegalArgumentException)
+    DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException)
+    DECAF_CATCHALL_THROW(IOException)
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::load( decaf::io::Reader* reader ) {
+void Properties::load(decaf::io::Reader* reader) {
 
-    try{
+    try {
 
-        if( reader == NULL ) {
+        if (reader == NULL) {
             throw NullPointerException(
-                __FILE__, __LINE__,
-                "The Reader instance passed was Null" );
+                __FILE__, __LINE__, "The Reader instance passed was Null");
         }
 
         throw UnsupportedOperationException(
-            __FILE__, __LINE__,
-            "Not yet Implemented." );
+            __FILE__, __LINE__, "Not yet Implemented.");
     }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCH_RETHROW( IllegalArgumentException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
-    DECAF_CATCHALL_THROW( IOException )
+    DECAF_CATCH_RETHROW(IOException)
+    DECAF_CATCH_RETHROW(IllegalArgumentException)
+    DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException)
+    DECAF_CATCHALL_THROW(IOException)
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::store( decaf::io::OutputStream* out, const std::string& comments DECAF_UNUSED ) {
+void Properties::store(decaf::io::OutputStream* out, const std::string& comments DECAF_UNUSED) {
 
-    try{
+    try {
 
-        if( out == NULL ) {
+        if (out == NULL) {
             throw NullPointerException(
-                __FILE__, __LINE__,
-                "The OutputStream instance passed was Null" );
+                __FILE__, __LINE__, "The OutputStream instance passed was Null");
         }
 
         std::ostringstream buffer;
         std::ostringstream writer;
 
-        if( comments != "" ) {
+        if (comments != "") {
             writer << "#";
             writer << comments;
             writer << std::endl;
@@ -545,49 +539,47 @@ void Properties::store( decaf::io::OutputStream* out, const std::string& comment
         writer << Date().toString();
         writer << std::endl;
 
-        Pointer< Iterator< MapEntry<std::string, std::string> > > entries(
+        Pointer<Iterator<MapEntry<std::string, std::string> > > entries(
                 this->internal->properties.entrySet().iterator());
         while (entries->hasNext()) {
             MapEntry<std::string, std::string> entry = entries->next();
 
-            dumpString( buffer, entry.getKey(), true );
+            dumpString(buffer, entry.getKey(), true);
             buffer << "=";
-            dumpString( buffer, entry.getValue(), false );
+            dumpString(buffer, entry.getValue(), false);
             buffer << std::endl;
 
             writer << buffer.str();
             buffer.str("");
         }
 
-        int length = (int)writer.str().length();
+        int length = (int) writer.str().length();
 
-        out->write( (const unsigned char*)writer.str().c_str(), length, 0, length );
+        out->write((const unsigned char*) writer.str().c_str(), length, 0, length);
         out->flush();
     }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
-    DECAF_CATCHALL_THROW( IOException )
+    DECAF_CATCH_RETHROW(IOException)
+    DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException)
+    DECAF_CATCHALL_THROW(IOException)
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Properties::store( decaf::io::Writer* writer, const std::string& comments DECAF_UNUSED ) {
+void Properties::store(decaf::io::Writer* writer, const std::string& comments DECAF_UNUSED) {
 
-    try{
+    try {
 
-        if( writer == NULL ) {
+        if (writer == NULL) {
             throw NullPointerException(
-                __FILE__, __LINE__,
-                "The Writer instance passed was Null" );
+                __FILE__, __LINE__, "The Writer instance passed was Null");
         }
 
         throw UnsupportedOperationException(
-            __FILE__, __LINE__,
-            "Not yet Implemented." );
+            __FILE__, __LINE__, "Not yet Implemented.");
     }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCH_RETHROW( NullPointerException )
-    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
-    DECAF_CATCHALL_THROW( IOException )
+    DECAF_CATCH_RETHROW(IOException)
+    DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_EXCEPTION_CONVERT(Exception, IOException)
+    DECAF_CATCHALL_THROW(IOException)
 }
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/main/decaf/util/Properties.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/Properties.h b/activemq-cpp/src/main/decaf/util/Properties.h
index 88b0afb..c24cc9c 100644
--- a/activemq-cpp/src/main/decaf/util/Properties.h
+++ b/activemq-cpp/src/main/decaf/util/Properties.h
@@ -50,7 +50,7 @@ namespace util{
      *
      * @since 1.0
      */
-    class DECAF_API Properties{
+    class DECAF_API Properties {
     private:
 
         PropertiesInternal* internal;
@@ -67,7 +67,7 @@ namespace util{
 
         Properties();
 
-        Properties( const Properties& src );
+        Properties(const Properties& src);
 
         virtual ~Properties();
 
@@ -79,7 +79,7 @@ namespace util{
          *
          * @return a reference to this List for use in chaining.
          */
-        Properties& operator= ( const Properties& src );
+        Properties& operator=(const Properties& src);
 
         /**
          * Returns true if the properties object is empty.
@@ -102,7 +102,7 @@ namespace util{
          * @return the value of the property with the given name, if it
          *         exists.  If it does not exist, returns NULL.
          */
-        const char* getProperty( const std::string& name ) const;
+        const char* getProperty(const std::string& name) const;
 
         /**
          * Looks up the value for the given property.
@@ -115,7 +115,7 @@ namespace util{
          * @return The value of the property specified by <code>name</code>, if it
          *         exists, otherwise the <code>defaultValue</code>.
          */
-        std::string getProperty( const std::string& name, const std::string& defaultValue ) const;
+        std::string getProperty(const std::string& name, const std::string& defaultValue) const;
 
         /**
          * Sets the value for a given property.  If the property already
@@ -128,7 +128,7 @@ namespace util{
          *
          * @returns the old value of the property or empty string if not set.
          */
-        std::string setProperty( const std::string& name, const std::string& value );
+        std::string setProperty(const std::string& name, const std::string& value);
 
         /**
          * Check to see if the Property exists in the set.
@@ -138,7 +138,7 @@ namespace util{
          *
          * @return true if property exists, false otherwise.
          */
-        bool hasProperty( const std::string& name ) const;
+        bool hasProperty(const std::string& name) const;
 
         /**
          * Removes the property with the given name.
@@ -148,7 +148,7 @@ namespace util{
          *
          * @returns the previous value of the property if set, or empty string.
          */
-        std::string remove( const std::string& name );
+        std::string remove(const std::string& name);
 
         /**
          * Returns an enumeration of all the keys in this property list, including distinct keys
@@ -166,16 +166,16 @@ namespace util{
          * @return list of pairs where the first is the name and the second
          *         is the value.
          */
-        std::vector< std::pair< std::string, std::string > > toArray() const;
+        std::vector<std::pair<std::string, std::string> > toArray() const;
 
         /**
          * Copies the contents of the given properties object to this one, if the
-         * given Properties instance in NULL then this List is not modified.
+         * given Properties instance in empty then this List is not modified.
          *
          * @param source
          *      The source properties object.
          */
-        void copy( const Properties& source );
+        void copy(const Properties& source);
 
         /**
          * Clones this object.
@@ -201,7 +201,7 @@ namespace util{
          *
          * @return true if the contents of the two Properties objects are the same.
          */
-        bool equals( const Properties& source ) const;
+        bool equals(const Properties& source) const;
 
         /**
          * Formats the contents of the Properties Object into a string that can be logged, etc.
@@ -224,7 +224,7 @@ namespace util{
          * @throw IllegalArgumentException if malformed data is found while reading the properties.
          * @throw NullPointerException if the passed stream is Null.
          */
-        void load( decaf::io::InputStream* stream );
+        void load(decaf::io::InputStream* stream);
 
         /**
          * Reads a property list (key and element pairs) from the input character stream in a
@@ -325,7 +325,7 @@ namespace util{
          * @throw IllegalArgumentException if malformed data is found while reading the properties.
          * @throw NullPointerException if the passed stream is Null.
          */
-        void load( decaf::io::Reader* reader );
+        void load(decaf::io::Reader* reader);
 
         /**
          * Writes this property list (key and element pairs) in this Properties table to the
@@ -355,7 +355,7 @@ namespace util{
          * @throw IOException if there is an error while writing from the stream.
          * @throw NullPointerException if the passed stream is Null.
          */
-        void store( decaf::io::OutputStream* out, const std::string& comment );
+        void store(decaf::io::OutputStream* out, const std::string& comment);
 
         /**
          * Writes this property list (key and element pairs) in this Properties table to the output
@@ -393,11 +393,11 @@ namespace util{
          * @throw IOException if there is an error while writing from the stream.
          * @throw NullPointerException if the passed stream is Null.
          */
-        void store( decaf::io::Writer* writer, const std::string& comments );
+        void store(decaf::io::Writer* writer, const std::string& comments);
 
     private:
 
-        void selectProperties( decaf::util::StlMap<std::string, std::string>& selectProperties ) const;
+        void selectProperties(decaf::util::StlMap<std::string, std::string>& selectProperties) const;
 
     };
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/Makefile.am
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/Makefile.am b/activemq-cpp/src/test/Makefile.am
index 12d9f21..aba643f 100644
--- a/activemq-cpp/src/test/Makefile.am
+++ b/activemq-cpp/src/test/Makefile.am
@@ -55,6 +55,8 @@ cc_sources = \
     activemq/transport/IOTransportTest.cpp \
     activemq/transport/TransportRegistryTest.cpp \
     activemq/transport/correlator/ResponseCorrelatorTest.cpp \
+    activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp \
+    activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp \
     activemq/transport/failover/FailoverTransportTest.cpp \
     activemq/transport/inactivity/InactivityMonitorTest.cpp \
     activemq/transport/mock/MockTransportFactoryTest.cpp \
@@ -305,6 +307,8 @@ h_sources = \
     activemq/transport/IOTransportTest.h \
     activemq/transport/TransportRegistryTest.h \
     activemq/transport/correlator/ResponseCorrelatorTest.h \
+    activemq/transport/discovery/DiscoveryAgentRegistryTest.h \
+    activemq/transport/discovery/DiscoveryTransportFactoryTest.h \
     activemq/transport/failover/FailoverTransportTest.h \
     activemq/transport/inactivity/InactivityMonitorTest.h \
     activemq/transport/mock/MockTransportFactoryTest.h \

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp
new file mode 100644
index 0000000..4e3190b
--- /dev/null
+++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.cpp
@@ -0,0 +1,87 @@
+/*
+ * 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 "DiscoveryAgentRegistryTest.h"
+
+#include <activemq/transport/discovery/DiscoveryAgent.h>
+#include <activemq/transport/discovery/DiscoveryAgentFactory.h>
+#include <activemq/transport/discovery/DiscoveryAgentRegistry.h>
+
+#include <decaf/net/URI.h>
+
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::transport::discovery;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::net;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class MockDiscoveryAgent : public DiscoveryAgent {
+    public:
+
+        virtual void start() {}
+        virtual void stop() {}
+        virtual void setDiscoveryListener(DiscoveryListener* listener) {}
+        virtual void registerService(const std::string& name) {}
+        virtual void serviceFailed(const activemq::commands::DiscoveryEvent& event) {}
+    };
+
+    class MockDiscoveryAgentFactory : public DiscoveryAgentFactory {
+    public:
+
+        virtual ~MockDiscoveryAgentFactory() {}
+
+        virtual decaf::lang::Pointer<DiscoveryAgent> createAgent(const decaf::net::URI& agentURI) {
+            return Pointer<DiscoveryAgent>(new MockDiscoveryAgent);
+        }
+
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DiscoveryAgentRegistryTest::DiscoveryAgentRegistryTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DiscoveryAgentRegistryTest::~DiscoveryAgentRegistryTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DiscoveryAgentRegistryTest::test() {
+
+    DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance();
+    registry.registerFactory("mock", new MockDiscoveryAgentFactory);
+
+    CPPUNIT_ASSERT_EQUAL(1, (int) registry.getAgentNames().size());
+
+    DiscoveryAgentFactory* factory = registry.findFactory("mock");
+    CPPUNIT_ASSERT(factory != NULL);
+
+    Pointer<DiscoveryAgent> agent(factory->createAgent(URI("mock://default")));
+    CPPUNIT_ASSERT(agent != NULL);
+
+    Pointer<MockDiscoveryAgent> mock = agent.dynamicCast<MockDiscoveryAgent>();
+    CPPUNIT_ASSERT(mock != NULL);
+
+    registry.unregisterAllFactories();
+}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h
new file mode 100644
index 0000000..761aec1
--- /dev/null
+++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryAgentRegistryTest.h
@@ -0,0 +1,45 @@
+/*
+ * 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 _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_
+#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace transport {
+namespace discovery {
+
+    class DiscoveryAgentRegistryTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( DiscoveryAgentRegistryTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        DiscoveryAgentRegistryTest();
+        virtual ~DiscoveryAgentRegistryTest();
+
+        void test();
+
+    };
+
+}}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYAGENTREGISTRYTEST_H_ */

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp
new file mode 100644
index 0000000..18405b2
--- /dev/null
+++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.cpp
@@ -0,0 +1,113 @@
+/*
+ * 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 "DiscoveryTransportFactoryTest.h"
+
+#include <activemq/transport/discovery/DiscoveryAgent.h>
+#include <activemq/transport/discovery/DiscoveryAgentFactory.h>
+#include <activemq/transport/discovery/DiscoveryAgentRegistry.h>
+#include <activemq/transport/discovery/DiscoveryTransportFactory.h>
+#include <activemq/transport/discovery/DiscoveryTransport.h>
+
+#include <decaf/net/URI.h>
+
+using namespace activemq;
+using namespace activemq::transport;
+using namespace activemq::transport::discovery;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::net;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class MockDiscoveryAgent : public DiscoveryAgent {
+    public:
+
+        virtual ~MockDiscoveryAgent() {}
+
+        virtual void start() {}
+        virtual void stop() {}
+        virtual void setDiscoveryListener(DiscoveryListener* listener) {}
+        virtual void registerService(const std::string& name) {}
+        virtual void serviceFailed(const activemq::commands::DiscoveryEvent& event) {}
+    };
+
+    class MockDiscoveryAgentFactory : public DiscoveryAgentFactory {
+    public:
+
+        virtual ~MockDiscoveryAgentFactory() {}
+
+        virtual decaf::lang::Pointer<DiscoveryAgent> createAgent(const decaf::net::URI& agentURI) {
+            return Pointer<DiscoveryAgent>(new MockDiscoveryAgent);
+        }
+
+    };
+
+    class MyTransportListener : public TransportListener {
+    public:
+
+        MyTransportListener() {}
+
+        virtual ~MyTransportListener() {}
+
+        virtual void onCommand(const Pointer<Command> command) {
+        }
+
+        virtual void onException(const decaf::lang::Exception& ex) {
+        }
+
+        virtual void transportInterrupted() {
+        }
+
+        virtual void transportResumed() {
+        }
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DiscoveryTransportFactoryTest::DiscoveryTransportFactoryTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DiscoveryTransportFactoryTest::~DiscoveryTransportFactoryTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DiscoveryTransportFactoryTest::setUp() {
+
+    DiscoveryAgentRegistry& registry = DiscoveryAgentRegistry::getInstance();
+    registry.registerFactory("mock", new MockDiscoveryAgentFactory);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DiscoveryTransportFactoryTest::test() {
+
+    DiscoveryTransportFactory factory;
+
+    Pointer<Transport> transport = factory.create(URI("discovery:mock://default"));
+    CPPUNIT_ASSERT(transport != NULL);
+
+    MyTransportListener listener;
+
+    transport->setTransportListener(&listener);
+    transport->start();
+    transport->close();
+}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h
new file mode 100644
index 0000000..093dac0
--- /dev/null
+++ b/activemq-cpp/src/test/activemq/transport/discovery/DiscoveryTransportFactoryTest.h
@@ -0,0 +1,47 @@
+/*
+ * 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 _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_
+#define _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace transport {
+namespace discovery {
+
+    class DiscoveryTransportFactoryTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( DiscoveryTransportFactoryTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        DiscoveryTransportFactoryTest();
+        virtual ~DiscoveryTransportFactoryTest();
+
+        void test();
+
+        virtual void setUp();
+
+    };
+
+}}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_DISCOVERY_DISCOVERYTRANSPORTFACTORYTEST_H_ */

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/util/URISupportTest.cpp b/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
index cf673d3..5ed8d1a 100644
--- a/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
+++ b/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
@@ -29,6 +29,15 @@ using namespace activemq;
 using namespace activemq::util;
 
 ////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    void verifyParams(const Properties& parameters) {
+        CPPUNIT_ASSERT(parameters.getProperty("proxyHost", "") == "localhost");
+        CPPUNIT_ASSERT(parameters.getProperty("proxyPort", "") == "80");
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void URISupportTest::test() {
 
     string test = "?option1=test1&option2=test2";
@@ -208,5 +217,39 @@ void URISupportTest::testParseComposite() {
     CPPUNIT_ASSERT( data.getComponents().get(1).toString() == "part2://host" );
     CPPUNIT_ASSERT( data.getComponents().get(2).toString() == "part3://host" );
     CPPUNIT_ASSERT( data.getComponents().get(3).toString() == "part4://host?option=value" );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void URISupportTest::testCreateWithQuery() {
+
+    URI source("vm://localhost");
+    URI dest = URISupport::createURIWithQuery(source, "network=true&one=two");
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("correct param count", 2, URISupport::parseParameters(dest).size());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("same uri, host", source.getHost(), dest.getHost());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("same uri, scheme", source.getScheme(), dest.getScheme());
+    CPPUNIT_ASSERT_MESSAGE("same uri, ssp", dest.getQuery() != source.getQuery());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void URISupportTest::testApplyParameters() {
+
+    URI uri("http://0.0.0.0:61616");
+    Properties parameters;
+    parameters.setProperty("t.proxyHost", "localhost");
+    parameters.setProperty("t.proxyPort", "80");
+
+    uri = URISupport::applyParameters(uri, parameters);
+    Properties appliedParameters = URISupport::parseParameters(uri);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("all params applied with no prefix", 2, appliedParameters.size());
+
+    // strip off params again
+    uri = URISupport::createURIWithQuery(uri, "");
+
+    uri = URISupport::applyParameters(uri, parameters, "joe");
+    appliedParameters = URISupport::parseParameters(uri);
+    CPPUNIT_ASSERT_MESSAGE("no params applied as none match joe", appliedParameters.isEmpty());
 
+    uri = URISupport::applyParameters(uri, parameters, "t.");
+    verifyParams(URISupport::parseParameters(uri));
 }

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/activemq/util/URISupportTest.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/activemq/util/URISupportTest.h b/activemq-cpp/src/test/activemq/util/URISupportTest.h
index f2a998b..123f5a3 100644
--- a/activemq-cpp/src/test/activemq/util/URISupportTest.h
+++ b/activemq-cpp/src/test/activemq/util/URISupportTest.h
@@ -30,6 +30,8 @@ namespace util{
        CPPUNIT_TEST( test );
        CPPUNIT_TEST( testURIParseEnv );
        CPPUNIT_TEST( testParseComposite );
+       CPPUNIT_TEST( testApplyParameters );
+       CPPUNIT_TEST( testCreateWithQuery );
        CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -40,6 +42,8 @@ namespace util{
         void test();
         void testURIParseEnv();
         void testParseComposite();
+        void testApplyParameters();
+        void testCreateWithQuery();
 
     };
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ba624ea9/activemq-cpp/src/test/testRegistry.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/testRegistry.cpp b/activemq-cpp/src/test/testRegistry.cpp
index e9ca662..f33e8ce 100644
--- a/activemq-cpp/src/test/testRegistry.cpp
+++ b/activemq-cpp/src/test/testRegistry.cpp
@@ -121,6 +121,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::mock::MockTransportFactory
 #include <activemq/transport/inactivity/InactivityMonitorTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::inactivity::InactivityMonitorTest );
 
+#include <activemq/transport/discovery/DiscoveryAgentRegistryTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::DiscoveryAgentRegistryTest );
+#include <activemq/transport/discovery/DiscoveryTransportFactoryTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::discovery::DiscoveryTransportFactoryTest );
+
 #include <activemq/transport/TransportRegistryTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportRegistryTest );
 #include <activemq/transport/IOTransportTest.h>


Mime
View raw message