Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Test: fix unstable test in core.test (#3080)
Browse files Browse the repository at this point in the history
* core.test: fix launch configuration
* Remove a lot of UI related bundles that fill the console with error
  messages.
* Add missing Apache Commons Collections (used by core.thing)
* add method to disable auto update
* fix unstable test (it depends on auto update = false)

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
  • Loading branch information
maggu2810 authored and kaikreuzer committed Feb 27, 2017
1 parent df99e23 commit fed2264
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bundles/core/org.eclipse.smarthome.core.test/CoreTests.launch
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.equinox.p2.director.app.product"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,ch.qos.logback.slf4j@default:false,com.eclipsesource.jaxrs.jersey-min@default:default,com.google.gson*2.2.4.v201311231704@default:default,com.google.guava@default:default,com.ibm.icu@default:default,javax.transaction@default:false,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.io@default:default,org.apache.commons.lang@default:default,org.codehaus.groovy@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.region@default:false,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.util@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.ui.cocoa@default:false,org.eclipse.ui.trace@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.slf4j.api@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.eclipse.smarthome.config.core.test@default:false,org.eclipse.smarthome.config.core@default:default,org.eclipse.smarthome.config.xml.test@default:false,org.eclipse.smarthome.config.xml@default:default,org.eclipse.smarthome.core*0.9.0.qualifier@default:true,org.eclipse.smarthome.core.autoupdate@default:default,org.eclipse.smarthome.core.test@default:false,org.eclipse.smarthome.core.thing.test@default:false,org.eclipse.smarthome.core.thing@default:default,org.eclipse.smarthome.io.console@default:default,org.eclipse.smarthome.test@default:default"/>
<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic@default:default,ch.qos.logback.core@default:default,ch.qos.logback.slf4j@default:false,com.eclipsesource.jaxrs.jersey-min@default:default,com.google.gson*2.2.4.v201311231704@default:default,com.google.guava@default:default,com.ibm.icu@default:default,javax.transaction@default:false,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.collections@default:default,org.apache.commons.io@default:default,org.apache.commons.lang@default:default,org.codehaus.groovy@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:true,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.region@default:false,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.transforms.hook@default:false,org.eclipse.equinox.util@default:default,org.eclipse.equinox.weaving.hook@default:false,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.slf4j.api@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="org.eclipse.smarthome.config.core@default:default,org.eclipse.smarthome.config.xml@default:default,org.eclipse.smarthome.core.autoupdate@default:default,org.eclipse.smarthome.core.test@default:false,org.eclipse.smarthome.core.thing@default:default,org.eclipse.smarthome.core@default:true,org.eclipse.smarthome.io.console@default:default,org.eclipse.smarthome.test@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import org.eclipse.smarthome.core.events.EventFactory
import org.eclipse.smarthome.core.events.EventPublisher
import org.eclipse.smarthome.core.events.EventSubscriber
import org.eclipse.smarthome.core.items.ItemProvider
import org.eclipse.smarthome.core.items.events.ItemEventFactory.ItemEventPayloadBean
import org.eclipse.smarthome.core.library.items.SwitchItem
import org.eclipse.smarthome.core.library.types.OnOffType
import org.eclipse.smarthome.core.types.Command
import org.eclipse.smarthome.test.OSGiTest
import org.junit.Before
import org.junit.Test

import com.google.common.collect.Sets
import com.google.gson.Gson

/**
* The {@link AbstractItemEventSubscriberOSGiTest} runs inside an OSGi container and tests the {@link AbstractItemEventSubscriber}.
Expand All @@ -44,35 +41,38 @@ class AbstractItemEventSubscriberOSGiTest extends OSGiTest {
commandEvent = null
updateEvent = null
eventPublisher = getService(EventPublisher)

itemProvider = [
getAll: {[new SwitchItem(ITEM_NAME)]},
addProviderChangeListener: {},
removeProviderChangeListener: {},
allItemsChanged: {}
allItemsChanged: {
}
] as ItemProvider
registerService(itemProvider)

def itemEventSubscriber = [
receiveCommand: { event -> commandEvent = event },
receiveUpdate: { event -> updateEvent = event },
] as AbstractItemEventSubscriber
registerService(itemEventSubscriber, EventSubscriber.class.getName())

disableItemAutoUpdate()
}

@Test
public void 'AbstractItemEventSubscriber receives ItemCommandEvents and ItemUpdateEvents correctly'() {
eventPublisher.post(ItemEventFactory.createCommandEvent(ITEM_NAME, OnOffType.ON))
waitForAssert { assertThat commandEvent, not(null)}
waitForAssert { assertThat updateEvent, is(null)}

commandEvent = null
updateEvent = null
eventPublisher.post(ItemEventFactory.createStateEvent(ITEM_NAME, OnOffType.ON))
waitForAssert { assertThat commandEvent, is(null)}
waitForAssert { assertThat updateEvent, not(null)}
}

@Test
public void 'AbstractItemEventSubscriber do not receive events if event type is not supported'() {
def someEventType = "SOME_EVENT_TYPE"
Expand All @@ -85,10 +85,9 @@ class AbstractItemEventSubscriberOSGiTest extends OSGiTest {
registerService(someEventFactory)

Event event = [ getType: { someEventType }, getPayload: { "{a: 'A', b: 'B'}" }, getTopic: { "smarthome/items" }, getSource: { null } ] as Event

eventPublisher.post(event)
waitForAssert { assertThat commandEvent, is(null)}
waitForAssert { assertThat updateEvent, is(null)}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ abstract class OSGiTest {
registeredServices.clear()
}

protected void disableItemAutoUpdate(){
def autoupdateConfig = [
autoUpdate: { String itemName -> return false }

] as AutoUpdateBindingConfigProvider
registerService(autoupdateConfig)
}

protected void enableItemAutoUpdate(){
def autoupdateConfig = [
autoUpdate: { String itemName -> return true }
Expand Down

0 comments on commit fed2264

Please sign in to comment.