copland 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +88 -0
- data/doc/manual-html/chapter-1.html +454 -0
- data/doc/manual-html/chapter-10.html +399 -0
- data/doc/manual-html/chapter-11.html +600 -0
- data/doc/manual-html/chapter-12.html +406 -0
- data/doc/manual-html/chapter-2.html +382 -0
- data/doc/manual-html/chapter-3.html +424 -0
- data/doc/manual-html/chapter-4.html +432 -0
- data/doc/manual-html/chapter-5.html +381 -0
- data/doc/manual-html/chapter-6.html +364 -0
- data/doc/manual-html/chapter-7.html +434 -0
- data/doc/manual-html/chapter-8.html +373 -0
- data/doc/manual-html/chapter-9.html +324 -0
- data/doc/manual-html/copland.png +0 -0
- data/doc/manual-html/index.html +331 -0
- data/doc/manual-html/manual.css +179 -0
- data/doc/manual-html/tutorial-1.html +407 -0
- data/doc/manual-html/tutorial-2.html +451 -0
- data/doc/manual-html/tutorial-3.html +484 -0
- data/doc/manual-html/tutorial-4.html +446 -0
- data/doc/manual-html/tutorial-5.html +520 -0
- data/doc/manual/chapter.erb +18 -0
- data/doc/manual/example.erb +18 -0
- data/doc/manual/img/copland.png +0 -0
- data/doc/manual/index.erb +30 -0
- data/doc/manual/manual.css +179 -0
- data/doc/manual/manual.rb +239 -0
- data/doc/manual/manual.yml +2643 -0
- data/doc/manual/page.erb +102 -0
- data/doc/manual/tutorial.erb +30 -0
- data/doc/packages/copland.html +764 -0
- data/doc/packages/copland.lib.html +439 -0
- data/doc/packages/copland.remote.html +2096 -0
- data/doc/packages/copland.webrick.html +925 -0
- data/doc/packages/index.html +49 -0
- data/doc/packages/packrat.css +125 -0
- data/examples/calc/calc.rb +47 -0
- data/examples/calc/package.yml +35 -0
- data/examples/calc/services.rb +74 -0
- data/examples/solitaire-cipher/README +11 -0
- data/examples/solitaire-cipher/Rakefile +57 -0
- data/examples/solitaire-cipher/bin/main.rb +14 -0
- data/examples/solitaire-cipher/lib/cipher.rb +230 -0
- data/examples/solitaire-cipher/lib/cli.rb +24 -0
- data/examples/solitaire-cipher/lib/package.yml +106 -0
- data/examples/solitaire-cipher/test/tc_deck.rb +30 -0
- data/examples/solitaire-cipher/test/tc_key-stream.rb +19 -0
- data/examples/solitaire-cipher/test/tc_keying-algorithms.rb +31 -0
- data/examples/solitaire-cipher/test/tc_solitaire-cipher.rb +66 -0
- data/examples/solitaire-cipher/test/tc_unkeyed-algorithm.rb +17 -0
- data/examples/solitaire-cipher/test/tests.rb +2 -0
- data/lib/copland.rb +56 -0
- data/lib/copland/class-factory.rb +95 -0
- data/lib/copland/configuration-point.rb +38 -0
- data/lib/copland/configuration-point/common.rb +203 -0
- data/lib/copland/configuration-point/errors.rb +44 -0
- data/lib/copland/configuration-point/list.rb +59 -0
- data/lib/copland/configuration-point/map.rb +59 -0
- data/lib/copland/configuration/errors.rb +43 -0
- data/lib/copland/configuration/loader.rb +113 -0
- data/lib/copland/configuration/yaml/configuration-point.rb +87 -0
- data/lib/copland/configuration/yaml/implementor.rb +134 -0
- data/lib/copland/configuration/yaml/interceptor.rb +63 -0
- data/lib/copland/configuration/yaml/listener.rb +56 -0
- data/lib/copland/configuration/yaml/loader.rb +122 -0
- data/lib/copland/configuration/yaml/package.rb +125 -0
- data/lib/copland/configuration/yaml/parser.rb +71 -0
- data/lib/copland/configuration/yaml/schema.rb +165 -0
- data/lib/copland/configuration/yaml/service-point.rb +116 -0
- data/lib/copland/configuration/yaml/utils.rb +82 -0
- data/lib/copland/default-schema-processor.rb +144 -0
- data/lib/copland/errors.rb +82 -0
- data/lib/copland/event-producer.rb +95 -0
- data/lib/copland/impl/builder-factory.rb +112 -0
- data/lib/copland/impl/copland-config.yml +1 -0
- data/lib/copland/impl/include-exclude.rb +140 -0
- data/lib/copland/impl/logging-interceptor.rb +106 -0
- data/lib/copland/impl/package.yml +217 -0
- data/lib/copland/impl/startup.rb +116 -0
- data/lib/copland/impl/symbol-source-manager.rb +131 -0
- data/lib/copland/impl/symbol-source.rb +63 -0
- data/lib/copland/instantiator.rb +38 -0
- data/lib/copland/instantiator/abstract.rb +91 -0
- data/lib/copland/instantiator/complex.rb +96 -0
- data/lib/copland/instantiator/identity.rb +58 -0
- data/lib/copland/instantiator/simple.rb +68 -0
- data/lib/copland/interceptor-chain.rb +166 -0
- data/lib/copland/interceptor.rb +139 -0
- data/lib/copland/log-factory.rb +206 -0
- data/lib/copland/models.rb +39 -0
- data/lib/copland/models/abstract.rb +78 -0
- data/lib/copland/models/prototype-deferred.rb +58 -0
- data/lib/copland/models/prototype.rb +58 -0
- data/lib/copland/models/proxy.rb +100 -0
- data/lib/copland/models/singleton-deferred.rb +59 -0
- data/lib/copland/models/singleton.rb +77 -0
- data/lib/copland/models/threaded.rb +65 -0
- data/lib/copland/ordering.rb +123 -0
- data/lib/copland/package.rb +246 -0
- data/lib/copland/registry.rb +368 -0
- data/lib/copland/schema.rb +206 -0
- data/lib/copland/service-point.rb +282 -0
- data/lib/copland/utils.rb +221 -0
- data/lib/copland/version.rb +47 -0
- data/test/conf-test/list-bad-key.yml +30 -0
- data/test/conf-test/list-bad-missing.yml +28 -0
- data/test/conf-test/list-bad-type.yml +28 -0
- data/test/conf-test/list-good.yml +29 -0
- data/test/conf-test/map-bad-key.yml +25 -0
- data/test/conf-test/map-bad-missing.yml +24 -0
- data/test/conf-test/map-bad-type.yml +23 -0
- data/test/conf-test/map-good.yml +25 -0
- data/test/configuration-point/package.yml +52 -0
- data/test/configuration/yaml/config/copland-config.yml +2 -0
- data/test/configuration/yaml/config/module.yml +2 -0
- data/test/configuration/yaml/config/subdir/copland-config.yml +2 -0
- data/test/configuration/yaml/config/subdir/package.yml +4 -0
- data/test/configuration/yaml/defaults/package.yml +5 -0
- data/test/configuration/yaml/defaults/subdir/package.yml +4 -0
- data/test/configuration/yaml/tc_config-loader.rb +86 -0
- data/test/configuration/yaml/tc_configuration-point-processor.rb +134 -0
- data/test/configuration/yaml/tc_implementor-processor.rb +104 -0
- data/test/configuration/yaml/tc_interceptor-processor.rb +85 -0
- data/test/configuration/yaml/tc_listener-processor.rb +69 -0
- data/test/configuration/yaml/tc_loader.rb +74 -0
- data/test/configuration/yaml/tc_package-processor.rb +120 -0
- data/test/configuration/yaml/tc_parser.rb +94 -0
- data/test/configuration/yaml/tc_schema-parser.rb +160 -0
- data/test/configuration/yaml/tc_service-point-processor.rb +104 -0
- data/test/configuration/yaml/tc_type-validator.rb +90 -0
- data/test/custom-logger.yml +3 -0
- data/test/impl/logging/package.yml +44 -0
- data/test/impl/logging/services.rb +84 -0
- data/test/impl/startup/package.yml +46 -0
- data/test/impl/startup/services.rb +47 -0
- data/test/impl/symbols/package.yml +24 -0
- data/test/impl/symbols/services.rb +38 -0
- data/test/impl/tc_builder-factory.rb +173 -0
- data/test/impl/tc_logging-interceptor.rb +148 -0
- data/test/impl/tc_startup.rb +59 -0
- data/test/impl/tc_symbol-sources.rb +61 -0
- data/test/logger.yml +6 -0
- data/test/mock.rb +201 -0
- data/test/schema/bad-package.yml +65 -0
- data/test/schema/package.yml +102 -0
- data/test/schema/services.rb +5 -0
- data/test/services/package.yml +79 -0
- data/test/services/simple.rb +87 -0
- data/test/tc_class-factory.rb +93 -0
- data/test/tc_complex-instantiator.rb +107 -0
- data/test/tc_configuration-point-contrib.rb +74 -0
- data/test/tc_configuration-point-schema.rb +122 -0
- data/test/tc_configuration-point.rb +91 -0
- data/test/tc_default-schema-processor.rb +297 -0
- data/test/tc_identity-instantiator.rb +61 -0
- data/test/tc_interceptors.rb +84 -0
- data/test/tc_logger.rb +131 -0
- data/test/tc_models.rb +176 -0
- data/test/tc_package.rb +165 -0
- data/test/tc_proxy.rb +65 -0
- data/test/tc_registry.rb +141 -0
- data/test/tc_schema.rb +78 -0
- data/test/tc_service-point.rb +178 -0
- data/test/tc_service.rb +70 -0
- data/test/tc_simple-instantiator.rb +61 -0
- data/test/tests.rb +93 -0
- data/tutorial/01/main.rb +7 -0
- data/tutorial/01/package.yml +8 -0
- data/tutorial/01/tutorial.rb +7 -0
- data/tutorial/02/main.rb +10 -0
- data/tutorial/02/package.yml +27 -0
- data/tutorial/02/tutorial.rb +46 -0
- data/tutorial/03/main.rb +24 -0
- data/tutorial/03/package.yml +29 -0
- data/tutorial/03/tutorial.rb +48 -0
- data/tutorial/04/main.rb +24 -0
- data/tutorial/04/package.yml +35 -0
- data/tutorial/04/tutorial.rb +48 -0
- data/tutorial/05/functions/package.yml +16 -0
- data/tutorial/05/functions/services.rb +15 -0
- data/tutorial/05/main.rb +10 -0
- data/tutorial/05/package.yml +35 -0
- data/tutorial/05/tutorial.rb +53 -0
- metadata +260 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
#--
|
2
|
+
# =============================================================================
|
3
|
+
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# * The names of its contributors may not be used to endorse or promote
|
17
|
+
# products derived from this software without specific prior written
|
18
|
+
# permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
# =============================================================================
|
32
|
+
#++
|
33
|
+
|
34
|
+
class SymbolTest
|
35
|
+
attr_accessor :one
|
36
|
+
attr_accessor :two
|
37
|
+
attr_accessor :three
|
38
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
#--
|
2
|
+
# =============================================================================
|
3
|
+
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# * The names of its contributors may not be used to endorse or promote
|
17
|
+
# products derived from this software without specific prior written
|
18
|
+
# permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
# =============================================================================
|
32
|
+
#++
|
33
|
+
|
34
|
+
$:.unshift ".."
|
35
|
+
$:.unshift "../../lib"
|
36
|
+
|
37
|
+
require 'test/unit'
|
38
|
+
require 'copland/errors'
|
39
|
+
require 'copland/registry'
|
40
|
+
require 'singleton'
|
41
|
+
require 'mock'
|
42
|
+
|
43
|
+
class MockFactoryBuiltService
|
44
|
+
attr_accessor :attr1
|
45
|
+
attr_accessor :attr2
|
46
|
+
attr_accessor :attr3
|
47
|
+
attr_reader :attr4
|
48
|
+
attr_accessor :attr5
|
49
|
+
attr_reader :attr6
|
50
|
+
|
51
|
+
def set_attr4( v )
|
52
|
+
@attr4 = v
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize( a=nil )
|
56
|
+
@attr3 = a
|
57
|
+
@attr5 = "not yet initialized!"
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize_service
|
61
|
+
@attr5 = "initialized!"
|
62
|
+
end
|
63
|
+
|
64
|
+
def custom_initialize
|
65
|
+
@attr5 = "custom initialize"
|
66
|
+
end
|
67
|
+
|
68
|
+
def compute( a, b )
|
69
|
+
@attr6 = @attr1 + a + b
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class MockSingletonBuiltService < MockFactoryBuiltService
|
74
|
+
include Singleton
|
75
|
+
end
|
76
|
+
|
77
|
+
class TC_BuilderFactory < Test::Unit::TestCase
|
78
|
+
def setup
|
79
|
+
@registry = Copland::Registry.build( "", :log_device=>STDOUT )
|
80
|
+
@factory = @registry.service( "copland.BuilderFactory" )
|
81
|
+
@point = MockServicePoint.new
|
82
|
+
end
|
83
|
+
|
84
|
+
def teardown
|
85
|
+
@registry.shutdown
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_no_parms
|
89
|
+
parms = { "class" => "MockFactoryBuiltService" }
|
90
|
+
svc = @factory.create_instance @point, parms
|
91
|
+
|
92
|
+
assert_instance_of MockFactoryBuiltService, svc
|
93
|
+
assert_nil svc.attr3
|
94
|
+
assert_equal "initialized!", svc.attr5
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_initialize_method
|
98
|
+
parms = { "class" => "MockFactoryBuiltService",
|
99
|
+
"initialize-method" => "custom_initialize" }
|
100
|
+
svc = @factory.create_instance @point, parms
|
101
|
+
|
102
|
+
assert_equal "custom initialize", svc.attr5
|
103
|
+
|
104
|
+
parms = { "class" => "MockFactoryBuiltService",
|
105
|
+
"initialize-method" => "bogus_initialize" }
|
106
|
+
svc = @factory.create_instance @point, parms
|
107
|
+
|
108
|
+
assert_equal "not yet initialized!", svc.attr5
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_parameters
|
112
|
+
parms = { "class" => "MockFactoryBuiltService",
|
113
|
+
"parameters" => [ "parm" ] }
|
114
|
+
svc = @factory.create_instance @point, parms
|
115
|
+
assert_equal "parm", svc.attr3
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_properties
|
119
|
+
parms = { "class" => "MockFactoryBuiltService",
|
120
|
+
"properties" => { "attr1" => "1",
|
121
|
+
"attr2" => "2",
|
122
|
+
"attr3" => "3",
|
123
|
+
"attr4" => "4",
|
124
|
+
"attr5" => "5" } }
|
125
|
+
svc = @factory.create_instance @point, parms
|
126
|
+
assert_equal "1", svc.attr1
|
127
|
+
assert_equal "2", svc.attr2
|
128
|
+
assert_equal "3", svc.attr3
|
129
|
+
assert_equal "4", svc.attr4
|
130
|
+
assert_equal "initialized!", svc.attr5
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_invoke
|
134
|
+
parms = { "class" => "MockFactoryBuiltService",
|
135
|
+
"properties" => { "attr1" => 1 },
|
136
|
+
"invoke" => { "compute" => [ 5, 6 ] } }
|
137
|
+
svc = @factory.create_instance @point, parms
|
138
|
+
assert_equal 12, svc.attr6
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_singleton_no_parms
|
142
|
+
parms = { "class" => "MockSingletonBuiltService" }
|
143
|
+
svc = @factory.create_instance @point, parms
|
144
|
+
|
145
|
+
assert_instance_of MockSingletonBuiltService, svc
|
146
|
+
assert_nil svc.attr3
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_singleton_parameters
|
150
|
+
parms = { "class" => "MockSingletonBuiltService",
|
151
|
+
"parameters" => [ "parm" ] }
|
152
|
+
|
153
|
+
assert_raise( Copland::CoplandException ) do
|
154
|
+
svc = @factory.create_instance @point, parms
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_singleton_properties
|
159
|
+
parms = { "class" => "MockSingletonBuiltService",
|
160
|
+
"properties" => { "attr1" => "1",
|
161
|
+
"attr2" => "2",
|
162
|
+
"attr3" => "3",
|
163
|
+
"attr4" => "4",
|
164
|
+
"attr5" => "5" } }
|
165
|
+
svc = @factory.create_instance @point, parms
|
166
|
+
assert_equal "1", svc.attr1
|
167
|
+
assert_equal "2", svc.attr2
|
168
|
+
assert_equal "3", svc.attr3
|
169
|
+
assert_equal "4", svc.attr4
|
170
|
+
assert_equal "initialized!", svc.attr5
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
#--
|
2
|
+
# =============================================================================
|
3
|
+
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# * The names of its contributors may not be used to endorse or promote
|
17
|
+
# products derived from this software without specific prior written
|
18
|
+
# permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
# =============================================================================
|
32
|
+
#++
|
33
|
+
|
34
|
+
$:.unshift File.dirname( __FILE__ )
|
35
|
+
$:.unshift ".."
|
36
|
+
$:.unshift "../../lib"
|
37
|
+
|
38
|
+
require 'copland/impl/logging-interceptor'
|
39
|
+
require 'copland/log-factory'
|
40
|
+
require 'copland/package'
|
41
|
+
require 'copland/registry'
|
42
|
+
require 'copland/service-point'
|
43
|
+
require 'test/unit'
|
44
|
+
require 'mock'
|
45
|
+
|
46
|
+
class TC_LoggingInterceptor < Test::Unit::TestCase
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@device = MockLogIO.new
|
50
|
+
@registry = Copland::Registry.build(
|
51
|
+
File.join( File.dirname( __FILE__ ), "logging" ),
|
52
|
+
:log_device => @device,
|
53
|
+
:log_default_level => Logger::DEBUG
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def teardown
|
58
|
+
@registry.shutdown
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_log
|
62
|
+
service = @registry.service( "logging.Test" )
|
63
|
+
|
64
|
+
assert_equal "", @device.message
|
65
|
+
service.echo 15
|
66
|
+
assert_match( /DEBUG -- logging.Test: echo\( 15 \)/, @device.message )
|
67
|
+
assert_match( /DEBUG -- logging.Test: echo => 15/, @device.message )
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_exclude
|
71
|
+
service = @registry.service( "logging.TestExclude" )
|
72
|
+
|
73
|
+
assert_equal "", @device.message
|
74
|
+
service.echo 15
|
75
|
+
assert_match( /DEBUG -- logging.TestExclude: echo\( 15 \)/, @device.message )
|
76
|
+
assert_match( /DEBUG -- logging.TestExclude: echo => 15/, @device.message )
|
77
|
+
|
78
|
+
@device.clear
|
79
|
+
assert_equal "", @device.message
|
80
|
+
service.echo_notme 15
|
81
|
+
assert_equal "", @device.message
|
82
|
+
|
83
|
+
@device.clear
|
84
|
+
assert_equal "", @device.message
|
85
|
+
service.echo_multiple 15, 16
|
86
|
+
assert_equal "", @device.message
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_include
|
90
|
+
service = @registry.service( "logging.TestInclude" )
|
91
|
+
|
92
|
+
assert_equal "", @device.message
|
93
|
+
service.echo 15
|
94
|
+
assert_match( /DEBUG -- logging.TestInclude: echo\( 15 \)/, @device.message )
|
95
|
+
assert_match( /DEBUG -- logging.TestInclude: echo => 15/, @device.message )
|
96
|
+
|
97
|
+
@device.clear
|
98
|
+
assert_equal "", @device.message
|
99
|
+
service.echo_notme 15
|
100
|
+
assert_equal "", @device.message
|
101
|
+
|
102
|
+
@device.clear
|
103
|
+
assert_equal "", @device.message
|
104
|
+
service.echo_notme_multiple 15, 16
|
105
|
+
assert_match( /DEBUG -- logging.TestInclude: echo_notme_multiple\( 15, 16 \)/, @device.message )
|
106
|
+
assert_match( /DEBUG -- logging.TestInclude: echo_notme_multiple => \[15, 16\]/, @device.message )
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_include2
|
110
|
+
service = @registry.service( "logging.TestInclude2" )
|
111
|
+
|
112
|
+
@device.clear
|
113
|
+
assert_equal "", @device.message
|
114
|
+
service.echo_notme 15
|
115
|
+
assert_match( /DEBUG -- logging.TestInclude2: echo_notme\( 15 \)/, @device.message )
|
116
|
+
assert_match( /DEBUG -- logging.TestInclude2: echo_notme => 15/, @device.message )
|
117
|
+
|
118
|
+
@device.clear
|
119
|
+
assert_equal "", @device.message
|
120
|
+
service.echo_notme_multiple 15, 16
|
121
|
+
assert_equal "", @device.message
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_arity
|
125
|
+
service = @registry.service( "logging.TestArity" )
|
126
|
+
|
127
|
+
assert_equal "", @device.message
|
128
|
+
service.echo 15, 16, 17
|
129
|
+
assert_match( /DEBUG -- logging.TestArity: echo\( 15, 16, 17 \)/, @device.message )
|
130
|
+
assert_match( /DEBUG -- logging.TestArity: echo => \[15, 16, 17\]/, @device.message )
|
131
|
+
|
132
|
+
@device.clear
|
133
|
+
assert_equal "", @device.message
|
134
|
+
service.too_few 1
|
135
|
+
assert_equal "", @device.message
|
136
|
+
|
137
|
+
@device.clear
|
138
|
+
assert_equal "", @device.message
|
139
|
+
service.too_many 1, 2, 3, 4, 5, 6, 7, 8
|
140
|
+
assert_equal "", @device.message
|
141
|
+
|
142
|
+
@device.clear
|
143
|
+
assert_equal "", @device.message
|
144
|
+
service.just_right 1, 2, 3, 4, 5
|
145
|
+
assert_equal "", @device.message
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#--
|
2
|
+
# =============================================================================
|
3
|
+
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# * The names of its contributors may not be used to endorse or promote
|
17
|
+
# products derived from this software without specific prior written
|
18
|
+
# permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
# =============================================================================
|
32
|
+
#++
|
33
|
+
|
34
|
+
$:.unshift File.dirname( __FILE__ )
|
35
|
+
$:.unshift ".."
|
36
|
+
$:.unshift "../../lib"
|
37
|
+
|
38
|
+
require 'startup/services'
|
39
|
+
require 'copland'
|
40
|
+
require 'test/unit'
|
41
|
+
|
42
|
+
class TC_Startup < Test::Unit::TestCase
|
43
|
+
|
44
|
+
def test_startup
|
45
|
+
assert_equal "not initialized", $startup_marker
|
46
|
+
assert_equal "sequence:", $ordered_startup_output
|
47
|
+
|
48
|
+
registry = Copland::Registry.build(
|
49
|
+
File.join( File.dirname( __FILE__ ), "startup" ),
|
50
|
+
:log_device => STDOUT
|
51
|
+
)
|
52
|
+
|
53
|
+
assert_equal "StartupTest service initialized", $startup_marker
|
54
|
+
assert_equal "sequence: B A C", $ordered_startup_output
|
55
|
+
|
56
|
+
registry.shutdown
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#--
|
2
|
+
# =============================================================================
|
3
|
+
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# * Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# * Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# * The names of its contributors may not be used to endorse or promote
|
17
|
+
# products derived from this software without specific prior written
|
18
|
+
# permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
# =============================================================================
|
32
|
+
#++
|
33
|
+
|
34
|
+
$:.unshift ".."
|
35
|
+
$:.unshift "../../lib"
|
36
|
+
$:.unshift File.dirname( __FILE__ )
|
37
|
+
|
38
|
+
require 'test/unit'
|
39
|
+
require 'copland/registry'
|
40
|
+
|
41
|
+
class TC_SymbolSources < Test::Unit::TestCase
|
42
|
+
|
43
|
+
def setup
|
44
|
+
@registry = Copland::Registry.build(
|
45
|
+
File.join( File.dirname( __FILE__ ), "symbols" ),
|
46
|
+
:log_device => STDOUT )
|
47
|
+
end
|
48
|
+
|
49
|
+
def teardown
|
50
|
+
@registry.shutdown
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_substitution_symbols
|
54
|
+
svc = @registry.service( "symbol-test.SymbolTest" )
|
55
|
+
|
56
|
+
assert_equal "hello", svc.one
|
57
|
+
assert_equal "earth", svc.two
|
58
|
+
assert_equal "foobar", svc.three
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|