activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r499451 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test: Makefile.am activemq/util/StringTokenizerTest.cpp activemq/util/StringTokenizerTest.h activemq/util/URISupportTest.cpp activemq/util/URISupportTest.h
Date Wed, 24 Jan 2007 15:58:00 GMT
Author: tabish
Date: Wed Jan 24 07:57:59 2007
New Revision: 499451

URL: http://svn.apache.org/viewvc?view=rev&rev=499451
Log:
http://issues.apache.org/activemq/browse/AMQCPP-30

Added:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
  (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h
  (with props)
Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?view=diff&rev=499451&r1=499450&r2=499451
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Wed Jan 24 07:57:59
2007
@@ -74,6 +74,7 @@
   activemq/util/PrimitiveMapTest.cpp \
   activemq/util/QueueTest.cpp \
   activemq/util/StringTokenizerTest.cpp \
+  activemq/util/URISupportTest.cpp \
   main.cpp
 
 ## Compile this as part of make check

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp?view=diff&rev=499451&r1=499450&r2=499451
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.cpp
Wed Jan 24 07:57:59 2007
@@ -18,3 +18,83 @@
 #include "StringTokenizerTest.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::StringTokenizerTest );
+
+#include <activemq/util/StringTokenizer.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void StringTokenizerTest::test()
+{
+    StringTokenizer tokenizer("stomp://127.0.0.1:23232", "://");
+    CPPUNIT_ASSERT( tokenizer.countTokens() == 3 );
+    CPPUNIT_ASSERT( tokenizer.nextToken() == "stomp" );
+    CPPUNIT_ASSERT( tokenizer.nextToken() == "127.0.0.1" );
+    CPPUNIT_ASSERT( tokenizer.nextToken() == "23232" );
+   
+    StringTokenizer tokenizer1("::://stomp://127.0.0.1:23232:", ":/");
+    CPPUNIT_ASSERT( tokenizer1.countTokens() == 3 );
+    CPPUNIT_ASSERT( tokenizer1.nextToken() == "stomp" );
+    CPPUNIT_ASSERT( tokenizer1.nextToken() == "127.0.0.1" );
+    CPPUNIT_ASSERT( tokenizer1.nextToken() == "23232" );
+   
+    StringTokenizer tokenizer2("test");
+    CPPUNIT_ASSERT( tokenizer2.countTokens() == 1 );
+    CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == true );
+    CPPUNIT_ASSERT( tokenizer2.nextToken() == "test" );
+    CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == false );
+    
+    StringTokenizer tokenizer3(":", ":");
+    CPPUNIT_ASSERT( tokenizer3.countTokens() == 0 );
+    CPPUNIT_ASSERT( tokenizer3.hasMoreTokens() == false );
+    CPPUNIT_ASSERT( tokenizer3.nextToken(" ") == ":" );
+    
+    try
+    {
+       tokenizer3.nextToken();
+       CPPUNIT_ASSERT( false );
+    }
+    catch(exceptions::NoSuchElementException ex)
+    {
+       CPPUNIT_ASSERT( true );
+    }
+    
+    StringTokenizer tokenizer4("the quick brown fox");
+    CPPUNIT_ASSERT( tokenizer4.countTokens() == 4 );
+    CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == true );
+    CPPUNIT_ASSERT( tokenizer4.nextToken() == "the" );
+    CPPUNIT_ASSERT( tokenizer4.nextToken() == "quick" );
+    CPPUNIT_ASSERT( tokenizer4.nextToken() == "brown" );
+    CPPUNIT_ASSERT( tokenizer4.nextToken() == "fox" );
+    CPPUNIT_ASSERT( tokenizer4.countTokens() == 0 );
+    CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == false );
+    
+    StringTokenizer tokenizer5("the:quick:brown:fox", ":", true);
+    CPPUNIT_ASSERT( tokenizer5.countTokens() == 7 );
+    CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == true );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == "the" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == "quick" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == "brown" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
+    CPPUNIT_ASSERT( tokenizer5.nextToken() == "fox" );
+    CPPUNIT_ASSERT( tokenizer5.countTokens() == 0 );
+    CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == false );
+    
+    std::vector<std::string> myArray;
+    StringTokenizer tokenizer6("the:quick:brown:fox", ":");
+    CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+    CPPUNIT_ASSERT( tokenizer6.toArray(myArray) == 4 );
+    CPPUNIT_ASSERT( tokenizer6.countTokens() == 0 );
+    tokenizer6.reset();
+    CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+    tokenizer6.reset("the:quick:brown:fox", "$");
+    CPPUNIT_ASSERT( tokenizer6.countTokens() == 1 );
+    tokenizer6.reset("this$is$a$test");
+    CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
+    tokenizer6.reset("this$is$a$test", "$", true);
+        CPPUNIT_ASSERT( tokenizer6.countTokens() == 7 );
+}

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h?view=diff&rev=499451&r1=499450&r2=499451
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/StringTokenizerTest.h
Wed Jan 24 07:57:59 2007
@@ -21,94 +21,20 @@
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
-#include <activemq/util/StringTokenizer.h>
-
 namespace activemq{
 namespace util{
 
    class StringTokenizerTest : public CppUnit::TestFixture 
    {
-     CPPUNIT_TEST_SUITE( StringTokenizerTest );
-     CPPUNIT_TEST( test );
-     CPPUNIT_TEST_SUITE_END();
+       CPPUNIT_TEST_SUITE( StringTokenizerTest );
+       CPPUNIT_TEST( test );
+       CPPUNIT_TEST_SUITE_END();
    public:
 
-   	virtual ~StringTokenizerTest() {}
-
-      void test()
-      {
-         StringTokenizer tokenizer("stomp://127.0.0.1:23232", "://");
-         CPPUNIT_ASSERT( tokenizer.countTokens() == 3 );
-         CPPUNIT_ASSERT( tokenizer.nextToken() == "stomp" );
-         CPPUNIT_ASSERT( tokenizer.nextToken() == "127.0.0.1" );
-         CPPUNIT_ASSERT( tokenizer.nextToken() == "23232" );
-
-         StringTokenizer tokenizer1("::://stomp://127.0.0.1:23232:", ":/");
-         CPPUNIT_ASSERT( tokenizer1.countTokens() == 3 );
-         CPPUNIT_ASSERT( tokenizer1.nextToken() == "stomp" );
-         CPPUNIT_ASSERT( tokenizer1.nextToken() == "127.0.0.1" );
-         CPPUNIT_ASSERT( tokenizer1.nextToken() == "23232" );
-
-         StringTokenizer tokenizer2("test");
-         CPPUNIT_ASSERT( tokenizer2.countTokens() == 1 );
-         CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == true );
-         CPPUNIT_ASSERT( tokenizer2.nextToken() == "test" );
-         CPPUNIT_ASSERT( tokenizer2.hasMoreTokens() == false );
-
-         StringTokenizer tokenizer3(":", ":");
-         CPPUNIT_ASSERT( tokenizer3.countTokens() == 0 );
-         CPPUNIT_ASSERT( tokenizer3.hasMoreTokens() == false );
-         CPPUNIT_ASSERT( tokenizer3.nextToken(" ") == ":" );
-
-         try
-         {
-            tokenizer3.nextToken();
-
-            CPPUNIT_ASSERT( false );
-         }
-         catch(exceptions::NoSuchElementException ex)
-         {
-            CPPUNIT_ASSERT( true );
-         }
-
-         StringTokenizer tokenizer4("the quick brown fox");
-         CPPUNIT_ASSERT( tokenizer4.countTokens() == 4 );
-         CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == true );
-         CPPUNIT_ASSERT( tokenizer4.nextToken() == "the" );
-         CPPUNIT_ASSERT( tokenizer4.nextToken() == "quick" );
-         CPPUNIT_ASSERT( tokenizer4.nextToken() == "brown" );
-         CPPUNIT_ASSERT( tokenizer4.nextToken() == "fox" );
-         CPPUNIT_ASSERT( tokenizer4.countTokens() == 0 );
-         CPPUNIT_ASSERT( tokenizer4.hasMoreTokens() == false );
-
-         StringTokenizer tokenizer5("the:quick:brown:fox", ":", true);
-         CPPUNIT_ASSERT( tokenizer5.countTokens() == 7 );
-         CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == true );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == "the" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == "quick" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == "brown" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == ":" );
-         CPPUNIT_ASSERT( tokenizer5.nextToken() == "fox" );
-         CPPUNIT_ASSERT( tokenizer5.countTokens() == 0 );
-         CPPUNIT_ASSERT( tokenizer5.hasMoreTokens() == false );
-
-         std::vector<std::string> myArray;
-         StringTokenizer tokenizer6("the:quick:brown:fox", ":");
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
-         CPPUNIT_ASSERT( tokenizer6.toArray(myArray) == 4 );
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 0 );
-         tokenizer6.reset();
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
-         tokenizer6.reset("the:quick:brown:fox", "$");
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 1 );
-         tokenizer6.reset("this$is$a$test");
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 4 );
-         tokenizer6.reset("this$is$a$test", "$", true);
-         CPPUNIT_ASSERT( tokenizer6.countTokens() == 7 );
+        virtual ~StringTokenizerTest() {}
 
-      }
+        void test();
+        
    };
 
 }}

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp?view=auto&rev=499451
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
(added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
Wed Jan 24 07:57:59 2007
@@ -0,0 +1,67 @@
+/*
+ * 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 "URISupportTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::URISupportTest );
+
+#include <activemq/util/URISupport.h>
+#include <activemq/util/SimpleProperties.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void URISupportTest::test()
+{
+    string test = "?option1=test1&option2=test2";
+    
+    SimpleProperties map = URISupport::parseQuery( test );
+
+    CPPUNIT_ASSERT( map.hasProperty( "option1" ) == true );
+    CPPUNIT_ASSERT( map.hasProperty( "option2" ) == true );
+    
+    CPPUNIT_ASSERT( map.getProperty( "option1", "" ) == "test1" );
+    CPPUNIT_ASSERT( map.getProperty( "option2", "" ) == "test2" );
+    
+    string test2 = "option&option";
+
+    try{
+        map = URISupport::parseQuery( test2 );
+        CPPUNIT_ASSERT( false );
+    } catch(...) {}
+
+    string test3 = "option1=test1&option2=test2";
+    
+    map = URISupport::parseQuery( test3 );
+
+    CPPUNIT_ASSERT( map.hasProperty( "option1" ) == true );
+    CPPUNIT_ASSERT( map.hasProperty( "option2" ) == true );
+    
+    CPPUNIT_ASSERT( map.getProperty( "option1", "" ) == "test1" );
+    CPPUNIT_ASSERT( map.getProperty( "option2", "" ) == "test2" );
+
+    string test4 = "http://cause.exception.com?option1=test1&option2=test2";
+
+    try{
+        map = URISupport::parseQuery( test4 );
+    } catch(...) {
+        CPPUNIT_ASSERT( false );
+    }
+}
+

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h?view=auto&rev=499451
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h
(added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h
Wed Jan 24 07:57:59 2007
@@ -0,0 +1,44 @@
+/*
+ * 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_UTIL_URISUPPORTTEST_H_
+#define _ACTIVEMQ_UTIL_URISUPPORTTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq{
+namespace util{
+    
+    class URISupportTest : public CppUnit::TestFixture { 
+
+       CPPUNIT_TEST_SUITE( URISupportTest );
+       CPPUNIT_TEST( test );
+       CPPUNIT_TEST_SUITE_END();
+
+    public:
+    
+        URISupportTest() {}
+        virtual ~URISupportTest() {}
+        
+        void test();
+        
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_URISUPPORTTEST_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/URISupportTest.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message