buildr4osgi 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/buildr4osgi.gemspec +2 -2
  2. data/lib/buildr4osgi.rb +2 -0
  3. data/lib/buildr4osgi/compile.rb +2 -1
  4. data/lib/buildr4osgi/compile/compiler.rb +1 -3
  5. data/lib/buildr4osgi/compile/external.rb +71 -0
  6. data/lib/buildr4osgi/eclipse.rb +3 -1
  7. data/lib/buildr4osgi/eclipse/feature.rb +12 -7
  8. data/lib/buildr4osgi/eclipse/p2.rb +137 -0
  9. data/lib/buildr4osgi/eclipse/site.rb +207 -0
  10. data/lib/buildr4osgi/osgi/bundle.rb +17 -12
  11. data/lib/buildr4osgi/osgi/bundle_package.rb +35 -11
  12. data/lib/buildr4osgi/osgi/container.rb +1 -0
  13. data/lib/buildr4osgi/osgi/execution_environment.rb +199 -0
  14. data/lib/buildr4osgi/osgi/library_extension.rb +14 -1
  15. data/lib/buildr4osgi/osgi/packaging_sources.rb +4 -0
  16. data/lib/buildr4osgi/osgi/project_extension.rb +59 -20
  17. data/lib/buildr4osgi/osgi/registry.rb +23 -29
  18. data/lib/buildr4osgi/osgi/resolving_strategies.rb +1 -0
  19. data/lib/buildr4osgi/osgi/version.rb +1 -1
  20. data/rakelib/all-in-one.rake +84 -0
  21. data/rakelib/stage.rake +5 -4
  22. data/spec/compile/external_spec.rb +41 -0
  23. data/spec/eclipse/p2_spec.rb +65 -0
  24. data/spec/eclipse/site_spec.rb +94 -0
  25. data/spec/osgi/bundle_package_spec.rb +13 -1
  26. data/spec/osgi/bundle_spec.rb +2 -2
  27. data/spec/osgi/execution_environment_spec.rb +48 -0
  28. data/spec/osgi/library_extension_spec.rb +15 -2
  29. data/spec/osgi/project_extension_spec.rb +86 -18
  30. data/spec/osgi/registry_spec.rb +30 -20
  31. data/spec/osgi/resolving_strategies_spec.rb +2 -2
  32. data/spec/osgi/version_spec.rb +6 -0
  33. data/spec/spec_helpers.rb +12 -0
  34. metadata +12 -16
  35. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.jar +0 -0
  36. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.pom +0 -82
  37. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
  38. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +0 -478
  39. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
  40. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
  41. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +0 -30
  42. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
  43. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
  44. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +0 -101
  45. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
  46. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
  47. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +0 -56
@@ -193,9 +193,9 @@ MANIFEST
193
193
 
194
194
  it "should find the bundle fragments" do
195
195
  foo = define("foo")
196
- foo.osgi.registry.containers = @eclipse_instances.dup
196
+ OSGi.registry.containers = @eclipse_instances.dup
197
197
 
198
- @bundle.fragments(foo).should == [@fragment]
198
+ @bundle.fragments.should == [@fragment]
199
199
  end
200
200
 
201
201
  end
@@ -0,0 +1,48 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe OSGi::ExecutionEnvironment do
19
+
20
+ it 'should create a frozen object' do
21
+ ee = OSGi::ExecutionEnvironment.new("example", "hello", ["com", "org"])
22
+ ee.should be_frozen
23
+ ee.packages.should be_frozen
24
+ end
25
+ end
26
+
27
+ describe OSGi::ExecutionEnvironmentConfiguration do
28
+
29
+ before :all do
30
+ @conf = OSGi::ExecutionEnvironmentConfiguration.new
31
+ end
32
+
33
+
34
+ it "should add the default execution environments" do
35
+ @conf.send( :available_ee).values.should include OSGi::NONE, OSGi::CDC10FOUNDATION10, OSGi::CDC10FOUNDATION11, OSGi::J2SE12, OSGi::J2SE13, OSGi::J2SE14, OSGi::J2SE15, OSGi::JAVASE16, OSGi::JAVASE17, OSGi::OSGIMINIMUM10, OSGi::OSGIMINIMUM11, OSGi::OSGIMINIMUM12
36
+ end
37
+
38
+ it "should set JavaSE1.6 as the default execution environment" do
39
+ @conf.current_execution_environment.should == OSGi::JAVASE16
40
+ end
41
+
42
+ it "should let the user define extra packages to be part of the execution environment" do
43
+ @conf.extra_packages << "com.sum.nedia"
44
+ @conf.extra_packages.should include("com.sum.nedia")
45
+ end
46
+ end
47
+
48
+
@@ -92,7 +92,7 @@ describe Buildr4OSGi::BuildLibraries do
92
92
  library_project(SLF4J, "group", "foo", "1.0.0")
93
93
  foo = project("foo")
94
94
  lambda {foo.package(:sources).invoke}.should_not raise_error
95
- sources = File.join(foo.base_dir, "target", "foo-1.0.0-sources.zip")
95
+ sources = File.join(foo.base_dir, "target", "foo-1.0.0-sources.jar")
96
96
  File.exists?(sources).should be_true
97
97
  Zip::ZipFile.open(sources) {|zip|
98
98
  zip.find_entry("org/slf4j/Marker.java").should_not be_nil
@@ -155,5 +155,18 @@ describe Buildr4OSGi::BuildLibraries do
155
155
  lambda {library_project(SLF4J, "org.nuxeo.libs", "org.nuxeo.logging", "1.1.2",
156
156
  :manifest => {"Require-Bundle" => "org.apache.log4j"})}.should_not raise_error(NoMethodError)
157
157
  end
158
- end
158
+ end
159
+
160
+ it "should not add a manifest Export-Package entry if that package was excluded" do
161
+ library_project(SLF4J, "org.hello.libs", "org.hello.logging", "1.1.2", :exclude => "org/slf4j/impl/*")
162
+ foo = project("org.hello.logging")
163
+ foo.package(:library_project).invoke
164
+ jar = File.join(foo.base_dir, "target", "org.hello.logging-1.1.2.jar")
165
+ File.exists?(jar).should be_true
166
+ Zip::ZipFile.open(jar) {|zip|
167
+ zip.find_entry("org/slf4j/impl").should be_nil
168
+ zip.find_entry("org/slf4j/helpers").should_not be_nil
169
+ zip.read("META-INF/MANIFEST.MF").should_not match /org\.slf4j\.impl/
170
+ }
171
+ end
159
172
  end
@@ -19,6 +19,14 @@ Spec::Runner.configure do |config|
19
19
  config.include Buildr4OSGi::SpecHelpers
20
20
  end
21
21
 
22
+ describe OSGi::BundleCollector do
23
+
24
+ it 'should be able to cache a resolved bundle' do
25
+ pending "TODO"
26
+ end
27
+
28
+ end
29
+
22
30
  describe OSGi::ProjectExtension do
23
31
 
24
32
  it 'should give a way to take project dependencies' do
@@ -47,6 +55,65 @@ describe OSGi::ProjectExtension do
47
55
  }
48
56
  end
49
57
 
58
+ it 'should get the execution environments from the project manifest' do
59
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
60
+ Bundle-RequiredExecutionEnvironment: JavaSE-1.6,
61
+ JavaSE-1.7
62
+ MANIFEST
63
+ foo = define("foo", :version => "1.0") do
64
+ package(:bundle)
65
+ end
66
+ foo.execution_environments.should == [OSGi::JAVASE16, OSGi::JAVASE17]
67
+ end
68
+
69
+ it 'should get the execution environment from the project manifest (bis)' do
70
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
71
+ Manifest-Version: 1.0
72
+ Bundle-ManifestVersion: 2
73
+ Bundle-Name: uh-core
74
+ Bundle-SymbolicName: org.thingy
75
+ Bundle-Version: 3.6.2.qualifier
76
+ Bundle-RequiredExecutionEnvironment: J2SE-1.5
77
+ Import-Package: blah,
78
+ blob
79
+ MANIFEST
80
+ foo = define("foo", :version => "1.0") do
81
+ package(:bundle)
82
+ end
83
+ foo.execution_environments.should == [OSGi::J2SE15]
84
+ end
85
+
86
+ it 'should return an empty array when no execution environment is specified' do
87
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
88
+ Manifest-Version: 1.0
89
+ Bundle-ManifestVersion: 2
90
+ Bundle-Name: uh-core
91
+ Bundle-SymbolicName: org.thingy
92
+ Bundle-Version: 3.6.2.qualifier
93
+ Import-Package: blah,
94
+ blob
95
+ MANIFEST
96
+ foo = define("foo", :version => "1.0") do
97
+ package(:bundle)
98
+ end
99
+ foo.execution_environments.should == []
100
+ end
101
+
102
+ it 'should return nil when no bundle packaging is specified' do
103
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
104
+ Manifest-Version: 1.0
105
+ Bundle-ManifestVersion: 2
106
+ Bundle-Name: uh-core
107
+ Bundle-SymbolicName: org.thingy
108
+ Bundle-Version: 3.6.2.qualifier
109
+ Import-Package: blah,
110
+ blob
111
+ MANIFEST
112
+ foo = define("foo", :version => "1.0") do
113
+ package(:jar)
114
+ end
115
+ foo.execution_environments.should be_nil
116
+ end
50
117
  end
51
118
 
52
119
  describe OSGi::DependenciesTask do
@@ -87,7 +154,7 @@ MANIFEST
87
154
  foo = define('foo', :version=> "1.0", :group => "grp" ) {
88
155
  package(:bundle)
89
156
  }
90
- foo.osgi.registry.containers = @eclipse_instances.dup
157
+ OSGi.registry.containers = @eclipse_instances.dup
91
158
  foo.manifest_dependencies.select {|b| b.name == "com.ibm.icu"}.should_not be_empty
92
159
  end
93
160
 
@@ -153,7 +220,7 @@ MANIFEST
153
220
  foo = define('foo', :version => "1.0", :group => "grp") {
154
221
  package(:bundle)
155
222
  }
156
- foo.osgi.registry.containers = @eclipse_instances.dup
223
+ OSGi.registry.containers = @eclipse_instances.dup
157
224
  foo.manifest_dependencies.select {|b| b.name == "com.ibm.icu"}.should_not be_empty
158
225
  foo.manifest_dependencies.select {|b| b.name == "com.ibm.icu" && b.version="[3.4.0,3.5.0)"}.should_not be_empty
159
226
  foo.manifest_dependencies.select {|b| b.name == "org.eclipse.core.resources" && b.version="3.5.0.R_20090512"}.should_not be_empty
@@ -182,7 +249,7 @@ MANIFEST
182
249
  package(:bundle)
183
250
  end
184
251
  end
185
- project('container').osgi.registry.containers = @eclipse_instances.dup
252
+ OSGi.registry.containers = @eclipse_instances.dup
186
253
  project('container:foo').manifest_dependencies.should include(project('container:bar'))
187
254
 
188
255
  end
@@ -198,7 +265,8 @@ MANIFEST
198
265
  foo = define('foo', :version => "1.0", :group => "grp") {
199
266
  package(:bundle)
200
267
  }
201
- foo.osgi.registry.containers = @eclipse_instances.dup
268
+ OSGi.registry.containers = @eclipse_instances.dup
269
+ foo.manifest_dependencies
202
270
  foo.manifest_dependencies.select {|b| b.name == "com.ibm.icu"}.should_not be_empty
203
271
  end
204
272
 
@@ -235,7 +303,7 @@ MANIFEST
235
303
  package(:bundle)
236
304
  end
237
305
  end
238
- project('container').osgi.registry.containers = @eclipse_instances.dup
306
+ OSGi.registry.containers = @eclipse_instances.dup
239
307
  project('container:foo').manifest_dependencies.should include(project('container:bar'))
240
308
  project('container:foo').manifest_dependencies.should_not include(project('container:bar2'))
241
309
  end
@@ -251,7 +319,7 @@ MANIFEST
251
319
  foo = define('foo', :version => "1.0", :group => "grp") {
252
320
  package(:bundle)
253
321
  }
254
- foo.osgi.registry.containers = @eclipse_instances.dup
322
+ OSGi.registry.containers = @eclipse_instances.dup
255
323
  foo.manifest_dependencies.select {|b| b.name == "com.ibm.icu"}.should_not be_empty
256
324
  end
257
325
 
@@ -288,7 +356,7 @@ MANIFEST
288
356
  package(:bundle)
289
357
  end
290
358
  end
291
- project('container').osgi.registry.containers = @eclipse_instances.dup
359
+ OSGi.registry.containers = @eclipse_instances.dup
292
360
  project('container:foo').manifest_dependencies.should include(project('container:bar'))
293
361
  project('container:foo').manifest_dependencies.should_not include(project('container:bar2'))
294
362
 
@@ -305,7 +373,7 @@ MANIFEST
305
373
  foo = define('foo', :version => "1.0", :group => "grp") {
306
374
  package(:bundle)
307
375
  }
308
- foo.osgi.registry.containers = @eclipse_instances.dup
376
+ OSGi.registry.containers = @eclipse_instances.dup
309
377
  foo.task('osgi:resolve:dependencies').invoke
310
378
  File.exist?('dependencies.yml').should be_true
311
379
  deps = YAML::load(File.read('dependencies.yml'))
@@ -339,7 +407,7 @@ MANIFEST
339
407
  package(:bundle)
340
408
  end
341
409
  end
342
- project('container').osgi.registry.containers = @eclipse_instances.dup
410
+ OSGi.registry.containers = @eclipse_instances.dup
343
411
  project('container').task('osgi:resolve:dependencies').invoke
344
412
  File.exist?('dependencies.yml').should be_true
345
413
  deps = YAML::load(File.read('dependencies.yml'))
@@ -371,7 +439,7 @@ MANIFEST
371
439
  package(:bundle)
372
440
  end
373
441
  end
374
- project('container').osgi.registry.containers = @eclipse_instances.dup
442
+ OSGi.registry.containers = @eclipse_instances.dup
375
443
  project('container').task('osgi:resolve:dependencies').invoke
376
444
  File.exist?('dependencies.yml').should be_true
377
445
  deps = YAML::load(File.read('dependencies.yml'))
@@ -403,7 +471,7 @@ MANIFEST
403
471
  package(:bundle)
404
472
  end
405
473
  end
406
- project('container').osgi.registry.containers = @eclipse_instances.dup
474
+ OSGi.registry.containers = @eclipse_instances.dup
407
475
  project('container:foo').task('osgi:resolve:dependencies').invoke
408
476
  project('container:bar').task('osgi:resolve:dependencies').invoke
409
477
  File.exist?('dependencies.yml').should be_true
@@ -432,7 +500,7 @@ MANIFEST
432
500
  package(:bundle)
433
501
  }
434
502
  end
435
- project('container').osgi.registry.containers = @eclipse_instances.dup
503
+ OSGi.registry.containers = @eclipse_instances.dup
436
504
  project('container').task('osgi:resolve:dependencies').invoke
437
505
  File.exist?('dependencies.yml').should be_true
438
506
  File.read('dependencies.yml').should == <<-CONTENTS
@@ -481,7 +549,7 @@ MANIFEST
481
549
  foo = define('foo', :version => "1.0", :group => "grp") {
482
550
  package(:bundle)
483
551
  }
484
- foo.osgi.registry.containers = @eclipse_instances.dup
552
+ OSGi.registry.containers = @eclipse_instances.dup
485
553
  foo.task('osgi:resolve:dependencies').invoke
486
554
  File.exist?('dependencies.yml').should be_true
487
555
  deps = YAML::load(File.read('dependencies.yml'))
@@ -514,7 +582,7 @@ MANIFEST
514
582
  foo = define('foo', :version => "1.0", :group => "grp") {
515
583
  package(:bundle)
516
584
  }
517
- foo.osgi.registry.containers = [e2]
585
+ OSGi.registry.containers = [e2]
518
586
  foo.task('osgi:resolve:dependencies').invoke
519
587
  File.exist?('dependencies.yml').should be_true
520
588
  deps = YAML::load(File.read('dependencies.yml'))
@@ -548,7 +616,7 @@ MANIFEST
548
616
  foo = define('foo', :version => "1.0", :group => "grp") {
549
617
  package(:bundle)
550
618
  }
551
- foo.osgi.registry.containers = [e2]
619
+ OSGi.registry.containers = [e2]
552
620
  foo.task('osgi:resolve:dependencies').invoke
553
621
  File.exist?('dependencies.yml').should be_true
554
622
  deps = YAML::load(File.read('dependencies.yml'))
@@ -587,7 +655,7 @@ MANIFEST
587
655
  foo = define('foo', :version => "1.0", :group => "grp") {
588
656
  package(:bundle)
589
657
  }
590
- foo.osgi.registry.containers = @eclipse_instances.dup
658
+ OSGi.registry.containers = @eclipse_instances.dup
591
659
  foo.dependencies
592
660
  foo.task('osgi:install:dependencies').invoke
593
661
  File.exist?(artifact("org.eclipse:org.eclipse.debug.ui:jar:3.4.1.v20080811_r341").to_s).should be_true
@@ -605,7 +673,7 @@ Require-Bundle: org.eclipse.debug.ui,
605
673
  org.eclipse.core.runtime.compatibility.registry
606
674
  MANIFEST
607
675
  foo = define('foo', :version => "1.0", :group => "grp") do package(:bundle) end
608
- foo.osgi.registry.containers = @eclipse_instances.dup
676
+ OSGi.registry.containers = @eclipse_instances.dup
609
677
 
610
678
  foo.task('osgi:resolve:dependencies').invoke
611
679
  foo.task('osgi:install:dependencies').invoke
@@ -632,7 +700,7 @@ MANIFEST
632
700
  foo = define('foo', :version => "1.0", :group => "grp") {
633
701
  package(:bundle)
634
702
  }
635
- foo.osgi.registry.containers = @eclipse_instances.dup
703
+ OSGi.registry.containers = @eclipse_instances.dup
636
704
  repositories.release_to = 'sftp://example.com/base'
637
705
 
638
706
  foo.task('osgi:resolve:dependencies').invoke
@@ -15,49 +15,59 @@
15
15
 
16
16
  require File.join(File.dirname(__FILE__), '../spec_helpers')
17
17
 
18
+ Spec::Runner.configure do |config|
19
+ config.include Buildr4OSGi::SpecHelpers
20
+ end
21
+
18
22
  describe OSGi::Registry do
19
23
 
20
24
  it 'should be possible to set containers from the Buildr settings' do
21
25
  pending "Doesn't work when using rake coverage"
22
26
  yaml = {"osgi" => ({"containers" => ["myContainer"]})}
23
27
  write 'home/.buildr/settings.yaml', yaml.to_yaml
24
- define("foo").osgi.registry.containers.should == ["myContainer"]
28
+ OSGi.registry.containers.should == ["myContainer"]
25
29
  end
26
30
 
27
- it 'should be accessible from a project' do
28
- define('foo').osgi.registry.should be_instance_of(OSGi::Registry)
31
+ it 'should be possible to set the containers from the OSGi environment variables' do
32
+ ENV['OSGi'] = "foo;bar"
33
+ OSGi.registry.containers.should == ["foo","bar"]
29
34
  end
30
35
 
36
+ it 'should fall back on OSGI if the constant OSGi is not defined, issuing a warning' do
37
+ ENV['OSGi'] = nil
38
+ ENV['OSGI'] = "foo;bar"
39
+ lambda {OSGi.registry.resolved_containers}.should show_warning "The correct constant to define for the OSGi containers is named OSGi"
40
+ ENV['OSGi'].should == ENV['OSGI']
41
+ end
31
42
 
32
-
33
- it 'should be possible to set the containers from the OSGi environment variables' do
34
- ENV['OSGi'] = "foo;bar"
35
- define('foo').osgi.registry.containers.should == ["foo","bar"]
43
+ it 'should not complain if OSGI is set and OSGi is also set' do
44
+ ENV['OSGI'] = nil
45
+ lambda {OSGi.registry.resolved_containers}.should_not show_warning "The correct constant to define for the OSGi containers is named OSGi"
36
46
  end
37
47
 
38
- it 'should be possible to modify the containers in the registry before the resolved_instances method is called' do
39
- foo = define('foo')
40
- lambda {foo.osgi.registry.containers << "hello"}.should_not raise_error
41
- lambda {foo.osgi.registry.containers = ["hello"]}.should_not raise_error
48
+ it 'should be possible to modify the containers in the registry before the resolved_containers method is called' do
49
+ lambda {OSGi.registry.containers << "hello"}.should_not raise_error
50
+ lambda {OSGi.registry.containers = ["hello"]}.should_not raise_error
42
51
  end
43
52
 
44
- it 'should throw an exception when modifying the containers in the registry after the resolved_instances method is called' do
53
+ it 'should throw an exception when modifying the containers in the registry after the resolved_containers method is called' do
45
54
  foo = define('foo')
46
- foo.osgi.registry.resolved_containers
47
- lambda {foo.osgi.registry.containers << "hello"}.should raise_error(TypeError)
48
- lambda {foo.osgi.registry.containers = ["hello"]}.should raise_error(RuntimeError, /Cannot set containers, containers have been resolved already/)
55
+ OSGi.registry.resolved_containers
56
+ lambda {OSGi.registry.containers << "hello"}.should raise_error(TypeError)
57
+ lambda {OSGi.registry.containers = ["hello"]}.should raise_error(RuntimeError, /Cannot set containers, containers have been resolved already/)
49
58
  end
50
59
  end
51
60
 
52
61
 
53
- describe OSGi::OSGi do
62
+ describe OSGi do
54
63
 
55
- it 'should add a new osgi method to projects' do
56
- define('foo').osgi.should be_instance_of(::OSGi::OSGi)
64
+ it 'should give a handle over the OSGi containers registry' do
65
+ OSGi.registry.should be_instance_of(::OSGi::Registry)
57
66
  end
58
67
 
59
- it 'should give a handle over the OSGi containers registry' do
60
- define('foo').osgi.registry.should be_instance_of(::OSGi::Registry)
68
+ it 'should help determine whether a package is part of the framework given by the execution environment' do
69
+ OSGi.is_framework_package?("com.mypackage").should be_false
70
+ OSGi.is_framework_package?(OSGi::JAVASE16.packages.first).should be_true
61
71
  end
62
72
 
63
73
  end
@@ -24,7 +24,7 @@ describe OSGi::BundleResolvingStrategies do
24
24
  end
25
25
 
26
26
  it 'should use latest by default to resolve bundle dependencies' do
27
- define('foo').osgi.options.bundle_resolving_strategy.should eql(:latest)
27
+ OSGi.options.bundle_resolving_strategy.should eql(:latest)
28
28
  end
29
29
 
30
30
  describe 'latest' do
@@ -70,7 +70,7 @@ describe OSGi::PackageResolvingStrategies do
70
70
  end
71
71
 
72
72
  it 'should use all by default to resolve package dependencies' do
73
- define('foo').osgi.options.package_resolving_strategy.should eql(:all)
73
+ OSGi.options.package_resolving_strategy.should eql(:all)
74
74
  end
75
75
 
76
76
  describe 'all' do
@@ -124,4 +124,10 @@ describe OSGi::VersionRange do
124
124
  r2.to_s.should eql("[1.0.0,2.0.0)")
125
125
  end
126
126
 
127
+ it 'should be able to consume a range with a space before or after the two limits' do
128
+ OSGi::VersionRange.parse("[1.0.0, 2.0.0)").should be_instance_of(OSGi::VersionRange)
129
+ OSGi::VersionRange.parse("[1.0.0 , 2.0.0)").should be_instance_of(OSGi::VersionRange)
130
+ OSGi::VersionRange.parse("[1.0.0 ,2.0.0)").should be_instance_of(OSGi::VersionRange)
131
+ end
132
+
127
133
  end
data/spec/spec_helpers.rb CHANGED
@@ -51,14 +51,26 @@ unless defined?(SpecHelpers)
51
51
 
52
52
  OSGi_REPOS = File.expand_path File.join(File.dirname(__FILE__), "..", "tmp", "osgi")
53
53
 
54
+ module MockInstanceWriter
55
+ def registry=(i)
56
+ @registry=i
57
+ end
58
+ end
59
+
54
60
  class << self
55
61
 
56
62
  def included(config)
63
+ config.before(:all) {
64
+ OSGi.extend MockInstanceWriter
65
+ }
66
+
57
67
  config.before(:each) {
58
68
  remoteRepositoryForHelpers()
69
+ OSGi.registry = OSGi::Registry.new
59
70
  }
60
71
  config.after(:all) {
61
72
  FileUtils.rm_rf Buildr4OSGi::SpecHelpers::OSGi_REPOS
73
+
62
74
  }
63
75
  end
64
76
  end