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 2013/01/25 20:05:28 UTC
svn commit: r1438649 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/test: Makefile.am
activemq/transport/tcp/ activemq/transport/tcp/TcpTransportTest.cpp
activemq/transport/tcp/TcpTransportTest.h testRegistry.cpp
Author: tabish
Date: Fri Jan 25 19:05:28 2013
New Revision: 1438649
URL: http://svn.apache.org/viewvc?rev=1438649&view=rev
Log:
Adds initial framework for an Tcp and SSL Transport connection test.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h (with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?rev=1438649&r1=1438648&r2=1438649&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Fri Jan 25 19:05:28 2013
@@ -55,6 +55,7 @@ cc_sources = \
activemq/transport/failover/FailoverTransportTest.cpp \
activemq/transport/inactivity/InactivityMonitorTest.cpp \
activemq/transport/mock/MockTransportFactoryTest.cpp \
+ activemq/transport/tcp/TcpTransportTest.cpp \
activemq/util/ActiveMQMessageTransformationTest.cpp \
activemq/util/AdvisorySupportTest.cpp \
activemq/util/IdGeneratorTest.cpp \
@@ -296,6 +297,7 @@ h_sources = \
activemq/transport/failover/FailoverTransportTest.h \
activemq/transport/inactivity/InactivityMonitorTest.h \
activemq/transport/mock/MockTransportFactoryTest.h \
+ activemq/transport/tcp/TcpTransportTest.h \
activemq/util/ActiveMQMessageTransformationTest.h \
activemq/util/AdvisorySupportTest.h \
activemq/util/IdGeneratorTest.h \
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp?rev=1438649&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp Fri Jan 25 19:05:28 2013
@@ -0,0 +1,153 @@
+/*
+ * 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 "TcpTransportTest.h"
+
+#include <activemq/transport/tcp/TcpTransportFactory.h>
+#include <activemq/transport/tcp/TcpTransport.h>
+
+#include <activemq/wireformat/openwire/OpenWireFormat.h>
+
+#include <decaf/lang/Pointer.h>
+#include <decaf/net/Socket.h>
+#include <decaf/net/SocketFactory.h>
+#include <decaf/net/ServerSocket.h>
+#include <decaf/io/InputStream.h>
+#include <decaf/io/OutputStream.h>
+#include <decaf/util/Random.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::net;
+using namespace decaf::io;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace activemq;
+using namespace activemq::wireformat;
+using namespace activemq::wireformat::openwire;
+using namespace activemq::transport;
+using namespace activemq::transport::tcp;
+
+////////////////////////////////////////////////////////////////////////////////
+TcpTransportTest::TcpTransportTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+TcpTransportTest::~TcpTransportTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+ class TestServer : public lang::Thread{
+ private:
+
+ bool done;
+ bool error;
+ Pointer<ServerSocket> server;
+ Pointer<OpenWireFormat> wireFormat;
+ CountDownLatch started;
+
+ public:
+
+ TestServer() : Thread(), done(false), error(false), server(), started(1) {
+ server.reset(new ServerSocket(0));
+
+ Properties properties;
+ this->wireFormat.reset(new OpenWireFormat(properties));
+ }
+
+ virtual ~TestServer() {
+ stop();
+ }
+
+ int getLocalPort() {
+ if (this->server.get() != NULL) {
+ return server->getLocalPort();
+ }
+
+ return 0;
+ }
+
+ void waitUntilStarted() {
+ this->started.await();
+ }
+
+ void waitUntilStopped() {
+ this->join();
+ }
+
+ void stop() {
+ try {
+ done = true;
+ server->close();
+ } catch (...) {}
+ }
+
+ virtual void run() {
+ try {
+
+ started.countDown();
+
+ while (!done) {
+
+ std::auto_ptr<Socket> socket(server->accept());
+ socket->setSoLinger(false, 0);
+
+ InputStream* is = socket->getInputStream();
+ DataInputStream ds(is);
+
+ socket->close();
+ }
+
+ } catch (IOException& ex) {
+ error = true;
+ } catch (...) {
+ error = true;
+ }
+ }
+ };
+
+ TestServer* server;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpTransportTest::setUp() {
+
+ server = new TestServer();
+ server->start();
+ server->waitUntilStarted();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpTransportTest::tearDown() {
+
+ if (server == NULL) {
+ return;
+ }
+
+ server->stop();
+ server->waitUntilStopped();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpTransportTest::testTransportCreateWithRadomFailures() {
+
+ Properties properties;
+ OpenWireFormat wireFormat(properties);
+ TcpTransportFactory factory;
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h?rev=1438649&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h Fri Jan 25 19:05:28 2013
@@ -0,0 +1,49 @@
+/*
+ * 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_TRANSPORT_TCP_TCPTRANSPORTTEST_H_
+#define _ACTIVEMQ_TRANSPORT_TCP_TCPTRANSPORTTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <activemq/util/Config.h>
+
+namespace activemq {
+namespace transport {
+namespace tcp {
+
+ class TcpTransportTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( TcpTransportTest );
+ CPPUNIT_TEST( testTransportCreateWithRadomFailures );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ TcpTransportTest();
+ virtual ~TcpTransportTest();
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ void testTransportCreateWithRadomFailures();
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_TRANSPORT_TCP_TCPTRANSPORTTEST_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/tcp/TcpTransportTest.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp?rev=1438649&r1=1438648&r2=1438649&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp Fri Jan 25 19:05:28 2013
@@ -105,6 +105,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION( activem
#include <activemq/transport/failover/FailoverTransportTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::failover::FailoverTransportTest );
+#include <activemq/transport/tcp/TcpTransportTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::tcp::TcpTransportTest );
+
#include <activemq/transport/correlator/ResponseCorrelatorTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::correlator::ResponseCorrelatorTest );