qpid_messaging 0.20.2 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/LICENSE +0 -4
- data/README.rdoc +15 -20
- data/TODO +10 -5
- data/ext/cqpid/cqpid.cpp +156 -40
- data/ext/cqpid/extconf.rb +10 -2
- data/lib/qpid_messaging.rb +56 -3
- data/lib/qpid_messaging/address.rb +51 -28
- data/lib/qpid_messaging/connection.rb +75 -46
- data/lib/qpid_messaging/duration.rb +49 -14
- data/lib/qpid_messaging/encoding.rb +5 -5
- data/lib/qpid_messaging/message.rb +61 -68
- data/lib/qpid_messaging/receiver.rb +62 -67
- data/lib/qpid_messaging/sender.rb +39 -56
- data/lib/qpid_messaging/session.rb +78 -81
- metadata +51 -61
- data/Rakefile +0 -137
- data/features/closing_a_connection.feature +0 -13
- data/features/closing_a_session.feature +0 -13
- data/features/connecting_to_a_broker.feature +0 -13
- data/features/creating_a_receiver.feature +0 -29
- data/features/creating_a_sender.feature +0 -25
- data/features/creating_a_session.feature +0 -12
- data/features/getting_the_connections_authenticated_username.feature +0 -8
- data/features/receiving_a_message.feature +0 -30
- data/features/sending_a_message.feature +0 -21
- data/features/session_returns_its_connection.feature +0 -12
- data/features/sessions_have_names.feature +0 -8
- data/features/step_definitions/address_steps.rb +0 -22
- data/features/step_definitions/connection_steps.rb +0 -93
- data/features/step_definitions/receiver_steps.rb +0 -69
- data/features/step_definitions/sender_steps.rb +0 -34
- data/features/step_definitions/session_steps.rb +0 -99
- data/features/support/env.rb +0 -22
- data/lib/qpid_messaging/errors.rb +0 -33
- data/lib/qpid_messaging/version.rb +0 -31
- data/spec/qpid_messaging/address_spec.rb +0 -87
- data/spec/qpid_messaging/connection_spec.rb +0 -191
- data/spec/qpid_messaging/duration_spec.rb +0 -56
- data/spec/qpid_messaging/encoding_spec.rb +0 -63
- data/spec/qpid_messaging/message_spec.rb +0 -305
- data/spec/qpid_messaging/receiver_spec.rb +0 -170
- data/spec/qpid_messaging/sender_spec.rb +0 -135
- data/spec/qpid_messaging/session_spec.rb +0 -353
- data/spec/spec_helper.rb +0 -20
@@ -1,69 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Given /^an existing receiver for "([^"]*)"$/ do |address|
|
21
|
-
steps %Q{
|
22
|
-
Given an open session
|
23
|
-
Then creating a receiver with "#{address}" succeeds
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
Given /^the receiver has no pending messages$/ do
|
28
|
-
available = @receiver.available
|
29
|
-
available.should == 0
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^getting the next message raises an error$/ do
|
33
|
-
lambda {
|
34
|
-
@message = @receiver.get Qpid::Messaging::Duration::IMMEDIATE
|
35
|
-
}.should raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
Given /^a sender and receiver for "([^"]*)"$/ do |address|
|
39
|
-
steps %Q{
|
40
|
-
Given an open session
|
41
|
-
Then creating a sender with "#{address}" succeeds
|
42
|
-
Then creating a receiver with "#{address}" succeeds
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
Then /^the receiver should receive a message with "([^"]*)"$/ do |content|
|
47
|
-
@message = @receiver.fetch Qpid::Messaging::Duration::IMMEDIATE
|
48
|
-
|
49
|
-
@message.should_not be_nil
|
50
|
-
@message.content.should == "#{content}"
|
51
|
-
end
|
52
|
-
|
53
|
-
Given /^the receiver has a capacity of (\d+)$/ do |capacity|
|
54
|
-
@receiver.capacity = capacity.to_i
|
55
|
-
end
|
56
|
-
|
57
|
-
Then /^the receiver should have (\d+) message available$/ do |available|
|
58
|
-
# TODO we shouldn't need to sleep a second in order to have this update
|
59
|
-
sleep 1
|
60
|
-
@receiver.available.should == available.to_i
|
61
|
-
end
|
62
|
-
|
63
|
-
Given /^given a sender for "([^"]*)"$/ do |address|
|
64
|
-
@sender = @session.create_sender "#{address}"
|
65
|
-
end
|
66
|
-
|
67
|
-
Given /^given a receiver for "([^"]*)"$/ do |address|
|
68
|
-
@receiver = @session.create_receiver "#{address}"
|
69
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Given /^the message "([^"]*)" is sent$/ do |content|
|
21
|
-
@sender.send Qpid::Messaging::Message.new :content => "#{content}"
|
22
|
-
end
|
23
|
-
|
24
|
-
Then /^sending the message "([^"]*)" should raise an error$/ do |content|
|
25
|
-
lambda {
|
26
|
-
steps %Q{
|
27
|
-
Then sending the message "#{content}" succeeds
|
28
|
-
}
|
29
|
-
}.should raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /^sending the message "([^"]*)" succeeds$/ do |content|
|
33
|
-
@sender.send Qpid::Messaging::Message.new :content => "#{content}"
|
34
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Given /^a closed session/ do
|
21
|
-
steps %Q{
|
22
|
-
Given an open connection
|
23
|
-
Then creating a session works
|
24
|
-
}
|
25
|
-
@connection.close
|
26
|
-
end
|
27
|
-
|
28
|
-
Then /^creating a sender with "([^"]*)" raises an exception$/ do |address|
|
29
|
-
lambda {
|
30
|
-
steps %Q{
|
31
|
-
@sender = @session.create_sender "#{address}"
|
32
|
-
}
|
33
|
-
}.should raise_error
|
34
|
-
end
|
35
|
-
|
36
|
-
Then /^creating a receiver with "([^"]*)" raises an exception$/ do |address|
|
37
|
-
lambda {
|
38
|
-
steps %Q{
|
39
|
-
@sender = @session.create_sender "#{address}"
|
40
|
-
}
|
41
|
-
}.should raise_error
|
42
|
-
end
|
43
|
-
|
44
|
-
Given /^an open session with a closed connection$/ do
|
45
|
-
steps %Q{
|
46
|
-
Given an open connection
|
47
|
-
Then creating a session works
|
48
|
-
}
|
49
|
-
@session.connection.close
|
50
|
-
end
|
51
|
-
|
52
|
-
Given /^an open session$/ do
|
53
|
-
steps %Q{
|
54
|
-
Given an open connection
|
55
|
-
Then creating a session works
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
Given /^the session is closed$/ do
|
60
|
-
@session.close
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /^creating a sender with "([^"]*)" succeeds$/ do |address|
|
64
|
-
@sender = @session.create_sender "#{address}"
|
65
|
-
@sender.should_not be_nil
|
66
|
-
end
|
67
|
-
|
68
|
-
Then /^creating a sender with an Address succeeds$/ do
|
69
|
-
@sender = @session.create_receiver @address
|
70
|
-
@sender.should_not be_nil
|
71
|
-
end
|
72
|
-
|
73
|
-
Then /^creating a receiver for a nonexistent queue raises an exception$/ do
|
74
|
-
lambda {
|
75
|
-
steps %Q{
|
76
|
-
Then creating a receiver with "queue-#{Time.new.to_i}" succeeds
|
77
|
-
}
|
78
|
-
}.should raise_error
|
79
|
-
end
|
80
|
-
|
81
|
-
Then /^creating a receiver with "([^"]*)" succeeds$/ do |address|
|
82
|
-
@receiver = @session.create_receiver "#{address}"
|
83
|
-
@receiver.should_not be_nil
|
84
|
-
end
|
85
|
-
|
86
|
-
Then /^creating a receiver with an Address succeeds$/ do
|
87
|
-
@receiver = @session.create_receiver @address
|
88
|
-
@receiver.should_not be_nil
|
89
|
-
end
|
90
|
-
|
91
|
-
Then /^closing the session does not raise an error$/ do
|
92
|
-
lambda {
|
93
|
-
@session.close
|
94
|
-
}.should_not raise_error
|
95
|
-
end
|
96
|
-
|
97
|
-
Then /^the connection for the session is in the (open|closed) state$/ do |state|
|
98
|
-
@session.connection.open?.should == false if state == "closed"
|
99
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../lib")
|
21
|
-
|
22
|
-
require 'qpid_messaging'
|
@@ -1,33 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
module Qpid
|
21
|
-
|
22
|
-
module Messaging
|
23
|
-
|
24
|
-
class KeyError < RuntimeError; end
|
25
|
-
|
26
|
-
class SessionNameException < Exception
|
27
|
-
def initialize(msg); super(msg); end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
module Qpid #:nodoc:
|
21
|
-
|
22
|
-
module Version
|
23
|
-
|
24
|
-
NUMBERS = [MAJOR = 0,
|
25
|
-
MINOR = 20,
|
26
|
-
BUILD = 2]
|
27
|
-
end
|
28
|
-
|
29
|
-
VERSION = Version::NUMBERS.join('.')
|
30
|
-
|
31
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require 'spec_helper'
|
21
|
-
|
22
|
-
module Qpid
|
23
|
-
|
24
|
-
module Messaging
|
25
|
-
|
26
|
-
describe Address do
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
@address = Qpid::Messaging::Address.new "my-name/my-subject;{create:always}"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "stores the name, subject and options when created" do
|
33
|
-
name = @address.name
|
34
|
-
subject = @address.subject
|
35
|
-
create = @address.options["create"]
|
36
|
-
|
37
|
-
name.should == "my-name"
|
38
|
-
subject.should == "my-subject"
|
39
|
-
create.should == "always"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "can update the name" do
|
43
|
-
@address.name = "new-name"
|
44
|
-
|
45
|
-
name = @address.name
|
46
|
-
|
47
|
-
name.should == "new-name"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "can update the subject" do
|
51
|
-
@address.subject = "new-subject"
|
52
|
-
|
53
|
-
subject = @address.subject
|
54
|
-
|
55
|
-
subject.should == "new-subject"
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can update the type" do
|
59
|
-
@address.address_type = "routed"
|
60
|
-
|
61
|
-
type = @address.address_type
|
62
|
-
|
63
|
-
type.should == "routed"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "can update the options" do
|
67
|
-
@address.options[:create] = :never
|
68
|
-
|
69
|
-
create = @address.options["create"]
|
70
|
-
|
71
|
-
create.should == "always"
|
72
|
-
end
|
73
|
-
|
74
|
-
it "can return a string representation" do
|
75
|
-
address = Qpid::Messaging::Address.new "foo/bar:{create:always,link:durable}"
|
76
|
-
result = address.to_s
|
77
|
-
|
78
|
-
result.should =~ /foo\/bar/
|
79
|
-
result.should =~ /create:always/
|
80
|
-
result.should =~ /link:durable/
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
@@ -1,191 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require 'spec_helper'
|
21
|
-
|
22
|
-
module Qpid
|
23
|
-
|
24
|
-
module Messaging
|
25
|
-
|
26
|
-
describe Connection do
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
@session_impl = double('Cqpid::Session')
|
30
|
-
@connection_impl = double('Cqpid::Connection')
|
31
|
-
|
32
|
-
@connection = Qpid::Messaging::Connection.new :impl => @connection_impl
|
33
|
-
end
|
34
|
-
|
35
|
-
it "accepts options on construction" do
|
36
|
-
expect {
|
37
|
-
connection = Qpid::Messaging::Connection.new :options => {:username => "foo"}
|
38
|
-
|
39
|
-
connection.options.should include("username")
|
40
|
-
}.to_not raise_error
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns the underlying implementation" do
|
44
|
-
impl = @connection.connection_impl
|
45
|
-
|
46
|
-
impl.should == @connection_impl
|
47
|
-
end
|
48
|
-
|
49
|
-
it "opens the connection" do
|
50
|
-
@connection_impl.should_receive(:open)
|
51
|
-
|
52
|
-
@connection.open
|
53
|
-
end
|
54
|
-
|
55
|
-
it "closes the connection" do
|
56
|
-
@connection_impl.should_receive(:close)
|
57
|
-
|
58
|
-
@connection.close
|
59
|
-
end
|
60
|
-
|
61
|
-
it "retrieves a session by name" do
|
62
|
-
@connection_impl.should_receive(:getSession).
|
63
|
-
with("farkle").
|
64
|
-
and_return(@session_impl)
|
65
|
-
|
66
|
-
session = @connection.session "farkle"
|
67
|
-
|
68
|
-
session.session_impl.should == @session_impl
|
69
|
-
end
|
70
|
-
|
71
|
-
it "raises an error when a session name is invalid" do
|
72
|
-
@connection_impl.should_receive(:getSession).
|
73
|
-
with("farkle").
|
74
|
-
and_raise(RuntimeError)
|
75
|
-
|
76
|
-
expect {
|
77
|
-
@connection.session "farkle"
|
78
|
-
}.to raise_error(SessionNameException)
|
79
|
-
end
|
80
|
-
|
81
|
-
####################################################################
|
82
|
-
# test conditions for when a connection is not connected to a broker
|
83
|
-
####################################################################
|
84
|
-
describe "when closed" do
|
85
|
-
|
86
|
-
before(:each) do
|
87
|
-
@connection_impl.should_receive(:isOpen).
|
88
|
-
and_return(false)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "returns false when not connected to a broker" do
|
92
|
-
open = @connection.open?
|
93
|
-
|
94
|
-
open.should == false
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should raise an error when creating a session on a closed connection" do
|
98
|
-
expect {
|
99
|
-
@connection.create_session
|
100
|
-
}.to raise_error(RuntimeError)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "raises an error when creating a transactional session on a closed connection" do
|
104
|
-
expect {
|
105
|
-
@connection.create_session :transactional => true
|
106
|
-
}.to raise_error(RuntimeError)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "raises an error when creating a named session on a closed connection" do
|
110
|
-
expect {
|
111
|
-
@connection.create_session :name => "test", :transactional => true
|
112
|
-
}.to raise_error(RuntimeError)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "returns a null username when not connected" do
|
116
|
-
username = @connection.authenticated_username
|
117
|
-
|
118
|
-
username.should be_nil
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
#########################################################
|
124
|
-
# test conditions for when a connection must be connected
|
125
|
-
#########################################################
|
126
|
-
describe "when connected" do
|
127
|
-
|
128
|
-
before(:each) do
|
129
|
-
@connection_impl.should_receive(:isOpen).
|
130
|
-
and_return(true)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "returns true when connected to a broker" do
|
134
|
-
open = @connection.open?
|
135
|
-
|
136
|
-
open.should == true
|
137
|
-
end
|
138
|
-
|
139
|
-
it "creates a session" do
|
140
|
-
@connection_impl.should_receive(:createSession).
|
141
|
-
and_return(@session_impl)
|
142
|
-
|
143
|
-
session = @connection.create_session
|
144
|
-
|
145
|
-
session.session_impl.should == @session_impl
|
146
|
-
end
|
147
|
-
|
148
|
-
it "creates a named session with a name when provided" do
|
149
|
-
@connection_impl.should_receive(:createSession).with("farkle").
|
150
|
-
and_return(@session_impl)
|
151
|
-
|
152
|
-
session = @connection.create_session :name => "farkle"
|
153
|
-
|
154
|
-
session.session_impl.should == @session_impl
|
155
|
-
end
|
156
|
-
|
157
|
-
it "creates a transactional session when specified" do
|
158
|
-
@connection_impl.should_receive(:createTransactionalSession).
|
159
|
-
and_return(@session_impl)
|
160
|
-
|
161
|
-
session = @connection.create_session :transactional => true
|
162
|
-
|
163
|
-
session.session_impl.should == @session_impl
|
164
|
-
end
|
165
|
-
|
166
|
-
it "creates a named transactional session when specified" do
|
167
|
-
@connection_impl.should_receive(:createTransactionalSession).
|
168
|
-
with("farkle").
|
169
|
-
and_return(@session_impl)
|
170
|
-
|
171
|
-
session = @connection.create_session :transactional => true, :name => "farkle"
|
172
|
-
|
173
|
-
session.session_impl.should == @session_impl
|
174
|
-
end
|
175
|
-
|
176
|
-
it "returns the authenticated username when connected" do
|
177
|
-
@connection_impl.should_receive(:getAuthenticatedUsername).
|
178
|
-
and_return("mcpierce")
|
179
|
-
|
180
|
-
username = @connection.authenticated_username
|
181
|
-
|
182
|
-
username.should == "mcpierce"
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|