Author: tabish
Date: Tue Dec 15 19:35:28 2009
New Revision: 890958
URL: http://svn.apache.org/viewvc?rev=890958&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-272
1. Add the UnsupportedOperationException type to CMS.
2. Update the MessageProducer interface to indicate what exceptions are thrown
from the send methods.
3. Fix the ActiveMQProducer class to throw the correct exceptions:
A. UnsupportedOperationException if called with a NULL Destination and
there's not default
B. UnsupportedOperationException if called with a Destination that is
not the default when one was specified.
C. InvalidDestinatioException if there's a default but Null is passed.
4. Adds new Integration tests to cover the cases outlined above.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp
(with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h
(with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt
activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/RELEASE_NOTES.txt Tue Dec 15
19:35:28 2009
@@ -25,6 +25,8 @@
std::size_t offset, std::size_t len )
* [AMQCPP-270] - Broker exception on message Ack,
* [AMQCPP-271] - Connection shutdown crashes if the server went down
+ * [AMQCPP-272] - MessageProducer is not throwing correct exceptions when
called with
+ invalid arguments.
Improvement
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Tue Dec 15
19:35:28 2009
@@ -475,6 +475,7 @@
cms/MessageFormatException.cpp \
cms/MessageNotReadableException.cpp \
cms/MessageNotWriteableException.cpp \
+ cms/UnsupportedOperationException.cpp \
decaf/internal/AprPool.cpp \
decaf/internal/DecafRuntime.cpp \
decaf/internal/io/StandardErrorOutputStream.cpp \
@@ -1083,6 +1084,7 @@
cms/TemporaryTopic.h \
cms/TextMessage.h \
cms/Topic.h \
+ cms/UnsupportedOperationException.h \
decaf/internal/AprPool.h \
decaf/internal/DecafRuntime.h \
decaf/internal/io/StandardErrorOutputStream.h \
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
Tue Dec 15 19:35:28 2009
@@ -592,7 +592,7 @@
this->getTransport().oneway( command );
}
AMQ_CATCH_EXCEPTION_CONVERT( IOException, ActiveMQException )
- AMQ_CATCH_EXCEPTION_CONVERT( UnsupportedOperationException,
ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT(
decaf::lang::exceptions::UnsupportedOperationException, ActiveMQException )
AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
@@ -627,7 +627,7 @@
}
AMQ_CATCH_RETHROW( ActiveMQException )
AMQ_CATCH_EXCEPTION_CONVERT( IOException, ActiveMQException )
- AMQ_CATCH_EXCEPTION_CONVERT( UnsupportedOperationException,
ActiveMQException )
+ AMQ_CATCH_EXCEPTION_CONVERT(
decaf::lang::exceptions::UnsupportedOperationException, ActiveMQException )
AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
Tue Dec 15 19:35:28 2009
@@ -90,65 +90,59 @@
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQProducer::send( cms::Message* message )
- throw ( cms::CMSException ) {
+void ActiveMQProducer::send( cms::Message* message ) throw ( cms::CMSException,
+
cms::MessageFormatException,
+
cms::InvalidDestinationException,
+
cms::UnsupportedOperationException ) {
try {
this->checkClosed();
- if( this->destination.get() == NULL ) {
- throw ActiveMQException(
- __FILE__, __LINE__,
- "ActiveMQProducer::send - "
- "Producer has no Destination, must call send( dest, msg )" );
- }
-
this->send( this->destination.get(), message );
}
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQProducer::send( cms::Message* message, int deliveryMode,
- int priority, long long timeToLive )
- throw ( cms::CMSException ) {
+void ActiveMQProducer::send( cms::Message* message, int deliveryMode, int
priority, long long timeToLive )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) {
+
try {
this->checkClosed();
- if( this->destination.get() == NULL ) {
- throw ActiveMQException(
- __FILE__, __LINE__,
- "ActiveMQProducer::send - "
- "Producer has no Destination, must call send( dest, msg )" );
- }
-
- this->send( this->destination.get(), message, deliveryMode,
- priority, timeToLive );
+ this->send( this->destination.get(), message, deliveryMode, priority,
timeToLive );
}
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQProducer::send( const cms::Destination* destination,
- cms::Message* message ) throw ( cms::CMSException
) {
+void ActiveMQProducer::send( const cms::Destination* destination,
cms::Message* message )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) {
try {
this->checkClosed();
- this->send( destination, message, defaultDeliveryMode,
- defaultPriority, defaultTimeToLive );
+ this->send( destination, message, defaultDeliveryMode,
defaultPriority, defaultTimeToLive );
}
AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
}
////////////////////////////////////////////////////////////////////////////////
-void ActiveMQProducer::send( const cms::Destination* destination,
- cms::Message* message, int deliveryMode,
- int priority, long long timeToLive )
- throw ( cms::CMSException ) {
+void ActiveMQProducer::send( const cms::Destination* destination,
cms::Message* message,
+ int deliveryMode, int priority, long long
timeToLive )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) {
try {
@@ -156,19 +150,39 @@
if( destination == NULL ) {
- throw ActiveMQException(
- __FILE__, __LINE__,
- "ActiveMQProducer::send - Attempting to send on NULL
destination");
+ if( this->producerInfo->getDestination() == NULL ) {
+ throw cms::UnsupportedOperationException( "A destination must
be specified.", NULL );
+ }
+
+ throw cms::InvalidDestinationException( "Don't understand null
destinations", NULL );
+ }
+
+ const cms::Destination* dest;
+ if( destination == dynamic_cast<cms::Destination*>(
this->producerInfo->getDestination().get() ) ) {
+ dest = destination;
+ } else if( this->producerInfo->getDestination() == NULL ) {
+
+ // TODO - We should apply a Transform so ensure the user hasn't
create some
+ // external cms::Destination implementation.
+ dest = destination;
+ } else {
+ throw cms::UnsupportedOperationException( string( "This producer
can only send messages to: " ) +
+
this->producerInfo->getDestination()->getPhysicalName(), NULL );
+ }
+
+ if( dest == NULL ) {
+ throw cms::CMSException( "No destination specified", NULL );
}
// configure the message
- message->setCMSDestination( destination );
+ message->setCMSDestination( dest );
message->setCMSDeliveryMode( deliveryMode );
message->setCMSPriority( priority );
long long expiration = 0LL;
if( !disableTimestamps ) {
+
long long timeStamp = System::currentTimeMillis();
message->setCMSTimestamp( timeStamp );
if( timeToLive > 0LL ) {
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
Tue Dec 15 19:35:28 2009
@@ -102,50 +102,102 @@
virtual void close() throw ( cms::CMSException );
/**
- * Sends the message to the default producer destination.
- * @param message A Message Object Pointer for the Message to send.
- * @throws CMSException
- */
- virtual void send( cms::Message* message ) throw ( cms::CMSException );
+ * Sends the message to the default producer destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * Uses default values for deliveryMode, priority, and time to live.
+ *
+ * @param message
+ * The message to be sent.
+ *
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( cms::Message* message ) throw ( cms::CMSException,
+
cms::MessageFormatException,
+
cms::InvalidDestinationException,
+
cms::UnsupportedOperationException );
/**
* Sends the message to the default producer destination, but does
* not take ownership of the message, caller must still destroy it.
- * @param message A Message Object Pointer
- * @param deliveryMode The delivery mode to be used.
- * @param priority The priority for this message.
- * @param timeToLive The time to live value for this message in
- * milliseconds.
- * @throws CMSException
- */
- virtual void send( cms::Message* message, int deliveryMode,
- int priority, long long timeToLive )
- throw ( cms::CMSException );
-
- /**
- * Sends the message to the designated destination.
- * @param destination The CMS Destination that defines where the
message is sent.
- * @param message A Message Object Pointer
- * @throws CMSException
- */
- virtual void send( const cms::Destination* destination,
- cms::Message* message ) throw ( cms::CMSException );
+ *
+ * @param message
+ * The message to be sent.
+ * @param deliveryMode
+ * The delivery mode to be used.
+ * @param priority
+ * The priority for this message.
+ * @param timeToLive
+ * The time to live value for this message in milliseconds.
+ *
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( cms::Message* message, int deliveryMode, int
priority, long long timeToLive )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException );
+
+ /**
+ * Sends the message to the designated destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * Uses default values for deliveryMode, priority, and time to live.
+ *
+ * @param destination
+ * The destination on which to send the message
+ * @param message
+ * the message to be sent.
+ *
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( const cms::Destination* destination, cms::Message*
message )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException );
/**
* Sends the message to the designated destination, but does
* not take ownership of the message, caller must still destroy it.
- * @param destination - a Message Object Pointer
- * @param message - a Message Object Pointer
- * @param deliveryMode The delivery mode to be used.
- * @param priority The priority for this message.
- * @param timeToLive The time to live value for this message in
- * milliseconds.
- * @throws CMSException
- */
- virtual void send( const cms::Destination* destination,
- cms::Message* message, int deliveryMode,
- int priority, long long timeToLive )
- throw ( cms::CMSException );
+ *
+ * @param destination
+ * The destination on which to send the message
+ * @param message
+ * The message to be sent.
+ * @param deliveryMode
+ * The delivery mode to be used.
+ * @param priority
+ * The priority for this message.
+ * @param timeToLive
+ * The time to live value for this message in milliseconds.
+ *
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( const cms::Destination* destination, cms::Message*
message,
+ int deliveryMode, int priority, long long
timeToLive )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException );
/**
* Sets the delivery mode for this Producer
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/CMSExceptionSupport.h
Tue Dec 15 19:35:28 2009
@@ -30,6 +30,7 @@
#include <cms/InvalidDestinationException.h>
#include <cms/InvalidSelectorException.h>
#include <cms/IllegalStateException.h>
+#include <cms/UnsupportedOperationException.h>
#include <decaf/lang/Exception.h>
@@ -93,6 +94,9 @@
} catch( cms::MessageNotWriteableException& ex ){ \
ex.setMark( __FILE__, __LINE__ ); \
throw ex; \
+ } catch( cms::UnsupportedOperationException& ex ){ \
+ ex.setMark( __FILE__, __LINE__ ); \
+ throw ex; \
} catch( cms::CMSException& ex ){ \
ex.setMark( __FILE__, __LINE__ ); \
throw ex; \
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h Tue
Dec 15 19:35:28 2009
@@ -23,6 +23,9 @@
#include <cms/Destination.h>
#include <cms/Closeable.h>
#include <cms/CMSException.h>
+#include <cms/InvalidDestinationException.h>
+#include <cms/MessageFormatException.h>
+#include <cms/UnsupportedOperationException.h>
#include <cms/DeliveryMode.h>
namespace cms{
@@ -64,9 +67,17 @@
* @param message
* The message to be sent.
*
- * @throws CMSException - if an internal error occurs.
- */
- virtual void send( Message* message ) throw ( CMSException ) = 0;
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( Message* message ) throw ( cms::CMSException,
+
cms::MessageFormatException,
+
cms::InvalidDestinationException,
+
cms::UnsupportedOperationException ) = 0;
/**
* Sends the message to the default producer destination, but does
@@ -81,10 +92,18 @@
* @param timeToLive
* The time to live value for this message in milliseconds.
*
- * @throws CMSException - if an internal error occurs.
- */
- virtual void send( Message* message, int deliveryMode, int priority,
- long long timeToLive) throw ( CMSException ) = 0;
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
+ */
+ virtual void send( Message* message, int deliveryMode, int priority,
long long timeToLive )
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) = 0;
/**
* Sends the message to the designated destination, but does
@@ -96,10 +115,18 @@
* @param message
* the message to be sent.
*
- * @throws CMSException - if an internal error occurs.
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
*/
virtual void send( const Destination* destination, Message* message )
- throw ( CMSException ) = 0;
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) = 0;
/**
* Sends the message to the designated destination, but does
@@ -116,11 +143,19 @@
* @param timeToLive
* The time to live value for this message in milliseconds.
*
- * @throws CMSException - if an internal error occurs.
+ * @throws CMSException - if an internal error occurs while sending
the message.
+ * @throws MessageFormatException - if an Invalid Message is given.
+ * @throws InvalidDestinationException - if a client uses this method
with a
+ * MessageProducer with an invalid destination.
+ * @throws UnsupportedOperationException - if a client uses this
method with a
+ * MessageProducer that did not specify a destination at
creation time.
*/
virtual void send( const Destination* destination, Message* message,
int deliveryMode, int priority, long long
timeToLive )
- throw ( CMSException ) = 0;
+ throw ( cms::CMSException,
+ cms::MessageFormatException,
+ cms::InvalidDestinationException,
+ cms::UnsupportedOperationException ) = 0;
/**
* Sets the delivery mode for this Producer
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp?rev=890958&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp
Tue Dec 15 19:35:28 2009
@@ -0,0 +1,45 @@
+/*
+ * 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 "UnsupportedOperationException.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+UnsupportedOperationException::UnsupportedOperationException() throw() :
CMSException() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+UnsupportedOperationException::UnsupportedOperationException( const
UnsupportedOperationException& ex )
+ throw() : CMSException( ex ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+UnsupportedOperationException::UnsupportedOperationException( const
std::string& message, const std::exception* cause )
+ throw() : CMSException( message, cause ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+UnsupportedOperationException::UnsupportedOperationException( const
std::string& message,
+ const
std::exception* cause,
+ const
std::vector< std::pair< std::string, int> >& stackTrace )
+ throw() : CMSException( message, cause, stackTrace ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+UnsupportedOperationException::~UnsupportedOperationException() throw() {
+}
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h?rev=890958&view=auto
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h
(added)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h
Tue Dec 15 19:35:28 2009
@@ -0,0 +1,52 @@
+/*
+ * 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 _CMS_UNSUPPORTEDOPERATIONEXCEPTION_H_
+#define _CMS_UNSUPPORTEDOPERATIONEXCEPTION_H_
+
+#include <cms/Config.h>
+#include <cms/CMSException.h>
+
+namespace cms {
+
+ /**
+ * This exception must be thrown when a CMS client attempts use a CMS
method that is not
+ * implemented or not supported by the CMS Provider in use.
+ *
+ * @since 2.0
+ */
+ class CMS_API UnsupportedOperationException : public CMSException {
+ public:
+
+ UnsupportedOperationException() throw();
+
+ UnsupportedOperationException( const UnsupportedOperationException& ex
) throw();
+
+ UnsupportedOperationException( const std::string& message,
+ const std::exception* cause ) throw();
+
+ UnsupportedOperationException( const std::string& message,
+ const std::exception* cause,
+ const std::vector< std::pair<
std::string, int> >& stackTrace ) throw();
+
+ virtual ~UnsupportedOperationException() throw();
+
+ };
+
+}
+
+#endif /* _CMS_UNSUPPORTEDOPERATIONEXCEPTION_H_ */
Propchange:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/UnsupportedOperationException.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
Tue Dec 15 19:35:28 2009
@@ -138,6 +138,53 @@
}
////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testProducerSendWithNullDestination() {
+
+ // Create CMS Object for Comms
+ cms::Session* session( cmsProvider->getSession() );
+
+ CMSListener listener( session );
+
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST
MESSAGE" ) );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw an InvalidDestinationException",
+ producer->send( NULL, txtMessage.get() ),
+ cms::InvalidDestinationException );
+
+ producer = cmsProvider->getNoDestProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw an UnsupportedOperationException",
+ producer->send( NULL, txtMessage.get() ),
+ cms::UnsupportedOperationException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testProducerSendToNonDefaultDestination() {
+
+ // Create CMS Object for Comms
+ cms::Session* session( cmsProvider->getSession() );
+
+ CMSListener listener( session );
+
+ cms::MessageProducer* producer = cmsProvider->getProducer();
+ producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+ auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST
MESSAGE" ) );
+ auto_ptr<cms::Destination> destination( session->createTemporaryTopic() );
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "Should Throw an UnsupportedOperationException",
+ producer->send( destination.get(), txtMessage.get() ),
+ cms::UnsupportedOperationException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
void SimpleTest::testSyncReceive() {
try {
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
Tue Dec 15 19:35:28 2009
@@ -33,6 +33,8 @@
virtual void testAutoAck();
virtual void testClientAck();
virtual void testProducerWithNullDestination();
+ virtual void testProducerSendWithNullDestination();
+ virtual void testProducerSendToNonDefaultDestination();
virtual void testSyncReceive();
virtual void testSyncReceiveClientAck();
virtual void testMultipleConnections();
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h?rev=890958&r1=890957&r2=890958&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
(original)
+++
activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
Tue Dec 15 19:35:28 2009
@@ -30,6 +30,8 @@
CPPUNIT_TEST( testAutoAck );
CPPUNIT_TEST( testClientAck );
CPPUNIT_TEST( testProducerWithNullDestination );
+ CPPUNIT_TEST( testProducerSendWithNullDestination );
+ CPPUNIT_TEST( testProducerSendToNonDefaultDestination );
CPPUNIT_TEST( testSyncReceive );
CPPUNIT_TEST( testSyncReceiveClientAck );
CPPUNIT_TEST( testMultipleConnections );