net-ping 1.4.1-x86-mingw32 → 1.5.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +258 -232
- data/MANIFEST +25 -23
- data/README +52 -46
- data/Rakefile +100 -89
- data/doc/ping.txt +274 -249
- data/examples/example_pingexternal.rb +16 -16
- data/examples/example_pinghttp.rb +22 -22
- data/examples/example_pingldap.rb +22 -0
- data/examples/example_pingtcp.rb +16 -16
- data/examples/example_pingudp.rb +12 -12
- data/lib/net/ping.rb +18 -15
- data/lib/net/ping/external.rb +122 -126
- data/lib/net/ping/http.rb +149 -120
- data/lib/net/ping/icmp.rb +180 -168
- data/lib/net/ping/ldap.rb +107 -0
- data/lib/net/ping/ping.rb +89 -88
- data/lib/net/ping/tcp.rb +83 -83
- data/lib/net/ping/udp.rb +119 -119
- data/lib/net/ping/wmi.rb +118 -118
- data/net-ping.gemspec +43 -38
- data/test/test_net_ping.rb +37 -37
- data/test/test_net_ping_external.rb +128 -121
- data/test/test_net_ping_http.rb +182 -176
- data/test/test_net_ping_icmp.rb +120 -116
- data/test/test_net_ping_ldap.rb +200 -0
- data/test/test_net_ping_tcp.rb +108 -108
- data/test/test_net_ping_udp.rb +122 -122
- data/test/test_net_ping_wmi.rb +84 -84
- metadata +59 -26
data/lib/net/ping/wmi.rb
CHANGED
@@ -1,118 +1,118 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'ping')
|
2
|
-
require 'win32ole'
|
3
|
-
|
4
|
-
# The Net module serves as a namespace only.
|
5
|
-
#
|
6
|
-
module Net
|
7
|
-
|
8
|
-
# The Ping::WMI class encapsulates the Win32_PingStatus WMI class for
|
9
|
-
# MS Windows.
|
10
|
-
#
|
11
|
-
class Ping::WMI < Ping
|
12
|
-
|
13
|
-
PingStatus = Struct.new(
|
14
|
-
'PingStatus',
|
15
|
-
:address,
|
16
|
-
:buffer_size,
|
17
|
-
:no_fragmentation,
|
18
|
-
:primary_address_resolution_status,
|
19
|
-
:protocol_address,
|
20
|
-
:protocol_address_resolved,
|
21
|
-
:record_route,
|
22
|
-
:reply_inconsistency,
|
23
|
-
:reply_size,
|
24
|
-
:resolve_address_names,
|
25
|
-
:response_time,
|
26
|
-
:response_time_to_live,
|
27
|
-
:route_record,
|
28
|
-
:route_record_resolved,
|
29
|
-
:source_route,
|
30
|
-
:source_route_type,
|
31
|
-
:status_code,
|
32
|
-
:timeout,
|
33
|
-
:timestamp_record,
|
34
|
-
:timestamp_record_address,
|
35
|
-
:timestamp_record_address_resolved,
|
36
|
-
:timestamp_route,
|
37
|
-
:time_to_live,
|
38
|
-
:type_of_service
|
39
|
-
)
|
40
|
-
|
41
|
-
# Unlike the ping method for other Ping subclasses, this version returns
|
42
|
-
# a PingStatus struct which contains various bits of information about
|
43
|
-
# the results of the ping itself, such as response time.
|
44
|
-
#
|
45
|
-
# In addition, this version allows you to pass certain options that are
|
46
|
-
# then passed on to the underlying WQL query. See the MSDN documentation
|
47
|
-
# on Win32_PingStatus for details.
|
48
|
-
#
|
49
|
-
# Examples:
|
50
|
-
#
|
51
|
-
# # Ping with no options
|
52
|
-
# Ping::WMI.ping('www.perl.com')
|
53
|
-
#
|
54
|
-
# # Ping with options
|
55
|
-
# Ping::WMI.ping('www.perl.com', :BufferSize => 64, :NoFragmentation => true)
|
56
|
-
#--
|
57
|
-
# The PingStatus struct is a wrapper for the Win32_PingStatus WMI class.
|
58
|
-
#
|
59
|
-
def ping(host = @host, options = {})
|
60
|
-
super(host)
|
61
|
-
|
62
|
-
lhost = Socket.gethostname
|
63
|
-
|
64
|
-
cs = "winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2"
|
65
|
-
wmi = WIN32OLE.connect(cs)
|
66
|
-
|
67
|
-
query = "select * from win32_pingstatus where address = '#{host}'"
|
68
|
-
|
69
|
-
unless options.empty?
|
70
|
-
options.each{ |key, value|
|
71
|
-
if value.is_a?(String)
|
72
|
-
query << " and #{key} = '#{value}'"
|
73
|
-
else
|
74
|
-
query << " and #{key} = #{value}"
|
75
|
-
end
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
|
-
status = Struct::PingStatus.new
|
80
|
-
|
81
|
-
wmi.execquery(query).each{ |obj|
|
82
|
-
status.address = obj.Address
|
83
|
-
status.buffer_size = obj.BufferSize
|
84
|
-
status.no_fragmentation = obj.NoFragmentation
|
85
|
-
status.primary_address_resolution_status = obj.PrimaryAddressResolutionStatus
|
86
|
-
status.protocol_address = obj.ProtocolAddress
|
87
|
-
status.protocol_address_resolved = obj.ProtocolAddressResolved
|
88
|
-
status.record_route = obj.RecordRoute
|
89
|
-
status.reply_inconsistency = obj.ReplyInconsistency
|
90
|
-
status.reply_size = obj.ReplySize
|
91
|
-
status.resolve_address_names = obj.ResolveAddressNames
|
92
|
-
status.response_time = obj.ResponseTime
|
93
|
-
status.response_time_to_live = obj.ResponseTimeToLive
|
94
|
-
status.route_record = obj.RouteRecord
|
95
|
-
status.route_record_resolved = obj.RouteRecordResolved
|
96
|
-
status.source_route = obj.SourceRoute
|
97
|
-
status.source_route_type = obj.SourceRouteType
|
98
|
-
status.status_code = obj.StatusCode
|
99
|
-
status.timeout = obj.Timeout
|
100
|
-
status.timestamp_record = obj.TimeStampRecord
|
101
|
-
status.timestamp_record_address = obj.TimeStampRecordAddress
|
102
|
-
status.timestamp_record_address_resolved = obj.TimeStampRecordAddressResolved
|
103
|
-
status.timestamp_route = obj.TimeStampRoute
|
104
|
-
status.time_to_live = obj.TimeToLive
|
105
|
-
status.type_of_service = obj.TypeOfService
|
106
|
-
}
|
107
|
-
|
108
|
-
status.freeze # Read-only data
|
109
|
-
end
|
110
|
-
|
111
|
-
# Unlike Net::Ping::WMI#ping, this method returns true or false to
|
112
|
-
# indicate whether or not the ping was successful.
|
113
|
-
#
|
114
|
-
def ping?(host = @host, options = {})
|
115
|
-
ping(host, options).status_code == 0
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
1
|
+
require File.join(File.dirname(__FILE__), 'ping')
|
2
|
+
require 'win32ole'
|
3
|
+
|
4
|
+
# The Net module serves as a namespace only.
|
5
|
+
#
|
6
|
+
module Net
|
7
|
+
|
8
|
+
# The Ping::WMI class encapsulates the Win32_PingStatus WMI class for
|
9
|
+
# MS Windows.
|
10
|
+
#
|
11
|
+
class Ping::WMI < Ping
|
12
|
+
|
13
|
+
PingStatus = Struct.new(
|
14
|
+
'PingStatus',
|
15
|
+
:address,
|
16
|
+
:buffer_size,
|
17
|
+
:no_fragmentation,
|
18
|
+
:primary_address_resolution_status,
|
19
|
+
:protocol_address,
|
20
|
+
:protocol_address_resolved,
|
21
|
+
:record_route,
|
22
|
+
:reply_inconsistency,
|
23
|
+
:reply_size,
|
24
|
+
:resolve_address_names,
|
25
|
+
:response_time,
|
26
|
+
:response_time_to_live,
|
27
|
+
:route_record,
|
28
|
+
:route_record_resolved,
|
29
|
+
:source_route,
|
30
|
+
:source_route_type,
|
31
|
+
:status_code,
|
32
|
+
:timeout,
|
33
|
+
:timestamp_record,
|
34
|
+
:timestamp_record_address,
|
35
|
+
:timestamp_record_address_resolved,
|
36
|
+
:timestamp_route,
|
37
|
+
:time_to_live,
|
38
|
+
:type_of_service
|
39
|
+
)
|
40
|
+
|
41
|
+
# Unlike the ping method for other Ping subclasses, this version returns
|
42
|
+
# a PingStatus struct which contains various bits of information about
|
43
|
+
# the results of the ping itself, such as response time.
|
44
|
+
#
|
45
|
+
# In addition, this version allows you to pass certain options that are
|
46
|
+
# then passed on to the underlying WQL query. See the MSDN documentation
|
47
|
+
# on Win32_PingStatus for details.
|
48
|
+
#
|
49
|
+
# Examples:
|
50
|
+
#
|
51
|
+
# # Ping with no options
|
52
|
+
# Ping::WMI.ping('www.perl.com')
|
53
|
+
#
|
54
|
+
# # Ping with options
|
55
|
+
# Ping::WMI.ping('www.perl.com', :BufferSize => 64, :NoFragmentation => true)
|
56
|
+
#--
|
57
|
+
# The PingStatus struct is a wrapper for the Win32_PingStatus WMI class.
|
58
|
+
#
|
59
|
+
def ping(host = @host, options = {})
|
60
|
+
super(host)
|
61
|
+
|
62
|
+
lhost = Socket.gethostname
|
63
|
+
|
64
|
+
cs = "winmgmts:{impersonationLevel=impersonate}!//#{lhost}/root/cimv2"
|
65
|
+
wmi = WIN32OLE.connect(cs)
|
66
|
+
|
67
|
+
query = "select * from win32_pingstatus where address = '#{host}'"
|
68
|
+
|
69
|
+
unless options.empty?
|
70
|
+
options.each{ |key, value|
|
71
|
+
if value.is_a?(String)
|
72
|
+
query << " and #{key} = '#{value}'"
|
73
|
+
else
|
74
|
+
query << " and #{key} = #{value}"
|
75
|
+
end
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
status = Struct::PingStatus.new
|
80
|
+
|
81
|
+
wmi.execquery(query).each{ |obj|
|
82
|
+
status.address = obj.Address
|
83
|
+
status.buffer_size = obj.BufferSize
|
84
|
+
status.no_fragmentation = obj.NoFragmentation
|
85
|
+
status.primary_address_resolution_status = obj.PrimaryAddressResolutionStatus
|
86
|
+
status.protocol_address = obj.ProtocolAddress
|
87
|
+
status.protocol_address_resolved = obj.ProtocolAddressResolved
|
88
|
+
status.record_route = obj.RecordRoute
|
89
|
+
status.reply_inconsistency = obj.ReplyInconsistency
|
90
|
+
status.reply_size = obj.ReplySize
|
91
|
+
status.resolve_address_names = obj.ResolveAddressNames
|
92
|
+
status.response_time = obj.ResponseTime
|
93
|
+
status.response_time_to_live = obj.ResponseTimeToLive
|
94
|
+
status.route_record = obj.RouteRecord
|
95
|
+
status.route_record_resolved = obj.RouteRecordResolved
|
96
|
+
status.source_route = obj.SourceRoute
|
97
|
+
status.source_route_type = obj.SourceRouteType
|
98
|
+
status.status_code = obj.StatusCode
|
99
|
+
status.timeout = obj.Timeout
|
100
|
+
status.timestamp_record = obj.TimeStampRecord
|
101
|
+
status.timestamp_record_address = obj.TimeStampRecordAddress
|
102
|
+
status.timestamp_record_address_resolved = obj.TimeStampRecordAddressResolved
|
103
|
+
status.timestamp_route = obj.TimeStampRoute
|
104
|
+
status.time_to_live = obj.TimeToLive
|
105
|
+
status.type_of_service = obj.TypeOfService
|
106
|
+
}
|
107
|
+
|
108
|
+
status.freeze # Read-only data
|
109
|
+
end
|
110
|
+
|
111
|
+
# Unlike Net::Ping::WMI#ping, this method returns true or false to
|
112
|
+
# indicate whether or not the ping was successful.
|
113
|
+
#
|
114
|
+
def ping?(host = @host, options = {})
|
115
|
+
ping(host, options).status_code == 0
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/net-ping.gemspec
CHANGED
@@ -1,38 +1,43 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rbconfig'
|
3
|
-
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'net-ping'
|
6
|
+
spec.version = '1.5.3'
|
7
|
+
spec.license = 'Artistic 2.0'
|
8
|
+
spec.author = 'Daniel J. Berger'
|
9
|
+
spec.email = 'djberg96@gmail.com'
|
10
|
+
spec.homepage = 'http://www.rubyforge.org/projects/shards'
|
11
|
+
spec.summary = 'A ping interface for Ruby.'
|
12
|
+
spec.test_file = 'test/test_net_ping.rb'
|
13
|
+
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
14
|
+
|
15
|
+
spec.rubyforge_project = 'shards'
|
16
|
+
spec.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
|
17
|
+
|
18
|
+
spec.add_dependency('net-ldap', '~> 0.2.2')
|
19
|
+
spec.add_dependency('ffi', '>= 1.0.0')
|
20
|
+
|
21
|
+
spec.add_development_dependency('test-unit', '>= 2.1.2')
|
22
|
+
spec.add_development_dependency('fakeweb', '>= 1.3.0')
|
23
|
+
spec.add_development_dependency('fakeldap', '~> 0.0.1')
|
24
|
+
|
25
|
+
if File::ALT_SEPARATOR && RUBY_PLATFORM != 'java'
|
26
|
+
spec.platform = Gem::Platform::CURRENT
|
27
|
+
spec.platform.cpu = 'universal'
|
28
|
+
spec.platform.version = nil
|
29
|
+
|
30
|
+
# Used primarily for icmp pings.
|
31
|
+
spec.add_development_dependency('win32-security', '>= 1.0.8')
|
32
|
+
|
33
|
+
if RUBY_VERSION.to_f < 1.9
|
34
|
+
spec.add_dependency('win32-open3', '>= 0.3.1')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
spec.description = <<-EOF
|
39
|
+
The net-ping library provides a ping interface for Ruby. It includes
|
40
|
+
separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping
|
41
|
+
classes.
|
42
|
+
EOF
|
43
|
+
end
|
data/test/test_net_ping.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
######################################################################
|
2
|
-
# test_net_ping.rb
|
3
|
-
#
|
4
|
-
# Test suite for all the Ping subclasses. Note that the Ping::ICMP
|
5
|
-
# class test won't be run unless this is run as a privileged process.
|
6
|
-
######################################################################
|
7
|
-
require 'test_net_ping_external'
|
8
|
-
require 'test_net_ping_http'
|
9
|
-
require 'test_net_ping_tcp'
|
10
|
-
require 'test_net_ping_udp'
|
11
|
-
require 'fakeweb'
|
12
|
-
|
13
|
-
if File::ALT_SEPARATOR
|
14
|
-
require 'win32/security'
|
15
|
-
require 'windows/system_info'
|
16
|
-
include Windows::SystemInfo
|
17
|
-
|
18
|
-
if windows_version >= 6 && Win32::Security.elevated_security?
|
19
|
-
require 'test_net_ping_icmp'
|
20
|
-
end
|
21
|
-
else
|
22
|
-
if Process.euid == 0
|
23
|
-
require 'test_net_ping_icmp'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
if File::ALT_SEPARATOR
|
28
|
-
require 'test_net_ping_wmi'
|
29
|
-
end
|
30
|
-
|
31
|
-
class TC_Net_Ping < Test::Unit::TestCase
|
32
|
-
def test_net_ping_version
|
33
|
-
assert_equal('1.
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
FakeWeb.allow_net_connect = false
|
1
|
+
######################################################################
|
2
|
+
# test_net_ping.rb
|
3
|
+
#
|
4
|
+
# Test suite for all the Ping subclasses. Note that the Ping::ICMP
|
5
|
+
# class test won't be run unless this is run as a privileged process.
|
6
|
+
######################################################################
|
7
|
+
require 'test_net_ping_external'
|
8
|
+
require 'test_net_ping_http'
|
9
|
+
require 'test_net_ping_tcp'
|
10
|
+
require 'test_net_ping_udp'
|
11
|
+
require 'fakeweb'
|
12
|
+
|
13
|
+
if File::ALT_SEPARATOR
|
14
|
+
require 'win32/security'
|
15
|
+
require 'windows/system_info'
|
16
|
+
include Windows::SystemInfo
|
17
|
+
|
18
|
+
if windows_version >= 6 && Win32::Security.elevated_security?
|
19
|
+
require 'test_net_ping_icmp'
|
20
|
+
end
|
21
|
+
else
|
22
|
+
if Process.euid == 0
|
23
|
+
require 'test_net_ping_icmp'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if File::ALT_SEPARATOR
|
28
|
+
require 'test_net_ping_wmi'
|
29
|
+
end
|
30
|
+
|
31
|
+
class TC_Net_Ping < Test::Unit::TestCase
|
32
|
+
def test_net_ping_version
|
33
|
+
assert_equal('1.5.2', Net::Ping::VERSION)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
FakeWeb.allow_net_connect = false
|
@@ -1,121 +1,128 @@
|
|
1
|
-
#########################################################################
|
2
|
-
# test_net_ping_external.rb
|
3
|
-
#
|
4
|
-
# Test case for the Net::PingExternal class. Run this via the 'test' or
|
5
|
-
# 'test:external' rake task.
|
6
|
-
#########################################################################
|
7
|
-
require 'rubygems'
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'net/ping/external'
|
12
|
-
|
13
|
-
class TC_Net_Ping_External < Test::Unit::TestCase
|
14
|
-
def setup
|
15
|
-
@host = '
|
16
|
-
@bogus = 'foo.bar.baz'
|
17
|
-
@pe = Net::Ping::External.new(@host)
|
18
|
-
@bad = Net::Ping::External.new(@bogus)
|
19
|
-
end
|
20
|
-
|
21
|
-
test "ping basic functionality" do
|
22
|
-
assert_respond_to(@pe, :ping)
|
23
|
-
end
|
24
|
-
|
25
|
-
test "ping with no arguments" do
|
26
|
-
assert_nothing_raised{ @pe.ping }
|
27
|
-
end
|
28
|
-
|
29
|
-
test "ping accepts a hostname" do
|
30
|
-
assert_nothing_raised{ @pe.ping(@host) }
|
31
|
-
end
|
32
|
-
|
33
|
-
test "ping returns a boolean" do
|
34
|
-
assert_boolean(@pe.ping)
|
35
|
-
assert_boolean(@bad.ping)
|
36
|
-
end
|
37
|
-
|
38
|
-
test "ping? alias" do
|
39
|
-
assert_respond_to(@pe, :ping?)
|
40
|
-
assert_alias_method(@pe, :ping?, :ping)
|
41
|
-
end
|
42
|
-
|
43
|
-
test "pingecho alias" do
|
44
|
-
assert_nothing_raised{ @pe.pingecho }
|
45
|
-
assert_alias_method(@pe, :pingecho, :ping)
|
46
|
-
end
|
47
|
-
|
48
|
-
test "pinging a good host returns true" do
|
49
|
-
assert_true(@pe.ping?)
|
50
|
-
end
|
51
|
-
|
52
|
-
test "pinging a bogus host returns false" do
|
53
|
-
assert_false(@bad.ping?)
|
54
|
-
end
|
55
|
-
|
56
|
-
test "duration basic functionality" do
|
57
|
-
assert_nothing_raised{ @pe.ping }
|
58
|
-
assert_respond_to(@pe, :duration)
|
59
|
-
assert_kind_of(Float, @pe.duration)
|
60
|
-
end
|
61
|
-
|
62
|
-
test "
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
@pe
|
119
|
-
@
|
120
|
-
end
|
121
|
-
|
1
|
+
#########################################################################
|
2
|
+
# test_net_ping_external.rb
|
3
|
+
#
|
4
|
+
# Test case for the Net::PingExternal class. Run this via the 'test' or
|
5
|
+
# 'test:external' rake task.
|
6
|
+
#########################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'net/ping/external'
|
12
|
+
|
13
|
+
class TC_Net_Ping_External < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@host = 'localhost'
|
16
|
+
@bogus = 'foo.bar.baz'
|
17
|
+
@pe = Net::Ping::External.new(@host)
|
18
|
+
@bad = Net::Ping::External.new(@bogus)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "ping basic functionality" do
|
22
|
+
assert_respond_to(@pe, :ping)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "ping with no arguments" do
|
26
|
+
assert_nothing_raised{ @pe.ping }
|
27
|
+
end
|
28
|
+
|
29
|
+
test "ping accepts a hostname" do
|
30
|
+
assert_nothing_raised{ @pe.ping(@host) }
|
31
|
+
end
|
32
|
+
|
33
|
+
test "ping returns a boolean" do
|
34
|
+
assert_boolean(@pe.ping)
|
35
|
+
assert_boolean(@bad.ping)
|
36
|
+
end
|
37
|
+
|
38
|
+
test "ping? alias" do
|
39
|
+
assert_respond_to(@pe, :ping?)
|
40
|
+
assert_alias_method(@pe, :ping?, :ping)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "pingecho alias" do
|
44
|
+
assert_nothing_raised{ @pe.pingecho }
|
45
|
+
assert_alias_method(@pe, :pingecho, :ping)
|
46
|
+
end
|
47
|
+
|
48
|
+
test "pinging a good host returns true" do
|
49
|
+
assert_true(@pe.ping?)
|
50
|
+
end
|
51
|
+
|
52
|
+
test "pinging a bogus host returns false" do
|
53
|
+
assert_false(@bad.ping?)
|
54
|
+
end
|
55
|
+
|
56
|
+
test "duration basic functionality" do
|
57
|
+
assert_nothing_raised{ @pe.ping }
|
58
|
+
assert_respond_to(@pe, :duration)
|
59
|
+
assert_kind_of(Float, @pe.duration)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "duration is unset if a bad ping follows a good ping" do
|
63
|
+
assert_nothing_raised{ @pe.ping }
|
64
|
+
assert_not_nil(@pe.duration)
|
65
|
+
assert_false(@pe.ping?(@bogus))
|
66
|
+
assert_nil(@pe.duration)
|
67
|
+
end
|
68
|
+
|
69
|
+
test "host getter basic functionality" do
|
70
|
+
assert_respond_to(@pe, :host)
|
71
|
+
assert_equal('localhost', @pe.host)
|
72
|
+
end
|
73
|
+
|
74
|
+
test "host setter basic functionality" do
|
75
|
+
assert_respond_to(@pe, :host=)
|
76
|
+
assert_nothing_raised{ @pe.host = @bad }
|
77
|
+
assert_equal(@bad, @pe.host)
|
78
|
+
end
|
79
|
+
|
80
|
+
test "port getter basic functionality" do
|
81
|
+
assert_respond_to(@pe, :port)
|
82
|
+
assert_equal(7, @pe.port)
|
83
|
+
end
|
84
|
+
|
85
|
+
test "port setter basic functionality" do
|
86
|
+
assert_respond_to(@pe, :port=)
|
87
|
+
assert_nothing_raised{ @pe.port = 90 }
|
88
|
+
assert_equal(90, @pe.port)
|
89
|
+
end
|
90
|
+
|
91
|
+
test "timeout getter basic functionality" do
|
92
|
+
assert_respond_to(@pe, :timeout)
|
93
|
+
assert_equal(5, @pe.timeout)
|
94
|
+
end
|
95
|
+
|
96
|
+
test "timeout setter basic functionality" do
|
97
|
+
assert_respond_to(@pe, :timeout=)
|
98
|
+
assert_nothing_raised{ @pe.timeout = 30 }
|
99
|
+
assert_equal(30, @pe.timeout)
|
100
|
+
end
|
101
|
+
|
102
|
+
test "exception method basic functionality" do
|
103
|
+
assert_respond_to(@pe, :exception)
|
104
|
+
assert_nil(@pe.exception)
|
105
|
+
end
|
106
|
+
|
107
|
+
test "pinging a bogus host stores exception data" do
|
108
|
+
assert_nothing_raised{ @bad.ping? }
|
109
|
+
assert_not_nil(@bad.exception)
|
110
|
+
end
|
111
|
+
|
112
|
+
test "pinging a good host results in no exception data" do
|
113
|
+
assert_nothing_raised{ @pe.ping }
|
114
|
+
assert_nil(@pe.exception)
|
115
|
+
end
|
116
|
+
|
117
|
+
test "warning basic functionality" do
|
118
|
+
assert_respond_to(@pe, :warning)
|
119
|
+
assert_nil(@pe.warning)
|
120
|
+
end
|
121
|
+
|
122
|
+
def teardown
|
123
|
+
@host = nil
|
124
|
+
@bogus = nil
|
125
|
+
@pe = nil
|
126
|
+
@bad = nil
|
127
|
+
end
|
128
|
+
end
|