You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2006/07/21 13:36:16 UTC
svn commit: r424272 [10/10] - in /incubator/activemq/trunk/activemq-cpp: ./
src/examples/ src/main/activemq/concurrent/ src/main/activemq/connector/
src/main/activemq/connector/stomp/
src/main/activemq/connector/stomp/commands/ src/main/activemq/connec...
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/StompSessionManagerTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/StompSessionManagerTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/StompSessionManagerTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/StompSessionManagerTest.h Fri Jul 21 04:36:09 2006
@@ -10,6 +10,7 @@
#include <activemq/connector/stomp/StompQueue.h>
#include <activemq/transport/DummyTransport.h>
#include <activemq/connector/stomp/commands/TextMessageCommand.h>
+#include <activemq/connector/stomp/commands/SubscribeCommand.h>
#include <activemq/transport/CommandListener.h>
#include <cms/Session.h>
#include <vector>
@@ -26,24 +27,47 @@
CPPUNIT_TEST( testConsumers );
CPPUNIT_TEST( testCommand );
CPPUNIT_TEST( testSendingCommands );
+ CPPUNIT_TEST( testSubscribeOptions );
CPPUNIT_TEST_SUITE_END();
public:
+ typedef std::pair< std::string, std::string > MyProperty;
+
class MyCommandListener : public transport::CommandListener{
public:
transport::Command* cmd;
+ commands::SubscribeCommand* subscribe;
+
+ // Properties that should be in an command
+ std::vector< MyProperty > expected;
public:
MyCommandListener(){
cmd = NULL;
+ subscribe = NULL;
}
virtual ~MyCommandListener(){}
virtual void onCommand( transport::Command* command ){
cmd = command;
+
+ subscribe = dynamic_cast< commands::SubscribeCommand* >( command );
+ if( subscribe )
+ {
+ const util::Properties& properties =
+ subscribe->getProperties();
+
+ for( size_t ix = 0; ix < expected.size(); ++ix )
+ {
+ std::string value =
+ properties.getProperty( expected[ix].first, "" );
+
+ CPPUNIT_ASSERT( value == expected[ix].second );
+ }
+ }
}
};
@@ -59,6 +83,8 @@
core::ActiveMQMessage* msg )
{
consumers.push_back( consumer );
+
+ delete msg;
}
};
@@ -71,20 +97,20 @@
transport::DummyTransport transport( &responseBuilder );
StompSessionManager manager( connectionId, &transport );
- SessionInfo* info1 = manager.createSession( cms::Session::AutoAcknowledge );
- CPPUNIT_ASSERT( info1->getAckMode() == cms::Session::AutoAcknowledge );
+ SessionInfo* info1 = manager.createSession( cms::Session::AUTO_ACKNOWLEDGE );
+ CPPUNIT_ASSERT( info1->getAckMode() == cms::Session::AUTO_ACKNOWLEDGE );
CPPUNIT_ASSERT( info1->getConnectionId() == connectionId );
- SessionInfo* info2 = manager.createSession( cms::Session::DupsOkAcknowledge );
- CPPUNIT_ASSERT( info2->getAckMode() == cms::Session::DupsOkAcknowledge );
+ SessionInfo* info2 = manager.createSession( cms::Session::DUPS_OK_ACKNOWLEDGE );
+ CPPUNIT_ASSERT( info2->getAckMode() == cms::Session::DUPS_OK_ACKNOWLEDGE );
CPPUNIT_ASSERT( info2->getConnectionId() == connectionId );
- SessionInfo* info3 = manager.createSession( cms::Session::ClientAcknowledge );
- CPPUNIT_ASSERT( info3->getAckMode() == cms::Session::ClientAcknowledge );
+ SessionInfo* info3 = manager.createSession( cms::Session::CLIENT_ACKNOWLEDGE );
+ CPPUNIT_ASSERT( info3->getAckMode() == cms::Session::CLIENT_ACKNOWLEDGE );
CPPUNIT_ASSERT( info3->getConnectionId() == connectionId );
- SessionInfo* info4 = manager.createSession( cms::Session::Transactional );
- CPPUNIT_ASSERT( info4->getAckMode() == cms::Session::Transactional );
+ SessionInfo* info4 = manager.createSession( cms::Session::SESSION_TRANSACTED );
+ CPPUNIT_ASSERT( info4->getAckMode() == cms::Session::SESSION_TRANSACTED );
CPPUNIT_ASSERT( info4->getConnectionId() == connectionId );
delete info1;
@@ -100,7 +126,7 @@
transport::DummyTransport transport( &responseBuilder );
StompSessionManager manager( connectionId, &transport );
- SessionInfo* info1 = manager.createSession( cms::Session::AutoAcknowledge );
+ SessionInfo* info1 = manager.createSession( cms::Session::AUTO_ACKNOWLEDGE );
std::string sel1 = "";
StompTopic dest1( "dummy.topic.1" );
ConsumerInfo* cinfo1 = manager.createConsumer( &dest1, info1, sel1 );
@@ -108,7 +134,7 @@
CPPUNIT_ASSERT( cinfo1->getDestination().toString() == dest1.toString() );
CPPUNIT_ASSERT( cinfo1->getMessageSelector() == sel1 );
- SessionInfo* info2 = manager.createSession( cms::Session::DupsOkAcknowledge );
+ SessionInfo* info2 = manager.createSession( cms::Session::DUPS_OK_ACKNOWLEDGE );
std::string sel2 = "mysel2";
StompTopic dest2( "dummy.topic.2" );
ConsumerInfo* cinfo2 = manager.createConsumer( &dest2, info2, sel2 );
@@ -116,7 +142,7 @@
CPPUNIT_ASSERT( cinfo2->getDestination().toString() == dest2.toString() );
CPPUNIT_ASSERT( cinfo2->getMessageSelector() == sel2 );
- SessionInfo* info3 = manager.createSession( cms::Session::ClientAcknowledge );
+ SessionInfo* info3 = manager.createSession( cms::Session::CLIENT_ACKNOWLEDGE );
std::string sel3 = "mysel3";
StompQueue dest3( "dummy.queue.1" );
ConsumerInfo* cinfo3 = manager.createConsumer( &dest3, info3, sel3 );
@@ -124,7 +150,7 @@
CPPUNIT_ASSERT( cinfo3->getDestination().toString() == dest3.toString() );
CPPUNIT_ASSERT( cinfo3->getMessageSelector() == sel3 );
- SessionInfo* info4 = manager.createSession( cms::Session::Transactional );
+ SessionInfo* info4 = manager.createSession( cms::Session::SESSION_TRANSACTED );
std::string sel4 = "";
StompTopic dest4( "dummy.queue.2" );
ConsumerInfo* cinfo4 = manager.createConsumer( &dest4, info4, sel4 );
@@ -153,23 +179,23 @@
StompTopic dest1( "dummy.topic" );
StompTopic dest2( "dummy.topic2" );
- SessionInfo* info1 = manager.createSession( cms::Session::AutoAcknowledge );
+ SessionInfo* info1 = manager.createSession( cms::Session::AUTO_ACKNOWLEDGE );
ConsumerInfo* cinfo1 = manager.createConsumer( &dest1, info1, "" );
- SessionInfo* info2 = manager.createSession( cms::Session::DupsOkAcknowledge );
+ SessionInfo* info2 = manager.createSession( cms::Session::DUPS_OK_ACKNOWLEDGE );
ConsumerInfo* cinfo2 = manager.createConsumer( &dest1, info2, "" );
- SessionInfo* info3 = manager.createSession( cms::Session::ClientAcknowledge );
+ SessionInfo* info3 = manager.createSession( cms::Session::CLIENT_ACKNOWLEDGE );
ConsumerInfo* cinfo3 = manager.createConsumer( &dest2, info3, "" );
- SessionInfo* info4 = manager.createSession( cms::Session::Transactional );
+ SessionInfo* info4 = manager.createSession( cms::Session::SESSION_TRANSACTED );
ConsumerInfo* cinfo4 = manager.createConsumer( &dest2, info4, "" );
MyMessageListener listener;
manager.setConsumerMessageListener( &listener );
commands::TextMessageCommand* msg = new commands::TextMessageCommand();
- msg->setCMSDestination( dest1 );
+ msg->setCMSDestination( &dest1 );
msg->setText( "hello world" );
manager.onStompCommand( msg );
@@ -183,7 +209,7 @@
listener.consumers.clear();
msg = new commands::TextMessageCommand();
- msg->setCMSDestination( dest2 );
+ msg->setCMSDestination( &dest2 );
msg->setText( "hello world" );
manager.onStompCommand( msg );
@@ -192,7 +218,7 @@
CPPUNIT_ASSERT( listener.consumers[ix] == cinfo3 ||
listener.consumers[ix] == cinfo4 );
}
-
+
delete info1;
delete info2;
delete info3;
@@ -218,13 +244,13 @@
MyCommandListener cmdListener;
transport.setOutgoingCommandListener( &cmdListener );
- SessionInfo* info1 = manager.createSession( cms::Session::AutoAcknowledge );
+ SessionInfo* info1 = manager.createSession( cms::Session::AUTO_ACKNOWLEDGE );
ConsumerInfo* cinfo1 = manager.createConsumer( &dest1, info1, "" );
CPPUNIT_ASSERT( cmdListener.cmd != NULL );
cmdListener.cmd = NULL;
- SessionInfo* info2 = manager.createSession( cms::Session::DupsOkAcknowledge );
+ SessionInfo* info2 = manager.createSession( cms::Session::DUPS_OK_ACKNOWLEDGE );
ConsumerInfo* cinfo2 = manager.createConsumer( &dest1, info2, "" );
CPPUNIT_ASSERT( cmdListener.cmd == NULL );
@@ -245,6 +271,97 @@
delete cinfo2;
}
+ void testSubscribeOptions(){
+
+ std::string connectionId = "testConnectionId";
+ StompResponseBuilder responseBuilder("testSessionId");
+ transport::DummyTransport transport( &responseBuilder );
+ StompSessionManager manager( connectionId, &transport );
+
+ MyProperty retroactive =
+ std::make_pair( "activemq.retroactive", "true" );
+ MyProperty prefetchSize =
+ std::make_pair( "activemq.prefetchSize", "1000" );
+ MyProperty maxPendingMsgLimit =
+ std::make_pair( "activemq.maximumPendingMessageLimit", "0" );
+ MyProperty noLocal =
+ std::make_pair( "activemq.noLocal", "true" );
+ MyProperty dispatchAsync =
+ std::make_pair( "activemq.dispatchAsync", "true" );
+ MyProperty selector =
+ std::make_pair( "selector", "test" );
+ MyProperty exclusive =
+ std::make_pair( "activemq.exclusive", "true" );
+ MyProperty priority =
+ std::make_pair( "activemq.priority", "1" );
+
+ SessionInfo* session = NULL;
+ ConsumerInfo* consumer = NULL;
+
+ MyCommandListener cmdListener;
+ transport.setOutgoingCommandListener( &cmdListener );
+
+ session = manager.createSession( cms::Session::AUTO_ACKNOWLEDGE );
+
+ cmdListener.expected.clear();
+ StompTopic dest1( "dummy.topic.1" );
+ consumer = manager.createConsumer( &dest1, session, "" );
+ CPPUNIT_ASSERT( consumer != NULL );
+ CPPUNIT_ASSERT( cmdListener.subscribe != NULL );
+
+ manager.removeConsumer( consumer );
+ CPPUNIT_ASSERT( cmdListener.cmd != NULL );
+ delete consumer;
+ cmdListener.cmd = NULL;
+ cmdListener.subscribe = NULL;
+
+ cmdListener.expected.clear();
+ cmdListener.expected.push_back( retroactive );
+ StompTopic dest2( "dummy.topic.1?consumer.retroactive=true" );
+ consumer = manager.createConsumer( &dest2, session, "" );
+ CPPUNIT_ASSERT( consumer != NULL );
+ CPPUNIT_ASSERT( cmdListener.subscribe != NULL );
+
+ manager.removeConsumer( consumer );
+ CPPUNIT_ASSERT( cmdListener.cmd != NULL );
+ delete consumer;
+ cmdListener.cmd = NULL;
+ cmdListener.subscribe = NULL;
+
+ cmdListener.expected.clear();
+ cmdListener.expected.push_back( retroactive );
+ cmdListener.expected.push_back( prefetchSize );
+ cmdListener.expected.push_back( maxPendingMsgLimit );
+ cmdListener.expected.push_back( noLocal );
+ cmdListener.expected.push_back( dispatchAsync );
+ cmdListener.expected.push_back( selector );
+ cmdListener.expected.push_back( exclusive );
+ cmdListener.expected.push_back( priority );
+ StompTopic dest3(
+ std::string( "dummy.topic.1?" ) +
+ "consumer.retroactive=" + retroactive.second + "&" +
+ "consumer.prefetchSize=" + prefetchSize.second + "&" +
+ "consumer.maximumPendingMessageLimit=" + maxPendingMsgLimit.second + "&" +
+ "consumer.noLocal=" + noLocal.second + "&" +
+ "consumer.dispatchAsync=" + dispatchAsync.second + "&" +
+ "consumer.selector=" + selector.second + "&" +
+ "consumer.exclusive=" + exclusive.second + "&" +
+ "consumer.priority=" + priority.second );
+ consumer = manager.createConsumer( &dest3, session, "" );
+ CPPUNIT_ASSERT( consumer != NULL );
+ CPPUNIT_ASSERT( cmdListener.subscribe != NULL );
+
+ manager.removeConsumer( consumer );
+ CPPUNIT_ASSERT( cmdListener.cmd != NULL );
+ delete consumer;
+ cmdListener.cmd = NULL;
+ cmdListener.subscribe = NULL;
+
+ // Done
+ delete session;
+
+ }
+
};
}}}
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h Fri Jul 21 04:36:09 2006
@@ -65,8 +65,8 @@
CPPUNIT_ASSERT( std::string( cmd.getTransactionId() ) ==
"ID:123456" );
StompTopic topic("testTopic");
- cmd.setCMSDestination( topic );
- CPPUNIT_ASSERT( cmd.getCMSDestination().toString() ==
+ cmd.setCMSDestination( &topic );
+ CPPUNIT_ASSERT( cmd.getCMSDestination()->toString() ==
"testTopic" );
StompFrame* frame = cmd.marshal().clone();
@@ -98,12 +98,12 @@
CPPUNIT_ASSERT( std::string( cmd.getCMSCorrelationId() ) ==
"ID:1234567" );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::PERSISTANT );
- cmd.setCMSDeliveryMode( cms::Message::NONPERSISTANT );
+ cms::DeliveryMode::PERSISTANT );
+ cmd.setCMSDeliveryMode( cms::DeliveryMode::NON_PERSISTANT );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::NONPERSISTANT );
- cmd.setCMSDestination( topic );
- CPPUNIT_ASSERT( cmd.getCMSDestination().toString() ==
+ cms::DeliveryMode::NON_PERSISTANT );
+ cmd.setCMSDestination( &topic );
+ CPPUNIT_ASSERT( cmd.getCMSDestination()->toString() ==
"testTopic" );
CPPUNIT_ASSERT( cmd.getCMSExpiration() == 0 );
cmd.setCMSExpiration( 123 );
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h Fri Jul 21 04:36:09 2006
@@ -66,7 +66,7 @@
CPPUNIT_ASSERT( std::string( cmd.getTransactionId() ) ==
"ID:123456" );
StompTopic topic("testTopic");
- cmd.setCMSDestination( topic );
+ cmd.setCMSDestination( &topic );
StompFrame* frame = cmd.marshal().clone();
@@ -98,11 +98,11 @@
CPPUNIT_ASSERT( std::string( cmd.getCMSCorrelationId() ) ==
"ID:1234567" );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::PERSISTANT );
- cmd.setCMSDeliveryMode( cms::Message::NONPERSISTANT );
+ cms::DeliveryMode::PERSISTANT );
+ cmd.setCMSDeliveryMode( cms::DeliveryMode::NON_PERSISTANT );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::NONPERSISTANT );
- CPPUNIT_ASSERT( cmd.getCMSDestination().toString() ==
+ cms::DeliveryMode::NON_PERSISTANT );
+ CPPUNIT_ASSERT( cmd.getCMSDestination()->toString() ==
"testTopic" );
CPPUNIT_ASSERT( cmd.getCMSExpiration() == 0 );
cmd.setCMSExpiration( 123 );
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/TextMessageCommandTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/TextMessageCommandTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/TextMessageCommandTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/TextMessageCommandTest.h Fri Jul 21 04:36:09 2006
@@ -65,7 +65,7 @@
CPPUNIT_ASSERT( std::string( cmd.getTransactionId() ) ==
"ID:123456" );
StompTopic topic("testTopic");
- cmd.setCMSDestination( topic );
+ cmd.setCMSDestination( &topic );
StompFrame* frame = cmd.marshal().clone();
@@ -97,11 +97,11 @@
CPPUNIT_ASSERT( std::string( cmd.getCMSCorrelationId() ) ==
"ID:1234567" );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::PERSISTANT );
- cmd.setCMSDeliveryMode( cms::Message::NONPERSISTANT );
+ cms::DeliveryMode::PERSISTANT );
+ cmd.setCMSDeliveryMode( cms::DeliveryMode::NON_PERSISTANT );
CPPUNIT_ASSERT( cmd.getCMSDeliveryMode() ==
- cms::Message::NONPERSISTANT );
- CPPUNIT_ASSERT( cmd.getCMSDestination().toString() ==
+ cms::DeliveryMode::NON_PERSISTANT );
+ CPPUNIT_ASSERT( cmd.getCMSDestination()->toString() ==
"testTopic" );
CPPUNIT_ASSERT( cmd.getCMSExpiration() == 0 );
cmd.setCMSExpiration( 123 );
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/marshal/MarshalerTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/marshal/MarshalerTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/marshal/MarshalerTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/connector/stomp/marshal/MarshalerTest.h Fri Jul 21 04:36:09 2006
@@ -38,15 +38,17 @@
// Sync to expected output
connectedCommand.setSessionId( "test" );
+ StompTopic myTopic( "a" );
+
// Sync to expected output
- textCommand.setCMSDestination( StompTopic("a") );
+ textCommand.setCMSDestination( &myTopic );
textCommand.setCMSMessageId( "123" );
textCommand.getProperties().setProperty(
"sampleProperty", "testvalue" );
textCommand.setText( "testMessage" );
// Sync to expected output
- bytesCommand.setCMSDestination( StompTopic("a") );
+ bytesCommand.setCMSDestination( &myTopic );
bytesCommand.setCMSMessageId( "123" );
bytesCommand.getProperties().setProperty(
"sampleProperty", "testvalue" );
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h Fri Jul 21 04:36:09 2006
@@ -10,9 +10,11 @@
#include <activemq/concurrent/Mutex.h>
#include <activemq/concurrent/Thread.h>
#include <activemq/core/ActiveMQConnectionFactory.h>
+#include <activemq/core/ActiveMQConnection.h>
#include <cms/Connection.h>
#include <activemq/transport/TransportFactoryMapRegistrar.h>
#include <activemq/transport/DummyTransportFactory.h>
+#include <activemq/connector/Connector.h>
namespace activemq{
namespace core{
@@ -21,11 +23,20 @@
{
CPPUNIT_TEST_SUITE( ActiveMQConnectionFactoryTest );
CPPUNIT_TEST( test );
+ CPPUNIT_TEST( test2 );
CPPUNIT_TEST_SUITE_END();
public:
-
- ActiveMQConnectionFactoryTest() {}
+
+ std::string username;
+ std::string password;
+ std::string clientId;
+
+ ActiveMQConnectionFactoryTest(){
+ username = "timmy";
+ password = "auth";
+ clientId = "12345";
+ }
virtual ~ActiveMQConnectionFactoryTest() {}
void test()
@@ -38,11 +49,10 @@
std::string URI =
"dummy://127.0.0.1:23232&wireFormat=stomp";
- ActiveMQConnectionFactory connectionFactory(URI);
+ ActiveMQConnectionFactory connectionFactory( URI );
cms::Connection* connection =
-
- connectionFactory.createConnection();
+ connectionFactory.createConnection();
CPPUNIT_ASSERT( connection != NULL );
@@ -56,6 +66,45 @@
CPPUNIT_ASSERT( false );
}
+ void test2()
+ {
+ try
+ {
+ transport::TransportFactoryMapRegistrar registrar(
+ "dummy", new transport::DummyTransportFactory() );
+
+ std::string URI = std::string() +
+ "dummy://127.0.0.1:23232&wireFormat=stomp?"
+ "username=" + username + "?password=" + password +
+ "?client-id=" + clientId;
+
+ ActiveMQConnectionFactory connectionFactory( URI );
+
+ cms::Connection* connection =
+ connectionFactory.createConnection();
+ CPPUNIT_ASSERT( connection != NULL );
+
+ ActiveMQConnection* amqConnection =
+ dynamic_cast< ActiveMQConnection* >( connection );
+ CPPUNIT_ASSERT( amqConnection != NULL );
+
+ connector::Connector* connector =
+ dynamic_cast< connector::Connector* >(
+ amqConnection->getConnectionData()->getConnector() );
+ CPPUNIT_ASSERT( connector != NULL );
+
+ CPPUNIT_ASSERT( username == connector->getUsername() );
+ CPPUNIT_ASSERT( password == connector->getPassword() );
+ CPPUNIT_ASSERT( clientId == connector->getClientId() );
+
+ return;
+ }
+ AMQ_CATCH_NOTHROW( exceptions::ActiveMQException )
+ AMQ_CATCHALL_NOTHROW( )
+
+ CPPUNIT_ASSERT( false );
+ }
+
};
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionTest.h Fri Jul 21 04:36:09 2006
@@ -169,7 +169,7 @@
session.setSessionId( 1 );
session.setConnectionId( "TEST:123" );
- session.setAckMode( cms::Session::AutoAcknowledge );
+ session.setAckMode( cms::Session::AUTO_ACKNOWLEDGE );
consumer.setConsumerId( 1 );
consumer.setSessionInfo( &session );
@@ -180,9 +180,8 @@
connector::stomp::commands::TextMessageCommand* cmd =
new connector::stomp::commands::TextMessageCommand;
-
- cmd->setCMSDestination(
- connector::stomp::StompTopic( "test" ) );
+ connector::stomp::StompTopic topic1( "test" );
+ cmd->setCMSDestination( &topic1 );
connector::ConsumerMessageListener* consumerListener =
dynamic_cast< connector::ConsumerMessageListener* >(
@@ -212,8 +211,8 @@
cmd = new connector::stomp::commands::TextMessageCommand;
- cmd->setCMSDestination(
- connector::stomp::StompTopic( "test" ) );
+ connector::stomp::StompTopic topic2( "test" );
+ cmd->setCMSDestination( &topic2 );
consumerListener->onConsumerMessage( &consumer, cmd );
CPPUNIT_ASSERT( msgListener.messages.size() == 1 );
@@ -221,12 +220,20 @@
connection.removeMessageListener( 1 );
msgListener.messages.clear();
+ session1->close();
+ session2->close();
+ session3->close();
connection.close();
consumerListener->onConsumerMessage( &consumer, cmd );
CPPUNIT_ASSERT( exListener.caughtOne == true );
delete cmd;
+
+ delete session1;
+ delete session2;
+ delete session3;
+
}
catch(...)
{
Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.cpp?rev=424272&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.cpp Fri Jul 21 04:36:09 2006
@@ -0,0 +1,3 @@
+#include "ActiveMQDestinationTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQDestinationTest );
Added: incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.h?rev=424272&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQDestinationTest.h Fri Jul 21 04:36:09 2006
@@ -0,0 +1,130 @@
+#ifndef ACTIVEMQDESTINATIONTEST_H_
+#define ACTIVEMQDESTINATIONTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/core/ActiveMQDestination.h>
+#include <cms/Topic.h>
+
+namespace activemq{
+namespace core{
+
+ class ActiveMQDestinationTest : public CppUnit::TestFixture
+ {
+ CPPUNIT_TEST_SUITE( ActiveMQDestinationTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ class MyDestination : public ActiveMQDestination< cms::Topic >
+ {
+ public:
+
+ MyDestination( const cms::Destination* dest ) :
+ ActiveMQDestination< cms::Topic >( dest ) {}
+
+ MyDestination( const std::string& name )
+ : ActiveMQDestination< cms::Topic >( name, cms::Destination::TOPIC )
+ {}
+
+ virtual ~MyDestination() {}
+
+ /**
+ * Converts the Destination Name into a String
+ * @return string name
+ */
+ virtual std::string toString(void) const {
+ return getName();
+ }
+
+ /**
+ * Converts the Destination to a String value representing the
+ * Provider specific name fot this destination, which is not
+ * necessarily equal to the User Supplied name of the Destination
+ * @return Provider specific Name
+ */
+ virtual std::string toProviderString(void) const {
+ return getName();
+ }
+
+ /**
+ * Creates a new instance of this destination type that is a
+ * copy of this one, and returns it.
+ * @returns cloned copy of this object
+ */
+ virtual cms::Destination* clone(void) const {
+ return new MyDestination( this );
+ }
+
+ /**
+ * Gets the name of this topic.
+ * @return The topic name.
+ */
+ virtual std::string getTopicName(void)
+ const throw( cms::CMSException ) { return getName(); }
+
+ };
+
+ ActiveMQDestinationTest() {}
+ virtual ~ActiveMQDestinationTest() {}
+
+ virtual void test()
+ {
+ MyDestination dest( "test" );
+
+ CPPUNIT_ASSERT( dest.getTopicName() == "test" );
+
+ MyDestination dest1( "test1?value1=1&value2=2" );
+
+ CPPUNIT_ASSERT( dest1.getTopicName() == "test1" );
+ CPPUNIT_ASSERT( dest1.getProperties().hasProperty( "value1" ) == true );
+ CPPUNIT_ASSERT( dest1.getProperties().hasProperty( "value2" ) == true );
+ CPPUNIT_ASSERT( dest1.getProperties().hasProperty( "value3" ) != true );
+
+ std::string value1 = dest1.getProperties().getProperty( "value1" );
+ std::string value2 = dest1.getProperties().getProperty( "value2" );
+
+ CPPUNIT_ASSERT( value1 == "1" );
+ CPPUNIT_ASSERT( value2 == "2" );
+
+ MyDestination* dest2 =
+ dynamic_cast< MyDestination* >( dest1.clone() );
+
+ CPPUNIT_ASSERT( dest2 != NULL );
+
+ CPPUNIT_ASSERT( dest2->getTopicName() == "test1" );
+ CPPUNIT_ASSERT( dest2->getProperties().hasProperty( "value1" ) == true );
+ CPPUNIT_ASSERT( dest2->getProperties().hasProperty( "value2" ) == true );
+ CPPUNIT_ASSERT( dest2->getProperties().hasProperty( "value3" ) != true );
+
+ value1 = dest2->getProperties().getProperty( "value1" );
+ value2 = dest2->getProperties().getProperty( "value2" );
+
+ CPPUNIT_ASSERT( value1 == "1" );
+ CPPUNIT_ASSERT( value2 == "2" );
+
+ delete dest2;
+
+ MyDestination dest3("dummy");
+ dest3.copy( dest1 );
+
+ CPPUNIT_ASSERT( dest3.getTopicName() == "test1" );
+ CPPUNIT_ASSERT( dest3.getProperties().hasProperty( "value1" ) == true );
+ CPPUNIT_ASSERT( dest3.getProperties().hasProperty( "value2" ) == true );
+ CPPUNIT_ASSERT( dest3.getProperties().hasProperty( "value3" ) != true );
+
+ value1 = dest3.getProperties().getProperty( "value1" );
+ value2 = dest3.getProperties().getProperty( "value2" );
+
+ CPPUNIT_ASSERT( value1 == "1" );
+ CPPUNIT_ASSERT( value2 == "2" );
+
+ }
+
+ };
+
+}}
+
+#endif /*ACTIVEMQDESTINATIONTEST_H_*/
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/core/ActiveMQSessionTest.h Fri Jul 21 04:36:09 2006
@@ -112,15 +112,15 @@
messages.clear();
}
- virtual void onMessage( const cms::Message& message )
+ virtual void onMessage( const cms::Message* message )
{
synchronized( &mutex )
{
if( ack ){
- message.acknowledge();
+ message->acknowledge();
}
- messages.push_back( message.clone() );
+ messages.push_back( message->clone() );
mutex.notifyAll();
}
@@ -186,7 +186,7 @@
// Init Message
msg->setText( message.c_str() );
- msg->setCMSDestination( destination );
+ msg->setCMSDestination( &destination );
msg->setCMSMessageId( "Id: 123456" );
// Send the Message
@@ -219,9 +219,9 @@
// Create a consumer
cms::MessageConsumer* consumer1 =
- session->createConsumer( *topic1 );
+ session->createConsumer( topic1 );
cms::MessageConsumer* consumer2 =
- session->createConsumer( *topic2 );
+ session->createConsumer( topic2 );
CPPUNIT_ASSERT( consumer1 != NULL );
CPPUNIT_ASSERT( consumer2 != NULL );
@@ -277,6 +277,9 @@
CPPUNIT_ASSERT( text1 == "This is a Test 1" );
CPPUNIT_ASSERT( text2 == "This is a Test 2" );
+ delete topic1;
+ delete topic2;
+
delete consumer1;
delete consumer2;
@@ -292,7 +295,7 @@
// Create an Auto Ack Session
cms::Session* session = connection->createSession(
- cms::Session::ClientAcknowledge );
+ cms::Session::CLIENT_ACKNOWLEDGE );
// Create a Topic
cms::Topic* topic1 = session->createTopic( "TestTopic1");
@@ -303,9 +306,9 @@
// Create a consumer
cms::MessageConsumer* consumer1 =
- session->createConsumer( *topic1 );
+ session->createConsumer( topic1 );
cms::MessageConsumer* consumer2 =
- session->createConsumer( *topic2 );
+ session->createConsumer( topic2 );
CPPUNIT_ASSERT( consumer1 != NULL );
CPPUNIT_ASSERT( consumer2 != NULL );
@@ -365,6 +368,9 @@
CPPUNIT_ASSERT( text1 == "This is a Test 1" );
CPPUNIT_ASSERT( text2 == "This is a Test 2" );
+ delete topic1;
+ delete topic2;
+
delete consumer1;
delete consumer2;
@@ -380,7 +386,7 @@
// Create an Auto Ack Session
cms::Session* session = connection->createSession(
- cms::Session::Transactional );
+ cms::Session::SESSION_TRANSACTED );
// Create a Topic
cms::Topic* topic1 = session->createTopic( "TestTopic1");
@@ -391,9 +397,9 @@
// Create a consumer
cms::MessageConsumer* consumer1 =
- session->createConsumer( *topic1 );
+ session->createConsumer( topic1 );
cms::MessageConsumer* consumer2 =
- session->createConsumer( *topic2 );
+ session->createConsumer( topic2 );
CPPUNIT_ASSERT( consumer1 != NULL );
CPPUNIT_ASSERT( consumer2 != NULL );
@@ -544,6 +550,9 @@
}
CPPUNIT_ASSERT( msgListener2.messages.size() == msgCount );
+
+ delete topic1;
+ delete topic2;
delete consumer1;
delete consumer2;
Modified: incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h Fri Jul 21 04:36:09 2006
@@ -53,6 +53,7 @@
virtual void onCommand( Command* command ){
const MyCommand* cmd = dynamic_cast<const MyCommand*>(command);
str += cmd->c;
+ delete command;
}
};
Modified: incubator/activemq/trunk/activemq-cpp/todo.txt
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/todo.txt?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/todo.txt (original)
+++ incubator/activemq/trunk/activemq-cpp/todo.txt Fri Jul 21 04:36:09 2006
@@ -1,36 +1,39 @@
-Client Side:
-
-* Work out platform independent build system
-* Complete Logging API
-* Add Destination URL like parameter processing
-* investigate the 999 (1000) messages bug in the broker
-
-
-* integration test against real AMQ broker (DONE)
-* finish unit testing of core api (DONE)
-* refactoring of core API (DONE)
-* Resolve static initialization when used as a library. (DONE)
-* Add Message Cloning to the Commands tests. (DONE)
-* enforce connected state in stomp connector (DONE)
-* Add setting username & password to connect command (DONE)
-* Dummy Transport that acts like a broker (DONE)
-* Update Session Manager to use Transport not Connector (DONE)
-* Add Transport Factory Lookup Method (DONE)
-* Connector Interfaces Cleanup (DONE)
-
-Server Side:
-
-* Implement Connected as a response (DONE)
-* Implement use of JMSType in all messages (DONE)
-* Add Content Length to all outgoing messages (DONE)
-
-Nice to Haves:
-
-* Add Connection Id support to Stomp Transport on Broker
-* Add Consumer Id support to Stomp Transport on Broker
-* implement selector algorithm - always pass null selector to broker,
- current implementation is limited to using the selector on the
- first consumer that is subscribed to a Topic.
-* Add Durable Subscriptions to Stomp Connector. (DONE)
-
-
+Client Side:
+
+* Work out platform independent build system
+* Complete Logging API
+* Add Destination URL like parameter processing
+* investigate the 999 (1000) messages bug in the broker
+
+
+* Make the enumerations have consistant case (DONE)
+* Create a DeliveryMode class with enum values (DONE)
+* rename Session::Transactional to SESSION_TRANSACTED (DONE)
+* integration test against real AMQ broker (DONE)
+* finish unit testing of core api (DONE)
+* refactoring of core API (DONE)
+* Resolve static initialization when used as a library. (DONE)
+* Add Message Cloning to the Commands tests. (DONE)
+* enforce connected state in stomp connector (DONE)
+* Add setting username & password to connect command (DONE)
+* Dummy Transport that acts like a broker (DONE)
+* Update Session Manager to use Transport not Connector (DONE)
+* Add Transport Factory Lookup Method (DONE)
+* Connector Interfaces Cleanup (DONE)
+
+Server Side:
+
+* Implement Connected as a response (DONE)
+* Implement use of JMSType in all messages (DONE)
+* Add Content Length to all outgoing messages (DONE)
+
+Nice to Haves:
+
+* Add Connection Id support to Stomp Transport on Broker
+* Add Consumer Id support to Stomp Transport on Broker
+* implement selector algorithm - always pass null selector to broker,
+ current implementation is limited to using the selector on the
+ first consumer that is subscribed to a Topic.
+* Add Durable Subscriptions to Stomp Connector. (DONE)
+
+
Modified: incubator/activemq/trunk/activemq-cpp/unix/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/unix/pom.xml?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/unix/pom.xml (original)
+++ incubator/activemq/trunk/activemq-cpp/unix/pom.xml Fri Jul 21 04:36:09 2006
@@ -53,7 +53,7 @@
</activation>
<properties>
- <compiler.options>-frtti -pthread -O3 -DNDEBUG -D_REENTRANT</compiler.options>
+ <compiler.options>-frtti -O3 -DNDEBUG -D_REENTRANT</compiler.options>
</properties>
</profile>
@@ -68,7 +68,7 @@
</activation>
<properties>
- <compiler.options>-frtti -g -pthread -DDEBUG -D_DEBUG -D_REENTRANT</compiler.options>
+ <compiler.options>-frtti -g -DDEBUG -D_DEBUG -D_REENTRANT</compiler.options>
</properties>
</profile>
Modified: incubator/activemq/trunk/activemq-cpp/win32-gcc/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/win32-gcc/pom.xml?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/win32-gcc/pom.xml (original)
+++ incubator/activemq/trunk/activemq-cpp/win32-gcc/pom.xml Fri Jul 21 04:36:09 2006
@@ -53,7 +53,7 @@
</activation>
<properties>
- <compiler.options>-frtti -pthread -O3 -DNDEBUG -D_REENTRANT -D_WIN32 -DWINVER=0x0502 -DWIN32_LEAN_AND_MEAN</compiler.options>
+ <compiler.options>-frtti -O3 -DNDEBUG -D_REENTRANT -D_WIN32 -DWINVER=0x0502 -DWIN32_LEAN_AND_MEAN</compiler.options>
</properties>
</profile>
@@ -68,7 +68,7 @@
</activation>
<properties>
- <compiler.options>-frtti -g -pthread -DDEBUG -D_DEBUG -D_REENTRANT -D_WIN32 -DWINVER=0x0502 -DWIN32_LEAN_AND_MEAN</compiler.options>
+ <compiler.options>-frtti -g -DDEBUG -D_DEBUG -D_REENTRANT -D_WIN32 -DWINVER=0x0502 -DWIN32_LEAN_AND_MEAN</compiler.options>
</properties>
</profile>