snmpjr 0.3.1-java → 0.3.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTFjOWFjNzJhNTEwY2I0MjE0Njg3ODMwNzk0OGY2YWUyOGFkYzJhOA==
4
+ M2Q0Njg3ZDA2MTZhNDliMzUwZjgyOTAxZjdhZjkyYzM3MjQ3MTdmOA==
5
5
  data.tar.gz: !binary |-
6
- MjA1NzRhZTA5MTI0MWM3NWVjZWFkZDQ0YmFlODM4NTcwOTdmZTJlNw==
6
+ MzVkNDJmYWQzMDNiMmFmNGUwZTRjYjE1ZGZiZTdjYTQwZWM4MDYzNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Yzc3ZmJiNWM2NGViNTE1ZTgzZGMzNmFmNjA3MWNlNmZhM2Y3ZGI0YzVjNTc5
10
- MmJlZWI3YTVkYjkwZmE1MTFhNmM3Y2UzNWJkMDEwZjRjY2M1MTU2NGQxZjFk
11
- ZWUzMDhlNWQ1NTEzOGI0YmRmMzdmZTcxNWEzMDI0NTY2YzA1YzI=
9
+ MTc0NDVlNDJiMTY3ZTcwMzhjNjkwNjk3YzhhZDBmOTgzZjVmMDU4M2RkMDlj
10
+ OWU5OTY1MGEwMDk3YTJiYjRiM2UzMzI1ZTlmZDRlNGYwMDZhMWVjMTljNzIx
11
+ MTkzNDQwOTU5ODE3ZjIzNjQxYjQ3MThkNzkxNWViZWM3Njg2ZWU=
12
12
  data.tar.gz: !binary |-
13
- M2YwNmFjMDJjMWEzZDJmNjEwMzlhMDA3YzYxNjRkYzJlZWU1NDBiYzhjZDQ5
14
- ZWY2ZGViODdhZmFhNmJiMDMxODRkMTBkMGJhNTU3N2IyY2RlNjdkNWYxYmYy
15
- NjQ2OTY2MjJiYWM0YzRiZmEyOTJlY2M4OTFkZTAwNDkyYTNlNmQ=
13
+ YThiNGQ0MDUxMGRkYWZjOTk4ZmRiM2I4MWFiNWY1YzFlNmZjOGQ1MjE2NDVj
14
+ MTMxMjRkNzMyZmZhZjUwY2FlN2IzMjYyNjA2NmJmZmY3ODE4Y2JlZjM4ZDJj
15
+ M2IwYzZhOTIyMDk0ZmRlMmI2NjQ2NWE2ODZmYThhNTE2ZDYzMDQ=
data/.semver CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 1
4
+ :patch: 3
5
5
  :special: ''
6
6
  :metadata: ''
data/history.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == v0.3.3 (06 January 2015)
2
+
3
+ == v0.3.2 (06 January 2015)
4
+
1
5
  == v0.3.1 (02 December 2014)
2
6
 
3
7
  == v0.3.0 (01 December 2014)
@@ -17,10 +17,10 @@ class Snmpjr
17
17
  begin
18
18
  result = @snmp.send(pdu, target)
19
19
  rescue Exception => error
20
- raise RuntimeError.new(error)
20
+ raise RuntimeError.new("#{error.inspect}: #{error_information pdu, target}")
21
21
  end
22
22
  if result.response.nil?
23
- raise Snmpjr::TargetTimeoutError.new('Request timed out')
23
+ raise Snmpjr::TargetTimeoutError.new("Request timed out: #{error_information pdu, target}")
24
24
  else
25
25
  result.response.variable_bindings.map{|vb|
26
26
  construct_response(vb)
@@ -28,6 +28,10 @@ class Snmpjr
28
28
  end
29
29
  end
30
30
 
31
+ def error_information pdu, target
32
+ "#{target.address}, OIDs: #{pdu.to_array.map {|binding| binding.oid.to_s }.inspect}"
33
+ end
34
+
31
35
  def close
32
36
  @snmp.close
33
37
  end
data/snmpjr.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'snmpjr/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'snmpjr'
8
- spec.version = '0.3.1'
8
+ spec.version = '0.3.2'
9
9
  spec.authors = ['Zen Kyprianou']
10
10
  spec.email = ['zen@kyprianou.eu']
11
11
  spec.summary = 'Simple SNMP interface for JRuby'
@@ -46,9 +46,10 @@ describe "snmpjr for snmp v2c" do
46
46
  end
47
47
 
48
48
  it 'the request times out after 5 seconds' do
49
+ host_ip = IPSocket.getaddress('demo.snmplabs.com')
49
50
  expect{
50
51
  subject.get '1.3.6.1.2.1.1.1.0'
51
- }.to raise_error(Snmpjr::TargetTimeoutError)
52
+ }.to raise_error(Snmpjr::TargetTimeoutError, %{Request timed out: #{host_ip}/161, OIDs: ["1.3.6.1.2.1.1.1.0"]})
52
53
  end
53
54
  end
54
55
  end
@@ -31,16 +31,17 @@ describe Snmpjr::SessionV2C do
31
31
  let(:vb2) { double :vb2 }
32
32
  let(:results) { [vb1, vb2] }
33
33
  let(:response) { double :response }
34
- let(:pdu) { double :pdu }
35
- let(:target) { double :target }
34
+ let(:pdu) { double :pdu, to_array: [vb1, vb2] }
35
+ let(:address) { double :address, to_s: "1.2.3.4/567" }
36
+ let(:target) { double :target, address: address }
36
37
 
37
38
  before do
38
39
  allow(snmp_session).to receive(:send).and_return response
39
40
  allow(vb1).to receive_message_chain('variable.to_s')
40
- allow(vb1).to receive_message_chain('oid.to_s')
41
+ allow(vb1).to receive_message_chain('oid.to_s') { "1.2.3" }
41
42
  allow(vb1).to receive(:is_exception)
42
43
  allow(vb2).to receive_message_chain('variable.to_s')
43
- allow(vb2).to receive_message_chain('oid.to_s')
44
+ allow(vb2).to receive_message_chain('oid.to_s') { "4.5.6" }
44
45
  allow(vb2).to receive(:is_exception)
45
46
  allow(response).to receive_message_chain('response.variable_bindings').and_return(results)
46
47
  end
@@ -58,19 +59,20 @@ describe Snmpjr::SessionV2C do
58
59
  it 'raises a timeout error' do
59
60
  expect {
60
61
  subject.send(pdu, target)
61
- }.to raise_error(Snmpjr::TargetTimeoutError)
62
+ }.to raise_error(Snmpjr::TargetTimeoutError, 'Request timed out: 1.2.3.4/567, OIDs: ["1.2.3", "4.5.6"]')
62
63
  end
63
64
  end
64
65
 
65
66
  context 'an exception is raised' do
67
+ let(:exception) { Exception.new "An error" }
66
68
  before do
67
- allow(snmp_session).to receive(:send).and_raise(Exception)
69
+ allow(snmp_session).to receive(:send).and_raise(exception)
68
70
  end
69
71
 
70
72
  it 'catches it and raises a ruby runtime error' do
71
73
  expect{
72
74
  subject.send(pdu, target)
73
- }.to raise_error(RuntimeError)
75
+ }.to raise_error(RuntimeError, %{#{exception.inspect}: 1.2.3.4/567, OIDs: ["1.2.3", "4.5.6"]})
74
76
  end
75
77
  end
76
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snmpjr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: java
6
6
  authors:
7
7
  - Zen Kyprianou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-n-bake
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.4.2
217
+ rubygems_version: 2.4.5
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: Simple SNMP interface for JRuby