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 2007/12/03 15:17:48 UTC
svn commit: r600546 - in /activemq/activemq-cpp/decaf/trunk/src/test:
Makefile.am decaf/internal/nio/BufferFactoryTest.cpp
decaf/internal/nio/BufferFactoryTest.h testRegistry.cpp
Author: tabish
Date: Mon Dec 3 06:17:47 2007
New Revision: 600546
URL: http://svn.apache.org/viewvc?rev=600546&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-153
Implementing the NIO Package.
Added:
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.cpp
activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.h
Modified:
activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am
activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am?rev=600546&r1=600545&r2=600546&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/Makefile.am Mon Dec 3 06:17:47 2007
@@ -19,6 +19,7 @@
decaf/internal/util/ByteArrayTest.cpp \
decaf/internal/nio/ByteArrayPerspectiveTest.cpp \
decaf/internal/nio/ByteArrayBufferTest.cpp \
+ decaf/internal/nio/BufferFactoryTest.cpp \
decaf/lang/ByteTest.cpp \
decaf/lang/CharacterTest.cpp \
decaf/lang/BooleanTest.cpp \
@@ -58,11 +59,11 @@
testRegistry.cpp \
main.cpp
-# decaf/nio/ByteBufferTest.cpp
-
h_sources = \
decaf/internal/util/ByteArrayTest.h \
decaf/internal/nio/ByteArrayPerspectiveTest.h \
+ decaf/internal/nio/ByteArrayBufferTest.h \
+ decaf/internal/nio/BufferFactoryTest.cpp \
decaf/lang/ByteTest.h \
decaf/lang/CharacterTest.h \
decaf/lang/BooleanTest.h \
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.cpp?rev=600546&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.cpp (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.cpp Mon Dec 3 06:17:47 2007
@@ -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.
+ */
+
+#include "BufferFactoryTest.h"
+
+#include <decaf/nio/ByteBuffer.h>
+#include <decaf/nio/CharBuffer.h>
+#include <decaf/nio/DoubleBuffer.h>
+#include <decaf/nio/FloatBuffer.h>
+#include <decaf/nio/LongBuffer.h>
+#include <decaf/nio/IntBuffer.h>
+#include <decaf/nio/ShortBuffer.h>
+
+using namespace decaf;
+using namespace decaf::internal;
+using namespace decaf::internal::nio;
+using namespace decaf::nio;
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferFactoryTest::testCreateByteBuffer1() {
+
+ ByteBuffer* buffer = BufferFactory::createByteBuffer( 500 );
+ CPPUNIT_ASSERT( buffer != NULL );
+ CPPUNIT_ASSERT( buffer->capacity() == 500 );
+ CPPUNIT_ASSERT( buffer->isReadOnly() == false );
+
+ delete buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferFactoryTest::testCreateByteBuffer2() {
+
+ std::vector<unsigned char> array;
+ array.resize( 500 );
+ ByteBuffer* buffer = BufferFactory::createByteBuffer( array );
+ CPPUNIT_ASSERT( buffer != NULL );
+ CPPUNIT_ASSERT( buffer->hasArray() == true );
+ CPPUNIT_ASSERT( buffer->array() == &array[0] );
+ CPPUNIT_ASSERT( buffer->capacity() == 500 );
+ CPPUNIT_ASSERT( buffer->isReadOnly() == false );
+
+ delete buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferFactoryTest::testCreateByteBuffer3() {
+
+ std::vector<unsigned char> array;
+ array.resize( 500 );
+ ByteBuffer* buffer = BufferFactory::createByteBuffer( &array[0], 100, 400 );
+ CPPUNIT_ASSERT( buffer != NULL );
+ CPPUNIT_ASSERT( buffer->hasArray() == true );
+ CPPUNIT_ASSERT( buffer->array() == &array[0] );
+ CPPUNIT_ASSERT( buffer->capacity() == 400 );
+ CPPUNIT_ASSERT( buffer->isReadOnly() == false );
+
+ delete buffer;
+}
Added: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.h?rev=600546&view=auto
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.h (added)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/BufferFactoryTest.h Mon Dec 3 06:17:47 2007
@@ -0,0 +1,51 @@
+/*
+ * 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_INTERNAL_NIO_BUFFERFACTORYTEST_H_
+#define _DECAF_INTERNAL_NIO_BUFFERFACTORYTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/internal/nio/BufferFactory.h>
+
+namespace decaf{
+namespace internal{
+namespace nio{
+
+ class BufferFactoryTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( BufferFactoryTest );
+ CPPUNIT_TEST( testCreateByteBuffer1 );
+ CPPUNIT_TEST( testCreateByteBuffer2 );
+ CPPUNIT_TEST( testCreateByteBuffer3 );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ BufferFactoryTest() {}
+ virtual ~BufferFactoryTest() {}
+
+ void testCreateByteBuffer1();
+ void testCreateByteBuffer2();
+ void testCreateByteBuffer3();
+
+ };
+
+}}}
+
+#endif /*_DECAF_INTERNAL_NIO_BUFFERFACTORYTEST_H_*/
Modified: activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp?rev=600546&r1=600545&r2=600546&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp Mon Dec 3 06:17:47 2007
@@ -24,6 +24,8 @@
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::ByteArrayPerspectiveTest );
#include <decaf/internal/nio/ByteArrayBufferTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::ByteArrayBufferTest );
+#include <decaf/internal/nio/BufferFactoryTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::internal::nio::BufferFactoryTest );
#include <decaf/nio/BufferTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::nio::BufferTest );