rspec-openhab-scripting 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/openhab/helpers.rb +9 -2
- data/lib/rspec/openhab/karaf.rb +51 -7
- data/lib/rspec/openhab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc03fc7377be69a2c03c83d60bbc9faab0e6fc343dde9876b9acbb3b6320826d
|
4
|
+
data.tar.gz: b509c499d267a18e4adbeffb1f744a57b2b81ca027f97300b712f3f71f4119ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f623a8485f6d2e0f85e265855167f1b3818a1060bb2528dd8f7045327f375f54bd89e392beec84807b47ac825c861f46282605e0d8e0b30e97d159be2df75a5
|
7
|
+
data.tar.gz: 2b8d9371d764fea96ebb401f1f389abce1bae4e04c33ba31c2927d00b1b2f12df99d0dc6020972d3a5c27d2935ff47c700a5554c0985877ae73234696d0c169d
|
@@ -165,7 +165,7 @@ module RSpec
|
|
165
165
|
|
166
166
|
filename.slice!(0..transform_path.length)
|
167
167
|
dir = File.dirname(filename)
|
168
|
-
modules = dir == "." ? [] : moduleize(dir)
|
168
|
+
modules = (dir == ".") ? [] : moduleize(dir)
|
169
169
|
basename = File.basename(filename)
|
170
170
|
method = basename[0...-7]
|
171
171
|
modules << method
|
@@ -217,8 +217,15 @@ module RSpec
|
|
217
217
|
next unless metadata.uid.namespace == "autoupdate"
|
218
218
|
|
219
219
|
to_add << metadata
|
220
|
+
|
221
|
+
# 3.2.0 can't remove single namespaces from the GenericMetadataProvider, so
|
222
|
+
# we have to remove everything from the item
|
223
|
+
unless gmp.respond_to?(:remove_metadata_by_namespace)
|
224
|
+
to_add.concat(gmp.all.select { |m2| m2.uid.item_name == metadata.uid.item_name })
|
225
|
+
gmp.remove_metadata(metadata.uid.item_name)
|
226
|
+
end
|
220
227
|
end
|
221
|
-
gmp.remove_metadata_by_namespace("autoupdate")
|
228
|
+
gmp.remove_metadata_by_namespace("autoupdate") if gmp.respond_to?(:remove_metadata_by_namespace)
|
222
229
|
|
223
230
|
to_add.each do |m|
|
224
231
|
if mmp.get(m.uid)
|
data/lib/rspec/openhab/karaf.rb
CHANGED
@@ -233,6 +233,22 @@ module RSpec
|
|
233
233
|
field.set(fs, OpenHAB::Core::Mocks::BundleInstallSupport.new(fs.installSupport, self))
|
234
234
|
end
|
235
235
|
wait_for_service("org.osgi.service.cm.ConfigurationAdmin") do |ca|
|
236
|
+
# register a listener, so that we can know if the Start Level Service is busted
|
237
|
+
bundle = org.osgi.framework.FrameworkUtil.get_bundle(ca.class)
|
238
|
+
listener = org.osgi.service.cm.ConfigurationListener.impl do |_method, event|
|
239
|
+
next unless event.type == org.osgi.service.cm.ConfigurationEvent::CM_UPDATED
|
240
|
+
next unless event.pid == "org.openhab.startlevel"
|
241
|
+
|
242
|
+
# have to wait for the StartLevelService itself to process this event
|
243
|
+
Thread.new do
|
244
|
+
sleep 1
|
245
|
+
reset_start_level_service
|
246
|
+
end
|
247
|
+
end
|
248
|
+
bundle.bundle_context.register_service(org.osgi.service.cm.ConfigurationListener.java_class,
|
249
|
+
listener,
|
250
|
+
nil)
|
251
|
+
|
236
252
|
cfg = ca.get_configuration("org.openhab.addons", nil)
|
237
253
|
props = cfg.properties || java.util.Hashtable.new
|
238
254
|
# remove all non-binding addons
|
@@ -310,7 +326,6 @@ module RSpec
|
|
310
326
|
org.openhab.core.thing.internal.console.FirmwareUpdateConsoleCommandExtension
|
311
327
|
],
|
312
328
|
# the following bundles are blocked completely from starting
|
313
|
-
"org.apache.felix.fileinstall" => nil,
|
314
329
|
"org.apache.karaf.http.core" => nil,
|
315
330
|
"org.apache.karaf.features.command" => nil,
|
316
331
|
"org.apache.karaf.shell.commands" => nil,
|
@@ -529,15 +544,16 @@ module RSpec
|
|
529
544
|
# import global variables and constants that openhab-scripting gem expects,
|
530
545
|
# since we're going to be running it in this same VM
|
531
546
|
def set_jruby_script_presets
|
532
|
-
wait_for_service("org.openhab.core.automation.module.script.
|
547
|
+
wait_for_service("org.openhab.core.automation.module.script.ScriptEngineFactory",
|
548
|
+
filter: "(service.config.description.uri=automation:jruby)") do |jrubyscripting|
|
549
|
+
# "org.openhab.core.automation.module.script.internal.ScriptExtensionManager") do |sem|
|
550
|
+
sem = ::OpenHAB::Core::OSGI.service(
|
551
|
+
"org.openhab.core.automation.module.script.internal.ScriptExtensionManager"
|
552
|
+
)
|
533
553
|
# since we're not created by the ScriptEngineManager, this never gets set; manually set it
|
534
554
|
$se = $scriptExtension = ScriptExtensionManagerWrapper.new(sem)
|
535
555
|
scope_values = sem.find_default_presets("rspec")
|
536
556
|
scope_values = scope_values.entry_set
|
537
|
-
jrubyscripting = ::OpenHAB::Core::OSGI.services(
|
538
|
-
"org.openhab.core.automation.module.script.ScriptEngineFactory",
|
539
|
-
filter: "(service.pid=org.openhab.automation.jrubyscripting)"
|
540
|
-
).first
|
541
557
|
|
542
558
|
%w[mapInstancePresets mapGlobalPresets].each do |method_name|
|
543
559
|
method = jrubyscripting.class.java_class.get_declared_method(method_name, java.util.Map::Entry.java_class)
|
@@ -680,12 +696,32 @@ module RSpec
|
|
680
696
|
startlevels = File.read(config_file)
|
681
697
|
startlevels.sub!(",rules:refresh,rules:dslprovider", "")
|
682
698
|
|
683
|
-
target_file = "#{oh_userdata}/
|
699
|
+
target_file = "#{oh_userdata}/services.cfg"
|
684
700
|
target_file_contents = File.read(target_file) if File.exist?(target_file)
|
685
701
|
File.write(target_file, startlevels) unless target_file_contents == startlevels
|
686
702
|
java.lang.System.set_property("openhab.servicecfg", target_file)
|
687
703
|
end
|
688
704
|
|
705
|
+
# workaround for https://github.com/openhab/openhab-core/pull/3092
|
706
|
+
def reset_start_level_service
|
707
|
+
sls = ::OpenHAB::Core::OSGI.service("org.openhab.core.service.StartLevelService")
|
708
|
+
rs = ::OpenHAB::Core::OSGI.service("org.openhab.core.service.ReadyService")
|
709
|
+
sls.class.field_reader :trackers, :markers
|
710
|
+
rs.class.field_reader :trackers
|
711
|
+
return unless sls.markers.empty?
|
712
|
+
# SLS thinks it has trackers that RS doesn't?! Yeah, we hit the bug
|
713
|
+
return if (sls.trackers.values - rs.trackers.keys).empty?
|
714
|
+
|
715
|
+
ca = ::OpenHAB::Core::OSGI.service("org.osgi.service.cm.ConfigurationAdmin")
|
716
|
+
cfg = ca.get_configuration("org.openhab.startlevel", nil)
|
717
|
+
props = cfg.properties
|
718
|
+
config = props.keys.to_h { |k| [k, props.get(k)] }
|
719
|
+
m = sls.class.java_class.get_declared_method("modified", java.util.Map)
|
720
|
+
m.accessible = true
|
721
|
+
sls.trackers.clear
|
722
|
+
m.invoke(sls, config)
|
723
|
+
end
|
724
|
+
|
689
725
|
def minimize_installed_features
|
690
726
|
# cuts down openhab-runtime-base significantly, makes sure
|
691
727
|
# openhab-runtime-ui doesn't get installed (from profile.cfg),
|
@@ -696,6 +732,13 @@ module RSpec
|
|
696
732
|
File.write("#{oh_userdata}/etc/org.apache.karaf.features.xml", <<~XML)
|
697
733
|
<?xml version="1.0" encoding="UTF-8"?>
|
698
734
|
<featuresProcessing xmlns="http://karaf.apache.org/xmlns/features-processing/v1.0.0" xmlns:f="http://karaf.apache.org/xmlns/features/v1.6.0">
|
735
|
+
<!-- From OpenHAB 3.2.0 -->
|
736
|
+
<bundleReplacements>
|
737
|
+
<bundle originalUri="mvn:org.ops4j.pax.logging/pax-logging-api/[0,2.0.13)" replacement="mvn:org.ops4j.pax.logging/pax-logging-api/2.0.13" mode="maven" />
|
738
|
+
<bundle originalUri="mvn:org.ops4j.pax.logging/pax-logging-log4j2/[0,2.0.13)" replacement="mvn:org.ops4j.pax.logging/pax-logging-log4j2/2.0.13" mode="maven" />
|
739
|
+
<bundle originalUri="mvn:org.ops4j.pax.logging/pax-logging-logback/[0,2.0.13)" replacement="mvn:org.ops4j.pax.logging/pax-logging-logback/2.0.13" mode="maven" />
|
740
|
+
</bundleReplacements>
|
741
|
+
|
699
742
|
<blacklistedFeatures>
|
700
743
|
<feature>openhab-runtime-ui</feature>
|
701
744
|
<feature>openhab-core-ui*</feature>
|
@@ -721,6 +764,7 @@ module RSpec
|
|
721
764
|
<f:feature>openhab-core-storage-json</f:feature>
|
722
765
|
<f:feature>openhab-automation-jrubyscripting</f:feature>
|
723
766
|
<f:feature>openhab-transport-http</f:feature>
|
767
|
+
<f:feature prerequisite="true">wrapper</f:feature>
|
724
768
|
<f:bundle>mvn:org.openhab.core.bundles/org.openhab.core.karaf/#{version}</f:bundle>
|
725
769
|
</feature>
|
726
770
|
</replacement>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|