rboss 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/jboss-profile +90 -0
- data/bin/twiddle +230 -0
- data/examples/jboss_profile/jbb_profile_1.yaml +32 -0
- data/examples/jboss_profile/jbb_profile_2.yaml +32 -0
- data/examples/jboss_profile/jboss_profile.yaml +7 -0
- data/examples/monitor/simple_monitor.rb +61 -0
- data/lib/rboss.rb +25 -0
- data/lib/rboss/component_processor.rb +177 -0
- data/lib/rboss/components/component.rb +52 -0
- data/lib/rboss/components/datasource.rb +198 -0
- data/lib/rboss/components/deploy_folder.rb +104 -0
- data/lib/rboss/components/hypersonic_replacer.rb +58 -0
- data/lib/rboss/components/jbossweb.rb +117 -0
- data/lib/rboss/components/jmx.rb +88 -0
- data/lib/rboss/components/mod_cluster.rb +81 -0
- data/lib/rboss/components/org/6.0/deploy_folder.rb +33 -0
- data/lib/rboss/components/org/jmx.rb +59 -0
- data/lib/rboss/components/profile_folder.rb +44 -0
- data/lib/rboss/components/resource.rb +53 -0
- data/lib/rboss/components/run_conf.rb +90 -0
- data/lib/rboss/components/run_conf.yaml +22 -0
- data/lib/rboss/components/service_script.rb +55 -0
- data/lib/rboss/components/slimming.rb +124 -0
- data/lib/rboss/components/soa-p/hypersonic_replacer.rb +79 -0
- data/lib/rboss/components/soa-p/jmx.rb +47 -0
- data/lib/rboss/components/xadatasource.rb +67 -0
- data/lib/rboss/file_processor.rb +107 -0
- data/lib/rboss/jboss_path.rb +53 -0
- data/lib/rboss/jboss_profile.rb +344 -0
- data/lib/rboss/resources/jboss_init_redhat.sh.erb +140 -0
- data/lib/rboss/resources/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml +282 -0
- data/lib/rboss/resources/mod_cluster.sar/mod_cluster-1.1.2.Final.jar +0 -0
- data/lib/rboss/resources/run.conf.erb +62 -0
- data/lib/rboss/twiddle.rb +25 -0
- data/lib/rboss/twiddle/base_monitor.rb +57 -0
- data/lib/rboss/twiddle/mbean.rb +82 -0
- data/lib/rboss/twiddle/monitor.rb +144 -0
- data/lib/rboss/twiddle/scanner.rb +92 -0
- data/lib/rboss/twiddle/twiddle.rb +71 -0
- data/lib/rboss/utils.rb +33 -0
- data/lib/rboss/version.rb +25 -0
- data/rboss.gemspec +20 -0
- data/test/datasource_test.rb +211 -0
- data/test/deploy_folder_test.rb +126 -0
- data/test/mbean_test.rb +53 -0
- data/test/test_helper.rb +124 -0
- data/test/test_suite.rb +35 -0
- metadata +109 -0
data/lib/rboss/utils.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
class String
|
24
|
+
|
25
|
+
def camelize
|
26
|
+
(self.split(/_/).collect { |n| n.capitalize }).join
|
27
|
+
end
|
28
|
+
|
29
|
+
def uncapitalize
|
30
|
+
self[0, 1].downcase + self[1..-1]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module RBoss
|
24
|
+
VERSION = "0.1.0"
|
25
|
+
end
|
data/rboss.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rboss/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rboss"
|
7
|
+
s.version = RBoss::VERSION
|
8
|
+
s.authors = ["Ataxexe"]
|
9
|
+
s.email = ["ataxexe@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A Ruby way to do a JBoss work!}
|
12
|
+
s.description = %q{This gem help you to create a JBoss profile and some other things like building twiddle scripts}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rboss"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'test_helper'
|
24
|
+
|
25
|
+
class DatasourceTest < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@types = %w{mysql oracle postgres}
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_datasource_type
|
32
|
+
@types.each do |type|
|
33
|
+
for_test_with :all do |profile|
|
34
|
+
profile.add :datasource,
|
35
|
+
:type => type
|
36
|
+
end
|
37
|
+
|
38
|
+
for_assertions_with :all do |jboss|
|
39
|
+
file = "#{jboss.profile}/deploy/#{type}-ds.xml"
|
40
|
+
assert File.exists? file
|
41
|
+
datasource_content = File.read file
|
42
|
+
assert datasource_content[type]
|
43
|
+
end
|
44
|
+
|
45
|
+
do_test
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_datasource_naming
|
50
|
+
@types.each do |type|
|
51
|
+
for_test_with :all do |profile|
|
52
|
+
profile.add :datasource,
|
53
|
+
:type => type,
|
54
|
+
:name => 'my-datasource'
|
55
|
+
end
|
56
|
+
|
57
|
+
for_assertions_with :all do |jboss|
|
58
|
+
file = "#{jboss.profile}/deploy/my-datasource-ds.xml"
|
59
|
+
assert File.exists? file
|
60
|
+
datasource_content = File.read file
|
61
|
+
assert datasource_content[type]
|
62
|
+
end
|
63
|
+
|
64
|
+
do_test
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_datasource_folder_inside_installation
|
69
|
+
@types.each do |type|
|
70
|
+
for_test_with :all do |profile|
|
71
|
+
profile.add :deploy_folder, 'deploy/datasources'
|
72
|
+
|
73
|
+
profile.add :datasource,
|
74
|
+
:type => type,
|
75
|
+
:folder => 'deploy/datasources'
|
76
|
+
end
|
77
|
+
|
78
|
+
for_assertions_with :all do |jboss|
|
79
|
+
file = "#{jboss.profile}/deploy/datasources/#{type}-ds.xml"
|
80
|
+
assert File.exists? file
|
81
|
+
datasource_content = File.read file
|
82
|
+
assert datasource_content[type]
|
83
|
+
end
|
84
|
+
|
85
|
+
do_test
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_datasource_folder_outside_installation
|
90
|
+
@types.each do |type|
|
91
|
+
for_test_with :all do |profile|
|
92
|
+
profile.add :deploy_folder, '/tmp/datasources'
|
93
|
+
|
94
|
+
profile.add :datasource,
|
95
|
+
:type => type,
|
96
|
+
:folder => '/tmp/datasources'
|
97
|
+
end
|
98
|
+
|
99
|
+
for_assertions_with :all do |jboss|
|
100
|
+
file = "/tmp/datasources/#{type}-ds.xml"
|
101
|
+
assert File.exists? file
|
102
|
+
datasource_content = File.read file
|
103
|
+
assert datasource_content[type]
|
104
|
+
|
105
|
+
`rm -rf /tmp/datasources`
|
106
|
+
end
|
107
|
+
|
108
|
+
do_test
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_datasource_attributes
|
113
|
+
@types.each do |type|
|
114
|
+
for_test_with :all do |profile|
|
115
|
+
|
116
|
+
profile.add :datasource,
|
117
|
+
:type => type,
|
118
|
+
:attributes => {
|
119
|
+
:jndi_name => "#{type}Datasource",
|
120
|
+
:user_name => "#{type}_user",
|
121
|
+
:password => "#{type}_password",
|
122
|
+
:connection_url => "#{type}_connection",
|
123
|
+
:driver_class => "#{type}_class"
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
for_assertions_with :all do |jboss|
|
128
|
+
file = "#{jboss.profile}/deploy/#{type}-ds.xml"
|
129
|
+
xml = REXML::Document::new File::new(file)
|
130
|
+
|
131
|
+
assert_tag xml, "//jndi-name", "#{type}Datasource", "local-tx-datasource"
|
132
|
+
assert_tag xml, "//user-name", "#{type}_user", "local-tx-datasource"
|
133
|
+
assert_tag xml, "//password", "#{type}_password", "local-tx-datasource"
|
134
|
+
assert_tag xml, "//connection-url", "#{type}_connection", "local-tx-datasource"
|
135
|
+
assert_tag xml, "//driver-class", "#{type}_class", "local-tx-datasource"
|
136
|
+
end
|
137
|
+
|
138
|
+
do_test
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_new_datasource_attributes
|
143
|
+
@types.each do |type|
|
144
|
+
for_test_with :all do |profile|
|
145
|
+
|
146
|
+
profile.add :datasource,
|
147
|
+
:type => type,
|
148
|
+
:attributes => {
|
149
|
+
:min_pool_size => 10,
|
150
|
+
:max_pool_size => 50,
|
151
|
+
:use_java_context => true
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
for_assertions_with :all do |jboss|
|
156
|
+
file = "#{jboss.profile}/deploy/#{type}-ds.xml"
|
157
|
+
xml = REXML::Document::new File::new(file)
|
158
|
+
|
159
|
+
assert_tag xml, "//min-pool-size", 10, "local-tx-datasource"
|
160
|
+
assert_tag xml, "//max-pool-size", 50, "local-tx-datasource"
|
161
|
+
end
|
162
|
+
|
163
|
+
do_test
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_datasource_encryption
|
168
|
+
@types.each do |type|
|
169
|
+
for_test_with :all do |profile|
|
170
|
+
|
171
|
+
profile.add :datasource,
|
172
|
+
:type => type,
|
173
|
+
:encrypt => true,
|
174
|
+
:attributes => {
|
175
|
+
:jndi_name => "MyDatasource",
|
176
|
+
:user_name => "user-name",
|
177
|
+
:password => "password"
|
178
|
+
}
|
179
|
+
end
|
180
|
+
|
181
|
+
for_assertions_with :all do |jboss|
|
182
|
+
file = "#{jboss.profile}/deploy/#{type}-ds.xml"
|
183
|
+
xml = REXML::Document::new File::new(file)
|
184
|
+
|
185
|
+
assert XPath::first(xml, "//user-name").nil?
|
186
|
+
assert XPath::first(xml, "//password").nil?
|
187
|
+
|
188
|
+
assert_tag xml, "//security-domain", type, "local-tx-datasource"
|
189
|
+
|
190
|
+
xml = REXML::Document::new File::new("#{jboss.profile}/deploy/#{type}.login-module.xml")
|
191
|
+
|
192
|
+
application_policy = XPath::first xml, "//application-policy[@name='#{type}']"
|
193
|
+
assert !application_policy.nil?
|
194
|
+
assert application_policy.parent.name == "policy"
|
195
|
+
|
196
|
+
assert_tag application_policy, ".//module-option[@name='username']", "user-name", "login-module"
|
197
|
+
assert_tag application_policy, ".//module-option[@name='password']", "5dfc52b51bd35553df8592078de921bc", "login-module"
|
198
|
+
assert_tag application_policy, ".//module-option[@name='managedConnectionFactoryName']", "jboss.jca:name=MyDatasource,service=LocalTxCM", "login-module"
|
199
|
+
end
|
200
|
+
|
201
|
+
do_test
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def assert_tag xml, path, value, parent_name = nil
|
206
|
+
tag = XPath::first xml, path
|
207
|
+
assert tag.text.strip == value.to_s
|
208
|
+
assert tag.parent.name == parent_name if parent_name
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'test_helper'
|
24
|
+
|
25
|
+
class DeployFolderTest < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def test_folder_inside_deploy
|
28
|
+
for_test_with :all do |profile|
|
29
|
+
profile.add :deploy_folder, 'deploy/rboss-deploy'
|
30
|
+
profile.add :deploy_folder, 'deploy/rboss/deploy'
|
31
|
+
end
|
32
|
+
|
33
|
+
for_assertions_with :all do |jboss|
|
34
|
+
assert(File.exists? "#{jboss.profile}/deploy/rboss-deploy")
|
35
|
+
assert(File.directory? "#{jboss.profile}/deploy/rboss-deploy")
|
36
|
+
assert(File.exists? "#{jboss.profile}/deploy/rboss/deploy")
|
37
|
+
assert(File.directory? "#{jboss.profile}/deploy/rboss/deploy")
|
38
|
+
end
|
39
|
+
|
40
|
+
do_test
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_folder_outside_deploy
|
44
|
+
for_test_with :all do |profile|
|
45
|
+
profile.add :deploy_folder, 'rboss-deploy'
|
46
|
+
profile.add :deploy_folder, 'rboss/deploy'
|
47
|
+
end
|
48
|
+
|
49
|
+
for_assertions_with :all do |jboss|
|
50
|
+
assert(File.exists? "#{jboss.profile}/rboss-deploy")
|
51
|
+
assert(File.directory? "#{jboss.profile}/rboss-deploy")
|
52
|
+
assert(File.exists? "#{jboss.profile}/rboss/deploy")
|
53
|
+
assert(File.directory? "#{jboss.profile}/rboss/deploy")
|
54
|
+
|
55
|
+
check_profile_xml "${jboss.server.home.url}rboss-deploy", "${jboss.server.home.url}rboss/deploy"
|
56
|
+
check_vfs_xml "${jboss.server.home.url}rboss-deploy", "${jboss.server.home.url}rboss/deploy"
|
57
|
+
end
|
58
|
+
|
59
|
+
for_assertions_with :org, 6.0 do |jboss|
|
60
|
+
assert(File.exists? "#{jboss.profile}/rboss-deploy")
|
61
|
+
assert(File.directory? "#{jboss.profile}/rboss-deploy")
|
62
|
+
assert(File.exists? "#{jboss.profile}/rboss/deploy")
|
63
|
+
assert(File.directory? "#{jboss.profile}/rboss/deploy")
|
64
|
+
|
65
|
+
check_profile_xml "${jboss.server.home.url}rboss-deploy", "${jboss.server.home.url}rboss/deploy"
|
66
|
+
end
|
67
|
+
|
68
|
+
do_test
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_folder_outside_jboss
|
72
|
+
for_test_with :all do |profile|
|
73
|
+
profile.add :deploy_folder, '/tmp/rboss-deploy'
|
74
|
+
profile.add :deploy_folder, '/tmp/rboss/deploy'
|
75
|
+
end
|
76
|
+
|
77
|
+
for_assertions_with :all do |jboss|
|
78
|
+
assert(File.exists? "/tmp/rboss-deploy")
|
79
|
+
assert(File.directory? "/tmp/rboss-deploy")
|
80
|
+
assert(File.exists? "/tmp/rboss/deploy")
|
81
|
+
assert(File.directory? "/tmp/rboss/deploy")
|
82
|
+
|
83
|
+
check_profile_xml 'file:///tmp/rboss-deploy', 'file:///tmp/rboss/deploy'
|
84
|
+
check_vfs_xml 'file:///tmp/rboss-deploy', 'file:///tmp/rboss/deploy'
|
85
|
+
end
|
86
|
+
|
87
|
+
for_assertions_with :org, 6.0 do |jboss|
|
88
|
+
assert(File.exists? "/tmp/rboss-deploy")
|
89
|
+
assert(File.directory? "/tmp/rboss-deploy")
|
90
|
+
assert(File.exists? "/tmp/rboss/deploy")
|
91
|
+
assert(File.directory? "/tmp/rboss/deploy")
|
92
|
+
|
93
|
+
check_profile_xml 'file:///tmp/rboss-deploy', 'file:///tmp/rboss/deploy'
|
94
|
+
end
|
95
|
+
|
96
|
+
do_test
|
97
|
+
|
98
|
+
`rm -rf /tmp/rboss*`
|
99
|
+
end
|
100
|
+
|
101
|
+
def check_profile_xml *names
|
102
|
+
xml = REXML::Document::new File::new("#{@jboss.profile}/conf/bootstrap/profile.xml")
|
103
|
+
element = XPath.first xml, "//property[@name='applicationURIs']"
|
104
|
+
element = XPath.first element, "//list[@elementClass='java.net.URI']"
|
105
|
+
element.each do |el|
|
106
|
+
names.delete el.text.strip if el.respond_to? :text
|
107
|
+
end
|
108
|
+
assert(names.empty?)
|
109
|
+
end
|
110
|
+
|
111
|
+
def check_vfs_xml *names
|
112
|
+
xml = REXML::Document::new File::new("#{@jboss.profile}/conf/bootstrap/vfs.xml")
|
113
|
+
element = XPath.first xml, "//property[@name='permanentRoots']"
|
114
|
+
element = XPath.first element, "//map[@keyClass='java.net.URL']"
|
115
|
+
XPath.each element, "//key" do |el|
|
116
|
+
if el.respond_to? :text
|
117
|
+
names.delete el.text.strip
|
118
|
+
value = XPath.first el.parent, "//value"
|
119
|
+
inject = XPath.first value, "//inject"
|
120
|
+
assert(inject.attributes["bean"] == "VfsNamesExceptionHandler")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
assert(names.empty?)
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/test/mbean_test.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
require_relative '../lib/rboss'
|
25
|
+
|
26
|
+
class MBeanTest < Test::Unit::TestCase
|
27
|
+
|
28
|
+
def twiddle
|
29
|
+
twiddle = Object.new
|
30
|
+
def twiddle.invoke command, *args
|
31
|
+
"#{command} #{args.join " "}".strip
|
32
|
+
end
|
33
|
+
twiddle
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_pattern_with_resource
|
37
|
+
mbean = JBoss::MBean::new :pattern => 'query=/#{resource}', :twiddle => twiddle
|
38
|
+
mbean.resource= "my_resource"
|
39
|
+
assert_equal "get query=/my_resource my_property", mbean[:my_property]
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_pattern_without_resource
|
43
|
+
mbean = JBoss::MBean::new :pattern => 'query=/resource', :twiddle => twiddle
|
44
|
+
assert_equal "get query=/resource my_property", mbean[:my_property]
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_invoke
|
48
|
+
mbean = JBoss::MBean::new :pattern => 'jboss.system:type=Server', :twiddle => twiddle
|
49
|
+
assert_equal "invoke jboss.system:type=Server shutdown", mbean.shutdown
|
50
|
+
assert_equal "invoke jboss.system:type=Server traceInstructions true", mbean.traceInstructions(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|