net-tnsping 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +11 -0
- data/MANIFEST +2 -2
- data/README +6 -6
- data/Rakefile +6 -4
- data/examples/example_tnsping.rb +28 -0
- data/lib/net/tnsping.rb +44 -15
- data/net-tnsping.gemspec +31 -0
- data/test/test_net_tnsping.rb +158 -0
- metadata +67 -44
- data/test/tc_tns_ping.rb +0 -103
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.3.0 - 22-Jul-2009
|
2
|
+
* Removed the old constant aliases. Use Ping::TNS and Ping::TNS::Error.
|
3
|
+
* Added documentation for individual accessors.
|
4
|
+
* Added aliases for Ping::TNS#db and Ping::TNS#dsn.
|
5
|
+
* Bug fix for Ping::TNS#port= where an instance variable wasn't set.
|
6
|
+
* Updated test suite to use test-unit 2.x features. Added test-unit 2.x as
|
7
|
+
a dependency as a result.
|
8
|
+
* Renamed the example program to avoid any confusion with test files.
|
9
|
+
* Updated the license to Artistic 2.0.
|
10
|
+
* Some gemspec updates.
|
11
|
+
|
1
12
|
== 1.2.0 - 20-Jul-2007
|
2
13
|
* Changed the TNSPing class name to Ping::TNS in order to follow the naming
|
3
14
|
convention in net-ping. The TNSPingError class was likewise changed to
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -18,10 +18,10 @@
|
|
18
18
|
ruby net-tnsping.gemspec
|
19
19
|
gem install net-tnsping-<version>.gem
|
20
20
|
|
21
|
-
===
|
22
|
-
You
|
23
|
-
test suite in order to get
|
24
|
-
name.
|
21
|
+
=== Test Note
|
22
|
+
You may want to manually tweak one instance variable (@@database) in the
|
23
|
+
test suite in order to get a more robust set of test results. Set it to
|
24
|
+
a known database name.
|
25
25
|
|
26
26
|
== Synopsis
|
27
27
|
require "net/tnsping"
|
@@ -173,7 +173,7 @@ Ping::TNS#tns_file=(path)
|
|
173
173
|
with some questions I had.
|
174
174
|
|
175
175
|
== Copyright
|
176
|
-
(C) 2003-
|
176
|
+
(C) 2003-2009 Daniel J. Berger
|
177
177
|
All rights reserved.
|
178
178
|
|
179
179
|
== Warranty
|
@@ -182,7 +182,7 @@ Ping::TNS#tns_file=(path)
|
|
182
182
|
warranties of merchantability and fitness for a particular purpose.
|
183
183
|
|
184
184
|
== License
|
185
|
-
|
185
|
+
Artistic 2.0
|
186
186
|
|
187
187
|
== Author
|
188
188
|
Daniel J. Berger
|
data/Rakefile
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
desc "Install the net-tnsping
|
4
|
+
desc "Install the net-tnsping library (non-gem)"
|
5
5
|
task :install do
|
6
6
|
dest = File.join(Config::CONFIG['sitelibdir'], 'net')
|
7
7
|
Dir.mkdir(dest) unless File.exists? dest
|
8
8
|
cp 'lib/net/tnsping.rb', dest, :verbose => true
|
9
9
|
end
|
10
10
|
|
11
|
-
desc "Install the net-tnsping
|
11
|
+
desc "Install the net-tnsping library as a gem"
|
12
12
|
task :install_gem do
|
13
13
|
ruby 'net-tnsping.gemspec'
|
14
14
|
file = Dir["*.gem"].first
|
15
15
|
sh "gem install #{file}"
|
16
16
|
end
|
17
17
|
|
18
|
+
desc "Run the example program"
|
19
|
+
task :example do |dsn|
|
20
|
+
ruby "-Ilib examples/example_tnsping.rb #{dsn}"
|
21
|
+
|
18
22
|
Rake::TestTask.new do |t|
|
19
|
-
t.libs << 'lib'
|
20
23
|
t.warning = true
|
21
|
-
t.test_files = FileList['test/tc*']
|
22
24
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# example_tnsping.rb
|
3
|
+
#
|
4
|
+
# Simple test script. Not required for installation. Modify as you see
|
5
|
+
# fit. You can run this program via the 'example' rake task.
|
6
|
+
#######################################################################
|
7
|
+
require "net/tnsping"
|
8
|
+
|
9
|
+
dsn = ARGV[0]
|
10
|
+
|
11
|
+
if dsn.nil?
|
12
|
+
puts "Usage: ruby test.rb <datasource>"
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
t = Net::Ping::TNS.new(dsn)
|
17
|
+
|
18
|
+
if t.ping_listener?
|
19
|
+
puts "Listener ping successful"
|
20
|
+
else
|
21
|
+
puts "Listener ping problems: " + t.exception
|
22
|
+
end
|
23
|
+
|
24
|
+
if t.ping_database?
|
25
|
+
puts "Database ping successful"
|
26
|
+
else
|
27
|
+
puts "Database ping problems: " + t.exception
|
28
|
+
end
|
data/lib/net/tnsping.rb
CHANGED
@@ -1,20 +1,49 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'dbi'
|
2
|
+
require 'net/ping'
|
3
3
|
|
4
4
|
module Net
|
5
5
|
class Ping::TNS < Ping::TCP
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
|
-
VERSION = '1.
|
8
|
+
VERSION = '1.3.0'
|
9
9
|
|
10
|
-
|
11
|
-
attr_accessor :
|
12
|
-
|
10
|
+
# Database name.
|
11
|
+
attr_accessor :db
|
12
|
+
|
13
|
+
# Database source name.
|
14
|
+
attr_accessor :dsn
|
15
|
+
|
16
|
+
# The full path to the tnsnames.ora file.
|
17
|
+
attr_accessor :tns_file
|
18
|
+
|
19
|
+
# The name of the host the database sits on.
|
20
|
+
attr_accessor :host
|
21
|
+
|
22
|
+
# The toplevel tns admin path.
|
23
|
+
attr_accessor :tns_admin
|
24
|
+
|
25
|
+
# The value of your ORACLE_HOME or ORA_HOME environment variable.
|
26
|
+
attr_accessor :ora_home
|
27
|
+
|
28
|
+
# The name of the oracle driver to use for connections. Defaults to OCI8.
|
29
|
+
attr_accessor :driver
|
30
|
+
|
31
|
+
# The timeout value for connection attempts. The default is 5 seconds.
|
32
|
+
attr_accessor :timeout
|
33
|
+
|
34
|
+
# A list of hosts for the given database name.
|
35
|
+
attr_reader :hosts
|
36
|
+
|
37
|
+
# A list of ports for the given database name
|
38
|
+
attr_reader :ports
|
39
|
+
|
40
|
+
# The port used when attempting a connection. The default is 1521.
|
41
|
+
attr_reader :port
|
13
42
|
|
14
43
|
# Creates and returns a new Ping::TNS object. If the db specified cannot
|
15
44
|
# be found in the tnsnames.ora file, then a Ping::TNS::Error is raised.
|
16
45
|
#
|
17
|
-
def initialize(db, driver=
|
46
|
+
def initialize(db, driver='OCI8', host=nil, port=1521, timeout=5)
|
18
47
|
@db = db
|
19
48
|
@dsn = "dbi:#{driver}:" << db
|
20
49
|
@host = host
|
@@ -33,12 +62,12 @@ module Net
|
|
33
62
|
elsif @ora_home
|
34
63
|
@tns_file = File.join(@ora_home, 'network', 'admin', 'tnsnames.ora')
|
35
64
|
else
|
36
|
-
@tns_file = File.join(ENV[
|
65
|
+
@tns_file = File.join((ENV['HOME'] || ENV['USERPROFILE']), 'tnsnames.ora')
|
37
66
|
end
|
38
67
|
|
39
68
|
yield self if block_given?
|
40
69
|
|
41
|
-
# If the host is not specified, look for it in the tnsnames.
|
70
|
+
# If the host is not specified, look for it in the tnsnames.ora file
|
42
71
|
if host.nil?
|
43
72
|
err_msg = "tnsnames.ora file could not be found"
|
44
73
|
raise Error, err_msg unless File.exists?(@tns_file)
|
@@ -54,6 +83,7 @@ module Net
|
|
54
83
|
# regardless of what is in the tnsnames.ora file.
|
55
84
|
#
|
56
85
|
def port=(num)
|
86
|
+
@port = num
|
57
87
|
@ports = [num]
|
58
88
|
end
|
59
89
|
|
@@ -191,21 +221,20 @@ module Net
|
|
191
221
|
value.strip!
|
192
222
|
next unless re_keys.match(key)
|
193
223
|
case key.downcase
|
194
|
-
when
|
224
|
+
when 'host'
|
195
225
|
@hosts.push(value)
|
196
|
-
when
|
226
|
+
when 'port'
|
197
227
|
@ports.push(value.to_i)
|
198
|
-
when
|
228
|
+
when 'sid'
|
199
229
|
@sid = value
|
200
230
|
end
|
201
231
|
}
|
202
232
|
end
|
203
233
|
|
234
|
+
alias database db
|
235
|
+
alias database_source_name dsn
|
204
236
|
alias ping_listener? ping?
|
205
237
|
alias oracle_home ora_home
|
206
238
|
alias oracle_home= ora_home=
|
207
239
|
end
|
208
|
-
|
209
|
-
TNSPing = Ping::TNS # Alias for backwards compatability
|
210
|
-
TNSPingError = Ping::TNS::Error # Alias for backwards compatability
|
211
240
|
end
|
data/net-tnsping.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'net-tnsping'
|
5
|
+
gem.version = '1.3.0'
|
6
|
+
gem.license = 'Artistic 2.0'
|
7
|
+
gem.author = 'Daniel J. Berger'
|
8
|
+
gem.email = 'djberg96@gmail.com'
|
9
|
+
gem.homepage = 'http://www.rubyforge.org/projects/shards'
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
11
|
+
gem.summary = 'A library for pinging Oracle listeners and databases'
|
12
|
+
gem.test_file = 'test/test_net_tnsping.rb'
|
13
|
+
gem.has_rdoc = true
|
14
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
15
|
+
|
16
|
+
gem.rubyforge_project = 'shards'
|
17
|
+
gem.extra_rdoc_files = ['CHANGES', 'MANIFEST', 'README']
|
18
|
+
|
19
|
+
gem.add_dependency('net-ping', '>= 1.0.0')
|
20
|
+
gem.add_dependency('test-unit', '>= 2.0.3')
|
21
|
+
|
22
|
+
gem.description = <<-EOF
|
23
|
+
The net-tnsping library provides a way to ping Oracle databases and
|
24
|
+
ensure that they're up and running. Unlike the tnsping command line
|
25
|
+
program, which only pings the listener, the net-tnsping library
|
26
|
+
pings both the listener and the database itself.
|
27
|
+
EOF
|
28
|
+
end
|
29
|
+
|
30
|
+
Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
|
31
|
+
Gem::Builder.new(spec).build
|
@@ -0,0 +1,158 @@
|
|
1
|
+
########################################################################
|
2
|
+
# test_tns_ping.rb
|
3
|
+
#
|
4
|
+
# Test suite for the net-tnsping library. This should be run via the
|
5
|
+
# 'rake test' task.
|
6
|
+
########################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'net/tnsping'
|
12
|
+
include Net
|
13
|
+
|
14
|
+
class TC_TNS_Ping < Test::Unit::TestCase
|
15
|
+
def self.startup
|
16
|
+
@@database = 'change_me' # Change to a valid host name
|
17
|
+
@@hostname = Socket.gethostname
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
if @@database == 'change_me'
|
22
|
+
@tnsp = Ping::TNS.new(@@database, 'OCI8', @@hostname)
|
23
|
+
else
|
24
|
+
@tnsp = Ping::TNS.new(@@database)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_version
|
29
|
+
assert_equal('1.3.0', Ping::TNS::VERSION)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_db_get
|
33
|
+
assert_respond_to(@tnsp, :db)
|
34
|
+
assert_nothing_raised{ @tnsp.db }
|
35
|
+
assert_equal(@@database, @tnsp.db)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_db_set
|
39
|
+
assert_respond_to(@tnsp, :db=)
|
40
|
+
assert_nothing_raised{ @tnsp.db = 'fubar' }
|
41
|
+
assert_equal('fubar', @tnsp.db)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_dsn_get
|
45
|
+
assert_respond_to(@tnsp, :dsn)
|
46
|
+
assert_nothing_raised{ @tnsp.dsn }
|
47
|
+
assert_equal("dbi:OCI8:#{@@database}", @tnsp.dsn)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_dsn_set
|
51
|
+
assert_respond_to(@tnsp, :dsn=)
|
52
|
+
assert_nothing_raised{ @tnsp.dsn = 'dbi:OCI8:fubar' }
|
53
|
+
assert_equal('dbi:OCI8:fubar', @tnsp.dsn)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_port_get
|
57
|
+
assert_respond_to(@tnsp, :port)
|
58
|
+
assert_equal(1521, @tnsp.port)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_port_set
|
62
|
+
assert_respond_to(@tnsp, :port=)
|
63
|
+
assert_nothing_raised{ @tnsp.port = 1555 }
|
64
|
+
assert_equal(1555, @tnsp.port)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_ports
|
68
|
+
assert_respond_to(@tnsp, :ports)
|
69
|
+
assert_kind_of(Array, @tnsp.ports)
|
70
|
+
assert(@tnsp.ports.length > 0)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_host_get
|
74
|
+
assert_respond_to(@tnsp, :host)
|
75
|
+
assert_equal(@@hostname, @tnsp.host)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_host_set
|
79
|
+
assert_respond_to(@tnsp, :host=)
|
80
|
+
assert_nothing_raised{ @tnsp.host = 'fubar' }
|
81
|
+
assert_equal('fubar', @tnsp.host)
|
82
|
+
end
|
83
|
+
|
84
|
+
def tests_hosts
|
85
|
+
assert_respond_to(@tnsp, :hosts)
|
86
|
+
assert_kind_of(Array, @tnsp.hosts)
|
87
|
+
assert(@tnsp.hosts.length > 0)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_tns_file_get
|
91
|
+
assert_respond_to(@tnsp, :tns_file)
|
92
|
+
omit_if(@@database == 'change_me', 'tns_file test skipped without real database')
|
93
|
+
assert_true(File.exist?(@tnsp.tns_file))
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_tns_file_set
|
97
|
+
assert_respond_to(@tnsp, :tns_file=)
|
98
|
+
assert_nothing_raised{ @tnsp.tns_file = 'fu_tnsnames.ora' }
|
99
|
+
assert_equal('fu_tnsnames.ora', @tnsp.tns_file)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_oracle_home_get
|
103
|
+
assert_respond_to(@tnsp, :oracle_home)
|
104
|
+
assert_kind_of([String, NilClass], @tnsp.oracle_home)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_oracle_home_set
|
108
|
+
assert_respond_to(@tnsp, :oracle_home=)
|
109
|
+
assert_nothing_raised{ @tnsp.oracle_home = ENV['HOME'] }
|
110
|
+
assert_equal(ENV['HOME'], @tnsp.oracle_home)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_tns_admin_get
|
114
|
+
assert_respond_to(@tnsp, :tns_admin)
|
115
|
+
assert_kind_of([String, NilClass], @tnsp.tns_admin)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_tns_admin_set
|
119
|
+
assert_respond_to(@tnsp, :tns_admin=)
|
120
|
+
assert_nothing_raised{ @tnsp.tns_admin = ENV['HOME'] }
|
121
|
+
assert_equal(ENV['HOME'], @tnsp.tns_admin)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_ping_listener
|
125
|
+
assert_respond_to(@tnsp, :ping?)
|
126
|
+
assert_nothing_raised{ @tnsp.ping? }
|
127
|
+
omit_if(@@database == 'change_me', 'ping listener test skipped without real database')
|
128
|
+
assert_equal(true, @tnsp.ping?)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_ping_database
|
132
|
+
assert_respond_to(@tnsp, :ping_database?)
|
133
|
+
assert_nothing_raised{ @tnsp.ping_database? }
|
134
|
+
omit_if(@@database == 'change_me', 'ping database test skipped without real database')
|
135
|
+
assert_equal(true, @tnsp.ping_database?)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_ping_all
|
139
|
+
assert_respond_to(@tnsp, :ping_all?)
|
140
|
+
assert_nothing_raised{ @tnsp.ping_all? }
|
141
|
+
omit_if(@@database == 'change_me', 'ping all test skipped without real database')
|
142
|
+
assert_equal(true, @tnsp.ping_all?)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_bad_db
|
146
|
+
assert_raises(Ping::TNS::Error){ Ping::TNS.new('bogus_db') }
|
147
|
+
@tnsp.port = 9999
|
148
|
+
assert_equal(false, @tnsp.ping_listener?)
|
149
|
+
end
|
150
|
+
|
151
|
+
def teardown
|
152
|
+
@tnsp = nil
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.shutdown
|
156
|
+
@@database = nil
|
157
|
+
end
|
158
|
+
end
|
metadata
CHANGED
@@ -1,60 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: net-tnsping
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2007-07-20 00:00:00 -06:00
|
8
|
-
summary: A package for pinging Oracle listeners and databases
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/shards
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.3.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Daniel J. Berger
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
- MANIFEST
|
35
|
-
- README
|
36
|
-
- Rakefile
|
37
|
-
- test/tc_tns_ping.rb
|
38
|
-
test_files:
|
39
|
-
- test/tc_tns_ping.rb
|
40
|
-
rdoc_options: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
43
|
-
- README
|
44
|
-
- CHANGES
|
45
|
-
executables: []
|
46
|
-
|
47
|
-
extensions: []
|
48
|
-
|
49
|
-
requirements: []
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
50
11
|
|
12
|
+
date: 2009-07-22 00:00:00 -06:00
|
13
|
+
default_executable:
|
51
14
|
dependencies:
|
52
15
|
- !ruby/object:Gem::Dependency
|
53
16
|
name: net-ping
|
17
|
+
type: :runtime
|
54
18
|
version_requirement:
|
55
|
-
version_requirements: !ruby/object:Gem::
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
20
|
requirements:
|
57
21
|
- - ">="
|
58
22
|
- !ruby/object:Gem::Version
|
59
23
|
version: 1.0.0
|
60
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: test-unit
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.3
|
34
|
+
version:
|
35
|
+
description: " The net-tnsping library provides a way to ping Oracle databases and\n ensure that they're up and running. Unlike the tnsping command line\n program, which only pings the listener, the net-tnsping library\n pings both the listener and the database itself.\n"
|
36
|
+
email: djberg96@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- CHANGES
|
43
|
+
- MANIFEST
|
44
|
+
- README
|
45
|
+
files:
|
46
|
+
- CHANGES
|
47
|
+
- examples/example_tnsping.rb
|
48
|
+
- lib/net/tnsping.rb
|
49
|
+
- MANIFEST
|
50
|
+
- net-tnsping.gemspec
|
51
|
+
- Rakefile
|
52
|
+
- README
|
53
|
+
- test/test_net_tnsping.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://www.rubyforge.org/projects/shards
|
56
|
+
licenses:
|
57
|
+
- Artistic 2.0
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: shards
|
78
|
+
rubygems_version: 1.3.4
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: A library for pinging Oracle listeners and databases
|
82
|
+
test_files:
|
83
|
+
- test/test_net_tnsping.rb
|
data/test/tc_tns_ping.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
########################################################################
|
2
|
-
# tc_tns_ping.rb
|
3
|
-
#
|
4
|
-
# Test suite for the tns-ping package. This should be run via the
|
5
|
-
# 'rake test' Rake task.
|
6
|
-
########################################################################
|
7
|
-
require "test/unit"
|
8
|
-
require "net/tnsping"
|
9
|
-
include Net
|
10
|
-
|
11
|
-
class TC_TNS_Ping < Test::Unit::TestCase
|
12
|
-
def setup
|
13
|
-
@db = 'changme' # Change to a valid host in your network
|
14
|
-
@tp = Ping::TNS.new(@db)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_version
|
18
|
-
assert_equal("1.2.0", Ping::TNS::VERSION)
|
19
|
-
assert_equal("1.2.0", TNSPing::VERSION) # Testing the alias really
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_db
|
23
|
-
assert_respond_to(@tp, :db)
|
24
|
-
assert_respond_to(@tp, :db=)
|
25
|
-
assert_nothing_raised{ @tp.db }
|
26
|
-
assert_equal(@db, @tp.db)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_dsn
|
30
|
-
assert_respond_to(@tp, :dsn)
|
31
|
-
assert_respond_to(@tp, :dsn=)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_port
|
35
|
-
assert_respond_to(@tp, :port)
|
36
|
-
assert_respond_to(@tp, :port=)
|
37
|
-
assert_equal(1521, @tp.port)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_ports
|
41
|
-
assert_respond_to(@tp, :ports)
|
42
|
-
assert_kind_of(Array, @tp.ports)
|
43
|
-
assert(@tp.ports.length > 0)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_host
|
47
|
-
assert_respond_to(@tp, :host)
|
48
|
-
assert_respond_to(@tp, :host=)
|
49
|
-
end
|
50
|
-
|
51
|
-
def tests_hosts
|
52
|
-
assert_respond_to(@tp, :hosts)
|
53
|
-
assert_kind_of(Array, @tp.hosts)
|
54
|
-
assert(@tp.hosts.length > 0)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_tns_file
|
58
|
-
assert_respond_to(@tp, :tns_file)
|
59
|
-
assert_respond_to(@tp, :tns_file=)
|
60
|
-
assert(File.exist?(@tp.tns_file))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_oracle_home
|
64
|
-
assert_respond_to(@tp, :oracle_home)
|
65
|
-
assert_respond_to(@tp, :oracle_home=)
|
66
|
-
assert_kind_of(String, @tp.oracle_home)
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_tns_admin
|
70
|
-
assert_respond_to(@tp, :tns_admin)
|
71
|
-
assert_respond_to(@tp, :tns_admin=)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_ping_listener
|
75
|
-
assert_respond_to(@tp, :ping?)
|
76
|
-
assert_nothing_raised{ @tp.ping? }
|
77
|
-
assert_equal(true, @tp.ping?)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_ping_database
|
81
|
-
assert_respond_to(@tp, :ping_database?)
|
82
|
-
assert_nothing_raised{ @tp.ping_database? }
|
83
|
-
assert_equal(true, @tp.ping_database?)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_ping_all
|
87
|
-
assert_respond_to(@tp, :ping_all?)
|
88
|
-
assert_nothing_raised{ @tp.ping_all? }
|
89
|
-
assert_equal(true, @tp.ping_all?)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_bad_db
|
93
|
-
assert_raises(Ping::TNS::Error){ Ping::TNS.new('bogus_db') }
|
94
|
-
assert_raises(TNSPingError){ Ping::TNS.new('bogus_db') } # Alias test
|
95
|
-
@tp.port = 9999
|
96
|
-
assert_equal(false, @tp.ping_listener?)
|
97
|
-
end
|
98
|
-
|
99
|
-
def teardown
|
100
|
-
@db = nil
|
101
|
-
@tp = nil
|
102
|
-
end
|
103
|
-
end
|