activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r767612 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity: TeamCityProgressListener.cpp TeamCityProgressListener.h
Date Wed, 22 Apr 2009 18:41:01 GMT
Author: tabish
Date: Wed Apr 22 18:41:01 2009
New Revision: 767612

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

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h
  (with props)

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp?rev=767612&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
Wed Apr 22 18:41:01 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/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h?rev=767612&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h
Wed Apr 22 18:41:01 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/trunk/activemq-cpp/src/test-integration/util/teamcity/TeamCityProgressListener.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message