net-ping 1.6.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +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
@@ -0,0 +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
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: net-ping
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.2
5
+ platform: universal-mingw32
6
+ authors:
7
+ - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.5.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: fakeweb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: win32-security
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.0
83
+ description: ! " The net-ping library provides a ping interface for Ruby. It includes\n
84
+ \ separate TCP, HTTP, LDAP, ICMP, UDP, WMI (for Windows) and external ping\n classes.\n"
85
+ email: djberg96@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files:
89
+ - README
90
+ - CHANGES
91
+ - doc/ping.txt
92
+ files:
93
+ - CHANGES
94
+ - doc/ping.txt
95
+ - examples/example_pingexternal.rb
96
+ - examples/example_pinghttp.rb
97
+ - examples/example_pingtcp.rb
98
+ - examples/example_pingudp.rb
99
+ - Gemfile
100
+ - lib/net/ping/external.rb
101
+ - lib/net/ping/helper.rb
102
+ - lib/net/ping/http.rb
103
+ - lib/net/ping/icmp.rb
104
+ - lib/net/ping/ping.rb
105
+ - lib/net/ping/tcp.rb
106
+ - lib/net/ping/udp.rb
107
+ - lib/net/ping/wmi.rb
108
+ - lib/net/ping.rb
109
+ - MANIFEST
110
+ - net-ping.gemspec
111
+ - Rakefile
112
+ - README
113
+ - test/test_net_ping.rb
114
+ - test/test_net_ping_external.rb
115
+ - test/test_net_ping_http.rb
116
+ - test/test_net_ping_icmp.rb
117
+ - test/test_net_ping_tcp.rb
118
+ - test/test_net_ping_udp.rb
119
+ - test/test_net_ping_wmi.rb
120
+ homepage: https://github.com/djberg96/net-ping
121
+ licenses:
122
+ - Artistic 2.0
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project: shards
140
+ rubygems_version: 2.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A ping interface for Ruby.
144
+ test_files:
145
+ - test/test_net_ping.rb