activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r767619 - in /activemq/activemq-cpp/branches/activemq-cpp-2.x/src: test-integration/ test-integration/util/ test-integration/util/teamcity/ test/ test/util/ test/util/teamcity/
Date Wed, 22 Apr 2009 18:57:54 GMT
Author: tabish
Date: Wed Apr 22 18:57:53 2009
New Revision: 767619

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

Added:
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
  (with props)
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h
  (with props)
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp
  (with props)
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h
  (with props)
Modified:
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/Makefile.am
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/main.cpp
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/Makefile.am
    activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/main.cpp

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/Makefile.am?rev=767619&r1=767618&r2=767619&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/Makefile.am (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/Makefile.am Wed Apr
22 18:57:53 2009
@@ -48,6 +48,7 @@
   activemq/test/openwire/OpenwireSlowListenerTest.cpp \
   activemq/test/openwire/OpenwireJmsMessageGroupsTest.cpp \
   TestRegistry.cpp \
+  util/teamcity/TeamCityProgressListener.cpp \
   main.cpp
 
 ## Compile this as part of make check

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/main.cpp?rev=767619&r1=767618&r2=767619&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/main.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/main.cpp Wed Apr
22 18:57:53 2009
@@ -17,31 +17,74 @@
 
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/TestListener.h>
 #include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/Outputter.h>
+#include <cppunit/XmlOutputter.h>
 #include <cppunit/TestResult.h>
+#include <util/teamcity/TeamCityProgressListener.h>
 #include <activemq/util/Config.h>
+#include <decaf/lang/Runtime.h>
+#include <decaf/lang/Integer.h>
 #include <iostream>
+#include <memory>
+
+int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED ) {
+
+    bool wasSuccessful = false;
+    std::ofstream outputFile;
+    bool useXMLOutputter = false;
+    std::auto_ptr<CppUnit::TestListener> listener( new CppUnit::BriefTestProgressListener
);
+
+    if( argc > 1 ) {
+        for( int i = 1; i < argc; ++i ) {
+            const std::string arg( argv[i] );
+            if( arg == "-teamcity" ) {
+                listener.reset( new test::util::teamcity::TeamCityProgressListener() );
+            } else if( arg == "-quiet" ) {
+                listener.reset( NULL );
+            } else if( arg == "-xml" ) {
+                if( ( i + 1 ) >= argc ) {
+                    std::cout << "-xml requires a filename to be specified" <<
std::endl;
+                    return -1;
+                }
+
+                std::ofstream outputFile( argv[++i] );
+                useXMLOutputter = true;
+            }
+        }
+    }
+
+    try {
 
-int main( int argc AMQCPP_UNUSED, char **argv AMQCPP_UNUSED)
-{
-    try
-    {
         CppUnit::TextUi::TestRunner runner;
         CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
         runner.addTest( registry.makeTest() );
-    
+
         // Shows a message as each test starts
-        CppUnit::BriefTestProgressListener listener;
-        runner.eventManager().addListener( &listener );
-        
+        if( listener.get() != NULL ) {
+            runner.eventManager().addListener( listener.get() );
+        }
+
+        // Specify XML output and inform the test runner of this format.  The TestRunner
+        // will delete the passed XmlOutputter for us.
+        if( useXMLOutputter ) {
+            runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(), outputFile
) );
+        }
+
         bool wasSuccessful = runner.run( "", false );
+
+        if( useXMLOutputter ) {
+            outputFile.close();
+        }
+
         return !wasSuccessful;
     }
     catch(...) {
         std::cout << "----------------------------------------" << std::endl;
         std::cout << "- AN ERROR HAS OCCURED:                -" << std::endl;
         std::cout << "- Do you have a Broker Running?        -" << std::endl;
-        std::cout << "----------------------------------------" << std::endl;
       
+        std::cout << "----------------------------------------" << std::endl;
     }
 }
 

Added: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp?rev=767619&view=auto
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
(added)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
Wed Apr 22 18:57:53 2009
@@ -0,0 +1,136 @@
+/*
+ * 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 <iostream>
+#include <sstream>
+#include "cppunit/Test.h"
+#include "cppunit/Exception.h"
+
+#include <util/teamcity/TeamCityProgressListener.h>
+
+using namespace CPPUNIT_NS;
+using namespace std;
+using namespace test;
+using namespace test::util;
+using namespace test::util::teamcity;
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::startTest( Test* test ) {
+    writeOpen( "testStarted" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static string sourceLine2string( const SourceLine& sline ) {
+
+    std::stringstream ss;
+    ss << sline.fileName() << ":" << sline.lineNumber();
+    return ss.str();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::addFailure( const TestFailure& failure ) {
+
+    const Exception *e = failure.thrownException();
+
+    string details = e->message().details();
+
+    if( e->sourceLine().isValid() ) {
+        details.append( " at " );
+        details.append( sourceLine2string( e->sourceLine() ) );
+        details.append( "\n" );
+    }
+
+    writeOpen( "testFailed" );
+    writeProperty( "name", failure.failedTest()->getName() );
+    writeProperty( "message", e->message().shortDescription() );
+    writeProperty( "details", details );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::endTest( Test* test ) {
+    writeOpen( "testFinished" );
+    writeProperty("name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::startSuite( Test* test ) {
+    writeOpen( "testSuiteStarted" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::endSuite( Test* test ) {
+    writeOpen( "testSuiteFinished" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string TeamCityProgressListener::escape( const std::string& value ) const {
+
+    std::string result;
+
+    for( std::size_t i = 0; i < value.length(); i++ ) {
+
+        char c = value[i];
+
+        switch(c) {
+            case '\n':
+                result.append( "|n" );
+                break;
+            case '\r':
+                result.append( "|r" );
+                break;
+            case '\'':
+                result.append( "|'" );
+                break;
+            case '|':
+                result.append( "||" );
+                break;
+            case ']':
+                result.append( "|]" );
+                break;
+            default:
+                result.append( &c, 1 );
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeOpen( const std::string& name ) {
+    std::cout << std::endl << "##teamcity[" << name;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeClose() {
+    std::cout << "]" << std::endl;
+    std::cout.flush();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeProperty( const std::string& name,
+                                              const std::string& value ) {
+
+    std::cout << " " << name << "='" << escape( value ) <<
"'";
+}

Propchange: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h?rev=767619&view=auto
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h
(added)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h
Wed Apr 22 18:57:53 2009
@@ -0,0 +1,72 @@
+/*
+ * 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 _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_
+#define _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_
+
+#include <cppunit/TestFailure.h>
+#include <cppunit/TestListener.h>
+
+#include <string>
+
+namespace test {
+namespace util {
+namespace teamcity {
+
+    /**
+     * CPPUnit Derived Test Listener that can output the test life cycle messages in
+     * a manner that can be processed by the TeamCity Continuous integration tool.
+     */
+    class TeamCityProgressListener: public CPPUNIT_NS::TestListener {
+    public:
+
+        TeamCityProgressListener() {}
+        ~TeamCityProgressListener() {}
+
+        void startTest( CPPUNIT_NS::Test *test );
+        void addFailure( const CPPUNIT_NS::TestFailure &failure );
+        void endTest( CPPUNIT_NS::Test *test );
+        void startSuite( CPPUNIT_NS::Test *test );
+        void endSuite( CPPUNIT_NS::Test *test );
+
+    private:
+
+        // Prevents the use of the copy constructor.
+        TeamCityProgressListener( const TeamCityProgressListener& );
+
+        // Prevents the use of the copy operator.
+        void operator =( const TeamCityProgressListener& );
+
+    protected:
+
+        /**
+         * Escapes the control characters in a string.
+         *
+         * @param value - String to escape
+         * @return the new escaped string.
+         */
+        virtual std::string escape( const std::string& value ) const;
+
+        virtual void writeOpen( const std::string& name );
+        virtual void writeProperty( const std::string& name, const std::string& value
);
+        virtual void writeClose();
+
+    };
+
+}}}
+
+#endif /* _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_ */

Propchange: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test-integration/util/teamcity/TeamCityProgressListener.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/Makefile.am?rev=767619&r1=767618&r2=767619&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/Makefile.am Wed Apr 22 18:57:53
2009
@@ -132,6 +132,7 @@
   decaf/util/concurrent/atomic/AtomicIntegerTest.cpp \
   decaf/nio/BufferTest.cpp \
   testRegistry.cpp \
+  util/teamcity/TeamCityProgressListener.cpp \
   main.cpp
 
 h_sources = \

Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/main.cpp?rev=767619&r1=767618&r2=767619&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/main.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/main.cpp Wed Apr 22 18:57:53
2009
@@ -17,40 +17,80 @@
 
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/TestListener.h>
 #include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/Outputter.h>
+#include <cppunit/XmlOutputter.h>
 #include <cppunit/TestResult.h>
+#include <util/teamcity/TeamCityProgressListener.h>
 #include <activemq/util/Config.h>
 #include <decaf/lang/Runtime.h>
 #include <decaf/lang/Integer.h>
 #include <iostream>
+#include <memory>
 
 int main( int argc, char **argv ) {
 
-    // ensure that we start the runtime.
-    decaf::lang::Runtime::getRuntime();
     bool wasSuccessful = false;
     int iterations = 1;
+    std::ofstream outputFile;
+    bool useXMLOutputter = false;
+    std::auto_ptr<CppUnit::TestListener> listener( new CppUnit::BriefTestProgressListener
);
 
     if( argc > 1 ) {
-        try {
-            iterations = decaf::lang::Integer::parseInt( argv[1] );
-        } catch( decaf::lang::exceptions::NumberFormatException& ex ) {
-            iterations = 1;
+        for( int i = 1; i < argc; ++i ) {
+            const std::string arg( argv[i] );
+            if( arg == "-runs" ) {
+                if( ( i + 1 ) >= argc ) {
+                    std::cout << "-runs requires a value for the iteration count" <<
std::endl;
+                    return -1;
+                }
+                try {
+                    iterations = decaf::lang::Integer::parseInt( argv[++i] );
+                } catch( decaf::lang::exceptions::NumberFormatException& ex ) {
+                    std::cout << "Invalid iteration count specified on command line:
"
+                              << argv[i] << std::endl;
+                    return -1;
+                }
+            } else if( arg == "-teamcity" ) {
+                listener.reset( new test::util::teamcity::TeamCityProgressListener() );
+            } else if( arg == "-quiet" ) {
+                listener.reset( NULL );
+            } else if( arg == "-xml" ) {
+                if( ( i + 1 ) >= argc ) {
+                    std::cout << "-xml requires a filename to be specified" <<
std::endl;
+                    return -1;
+                }
+
+                std::ofstream outputFile( argv[++i] );
+                useXMLOutputter = true;
+            }
         }
     }
 
     for( int i = 0; i < iterations; ++i ) {
+
         CppUnit::TextUi::TestRunner runner;
         CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
         runner.addTest( registry.makeTest() );
 
         // Shows a message as each test starts
-        CppUnit::BriefTestProgressListener listener;
-        runner.eventManager().addListener( &listener );
+        if( listener.get() != NULL ) {
+            runner.eventManager().addListener( listener.get() );
+        }
+
+        // Specify XML output and inform the test runner of this format.  The TestRunner
+        // will delete the passed XmlOutputter for us.
+        if( useXMLOutputter ) {
+            runner.setOutputter( new CppUnit::XmlOutputter( &runner.result(), outputFile
) );
+        }
 
         wasSuccessful = runner.run( "", false );
+
+        if( useXMLOutputter ) {
+            outputFile.close();
+        }
     }
 
     return !wasSuccessful;
 }
-

Added: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp?rev=767619&view=auto
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp
(added)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp
Wed Apr 22 18:57:53 2009
@@ -0,0 +1,136 @@
+/*
+ * 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 <iostream>
+#include <sstream>
+#include "cppunit/Test.h"
+#include "cppunit/Exception.h"
+
+#include <util/teamcity/TeamCityProgressListener.h>
+
+using namespace CPPUNIT_NS;
+using namespace std;
+using namespace test;
+using namespace test::util;
+using namespace test::util::teamcity;
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::startTest( Test* test ) {
+    writeOpen( "testStarted" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+static string sourceLine2string( const SourceLine& sline ) {
+
+    std::stringstream ss;
+    ss << sline.fileName() << ":" << sline.lineNumber();
+    return ss.str();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::addFailure( const TestFailure& failure ) {
+
+    const Exception *e = failure.thrownException();
+
+    string details = e->message().details();
+
+    if( e->sourceLine().isValid() ) {
+        details.append( " at " );
+        details.append( sourceLine2string( e->sourceLine() ) );
+        details.append( "\n" );
+    }
+
+    writeOpen( "testFailed" );
+    writeProperty( "name", failure.failedTest()->getName() );
+    writeProperty( "message", e->message().shortDescription() );
+    writeProperty( "details", details );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::endTest( Test* test ) {
+    writeOpen( "testFinished" );
+    writeProperty("name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::startSuite( Test* test ) {
+    writeOpen( "testSuiteStarted" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::endSuite( Test* test ) {
+    writeOpen( "testSuiteFinished" );
+    writeProperty( "name", test->getName() );
+    writeClose();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string TeamCityProgressListener::escape( const std::string& value ) const {
+
+    std::string result;
+
+    for( std::size_t i = 0; i < value.length(); i++ ) {
+
+        char c = value[i];
+
+        switch(c) {
+            case '\n':
+                result.append( "|n" );
+                break;
+            case '\r':
+                result.append( "|r" );
+                break;
+            case '\'':
+                result.append( "|'" );
+                break;
+            case '|':
+                result.append( "||" );
+                break;
+            case ']':
+                result.append( "|]" );
+                break;
+            default:
+                result.append( &c, 1 );
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeOpen( const std::string& name ) {
+    std::cout << std::endl << "##teamcity[" << name;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeClose() {
+    std::cout << "]" << std::endl;
+    std::cout.flush();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TeamCityProgressListener::writeProperty( const std::string& name,
+                                              const std::string& value ) {
+
+    std::cout << " " << name << "='" << escape( value ) <<
"'";
+}

Propchange: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h?rev=767619&view=auto
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h
(added)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h
Wed Apr 22 18:57:53 2009
@@ -0,0 +1,72 @@
+/*
+ * 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 _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_
+#define _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_
+
+#include <cppunit/TestFailure.h>
+#include <cppunit/TestListener.h>
+
+#include <string>
+
+namespace test {
+namespace util {
+namespace teamcity {
+
+    /**
+     * CPPUnit Derived Test Listener that can output the test life cycle messages in
+     * a manner that can be processed by the TeamCity Continuous integration tool.
+     */
+    class TeamCityProgressListener: public CPPUNIT_NS::TestListener {
+    public:
+
+        TeamCityProgressListener() {}
+        ~TeamCityProgressListener() {}
+
+        void startTest( CPPUNIT_NS::Test *test );
+        void addFailure( const CPPUNIT_NS::TestFailure &failure );
+        void endTest( CPPUNIT_NS::Test *test );
+        void startSuite( CPPUNIT_NS::Test *test );
+        void endSuite( CPPUNIT_NS::Test *test );
+
+    private:
+
+        // Prevents the use of the copy constructor.
+        TeamCityProgressListener( const TeamCityProgressListener& );
+
+        // Prevents the use of the copy operator.
+        void operator =( const TeamCityProgressListener& );
+
+    protected:
+
+        /**
+         * Escapes the control characters in a string.
+         *
+         * @param value - String to escape
+         * @return the new escaped string.
+         */
+        virtual std::string escape( const std::string& value ) const;
+
+        virtual void writeOpen( const std::string& name );
+        virtual void writeProperty( const std::string& name, const std::string& value
);
+        virtual void writeClose();
+
+    };
+
+}}}
+
+#endif /* _TEST_UTIL_TEAMCITY_TEAMCITYPROGRESSLISTENER_H_ */

Propchange: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/test/util/teamcity/TeamCityProgressListener.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message