You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/08/29 02:14:19 UTC

svn commit: r690054 - in /activemq/activemq-cpp/trunk/src: main/ main/decaf/util/concurrent/atomic/ test/ test/decaf/util/concurrent/atomic/

Author: tabish
Date: Thu Aug 28 17:14:18 2008
New Revision: 690054

URL: http://svn.apache.org/viewvc?rev=690054&view=rev
Log:
Add Class AtomicInteger and tests.

Added:
    activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
    activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
    activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp
    activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.h
Modified:
    activemq/activemq-cpp/trunk/src/main/Makefile.am
    activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
    activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
    activemq/activemq-cpp/trunk/src/test/Makefile.am
    activemq/activemq-cpp/trunk/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=690054&r1=690053&r2=690054&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Thu Aug 28 17:14:18 2008
@@ -131,6 +131,7 @@
     decaf/util/concurrent/PooledThread.cpp \
     decaf/util/concurrent/ThreadPool.cpp \
     decaf/util/concurrent/atomic/AtomicBoolean.cpp \
+    decaf/util/concurrent/atomic/AtomicInteger.cpp \
     decaf/util/Date.cpp \
     decaf/util/UUID.cpp \
     decaf/util/StringTokenizer.cpp \
@@ -388,6 +389,7 @@
     decaf/util/concurrent/TaskListener.h \
     decaf/util/concurrent/ThreadPool.h \
     decaf/util/concurrent/atomic/AtomicBoolean.h \
+    decaf/util/concurrent/atomic/AtomicInteger.h \
     decaf/util/Config.h \
     decaf/util/Date.h \
     decaf/util/UUID.h \

Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp?rev=690054&r1=690053&r2=690054&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp Thu Aug 28 17:14:18 2008
@@ -53,6 +53,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string AtomicBoolean::toString() {
+std::string AtomicBoolean::toString() const {
     return Boolean::toString( this->value ? true : false );
 }

Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h?rev=690054&r1=690053&r2=690054&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h Thu Aug 28 17:14:18 2008
@@ -90,7 +90,7 @@
          * Returns the String representation of the current value.
          * @returns the String representation of the current value.
          */
-        std::string toString();
+        std::string toString() const;
 
     };
 

Added: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp?rev=690054&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp Thu Aug 28 17:14:18 2008
@@ -0,0 +1,110 @@
+/*
+ * 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 "AtomicInteger.h"
+
+#include <decaf/lang/Integer.h>
+#include <apr_atomic.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace decaf::util::concurrent::atomic;
+
+////////////////////////////////////////////////////////////////////////////////
+AtomicInteger::AtomicInteger() : value( 0 ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+AtomicInteger::AtomicInteger( int initialValue ) : value( initialValue ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::getAndSet( int newValue ) {
+    for(;;) {
+        int current = get();
+        if( compareAndSet( current, newValue ) ) {
+            return current;
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool AtomicInteger::compareAndSet( int expect, int update ) {
+    return apr_atomic_cas32( &this->value, update, expect ) == (unsigned int)expect;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::getAndIncrement() {
+    return apr_atomic_inc32( &this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::getAndDecrement() {
+    int previous = (int)this->value;
+    apr_atomic_dec32( &this->value );
+    return previous;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::getAndAdd( int delta ) {
+    return apr_atomic_add32( &this->value, delta );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::incrementAndGet() {
+    apr_atomic_inc32( &this->value );
+    return this->value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::decrementAndGet() {
+    apr_atomic_dec32( &this->value );
+    return this->value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::addAndGet( int delta ) {
+    apr_atomic_add32( &this->value, delta );
+    return this->value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string AtomicInteger::toString() const {
+    return Integer::toString( this->value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int AtomicInteger::intValue() const {
+    return this->value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long AtomicInteger::longValue() const {
+    return Integer( value ).longValue();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float AtomicInteger::floatValue() const {
+    return Integer( value ).floatValue();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double AtomicInteger::doubleValue() const {
+    return Integer( value ).doubleValue();
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.h?rev=690054&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/atomic/AtomicInteger.h Thu Aug 28 17:14:18 2008
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H_
+#define _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Number.h>
+#include <string>
+
+namespace decaf {
+namespace util {
+namespace concurrent {
+namespace atomic {
+
+    /**
+     * An int value that may be updated atomically. An AtomicInteger is used in
+     * applications such as atomically incremented counters, and cannot be used
+     * as a replacement for an Integer. However, this class does extend Number
+     * to allow uniform access by tools and utilities that deal with
+     * numerically-based classes.
+     */
+    class DECAF_API AtomicInteger : public decaf::lang::Number {
+    private:
+
+        volatile unsigned int value;
+
+    public:
+
+        /**
+         * Create a new AtomicInteger with an initial value of 0.
+         */
+        AtomicInteger();
+
+        /**
+         * Create a new AtomicInteger with the given initial value.
+         * @param initialValue - The initial value of this object.
+         */
+        AtomicInteger( int initialValue );
+
+        virtual ~AtomicInteger() {}
+
+        /**
+         * Gets the current value.
+         * @returns the current value.
+         */
+        int get() const {
+            return this->value;
+        }
+
+        /**
+         * Sets to the given value.
+         * @param newValue - the new value
+         */
+        void set( int newValue ) {
+            this->value = newValue;
+        }
+
+        /**
+         * Atomically sets to the given value and returns the old value.
+         * @param newValue - the new value.
+         * @returns the previous value.
+         */
+        int getAndSet( int newValue );
+
+        /**
+         * Atomically sets the value to the given updated value if the current
+         * value == the expected value.
+         *
+         * @param expect - the expected value
+         * @param update - the new value
+         * @returns true if successful. False return indicates that the actual
+         * value was not equal to the expected value.
+         */
+        bool compareAndSet( int expect, int update );
+
+        /**
+         * Atomically increments by one the current value.
+         * @returns the previous value.
+         */
+        int getAndIncrement();
+
+        /**
+         * Atomically decrements by one the current value.
+         * @returns the previous value.
+         */
+        int getAndDecrement();
+
+        /**
+         * Atomically adds the given value to the current value.
+         * @param delta - The value to add.
+         * @returns the previous value.
+         */
+        int getAndAdd( int delta );
+
+        /**
+         * Atomically increments by one the current value.
+         * @returns the updated value.
+         */
+        int incrementAndGet();
+
+        /**
+         * Atomically decrements by one the current value.
+         * @returns the updated value.
+         */
+        int decrementAndGet();
+
+        /**
+         * Atomically adds the given value to the current value.
+         * @param delta - the value to add.
+         * @returns the updated value.
+         */
+        int addAndGet( int delta );
+
+        /**
+         * Returns the String representation of the current value.
+         * @returns the String representation of the current value.
+         */
+        std::string toString() const;
+
+        /**
+         * Description copied from class: Number
+         * Returns the value of the specified number as an int. This may involve
+         * rounding or truncation.
+         * @returns the numeric value represented by this object after conversion
+         * to type int.
+         */
+        int intValue() const;
+
+        /**
+         * Description copied from class: Number
+         * Returns the value of the specified number as a long. This may involve
+         * rounding or truncation.
+         * @returns the numeric value represented by this object after conversion
+         * to type long long.
+         */
+        long long longValue() const;
+
+        /**
+         * Description copied from class: Number
+         * Returns the value of the specified number as a float. This may involve
+         * rounding.
+         * @returns the numeric value represented by this object after conversion
+         * to type float.
+         */
+        float floatValue() const;
+
+        /**
+         * Description copied from class: Number
+         * Returns the value of the specified number as a double. This may
+         * involve rounding.
+         * @returns the numeric value represented by this object after conversion
+         * to type double.
+         */
+        double doubleValue() const;
+
+    };
+
+}}}}
+
+#endif /*_DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGER_H_ */

Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=690054&r1=690053&r2=690054&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Thu Aug 28 17:14:18 2008
@@ -126,6 +126,7 @@
   decaf/util/concurrent/MutexTest.cpp \
   decaf/util/concurrent/ThreadPoolTest.cpp \
   decaf/util/concurrent/atomic/AtomicBooleanTest.cpp \
+  decaf/util/concurrent/atomic/AtomicIntegerTest.cpp \
   decaf/nio/BufferTest.cpp \
   testRegistry.cpp \
   main.cpp
@@ -241,6 +242,7 @@
   decaf/util/concurrent/MutexTest.h \
   decaf/util/concurrent/ThreadPoolTest.h \
   decaf/util/concurrent/atomic/AtomicBooleanTest.h \
+  decaf/util/concurrent/atomic/AtomicIntegerTest.h \
   decaf/nio/BufferTest.h  
 
 ## include activemq/connector/openwire/marshal/v1/srcmakefile.mk

Added: activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp?rev=690054&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp Thu Aug 28 17:14:18 2008
@@ -0,0 +1,223 @@
+/*
+ * 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 "AtomicIntegerTest.h"
+
+#include <decaf/util/concurrent/atomic/AtomicInteger.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Thread.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace decaf::util::concurrent::atomic;
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testConstructor() {
+    AtomicInteger ai;
+    CPPUNIT_ASSERT( ai.get() == 0 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testConstructor2() {
+    AtomicInteger ai( 999 );
+    CPPUNIT_ASSERT( ai.get() == 999 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testGetSet() {
+    AtomicInteger ai( 2 );
+    CPPUNIT_ASSERT( 2 == ai.get() );
+    ai.set( 5 );
+    CPPUNIT_ASSERT( 5 == ai.get() );
+    ai.set( 6 );
+    CPPUNIT_ASSERT( 6 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testCompareAndSet() {
+    AtomicInteger ai( 25 );
+    CPPUNIT_ASSERT( ai.compareAndSet( 25, 50 ) );
+    CPPUNIT_ASSERT( 50 == ai.get() );
+    CPPUNIT_ASSERT( ai.compareAndSet( 50, 25 ) );
+    CPPUNIT_ASSERT( 25 == ai.get() );
+    CPPUNIT_ASSERT( !ai.compareAndSet( 50, 75 ) );
+    CPPUNIT_ASSERT( ai.get() != 75 );
+    CPPUNIT_ASSERT( ai.compareAndSet( 25, 50 ) );
+    CPPUNIT_ASSERT( 50 == ai.get() );
+
+    AtomicInteger ai2( 1 );
+    CPPUNIT_ASSERT( ai2.compareAndSet( 1, 2 ) );
+    CPPUNIT_ASSERT( ai2.compareAndSet( 2, -4 ) );
+    CPPUNIT_ASSERT( -4 == ai2.get() );
+    CPPUNIT_ASSERT( !ai2.compareAndSet( -5, 7 ) );
+    CPPUNIT_ASSERT( 7 != ai2.get() );
+    CPPUNIT_ASSERT( ai2.compareAndSet( -4, 7 ) );
+    CPPUNIT_ASSERT( 7 == ai2.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+class MyIntRunnable: public Runnable {
+private:
+
+    AtomicInteger* aip;
+
+public:
+
+    MyIntRunnable( AtomicInteger* ai ) :
+        aip( ai ) {
+    }
+
+    virtual void run() {
+        while( !aip->compareAndSet( 2, 3 ) ) {
+            Thread::yield();
+        }
+    }
+
+};
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testCompareAndSetInMultipleThreads() {
+    AtomicInteger ai( 1 );
+
+    MyIntRunnable runnable( &ai );
+    Thread t( &runnable );
+
+    try {
+
+        t.start();
+        CPPUNIT_ASSERT( ai.compareAndSet( 1, 2 ) );
+        t.join();
+        CPPUNIT_ASSERT( ai.get() == 3 );
+
+    } catch( Exception& e ) {
+        CPPUNIT_FAIL( "Should Not Throw" );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testGetAndSet() {
+    AtomicInteger ai( 50 );
+    CPPUNIT_ASSERT( 50 == ai.getAndSet( 75 ) );
+    CPPUNIT_ASSERT( 75 == ai.getAndSet( 25 ) );
+    CPPUNIT_ASSERT( 25 == ai.getAndSet( 100 ) );
+    CPPUNIT_ASSERT( 100 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testToString() {
+    AtomicInteger ai;
+    CPPUNIT_ASSERT( ai.toString() == Integer::toString( 0 ) );
+    ai.set( 999 );
+    CPPUNIT_ASSERT( ai.toString() == Integer::toString( 999 ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testGetAndAdd() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 1 == ai.getAndAdd(2) );
+    CPPUNIT_ASSERT( 3 == ai.get() );
+    CPPUNIT_ASSERT( 3 == ai.getAndAdd(-4) );
+    CPPUNIT_ASSERT( -1 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testGetAndDecrement() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 1 == ai.getAndDecrement() );
+    CPPUNIT_ASSERT( 0 == ai.getAndDecrement() );
+    CPPUNIT_ASSERT( -1 == ai.getAndDecrement() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testGetAndIncrement() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 1 == ai.getAndIncrement() );
+    CPPUNIT_ASSERT( 2 == ai.get() );
+    ai.set( -2 );
+    CPPUNIT_ASSERT( -2 == ai.getAndIncrement() );
+    CPPUNIT_ASSERT( -1 == ai.getAndIncrement() );
+    CPPUNIT_ASSERT( 0 == ai.getAndIncrement() );
+    CPPUNIT_ASSERT( 1 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testAddAndGet() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 3 == ai.addAndGet(2) );
+    CPPUNIT_ASSERT( 3 == ai.get() );
+    CPPUNIT_ASSERT( -1 == ai.addAndGet(-4) );
+    CPPUNIT_ASSERT( -1 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testDecrementAndGet() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 0 == ai.decrementAndGet() );
+    CPPUNIT_ASSERT( -1 == ai.decrementAndGet() );
+    CPPUNIT_ASSERT( -2 == ai.decrementAndGet() );
+    CPPUNIT_ASSERT( -2 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testIncrementAndGet() {
+    AtomicInteger ai( 1 );
+    CPPUNIT_ASSERT( 2 == ai.incrementAndGet() );
+    CPPUNIT_ASSERT( 2 == ai.get() );
+    ai.set( -2 );
+    CPPUNIT_ASSERT( -1 == ai.incrementAndGet() );
+    CPPUNIT_ASSERT( 0 == ai.incrementAndGet() );
+    CPPUNIT_ASSERT( 1 == ai.incrementAndGet() );
+    CPPUNIT_ASSERT( 1 == ai.get() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testIntValue() {
+    AtomicInteger ai;
+    for( int i = -12; i < 6; ++i ) {
+        ai.set( i );
+        CPPUNIT_ASSERT( i == ai.intValue() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testLongValue() {
+    AtomicInteger ai;
+    for( int i = -12; i < 6; ++i ) {
+        ai.set( i );
+        CPPUNIT_ASSERT( (long long)i == ai.longValue() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testFloatValue() {
+    AtomicInteger ai;
+    for( int i = -12; i < 6; ++i ) {
+        ai.set( i );
+        CPPUNIT_ASSERT( (float)i == ai.floatValue() );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AtomicIntegerTest::testDoubleValue() {
+    AtomicInteger ai;
+    for( int i = -12; i < 6; ++i ) {
+        ai.set( i );
+        CPPUNIT_ASSERT( (double)i == ai.doubleValue() );
+    }
+}

Added: activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.h?rev=690054&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.h Thu Aug 28 17:14:18 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGERTEST_H_
+#define _DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf {
+namespace util {
+namespace concurrent {
+namespace atomic {
+
+    class AtomicIntegerTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( AtomicIntegerTest );
+        CPPUNIT_TEST( testConstructor );
+        CPPUNIT_TEST( testConstructor2 );
+        CPPUNIT_TEST( testGetSet );
+        CPPUNIT_TEST( testCompareAndSet );
+        CPPUNIT_TEST( testCompareAndSetInMultipleThreads );
+        CPPUNIT_TEST( testGetAndSet );
+        CPPUNIT_TEST( testToString );
+        CPPUNIT_TEST( testDoubleValue );
+        CPPUNIT_TEST( testFloatValue );
+        CPPUNIT_TEST( testLongValue );
+        CPPUNIT_TEST( testIntValue );
+        CPPUNIT_TEST( testIncrementAndGet );
+        CPPUNIT_TEST( testDecrementAndGet );
+        CPPUNIT_TEST( testAddAndGet );
+        CPPUNIT_TEST( testGetAndIncrement );
+        CPPUNIT_TEST( testGetAndDecrement );
+        CPPUNIT_TEST( testGetAndAdd );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        AtomicIntegerTest() {}
+        virtual ~AtomicIntegerTest() {}
+
+        void testConstructor();
+        void testConstructor2();
+        void testGetSet();
+        void testCompareAndSet();
+        void testCompareAndSetInMultipleThreads();
+        void testGetAndSet();
+        void testToString();
+        void testDoubleValue();
+        void testFloatValue();
+        void testLongValue();
+        void testIntValue();
+        void testIncrementAndGet();
+        void testDecrementAndGet();
+        void testAddAndGet();
+        void testGetAndIncrement();
+        void testGetAndDecrement();
+        void testGetAndAdd();
+
+    };
+
+}}}}
+
+#endif /*_DECAF_UTIL_CONCURRENT_ATOMIC_ATOMICINTEGERTEST_H_*/

Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=690054&r1=690053&r2=690054&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Thu Aug 28 17:14:18 2008
@@ -243,6 +243,8 @@
 
 #include <decaf/util/concurrent/atomic/AtomicBooleanTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::atomic::AtomicBooleanTest );
+#include <decaf/util/concurrent/atomic/AtomicIntegerTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::atomic::AtomicIntegerTest );
 
 #include <decaf/util/DateTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::DateTest );