net-ping 1.7.1-universal-mingw32 → 1.7.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,105 +1,105 @@
1
- #####################################################################
2
- # test_net_ping_tcp.rb
3
- #
4
- # Test case for the Net::PingTCP class. This test should be run via
5
- # the 'test' or 'test:tcp' Rake task.
6
- #####################################################################
7
- require 'test-unit'
8
- require 'net/ping/tcp'
9
- include Net
10
-
11
- class TC_PingTCP < Test::Unit::TestCase
12
- def setup
13
- @host = 'localhost'
14
- @port = 22
15
- @tcp = Ping::TCP.new(@host, @port)
16
- end
17
-
18
- def test_ping
19
- assert_respond_to(@tcp, :ping)
20
- assert_nothing_raised{ @tcp.ping }
21
- assert_nothing_raised{ @tcp.ping(@host) }
22
- end
23
-
24
- def test_ping_aliases
25
- assert_respond_to(@tcp, :ping?)
26
- assert_respond_to(@tcp, :pingecho)
27
- assert_nothing_raised{ @tcp.ping? }
28
- assert_nothing_raised{ @tcp.ping?(@host) }
29
- assert_nothing_raised{ @tcp.pingecho }
30
- assert_nothing_raised{ @tcp.pingecho(@host) }
31
- end
32
-
33
- def test_ping_service_check_false
34
- msg = "+this test may fail depending on your network environment+"
35
- Ping::TCP.service_check = false
36
- @tcp = Ping::TCP.new('localhost')
37
- assert_false(@tcp.ping?, msg)
38
- assert_false(@tcp.exception.nil?, "Bad exception data")
39
- end
40
-
41
- def test_ping_service_check_true
42
- msg = "+this test may fail depending on your network environment+"
43
- Ping::TCP.service_check = true
44
- assert_true(@tcp.ping?, msg)
45
- end
46
-
47
- def test_service_check
48
- assert_respond_to(Ping::TCP, :service_check)
49
- assert_respond_to(Ping::TCP, :service_check=)
50
- end
51
-
52
- # These will be removed eventually
53
- def test_service_check_aliases
54
- assert_respond_to(Ping::TCP, :econnrefused)
55
- assert_respond_to(Ping::TCP, :econnrefused=)
56
- assert_respond_to(Ping::TCP, :ecr)
57
- assert_respond_to(Ping::TCP, :ecr=)
58
- end
59
-
60
- def test_service_check_expected_errors
61
- assert_raises(ArgumentError){ Ping::TCP.service_check = "blah" }
62
- end
63
-
64
- # If the ping failed, the duration will be nil
65
- def test_duration
66
- assert_nothing_raised{ @tcp.ping }
67
- assert_respond_to(@tcp, :duration)
68
- omit_if(@tcp.duration.nil?, 'ping failed, skipping')
69
- assert_kind_of(Float, @tcp.duration)
70
- end
71
-
72
- def test_host
73
- assert_respond_to(@tcp, :host)
74
- assert_respond_to(@tcp, :host=)
75
- assert_equal(@host, @tcp.host)
76
- end
77
-
78
- def test_port
79
- assert_respond_to(@tcp, :port)
80
- assert_respond_to(@tcp, :port=)
81
- assert_equal(22, @tcp.port)
82
- end
83
-
84
- def test_timeout
85
- assert_respond_to(@tcp, :timeout)
86
- assert_respond_to(@tcp, :timeout=)
87
- assert_equal(5, @tcp.timeout)
88
- end
89
-
90
- def test_exception
91
- msg = "+this test may fail depending on your network environment+"
92
- assert_respond_to(@tcp, :exception)
93
- assert_nothing_raised{ @tcp.ping }
94
- assert_nil(@tcp.exception, msg)
95
- end
96
-
97
- def test_warning
98
- assert_respond_to(@tcp, :warning)
99
- end
100
-
101
- def teardown
102
- @host = nil
103
- @tcp = nil
104
- end
105
- end
1
+ #####################################################################
2
+ # test_net_ping_tcp.rb
3
+ #
4
+ # Test case for the Net::PingTCP class. This test should be run via
5
+ # the 'test' or 'test:tcp' Rake task.
6
+ #####################################################################
7
+ require 'test-unit'
8
+ require 'net/ping/tcp'
9
+ include Net
10
+
11
+ class TC_PingTCP < Test::Unit::TestCase
12
+ def setup
13
+ @host = 'localhost'
14
+ @port = 22
15
+ @tcp = Ping::TCP.new(@host, @port)
16
+ end
17
+
18
+ def test_ping
19
+ assert_respond_to(@tcp, :ping)
20
+ assert_nothing_raised{ @tcp.ping }
21
+ assert_nothing_raised{ @tcp.ping(@host) }
22
+ end
23
+
24
+ def test_ping_aliases
25
+ assert_respond_to(@tcp, :ping?)
26
+ assert_respond_to(@tcp, :pingecho)
27
+ assert_nothing_raised{ @tcp.ping? }
28
+ assert_nothing_raised{ @tcp.ping?(@host) }
29
+ assert_nothing_raised{ @tcp.pingecho }
30
+ assert_nothing_raised{ @tcp.pingecho(@host) }
31
+ end
32
+
33
+ def test_ping_service_check_false
34
+ msg = "+this test may fail depending on your network environment+"
35
+ Ping::TCP.service_check = false
36
+ @tcp = Ping::TCP.new('localhost')
37
+ assert_false(@tcp.ping?, msg)
38
+ assert_false(@tcp.exception.nil?, "Bad exception data")
39
+ end
40
+
41
+ def test_ping_service_check_true
42
+ msg = "+this test may fail depending on your network environment+"
43
+ Ping::TCP.service_check = true
44
+ assert_true(@tcp.ping?, msg)
45
+ end
46
+
47
+ def test_service_check
48
+ assert_respond_to(Ping::TCP, :service_check)
49
+ assert_respond_to(Ping::TCP, :service_check=)
50
+ end
51
+
52
+ # These will be removed eventually
53
+ def test_service_check_aliases
54
+ assert_respond_to(Ping::TCP, :econnrefused)
55
+ assert_respond_to(Ping::TCP, :econnrefused=)
56
+ assert_respond_to(Ping::TCP, :ecr)
57
+ assert_respond_to(Ping::TCP, :ecr=)
58
+ end
59
+
60
+ def test_service_check_expected_errors
61
+ assert_raises(ArgumentError){ Ping::TCP.service_check = "blah" }
62
+ end
63
+
64
+ # If the ping failed, the duration will be nil
65
+ def test_duration
66
+ assert_nothing_raised{ @tcp.ping }
67
+ assert_respond_to(@tcp, :duration)
68
+ omit_if(@tcp.duration.nil?, 'ping failed, skipping')
69
+ assert_kind_of(Float, @tcp.duration)
70
+ end
71
+
72
+ def test_host
73
+ assert_respond_to(@tcp, :host)
74
+ assert_respond_to(@tcp, :host=)
75
+ assert_equal(@host, @tcp.host)
76
+ end
77
+
78
+ def test_port
79
+ assert_respond_to(@tcp, :port)
80
+ assert_respond_to(@tcp, :port=)
81
+ assert_equal(22, @tcp.port)
82
+ end
83
+
84
+ def test_timeout
85
+ assert_respond_to(@tcp, :timeout)
86
+ assert_respond_to(@tcp, :timeout=)
87
+ assert_equal(5, @tcp.timeout)
88
+ end
89
+
90
+ def test_exception
91
+ msg = "+this test may fail depending on your network environment+"
92
+ assert_respond_to(@tcp, :exception)
93
+ assert_nothing_raised{ @tcp.ping }
94
+ assert_nil(@tcp.exception, msg)
95
+ end
96
+
97
+ def test_warning
98
+ assert_respond_to(@tcp, :warning)
99
+ end
100
+
101
+ def teardown
102
+ @host = nil
103
+ @tcp = nil
104
+ end
105
+ end
@@ -1,119 +1,119 @@
1
- ########################################################################
2
- # test_net_ping_udp.rb
3
- #
4
- # Test case for the Net::Ping::UDP class. This should be run via the
5
- # 'test' or 'test:udp' Rake tasks.
6
- #
7
- # If someone could provide me a host where a udp ping actually
8
- # works (with a service check), I would appreciate it. :)
9
- ########################################################################
10
- require 'test-unit'
11
- require 'net/ping/udp'
12
-
13
- class TC_Net_Ping_UDP < Test::Unit::TestCase
14
- def setup
15
- Net::Ping::UDP.service_check = false
16
- @host = '127.0.0.1'
17
- @udp = Net::Ping::UDP.new(@host)
18
- end
19
-
20
- test "ping basic functionality" do
21
- assert_respond_to(@udp, :ping)
22
- assert_nothing_raised{ @udp.ping }
23
- end
24
-
25
- test "ping accepts a host as an argument" do
26
- assert_nothing_raised{ @udp.ping(@host) }
27
- end
28
-
29
- test "ping? is an alias for ping" do
30
- assert_respond_to(@udp, :ping?)
31
- assert_alias_method(@udp, :ping?, :ping)
32
- end
33
-
34
- test "pingecho is an alias for ping" do
35
- assert_respond_to(@udp, :pingecho)
36
- assert_alias_method(@udp, :pingecho, :ping)
37
- end
38
-
39
- test "a successful udp ping returns true" do
40
- assert_true(@udp.ping?)
41
- end
42
-
43
- test "bind basic functionality" do
44
- assert_respond_to(@udp, :bind)
45
- assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
46
- end
47
-
48
- test "duration basic functionality" do
49
- assert_nothing_raised{ @udp.ping }
50
- assert_respond_to(@udp, :duration)
51
- assert_kind_of(Float, @udp.duration)
52
- end
53
-
54
- test "host basic functionality" do
55
- assert_respond_to(@udp, :host)
56
- assert_respond_to(@udp, :host=)
57
- assert_equal('127.0.0.1', @udp.host)
58
- end
59
-
60
- test "port basic functionality" do
61
- assert_respond_to(@udp, :port)
62
- assert_respond_to(@udp, :port=)
63
- assert_equal(7, @udp.port)
64
- end
65
-
66
- test "timeout basic functionality" do
67
- assert_respond_to(@udp, :timeout)
68
- assert_respond_to(@udp, :timeout=)
69
- end
70
-
71
- test "timeout default value is five" do
72
- assert_equal(5, @udp.timeout)
73
- end
74
-
75
- test "exception basic functionality" do
76
- assert_respond_to(@udp, :exception)
77
- end
78
-
79
- test "the exception attribute returns nil if the ping is successful" do
80
- assert_true(@udp.ping?)
81
- assert_nil(@udp.exception)
82
- end
83
-
84
- test "the exception attribute is not nil if the ping is unsuccessful" do
85
- assert_false(@udp.ping?('www.ruby-lang.org'))
86
- assert_not_nil(@udp.exception)
87
- end
88
-
89
- test "warning basic functionality" do
90
- assert_respond_to(@udp, :warning)
91
- end
92
-
93
- test "the warning attribute returns nil if the ping is successful" do
94
- assert_true(@udp.ping?)
95
- assert_nil(@udp.warning)
96
- end
97
-
98
- test "service_check basic functionality" do
99
- assert_respond_to(Net::Ping::UDP, :service_check)
100
- assert_respond_to(Net::Ping::UDP, :service_check=)
101
- end
102
-
103
- test "service_check attribute has been set to false" do
104
- assert_false(Net::Ping::UDP.service_check)
105
- end
106
-
107
- test "service_check getter method does not accept arguments" do
108
- assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
109
- end
110
-
111
- test "service_check setter method only accepts boolean arguments" do
112
- assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
113
- end
114
-
115
- def teardown
116
- @host = nil
117
- @udp = nil
118
- end
119
- end
1
+ ########################################################################
2
+ # test_net_ping_udp.rb
3
+ #
4
+ # Test case for the Net::Ping::UDP class. This should be run via the
5
+ # 'test' or 'test:udp' Rake tasks.
6
+ #
7
+ # If someone could provide me a host where a udp ping actually
8
+ # works (with a service check), I would appreciate it. :)
9
+ ########################################################################
10
+ require 'test-unit'
11
+ require 'net/ping/udp'
12
+
13
+ class TC_Net_Ping_UDP < Test::Unit::TestCase
14
+ def setup
15
+ Net::Ping::UDP.service_check = false
16
+ @host = '127.0.0.1'
17
+ @udp = Net::Ping::UDP.new(@host)
18
+ end
19
+
20
+ test "ping basic functionality" do
21
+ assert_respond_to(@udp, :ping)
22
+ assert_nothing_raised{ @udp.ping }
23
+ end
24
+
25
+ test "ping accepts a host as an argument" do
26
+ assert_nothing_raised{ @udp.ping(@host) }
27
+ end
28
+
29
+ test "ping? is an alias for ping" do
30
+ assert_respond_to(@udp, :ping?)
31
+ assert_alias_method(@udp, :ping?, :ping)
32
+ end
33
+
34
+ test "pingecho is an alias for ping" do
35
+ assert_respond_to(@udp, :pingecho)
36
+ assert_alias_method(@udp, :pingecho, :ping)
37
+ end
38
+
39
+ test "a successful udp ping returns true" do
40
+ assert_true(@udp.ping?)
41
+ end
42
+
43
+ test "bind basic functionality" do
44
+ assert_respond_to(@udp, :bind)
45
+ assert_nothing_raised{ @udp.bind('127.0.0.1', 80) }
46
+ end
47
+
48
+ test "duration basic functionality" do
49
+ assert_nothing_raised{ @udp.ping }
50
+ assert_respond_to(@udp, :duration)
51
+ assert_kind_of(Float, @udp.duration)
52
+ end
53
+
54
+ test "host basic functionality" do
55
+ assert_respond_to(@udp, :host)
56
+ assert_respond_to(@udp, :host=)
57
+ assert_equal('127.0.0.1', @udp.host)
58
+ end
59
+
60
+ test "port basic functionality" do
61
+ assert_respond_to(@udp, :port)
62
+ assert_respond_to(@udp, :port=)
63
+ assert_equal(7, @udp.port)
64
+ end
65
+
66
+ test "timeout basic functionality" do
67
+ assert_respond_to(@udp, :timeout)
68
+ assert_respond_to(@udp, :timeout=)
69
+ end
70
+
71
+ test "timeout default value is five" do
72
+ assert_equal(5, @udp.timeout)
73
+ end
74
+
75
+ test "exception basic functionality" do
76
+ assert_respond_to(@udp, :exception)
77
+ end
78
+
79
+ test "the exception attribute returns nil if the ping is successful" do
80
+ assert_true(@udp.ping?)
81
+ assert_nil(@udp.exception)
82
+ end
83
+
84
+ test "the exception attribute is not nil if the ping is unsuccessful" do
85
+ assert_false(@udp.ping?('www.ruby-lang.org'))
86
+ assert_not_nil(@udp.exception)
87
+ end
88
+
89
+ test "warning basic functionality" do
90
+ assert_respond_to(@udp, :warning)
91
+ end
92
+
93
+ test "the warning attribute returns nil if the ping is successful" do
94
+ assert_true(@udp.ping?)
95
+ assert_nil(@udp.warning)
96
+ end
97
+
98
+ test "service_check basic functionality" do
99
+ assert_respond_to(Net::Ping::UDP, :service_check)
100
+ assert_respond_to(Net::Ping::UDP, :service_check=)
101
+ end
102
+
103
+ test "service_check attribute has been set to false" do
104
+ assert_false(Net::Ping::UDP.service_check)
105
+ end
106
+
107
+ test "service_check getter method does not accept arguments" do
108
+ assert_raise(ArgumentError){ Net::Ping::UDP.service_check(1) }
109
+ end
110
+
111
+ test "service_check setter method only accepts boolean arguments" do
112
+ assert_raise(ArgumentError){ Net::Ping::UDP.service_check = 1 }
113
+ end
114
+
115
+ def teardown
116
+ @host = nil
117
+ @udp = nil
118
+ end
119
+ end
@@ -1,81 +1,81 @@
1
- #######################################################################
2
- # test_net_ping_wmi.rb
3
- #
4
- # Test case for the Net::Ping::WMI class. These tests will only be
5
- # run MS Windows. You should run this test via the 'test' or
6
- # 'test:wmi' Rake task.
7
- #######################################################################
8
- require 'test-unit'
9
- require 'net/ping/wmi'
10
- include Net
11
-
12
- class TC_Ping_WMI < Test::Unit::TestCase
13
- def self.startup
14
- @@windows = File::ALT_SEPARATOR
15
- end
16
-
17
- def setup
18
- @host = "www.ruby-lang.org"
19
- @wmi = Ping::WMI.new(@host) if @@windows
20
- end
21
-
22
- def test_ping_basic
23
- omit_unless(@@windows, 'skipped on Unix platforms')
24
- assert_respond_to(@wmi, :ping)
25
- assert_nothing_raised{ @wmi.ping }
26
- end
27
-
28
- def test_ping_with_host
29
- omit_unless(@@windows, 'skipped on Unix platforms')
30
- assert_nothing_raised{ @wmi.ping(@host) }
31
- end
32
-
33
- def test_ping_with_options
34
- omit_unless(@@windows, 'skipped on Unix platforms')
35
- assert_nothing_raised{ @wmi.ping(@host, :NoFragmentation => true) }
36
- end
37
-
38
- def test_pingecho_alias
39
- omit_unless(@@windows, 'skipped on Unix platforms')
40
- assert_respond_to(@wmi, :pingecho)
41
- assert_nothing_raised{ @wmi.pingecho }
42
- assert_nothing_raised{ @wmi.pingecho(@host) }
43
- end
44
-
45
- def test_ping_returns_struct
46
- omit_unless(@@windows, 'skipped on Unix platforms')
47
- assert_kind_of(Struct::PingStatus, @wmi.ping)
48
- end
49
-
50
- def test_ping_returns_boolean
51
- omit_unless(@@windows, 'skipped on Unix platforms')
52
- assert_boolean(@wmi.ping?)
53
- assert_boolean(@wmi.ping?(@host))
54
- end
55
-
56
- def test_ping_expected_failure
57
- omit_unless(@@windows, 'skipped on Unix platforms')
58
- assert_false(Ping::WMI.new('bogus').ping?)
59
- assert_false(Ping::WMI.new('http://www.asdfhjklasdfhlkj.com').ping?)
60
- end
61
-
62
- def test_exception
63
- omit_unless(@@windows, 'skipped on Unix platforms')
64
- assert_respond_to(@wmi, :exception)
65
- assert_nothing_raised{ @wmi.ping }
66
- assert_nil(@wmi.exception)
67
- end
68
-
69
- def test_warning
70
- assert_respond_to(@wmi, :warning)
71
- end
72
-
73
- def teardown
74
- @host = nil
75
- @wmi = nil
76
- end
77
-
78
- def self.shutdown
79
- @@windows = nil
80
- end
81
- end
1
+ #######################################################################
2
+ # test_net_ping_wmi.rb
3
+ #
4
+ # Test case for the Net::Ping::WMI class. These tests will only be
5
+ # run MS Windows. You should run this test via the 'test' or
6
+ # 'test:wmi' Rake task.
7
+ #######################################################################
8
+ require 'test-unit'
9
+ require 'net/ping/wmi'
10
+ include Net
11
+
12
+ class TC_Ping_WMI < Test::Unit::TestCase
13
+ def self.startup
14
+ @@windows = File::ALT_SEPARATOR
15
+ end
16
+
17
+ def setup
18
+ @host = "www.ruby-lang.org"
19
+ @wmi = Ping::WMI.new(@host) if @@windows
20
+ end
21
+
22
+ def test_ping_basic
23
+ omit_unless(@@windows, 'skipped on Unix platforms')
24
+ assert_respond_to(@wmi, :ping)
25
+ assert_nothing_raised{ @wmi.ping }
26
+ end
27
+
28
+ def test_ping_with_host
29
+ omit_unless(@@windows, 'skipped on Unix platforms')
30
+ assert_nothing_raised{ @wmi.ping(@host) }
31
+ end
32
+
33
+ def test_ping_with_options
34
+ omit_unless(@@windows, 'skipped on Unix platforms')
35
+ assert_nothing_raised{ @wmi.ping(@host, :NoFragmentation => true) }
36
+ end
37
+
38
+ def test_pingecho_alias
39
+ omit_unless(@@windows, 'skipped on Unix platforms')
40
+ assert_respond_to(@wmi, :pingecho)
41
+ assert_nothing_raised{ @wmi.pingecho }
42
+ assert_nothing_raised{ @wmi.pingecho(@host) }
43
+ end
44
+
45
+ def test_ping_returns_struct
46
+ omit_unless(@@windows, 'skipped on Unix platforms')
47
+ assert_kind_of(Struct::PingStatus, @wmi.ping)
48
+ end
49
+
50
+ def test_ping_returns_boolean
51
+ omit_unless(@@windows, 'skipped on Unix platforms')
52
+ assert_boolean(@wmi.ping?)
53
+ assert_boolean(@wmi.ping?(@host))
54
+ end
55
+
56
+ def test_ping_expected_failure
57
+ omit_unless(@@windows, 'skipped on Unix platforms')
58
+ assert_false(Ping::WMI.new('bogus').ping?)
59
+ assert_false(Ping::WMI.new('http://www.asdfhjklasdfhlkj.com').ping?)
60
+ end
61
+
62
+ def test_exception
63
+ omit_unless(@@windows, 'skipped on Unix platforms')
64
+ assert_respond_to(@wmi, :exception)
65
+ assert_nothing_raised{ @wmi.ping }
66
+ assert_nil(@wmi.exception)
67
+ end
68
+
69
+ def test_warning
70
+ assert_respond_to(@wmi, :warning)
71
+ end
72
+
73
+ def teardown
74
+ @host = nil
75
+ @wmi = nil
76
+ end
77
+
78
+ def self.shutdown
79
+ @@windows = nil
80
+ end
81
+ end