summaryrefslogtreecommitdiff
path: root/cpp/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/bindings')
-rw-r--r--cpp/bindings/qmf/ruby/CMakeLists.txt5
-rw-r--r--cpp/bindings/qmf2/ruby/CMakeLists.txt5
-rw-r--r--cpp/bindings/qpid/python/python.i124
-rw-r--r--cpp/bindings/qpid/ruby/CMakeLists.txt5
-rw-r--r--cpp/bindings/qpid/ruby/LICENSE29
-rw-r--r--cpp/bindings/qpid/ruby/README.rdoc2
-rw-r--r--cpp/bindings/qpid/ruby/features/creating_a_receiver.feature4
-rw-r--r--cpp/bindings/qpid/ruby/features/creating_a_sender.feature6
-rw-r--r--cpp/bindings/qpid/ruby/features/receiving_a_message.feature10
-rw-r--r--cpp/bindings/qpid/ruby/features/sending_a_message.feature6
-rw-r--r--cpp/bindings/qpid/ruby/features/step_definitions/address_steps.rb7
-rw-r--r--cpp/bindings/qpid/ruby/features/step_definitions/receiver_steps.rb8
12 files changed, 117 insertions, 94 deletions
diff --git a/cpp/bindings/qmf/ruby/CMakeLists.txt b/cpp/bindings/qmf/ruby/CMakeLists.txt
index 4b6ba2c1c3..702606139b 100644
--- a/cpp/bindings/qmf/ruby/CMakeLists.txt
+++ b/cpp/bindings/qmf/ruby/CMakeLists.txt
@@ -21,13 +21,12 @@
## Use Swig to generate a literal binding to the C++ API
##------------------------------------------------------
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include")
+
+include_directories(${RUBY_INCLUDE_DIRS} ${qpid-cpp_SOURCE_DIR}/include)
swig_add_module(qmfengine_ruby ruby ${CMAKE_CURRENT_SOURCE_DIR}/ruby.i)
swig_link_libraries(qmfengine_ruby qmf qmfconsole ${RUBY_LIBRARY})
-set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-I${RUBY_INCLUDE_DIR} -I${qpid-cpp_SOURCE_DIR}/include")
-
##----------------------------------
## Install the complete Ruby binding
##----------------------------------
diff --git a/cpp/bindings/qmf2/ruby/CMakeLists.txt b/cpp/bindings/qmf2/ruby/CMakeLists.txt
index 3bc97cf35f..1cb969f7dc 100644
--- a/cpp/bindings/qmf2/ruby/CMakeLists.txt
+++ b/cpp/bindings/qmf2/ruby/CMakeLists.txt
@@ -21,13 +21,12 @@
## Use Swig to generate a literal binding to the C++ API
##------------------------------------------------------
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include")
+
+include_directories(${RUBY_INCLUDE_DIRS} ${qpid-cpp_SOURCE_DIR}/include)
swig_add_module(cqmf2_ruby ruby ${CMAKE_CURRENT_SOURCE_DIR}/ruby.i)
swig_link_libraries(cqmf2_ruby qmf2 ${RUBY_LIBRARY})
-set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-I${RUBY_INCLUDE_DIR} -I${qpid-cpp_SOURCE_DIR}/include")
-
##----------------------------------
## Install the complete Ruby binding
##----------------------------------
diff --git a/cpp/bindings/qpid/python/python.i b/cpp/bindings/qpid/python/python.i
index a53cf3b853..4d8a64b376 100644
--- a/cpp/bindings/qpid/python/python.i
+++ b/cpp/bindings/qpid/python/python.i
@@ -33,41 +33,68 @@
* names as in the C++ library. They get renamed to their Python
* equivalents when brought into the Python wrapping
*/
+%define QPID_EXCEPTION(exception, parent)
%{
-static PyObject* pNoMessageAvailable;
-static PyObject* pTargetCapacityExceeded;
-static PyObject* pNotFound;
-static PyObject* pTransportFailure;
+static PyObject* exception;
%}
-
%init %{
- pNoMessageAvailable = PyErr_NewException(
- "_cqpid.NoMessageAvailable", NULL, NULL);
- Py_INCREF(pNoMessageAvailable);
- PyModule_AddObject(m, "NoMessageAvailable", pNoMessageAvailable);
-
- pTargetCapacityExceeded = PyErr_NewException(
- "_cqpid.TargetCapacityExceeded", NULL, NULL);
- Py_INCREF(pTargetCapacityExceeded);
- PyModule_AddObject(m, "TargetCapacityExceeded", pTargetCapacityExceeded);
-
- pNotFound = PyErr_NewException(
- "_cqpid.NotFound", NULL, NULL);
- Py_INCREF(pNotFound);
- PyModule_AddObject(m, "NotFound", pNotFound);
-
- pTransportFailure = PyErr_NewException(
- "_cqpid.TransportFailure", NULL, NULL);
- Py_INCREF(pTransportFailure);
- PyModule_AddObject(m, "TransportFailure", pTransportFailure);
+ exception = PyErr_NewException(
+ (char *) ("_cqpid." #exception), parent, NULL);
+ Py_INCREF(exception);
+ PyModule_AddObject(m, #exception, exception);
%}
-
%pythoncode %{
- Empty = _cqpid.NoMessageAvailable
- TargetCapacityExceeded = _cqpid.TargetCapacityExceeded
- NotFound = _cqpid.NotFound
- ConnectError = _cqpid.TransportFailure
+ exception = _cqpid. ## exception
%}
+%enddef
+
+ /* Python equivalents of C++ exceptions. */
+ /* */
+ /* Commented out lines are exceptions in the Python library, but not */
+ /* in the C++ library. */
+
+QPID_EXCEPTION(MessagingError, NULL)
+
+QPID_EXCEPTION(LinkError, MessagingError)
+QPID_EXCEPTION(AddressError, LinkError)
+QPID_EXCEPTION(ResolutionError, AddressError)
+QPID_EXCEPTION(AssertionFailed, ResolutionError)
+QPID_EXCEPTION(NotFound, ResolutionError)
+QPID_EXCEPTION(InvalidOption, LinkError)
+QPID_EXCEPTION(MalformedAddress, LinkError)
+QPID_EXCEPTION(ReceiverError, LinkError)
+QPID_EXCEPTION(FetchError, ReceiverError)
+QPID_EXCEPTION(Empty, FetchError)
+/* QPID_EXCEPTION(InsufficientCapacity, LinkError) */
+/* QPID_EXCEPTION(LinkClosed, LinkError) */
+QPID_EXCEPTION(SenderError, LinkError)
+QPID_EXCEPTION(SendError, SenderError)
+QPID_EXCEPTION(TargetCapacityExceeded, SendError)
+
+QPID_EXCEPTION(ConnectionError, MessagingError)
+QPID_EXCEPTION(ConnectError, ConnectionError)
+/* QPID_EXCEPTION(AuthenticationFailure, ConnectError) */
+/* QPID_EXCEPTION(VersionError, ConnectError) */
+/* QPID_EXCEPTION(ConnectionClosed, ConnectionError) */
+/* QPID_EXCEPTION(HeartbeartTimeout, ConnectionError) */
+
+QPID_EXCEPTION(SessionError, MessagingError)
+/* QPID_EXCEPTION(Detached, SessionError) */
+/* QPID_EXCEPTION(NontransactionalSession, SessionError) */
+/* QPID_EXCEPTION(ServerError, SessionError) */
+/* QPID_EXCEPTION(SessionClosed, SessionError) */
+QPID_EXCEPTION(TransactionError, SessionError)
+QPID_EXCEPTION(TransactionAborted, TransactionError)
+QPID_EXCEPTION(UnauthorizedAccess, SessionError)
+
+/* QPID_EXCEPTION(InternalError, MessagingError) */
+
+%define TRANSLATE_EXCEPTION(cpp_exception, py_exception)
+ catch ( cpp_exception & ex) {
+ pExceptionType = py_exception;
+ error = ex.what();
+ }
+%enddef
/* Define the general-purpose exception handling */
%exception {
@@ -76,22 +103,31 @@ static PyObject* pTransportFailure;
Py_BEGIN_ALLOW_THREADS;
try {
$action
- } catch (qpid::messaging::NoMessageAvailable & ex) {
- pExceptionType = pNoMessageAvailable;
- error = ex.what();
- } catch (qpid::messaging::TargetCapacityExceeded & ex) {
- pExceptionType = pTargetCapacityExceeded;
- error = ex.what();
- } catch (qpid::messaging::NotFound & ex) {
- pExceptionType = pNotFound;
- error = ex.what();
- } catch (qpid::messaging::TransportFailure & ex) {
- pExceptionType = pTransportFailure;
- error = ex.what();
- } catch (qpid::types::Exception& ex) {
- pExceptionType = PyExc_RuntimeError;
- error = ex.what();
}
+ /* Catch and translate exceptions. */
+ TRANSLATE_EXCEPTION(qpid::messaging::NoMessageAvailable, Empty)
+ TRANSLATE_EXCEPTION(qpid::messaging::NotFound, NotFound)
+ TRANSLATE_EXCEPTION(qpid::messaging::AssertionFailed, AssertionFailed)
+ TRANSLATE_EXCEPTION(qpid::messaging::ResolutionError, ResolutionError)
+ TRANSLATE_EXCEPTION(qpid::messaging::TargetCapacityExceeded,
+ TargetCapacityExceeded)
+ TRANSLATE_EXCEPTION(qpid::messaging::TransportFailure, ConnectError)
+ TRANSLATE_EXCEPTION(qpid::messaging::MalformedAddress, MalformedAddress)
+ TRANSLATE_EXCEPTION(qpid::messaging::AddressError, AddressError)
+ TRANSLATE_EXCEPTION(qpid::messaging::FetchError, FetchError)
+ TRANSLATE_EXCEPTION(qpid::messaging::ReceiverError, ReceiverError)
+ TRANSLATE_EXCEPTION(qpid::messaging::SendError, SendError)
+ TRANSLATE_EXCEPTION(qpid::messaging::SenderError, SenderError)
+ TRANSLATE_EXCEPTION(qpid::messaging::InvalidOptionString, InvalidOption)
+ TRANSLATE_EXCEPTION(qpid::messaging::LinkError, LinkError)
+ TRANSLATE_EXCEPTION(qpid::messaging::TransactionAborted, TransactionAborted)
+ TRANSLATE_EXCEPTION(qpid::messaging::TransactionError, TransactionError)
+ TRANSLATE_EXCEPTION(qpid::messaging::UnauthorizedAccess, UnauthorizedAccess)
+ TRANSLATE_EXCEPTION(qpid::messaging::SessionError, SessionError)
+ TRANSLATE_EXCEPTION(qpid::messaging::ConnectionError, ConnectionError)
+ TRANSLATE_EXCEPTION(qpid::messaging::KeyError, PyExc_KeyError)
+ TRANSLATE_EXCEPTION(qpid::messaging::MessagingException, MessagingError)
+ TRANSLATE_EXCEPTION(qpid::types::Exception, PyExc_RuntimeError)
Py_END_ALLOW_THREADS;
if (!error.empty()) {
PyErr_SetString(pExceptionType, error.c_str());
diff --git a/cpp/bindings/qpid/ruby/CMakeLists.txt b/cpp/bindings/qpid/ruby/CMakeLists.txt
index 8a8c88b595..9b32ff5728 100644
--- a/cpp/bindings/qpid/ruby/CMakeLists.txt
+++ b/cpp/bindings/qpid/ruby/CMakeLists.txt
@@ -30,12 +30,13 @@ set(GEM_OUTPUT_FILE ${GEM_OUTPUT_PATH}/pkg/qpid-${qpidc_version}.0.gem)
## Use Swig to generate a literal binding to the C++ API
##------------------------------------------------------
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include")
+
+include_directories(${RUBY_INCLUDE_DIRS} ${qpid-cpp_SOURCE_DIR}/include)
swig_add_module(cqpid_ruby ruby ${CMAKE_CURRENT_SOURCE_DIR}/ruby.i)
swig_link_libraries(cqpid_ruby qpidmessaging qpidtypes qmf2 ${RUBY_LIBRARY})
-set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -I${RUBY_INCLUDE_DIR} -I${qpid-cpp_SOURCE_DIR}/include")
+set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
##----------------------------------
## Install the complete Ruby binding
diff --git a/cpp/bindings/qpid/ruby/LICENSE b/cpp/bindings/qpid/ruby/LICENSE
index cff2a5e25d..232fd660d6 100644
--- a/cpp/bindings/qpid/ruby/LICENSE
+++ b/cpp/bindings/qpid/ruby/LICENSE
@@ -203,32 +203,3 @@
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.
-
-=========================================================================
-== Boost License ==
-=========================================================================
-
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
diff --git a/cpp/bindings/qpid/ruby/README.rdoc b/cpp/bindings/qpid/ruby/README.rdoc
index 478fc939d9..5c60a15588 100644
--- a/cpp/bindings/qpid/ruby/README.rdoc
+++ b/cpp/bindings/qpid/ruby/README.rdoc
@@ -2,7 +2,7 @@
Qpid is an cross-platform enterprise messaging system.
-Version :: 0.17.0
+Version :: 0.19.0
= Links
diff --git a/cpp/bindings/qpid/ruby/features/creating_a_receiver.feature b/cpp/bindings/qpid/ruby/features/creating_a_receiver.feature
index f509f49115..1f758153af 100644
--- a/cpp/bindings/qpid/ruby/features/creating_a_receiver.feature
+++ b/cpp/bindings/qpid/ruby/features/creating_a_receiver.feature
@@ -21,9 +21,9 @@ Feature: Creating a receiver
Scenario: The address string is fine
Given an open session
- Then creating a receiver with "my-queue;{create:always}" succeeds
+ Then creating a receiver with "my-queue;{create:always,delete:always}" succeeds
Scenario: Using an Address object
Given an open session
- And an Address with the name "create-receiver-test" and subject "foo" and option "create" set to "always"
+ And an Address with the name "create-receiver-test" and subject "foo" and option "create" set to "always" and "delete" set to "always"
Then creating a receiver with an Address succeeds
diff --git a/cpp/bindings/qpid/ruby/features/creating_a_sender.feature b/cpp/bindings/qpid/ruby/features/creating_a_sender.feature
index ac75543c2d..1c09ff837d 100644
--- a/cpp/bindings/qpid/ruby/features/creating_a_sender.feature
+++ b/cpp/bindings/qpid/ruby/features/creating_a_sender.feature
@@ -5,11 +5,11 @@ Feature: Creating a sender
Scenario: The session is closed
Given a closed session
- Then creating a sender with "my-queue;{create:always}" raises an exception
+ Then creating a sender with "my-queue;{create:always,delete:always}" raises an exception
Scenario: The connection is closed
Given an open session with a closed connection
- Then creating a sender with "my-queue;{create:always}" raises an exception
+ Then creating a sender with "my-queue;{create:always,delete:always}" raises an exception
Scenario: The address is malformed
Given an open session
@@ -17,7 +17,7 @@ Feature: Creating a sender
Scenario: The address string is valid
Given an open session
- Then creating a sender with "my-queue;{create:always}" succeeds
+ Then creating a sender with "my-queue;{create:always,delete:always}" succeeds
Scenario: Using an Address object
Given an open session
diff --git a/cpp/bindings/qpid/ruby/features/receiving_a_message.feature b/cpp/bindings/qpid/ruby/features/receiving_a_message.feature
index b68a78c337..7b6db4a5ac 100644
--- a/cpp/bindings/qpid/ruby/features/receiving_a_message.feature
+++ b/cpp/bindings/qpid/ruby/features/receiving_a_message.feature
@@ -4,24 +4,26 @@ Feature: Receving a message
I need to be able to receive messages
Scenario: Receiving after the session is closed
- Given a sender and receiver for "my-queue;{create:always}"
+ Given a sender and receiver for "my-queue;{create:always,delete:always}"
And the message "this is a test" is sent
And the session is closed
Then getting the next message raises an error
Scenario: Receiving after the connection is closed
- Given a sender and receiver for "my-queue;{create:always}"
+ Given a sender and receiver for "my-queue;{create:always,delete:always}"
And the message "this is a test" is sent
And the connection is closed
Then getting the next message raises an error
Scenario: No message is received on an empty queue
- Given an existing receiver for "my-queue;{create:always}"
+ Given an existing receiver for "my-queue;{create:always,delete:always}"
And the receiver has no pending messages
Then getting the next message raises an error
Scenario: A message is pending
- Given a sender and receiver for "my-queue;{create:always}"
+ Given an open session
+ And given a sender for "my-queue;{create:always}"
+ And given a receiver for "my-queue;{create:always,delete:always}"
And the receiver has a capacity of 1
And the message "this is a test" is sent
Then the receiver should have 1 message available
diff --git a/cpp/bindings/qpid/ruby/features/sending_a_message.feature b/cpp/bindings/qpid/ruby/features/sending_a_message.feature
index b1127d3664..45cbd42f06 100644
--- a/cpp/bindings/qpid/ruby/features/sending_a_message.feature
+++ b/cpp/bindings/qpid/ruby/features/sending_a_message.feature
@@ -5,17 +5,17 @@ Feature: Sending a message
Scenario: The session is closed
Given an open session
- And creating a sender with "my-queue;{create:always}" succeeds
+ And creating a sender with "my-queue;{create:always,delete:always}" succeeds
And the session is closed
Then sending the message "This is a test" should raise an error
Scenario: The connection is closed
Given an open session
- And creating a sender with "my-queue;{create:always}" succeeds
+ And creating a sender with "my-queue;{create:always,delete:always}" succeeds
And the connection is closed
Then sending the message "This is a test" should raise an error
Scenario: The message sends successfully
Given an open session
- And creating a sender with "my-queue;{create:always}" succeeds
+ And creating a sender with "my-queue;{create:always,delete:always}" succeeds
Then sending the message "This is a test" succeeds \ No newline at end of file
diff --git a/cpp/bindings/qpid/ruby/features/step_definitions/address_steps.rb b/cpp/bindings/qpid/ruby/features/step_definitions/address_steps.rb
index 845cc2b116..0531e5ee69 100644
--- a/cpp/bindings/qpid/ruby/features/step_definitions/address_steps.rb
+++ b/cpp/bindings/qpid/ruby/features/step_definitions/address_steps.rb
@@ -22,3 +22,10 @@ Given /^an Address with the name "([^"]*)" and subject "([^"]*)" and option "([^
options["#{key}"] = "#{value}"
@address = Qpid::Messaging::Address.new "#{name}", "#{subject}", options
end
+
+Given /^an Address with the name "([^"]*)" and subject "([^"]*)" and option "([^"]*)" set to "([^"]*)" and "([^"]*)" set to "([^"]*)"$/ do |name, subject, key1, value1, key2, value2|
+ options = Hash.new
+ options["#{key1}"] = "#{value1}"
+ options["#{key2}"] = "#{value2}"
+ @address = Qpid::Messaging::Address.new "#{name}", "#{subject}", options
+end
diff --git a/cpp/bindings/qpid/ruby/features/step_definitions/receiver_steps.rb b/cpp/bindings/qpid/ruby/features/step_definitions/receiver_steps.rb
index a8c8aa4a43..e454dac345 100644
--- a/cpp/bindings/qpid/ruby/features/step_definitions/receiver_steps.rb
+++ b/cpp/bindings/qpid/ruby/features/step_definitions/receiver_steps.rb
@@ -59,3 +59,11 @@ Then /^the receiver should have (\d+) message available$/ do |available|
sleep 1
@receiver.available.should == available.to_i
end
+
+Given /^given a sender for "([^"]*)"$/ do |address|
+ @sender = @session.create_sender "#{address}"
+end
+
+Given /^given a receiver for "([^"]*)"$/ do |address|
+ @receiver = @session.create_receiver "#{address}"
+end