From 223889c6d0449dd50edab4a662155b8e5cd39287 Mon Sep 17 00:00:00 2001 From: Markus Rathgeb Date: Wed, 6 Feb 2019 14:05:36 +0100 Subject: [PATCH] migrate tests for thing.xml Signed-off-by: Markus Rathgeb --- .../org.eclipse.core.resources.prefs | 2 + .../itest.bndrun | 7 +- .../thing/xml/test/ChannelTypesI18nTest.java | 80 +++--- .../core/thing/xml/test/ChannelTypesTest.java | 54 ++-- .../xml/test/ConfigDescriptionsTest.java | 166 +++++------- .../core/thing/xml/test/LoadedTestBundle.java | 132 +++++++++ .../SystemChannelsInChannelGroupsTest.java | 91 +++---- .../xml/test/SystemWideChannelTypesTest.java | 194 +++++-------- .../thing/xml/test/ThingTypeI18nTest.java | 255 ++++++++---------- .../core/thing/xml/test/ThingTypesTest.java | 231 +++++++--------- .../ESH-INF/i18n/somebinding.properties | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/i18n/SystemChannels_de.properties | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/binding/binding.xml | 0 .../ESH-INF/thing/thing-types.xml | 0 .../ESH-INF/i18n/yahooweather_de.properties | 0 .../ESH-INF/thing/thing-types.xml | 0 itests/pom.xml | 2 +- 29 files changed, 595 insertions(+), 619 deletions(-) create mode 100644 itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/LoadedTestBundle.java rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/{src/main/resources => }/ESH-INF/i18n/somebinding.properties (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/{src/main/resources => }/ESH-INF/i18n/SystemChannels_de.properties (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/{src/main/resources => }/ESH-INF/binding/binding.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/{src/main/resources => }/ESH-INF/i18n/yahooweather_de.properties (100%) rename itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/{src/main/resources => }/ESH-INF/thing/thing-types.xml (100%) diff --git a/itests/org.openhab.core.thing.xml.tests/.settings/org.eclipse.core.resources.prefs b/itests/org.openhab.core.thing.xml.tests/.settings/org.eclipse.core.resources.prefs index 99f26c020..abdea9ac0 100644 --- a/itests/org.openhab.core.thing.xml.tests/.settings/org.eclipse.core.resources.prefs +++ b/itests/org.openhab.core.thing.xml.tests/.settings/org.eclipse.core.resources.prefs @@ -1,2 +1,4 @@ eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 encoding/=UTF-8 diff --git a/itests/org.openhab.core.thing.xml.tests/itest.bndrun b/itests/org.openhab.core.thing.xml.tests/itest.bndrun index d035dcf52..e2050afa2 100644 --- a/itests/org.openhab.core.thing.xml.tests/itest.bndrun +++ b/itests/org.openhab.core.thing.xml.tests/itest.bndrun @@ -3,7 +3,9 @@ Bundle-SymbolicName: ${project.artifactId} Fragment-Host: org.openhab.core.thing.xml --runrequires: bnd.identity;id='org.openhab.core.thing.xml.tests' +-runrequires: \ + bnd.identity;id='org.openhab.core.thing.xml.tests',\ + bnd.identity;id='org.openhab.core.binding.xml' # # done @@ -39,4 +41,5 @@ Fragment-Host: org.openhab.core.thing.xml osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\ slf4j.api;version='[1.7.21,1.7.22)',\ tec.uom.lib.uom-lib-common;version='[1.0.2,1.0.3)',\ - tec.uom.se;version='[1.0.8,1.0.9)' \ No newline at end of file + tec.uom.se;version='[1.0.8,1.0.9)',\ + org.openhab.core.binding.xml;version='[2.5.0,2.5.1)' \ No newline at end of file diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesI18nTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesI18nTest.java index caddd5449..22b29637d 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesI18nTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesI18nTest.java @@ -13,9 +13,10 @@ package org.eclipse.smarthome.core.thing.xml.test; import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.*; import java.util.Collection; +import java.util.Optional; import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; import org.eclipse.smarthome.core.thing.type.ChannelDefinition; @@ -24,12 +25,12 @@ import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider; import org.eclipse.smarthome.core.thing.type.ChannelType; import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider; import org.eclipse.smarthome.core.thing.type.ThingType; +import org.eclipse.smarthome.test.BundleCloseable; import org.eclipse.smarthome.test.SyntheticBundleInstaller; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; /*** * @@ -60,50 +61,57 @@ public class ChannelTypesI18nTest extends JavaOSGiTest { assertThat(thingTypeProvider, is(notNullValue())); } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - } - @Test public void channelTypesShouldTranslateCorrectly() throws Exception { - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + try (BundleCloseable bundle = new BundleCloseable( + SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME))) { + assertThat(bundle, is(notNullValue())); - Collection channelTypes = channelTypeProvider.getChannelTypes(null); - ChannelType channelType1 = channelTypes.stream() - .filter(c -> c.getUID().toString().equals("somebinding:channel-with-i18n")).findFirst().get(); - assertThat(channelType1, is(not(nullValue()))); - assertThat(channelType1.getLabel(), is(equalTo("Channel Label"))); - assertThat(channelType1.getDescription(), is(equalTo("Channel Description"))); + ChannelType channelType1 = waitForAssert(() -> { + final Optional opt = channelTypeProvider.getChannelTypes(null).stream() + .filter(c -> c.getUID().toString().equals("somebinding:channel-with-i18n")).findFirst(); + assertTrue(opt.isPresent()); + return opt.get(); + }); + assertThat(channelType1, is(not(nullValue()))); + assertThat(channelType1.getLabel(), is(equalTo("Channel Label"))); + assertThat(channelType1.getDescription(), is(equalTo("Channel Description"))); - Collection channelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null); - ChannelGroupType channelGroupType = channelGroupTypes.stream() - .filter(c -> c.getUID().toString().equals("somebinding:channelgroup-with-i18n")).findFirst().get(); - assertThat(channelGroupType, is(not(nullValue()))); - assertThat(channelGroupType.getLabel(), is(equalTo("Channel Group Label"))); - assertThat(channelGroupType.getDescription(), is(equalTo("Channel Group Description"))); + Collection channelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null); + ChannelGroupType channelGroupType = channelGroupTypes.stream() + .filter(c -> c.getUID().toString().equals("somebinding:channelgroup-with-i18n")).findFirst().get(); + assertThat(channelGroupType, is(not(nullValue()))); + assertThat(channelGroupType.getLabel(), is(equalTo("Channel Group Label"))); + assertThat(channelGroupType.getDescription(), is(equalTo("Channel Group Description"))); + } } @Test public void channelDefinitionsShouldBeTranslatedCorrectly() throws Exception { - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + try (BundleCloseable bundle = new BundleCloseable( + SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME))) { + assertThat(bundle, is(notNullValue())); - ThingType thingType = thingTypeProvider.getThingTypes(null).stream() - .filter(it -> it.getUID().toString().equals("somebinding:something")).findFirst().get(); - assertThat(thingType, is(notNullValue())); - assertThat(thingType.getChannelDefinitions().size(), is(2)); + ThingType thingType = waitForAssert(() -> { + Optional thingTypeOpt = thingTypeProvider.getThingTypes(null).stream() + .filter(it -> it.getUID().toString().equals("somebinding:something")).findFirst(); + Assert.assertTrue(thingTypeOpt.isPresent()); + final ThingType thingTypeTmp = thingTypeOpt.get(); + // assertThat(thingTypeTmp, is(notNullValue())); + assertThat(thingTypeTmp.getChannelDefinitions().size(), is(2)); + return thingTypeTmp; + }); - ChannelDefinition channelDefinition1 = thingType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("channelPlain")).findFirst().get(); - assertThat(channelDefinition1.getLabel(), is(equalTo("Channel Plain Label"))); - assertThat(channelDefinition1.getDescription(), is(equalTo("Channel Plain Description"))); + ChannelDefinition channelDefinition1 = thingType.getChannelDefinitions().stream() + .filter(it -> it.getId().equals("channelPlain")).findFirst().get(); + assertThat(channelDefinition1.getLabel(), is(equalTo("Channel Plain Label"))); + assertThat(channelDefinition1.getDescription(), is(equalTo("Channel Plain Description"))); - ChannelDefinition channelDefinition2 = thingType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("channelInplace")).findFirst().get(); - assertThat(channelDefinition2.getLabel(), is(equalTo("Channel Inplace Label"))); - assertThat(channelDefinition2.getDescription(), is(equalTo("Channel Inplace Description"))); + ChannelDefinition channelDefinition2 = thingType.getChannelDefinitions().stream() + .filter(it -> it.getId().equals("channelInplace")).findFirst().get(); + assertThat(channelDefinition2.getLabel(), is(equalTo("Channel Inplace Label"))); + assertThat(channelDefinition2.getDescription(), is(equalTo("Channel Inplace Description"))); + } } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java index 0deeabf3e..6844c8719 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java @@ -21,12 +21,11 @@ import org.eclipse.smarthome.core.thing.type.ChannelGroupType; import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider; import org.eclipse.smarthome.core.thing.type.ChannelType; import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider; +import org.eclipse.smarthome.test.BundleCloseable; import org.eclipse.smarthome.test.SyntheticBundleInstaller; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; /*** * @@ -52,42 +51,43 @@ public class ChannelTypesTest extends JavaOSGiTest { assertThat(channelGroupTypeProvider, is(notNullValue())); } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - } - @Test public void ChannelTypesShouldBeLoaded() throws Exception { int initialNumberOfChannelTypes = channelTypeProvider.getChannelTypes(null).size(); int initialNumberOfChannelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null).size(); // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + try (BundleCloseable bundle = new BundleCloseable( + SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME))) { + assertThat(bundle, is(notNullValue())); - Collection channelTypes = channelTypeProvider.getChannelTypes(null); - assertThat(channelTypes.size(), is(initialNumberOfChannelTypes + 2)); + Collection channelTypes = waitForAssert(() -> { + Collection channelTypesTmp = channelTypeProvider.getChannelTypes(null); + assertThat(channelTypesTmp.size(), is(initialNumberOfChannelTypes + 2)); + return channelTypesTmp; + }); - ChannelType channelType1 = channelTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channel1")).findFirst().get(); - assertThat(channelType1, is(not(nullValue()))); + ChannelType channelType1 = channelTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channel1")).findFirst().get(); + assertThat(channelType1, is(not(nullValue()))); - ChannelType channelType2 = channelTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channel-without-reference")).findFirst().get(); - assertThat(channelType2, is(not(nullValue()))); + ChannelType channelType2 = channelTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channel-without-reference")).findFirst() + .get(); + assertThat(channelType2, is(not(nullValue()))); - Collection channelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null); - assertThat(channelGroupTypes.size(), is(initialNumberOfChannelGroupTypes + 1)); + Collection channelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null); + assertThat(channelGroupTypes.size(), is(initialNumberOfChannelGroupTypes + 1)); - ChannelGroupType channelGroupType = channelGroupTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channelgroup")).findFirst().get(); - assertThat(channelGroupType, is(not(nullValue()))); - assertThat(channelGroupType.getCategory(), is("Temperature")); + ChannelGroupType channelGroupType = channelGroupTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channelgroup")).findFirst().get(); + assertThat(channelGroupType, is(not(nullValue()))); + assertThat(channelGroupType.getCategory(), is("Temperature")); + } - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - - assertThat(channelTypeProvider.getChannelTypes(null).size(), is(initialNumberOfChannelTypes)); - assertThat(channelGroupTypeProvider.getChannelGroupTypes(null).size(), is(initialNumberOfChannelGroupTypes)); + waitForAssert( + () -> assertThat(channelTypeProvider.getChannelTypes(null).size(), is(initialNumberOfChannelTypes))); + waitForAssert(() -> assertThat(channelGroupTypeProvider.getChannelGroupTypes(null).size(), + is(initialNumberOfChannelGroupTypes))); } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java index 1b4e017a0..9d370028c 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java @@ -23,142 +23,114 @@ import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; import org.eclipse.smarthome.config.core.ConfigDescriptionParameter.Type; import org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup; import org.eclipse.smarthome.config.core.ConfigDescriptionRegistry; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; public class ConfigDescriptionsTest extends JavaOSGiTest { - private static final String TEST_BUNDLE_NAME = "ConfigDescriptionsTest.bundle"; + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("ConfigDescriptionsTest.bundle", bundleContext, this::getService, + new StuffAddition().configDescriptions(3)); + } private ConfigDescriptionRegistry configDescriptionRegistry; @Before - public void setUp() { + public void before() { configDescriptionRegistry = getService(ConfigDescriptionRegistry.class); assertThat(configDescriptionRegistry, is(notNullValue())); } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - } - @Test public void syntheticBundleShouldLoadFromTestResource() throws Exception { - - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); + try (final AutoCloseable unused = loadedTestBundle()) { + } } @Test public void ConfigDescriptionsShouldLoadProperly() throws Exception { - int initialNumberOfConfigDescriptions = configDescriptionRegistry.getConfigDescriptions().size(); + try (final AutoCloseable unused = loadedTestBundle()) { + URI bridgeURI = new URI("thing-type:hue:bridge"); + ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(bridgeURI)).findFirst().get(); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + assertThat(bridgeConfigDescription, is(notNullValue())); - Collection configDescriptions = configDescriptionRegistry.getConfigDescriptions(); - assertThat(configDescriptions.size(), is(initialNumberOfConfigDescriptions + 3)); + Collection parameters = bridgeConfigDescription.getParameters(); + assertThat(parameters.size(), is(2)); - URI bridgeURI = new URI("thing-type:hue:bridge"); - ConfigDescription bridgeConfigDescription = configDescriptions.stream() - .filter(it -> it.getUID().equals(bridgeURI)).findFirst().get(); + ConfigDescriptionParameter ipParameter = parameters.stream().filter(it -> it.getName().equals("ip")) + .findFirst().get(); + assertThat(ipParameter, is(notNullValue())); + assertThat(ipParameter.getType(), is(Type.TEXT)); + assertThat(ipParameter.getContext(), is("network-address")); + assertThat(ipParameter.getLabel(), is("Network Address")); + assertThat(ipParameter.getDescription(), is("Network address of the hue bridge.")); + assertThat(ipParameter.isRequired(), is(true)); - assertThat(bridgeConfigDescription, is(notNullValue())); + ConfigDescriptionParameter userNameParameter = parameters.stream() + .filter(it -> it.getName().equals("username")).findFirst().get(); + assertThat(userNameParameter, is(notNullValue())); - Collection parameters = bridgeConfigDescription.getParameters(); - assertThat(parameters.size(), is(2)); + assertThat(userNameParameter.isAdvanced(), is(true)); - ConfigDescriptionParameter ipParameter = parameters.stream().filter(it -> it.getName().equals("ip")).findFirst() - .get(); - assertThat(ipParameter, is(notNullValue())); - assertThat(ipParameter.getType(), is(Type.TEXT)); - assertThat(ipParameter.getContext(), is("network-address")); - assertThat(ipParameter.getLabel(), is("Network Address")); - assertThat(ipParameter.getDescription(), is("Network address of the hue bridge.")); - assertThat(ipParameter.isRequired(), is(true)); + assertThat(userNameParameter.getType(), is(Type.TEXT)); + assertThat(userNameParameter.getContext(), is("password")); + assertThat(userNameParameter.getLabel(), is("Username")); + assertThat(userNameParameter.getDescription(), + is("Name of a registered hue bridge user, that allows to access the API.")); - ConfigDescriptionParameter userNameParameter = parameters.stream().filter(it -> it.getName().equals("username")) - .findFirst().get(); - assertThat(userNameParameter, is(notNullValue())); + URI colorURI = new URI("channel-type:hue:color"); + ConfigDescription colorConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(colorURI)).findFirst().get(); - assertThat(userNameParameter.isAdvanced(), is(true)); + assertThat(colorConfigDescription, is(notNullValue())); - assertThat(userNameParameter.getType(), is(Type.TEXT)); - assertThat(userNameParameter.getContext(), is("password")); - assertThat(userNameParameter.getLabel(), is("Username")); - assertThat(userNameParameter.getDescription(), - is("Name of a registered hue bridge user, that allows to access the API.")); + parameters = colorConfigDescription.getParameters(); + assertThat(parameters.size(), is(1)); - URI colorURI = new URI("channel-type:hue:color"); - ConfigDescription colorConfigDescription = configDescriptions.stream() - .filter(it -> it.getUID().equals(colorURI)).findFirst().get(); + ConfigDescriptionParameter lastDimValueParameter = parameters.stream() + .filter(it -> it.getName().equals("lastDimValue")).findFirst().get(); + assertThat(lastDimValueParameter, is(notNullValue())); + assertThat(lastDimValueParameter.getType(), is(Type.BOOLEAN)); - assertThat(colorConfigDescription, is(notNullValue())); + Collection groups = bridgeConfigDescription.getParameterGroups(); + assertThat(groups.size(), is(2)); - parameters = colorConfigDescription.getParameters(); - assertThat(parameters.size(), is(1)); - - ConfigDescriptionParameter lastDimValueParameter = parameters.stream() - .filter(it -> it.getName().equals("lastDimValue")).findFirst().get(); - assertThat(lastDimValueParameter, is(notNullValue())); - assertThat(lastDimValueParameter.getType(), is(Type.BOOLEAN)); - - Collection groups = bridgeConfigDescription.getParameterGroups(); - assertThat(groups.size(), is(2)); - - ConfigDescriptionParameterGroup group1 = groups.stream().filter(it -> it.getName().equals("group1")).findFirst() - .get(); - assertThat(group1, is(notNullValue())); - assertThat(group1.getContext(), is("Group1-context")); - assertThat(group1.getLabel(), is("Group Label 1")); - assertThat(group1.getDescription(), is("Group description 1")); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); + ConfigDescriptionParameterGroup group1 = groups.stream().filter(it -> it.getName().equals("group1")) + .findFirst().get(); + assertThat(group1, is(notNullValue())); + assertThat(group1.getContext(), is("Group1-context")); + assertThat(group1.getLabel(), is("Group Label 1")); + assertThat(group1.getDescription(), is("Group description 1")); + } } @Test public void parametersWithOptionsAndFiltersShouldLoadProperly() throws Exception { - int initialNumberOfConfigDescriptions = configDescriptionRegistry.getConfigDescriptions().size(); + try (final AutoCloseable unused = loadedTestBundle()) { + URI dummyURI = new URI("thing-type:hue:dummy"); + ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(dummyURI)).findFirst().get(); + assertThat(bridgeConfigDescription, is(notNullValue())); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + Collection parameters = bridgeConfigDescription.getParameters(); + assertThat(parameters.size(), is(2)); - Collection configDescriptions = configDescriptionRegistry.getConfigDescriptions(); - assertThat(configDescriptions.size(), is(initialNumberOfConfigDescriptions + 3)); + ConfigDescriptionParameter unitParameter = parameters.stream().filter(it -> it.getName().equals("unit")) + .findFirst().get(); + assertThat(unitParameter, is(notNullValue())); + assertThat(join(unitParameter.getOptions(), ","), is( + "ParameterOption [value=\"us\", label=\"US\"],ParameterOption [value=\"metric\", label=\"Metric\"]")); - URI dummyURI = new URI("thing-type:hue:dummy"); - ConfigDescription bridgeConfigDescription = configDescriptions.stream() - .filter(it -> it.getUID().equals(dummyURI)).findFirst().get(); - assertThat(bridgeConfigDescription, is(notNullValue())); - - Collection parameters = bridgeConfigDescription.getParameters(); - assertThat(parameters.size(), is(2)); - - ConfigDescriptionParameter unitParameter = parameters.stream().filter(it -> it.getName().equals("unit")) - .findFirst().get(); - assertThat(unitParameter, is(notNullValue())); - assertThat(join(unitParameter.getOptions(), ","), is( - "ParameterOption [value=\"us\", label=\"US\"],ParameterOption [value=\"metric\", label=\"Metric\"]")); - - ConfigDescriptionParameter lightParameter = parameters.stream() - .filter(it -> it.getName().equals("color-alarming-light")).findFirst().get(); - assertThat(lightParameter, is(notNullValue())); - assertThat(join(lightParameter.getFilterCriteria(), ","), is( - "FilterCriteria [name=\"tags\", value=\"alarm, light\"],FilterCriteria [name=\"type\", value=\"color\"],FilterCriteria [name=\"binding-id\", value=\"hue\"]")); + ConfigDescriptionParameter lightParameter = parameters.stream() + .filter(it -> it.getName().equals("color-alarming-light")).findFirst().get(); + assertThat(lightParameter, is(notNullValue())); + assertThat(join(lightParameter.getFilterCriteria(), ","), is( + "FilterCriteria [name=\"tags\", value=\"alarm, light\"],FilterCriteria [name=\"type\", value=\"color\"],FilterCriteria [name=\"binding-id\", value=\"hue\"]")); + } } private String join(Collection elements, String separator) { diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/LoadedTestBundle.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/LoadedTestBundle.java new file mode 100644 index 000000000..f937f1b6e --- /dev/null +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/LoadedTestBundle.java @@ -0,0 +1,132 @@ +package org.eclipse.smarthome.core.thing.xml.test; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.config.core.ConfigDescriptionRegistry; +import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; +import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; +import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; +import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.test.java.JavaTest; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; + +public class LoadedTestBundle extends JavaTest implements AutoCloseable { + + @FunctionalInterface + public interface ServiceProvider { + @Nullable T getService(Class clazz); + } + + public static class StuffAddition { + public int addedThingTypes = -1; + public int addedChannelTypes = -1; + public int addedChannelGroupTypes = -1; + public int addedConfigDescriptions = -1; + + public StuffAddition() { + } + + StuffAddition thingTypes(int nr) { + addedThingTypes = nr; + return this; + } + + StuffAddition channelTypes(int nr) { + addedChannelTypes = nr; + return this; + } + + StuffAddition channelGroupTypes(int nr) { + addedChannelGroupTypes = nr; + return this; + } + + StuffAddition configDescriptions(int nr) { + addedConfigDescriptions = nr; + return this; + } + } + + private final ThingTypeProvider thingTypeProvider; + private final ChannelTypeRegistry channelTypeRegistry; + private final ChannelGroupTypeRegistry channelGroupTypeRegistry; + private final ConfigDescriptionRegistry configDescriptionRegistry; + + private final int initialNumberOfThingTypes; + private final int initialNumberOfChannelTypes; + private final int initialNumberOfChannelGroupTypes; + private final int initialNumberOfConfigDescriptions; + + private final Bundle bundle; + + public LoadedTestBundle(String testBundleName, BundleContext bundleContext, ServiceProvider serviceProvider, + StuffAddition stuffAddition) throws Exception { + thingTypeProvider = serviceProvider.getService(ThingTypeProvider.class); + assertThat(thingTypeProvider, is(notNullValue())); + + channelTypeRegistry = serviceProvider.getService(ChannelTypeRegistry.class); + assertThat(channelTypeRegistry, is(notNullValue())); + + channelGroupTypeRegistry = serviceProvider.getService(ChannelGroupTypeRegistry.class); + assertThat(channelGroupTypeRegistry, is(notNullValue())); + + configDescriptionRegistry = serviceProvider.getService(ConfigDescriptionRegistry.class); + assertThat(configDescriptionRegistry, is(notNullValue())); + + initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + initialNumberOfChannelTypes = channelTypeRegistry.getChannelTypes().size(); + initialNumberOfChannelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes().size(); + initialNumberOfConfigDescriptions = configDescriptionRegistry.getConfigDescriptions().size(); + + this.bundle = SyntheticBundleInstaller.install(bundleContext, testBundleName); + assertThat(bundle, is(notNullValue())); + + if (stuffAddition.addedThingTypes >= 0) { + waitForAssert(() -> { + assertThat(thingTypeProvider.getThingTypes(null).size(), + is(initialNumberOfThingTypes + stuffAddition.addedThingTypes)); + }); + } + if (stuffAddition.addedChannelTypes >= 0) { + waitForAssert(() -> { + assertThat(channelTypeRegistry.getChannelTypes().size(), + is(initialNumberOfChannelTypes + stuffAddition.addedChannelTypes)); + }); + } + if (stuffAddition.addedChannelGroupTypes >= 0) { + waitForAssert(() -> { + assertThat(channelGroupTypeRegistry.getChannelGroupTypes().size(), + is(initialNumberOfChannelGroupTypes + stuffAddition.addedChannelGroupTypes)); + }); + } + if (stuffAddition.addedConfigDescriptions >= 0) { + waitForAssert(() -> { + assertThat(configDescriptionRegistry.getConfigDescriptions().size(), + is(initialNumberOfConfigDescriptions + stuffAddition.addedConfigDescriptions)); + }); + } + } + + @Override + public void close() throws BundleException { + bundle.uninstall(); + assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); + + waitForAssert(() -> { + assertThat(thingTypeProvider.getThingTypes(null).size(), is(initialNumberOfThingTypes)); + }); + waitForAssert(() -> { + assertThat(channelTypeRegistry.getChannelTypes().size(), is(initialNumberOfChannelTypes)); + }); + waitForAssert(() -> { + assertThat(channelGroupTypeRegistry.getChannelGroupTypes().size(), is(initialNumberOfChannelGroupTypes)); + }); + waitForAssert(() -> { + assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(initialNumberOfConfigDescriptions)); + }); + } +} diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java index 13bfa7f88..931aef246 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemChannelsInChannelGroupsTest.java @@ -15,7 +15,6 @@ package org.eclipse.smarthome.core.thing.xml.test; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.assertThat; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -26,12 +25,10 @@ import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeUID; import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; /** * @author Simon Kaufmann - Initial contribution and API @@ -39,7 +36,10 @@ import org.osgi.framework.Bundle; */ public class SystemChannelsInChannelGroupsTest extends JavaOSGiTest { - private static final String SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME = "SystemChannelsInChannelGroups.bundle"; + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("SystemChannelsInChannelGroups.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(1).channelTypes(1).channelGroupTypes(1)); + } private ThingTypeProvider thingTypeProvider; private ChannelTypeRegistry channelTypeRegistry; @@ -57,73 +57,46 @@ public class SystemChannelsInChannelGroupsTest extends JavaOSGiTest { assertThat(channelGroupTypeRegistry, is(notNullValue())); } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME); - } - @Test public void systemChannelsInChannelGroupsShouldLoadAndUnload() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); - int initialNumberOfChannelTypes = channelTypeRegistry.getChannelTypes().size(); - int initialNumberOfChannelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes().size(); - - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); - - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 1)); - assertThat(channelTypeRegistry.getChannelTypes().size(), is(initialNumberOfChannelTypes + 1)); - assertThat(channelGroupTypeRegistry.getChannelGroupTypes().size(), is(initialNumberOfChannelGroupTypes + 1)); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); - - assertThat(thingTypeProvider.getThingTypes(null).size(), is(initialNumberOfThingTypes)); - assertThat(channelTypeRegistry.getChannelTypes().size(), is(initialNumberOfChannelTypes)); - assertThat(channelGroupTypeRegistry.getChannelGroupTypes().size(), is(initialNumberOfChannelGroupTypes)); - + try (final AutoCloseable unused = loadedTestBundle()) { + } } @Test public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions() throws Exception { - // install test bundle - Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, - SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME); - assertThat(sysBundle, is(notNullValue())); + try (final AutoCloseable unused = loadedTestBundle()) { + List thingTypes = thingTypeProvider.getThingTypes(null).stream() + .filter(it -> it.getUID().getId().equals("wireless-router")).collect(Collectors.toList()); + assertThat(thingTypes.size(), is(1)); - List thingTypes = thingTypeProvider.getThingTypes(null).stream() - .filter(it -> it.getUID().getId().equals("wireless-router")).collect(Collectors.toList()); + List channelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes(); - assertThat(thingTypes.size(), is(1)); + ChannelGroupType channelGroup = channelGroupTypes.stream().filter( + it -> it.getUID().equals(new ChannelGroupTypeUID("SystemChannelsInChannelGroups:channelGroup"))) + .findFirst().get(); + assertThat(channelGroup, is(notNullValue())); - List channelGroupTypes = channelGroupTypeRegistry.getChannelGroupTypes(); + List channelDefs = channelGroup.getChannelDefinitions(); - ChannelGroupType channelGroup = channelGroupTypes.stream() - .filter(it -> it.getUID().equals(new ChannelGroupTypeUID("SystemChannelsInChannelGroups:channelGroup"))) - .findFirst().get(); - assertThat(channelGroup, is(notNullValue())); + List myChannel = channelDefs.stream().filter( + it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) + .collect(Collectors.toList()); - List channelDefs = channelGroup.getChannelDefinitions(); + List sigStr = channelDefs.stream() + .filter(it -> it.getId().equals("sigstr") + && it.getChannelTypeUID().getAsString().equals("system:signal-strength")) + .collect(Collectors.toList()); - List myChannel = channelDefs.stream().filter( - it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) - .collect(Collectors.toList()); + List lowBat = channelDefs.stream() + .filter(it -> it.getId().equals("lowbat") + && it.getChannelTypeUID().getAsString().equals("system:low-battery")) + .collect(Collectors.toList()); - List sigStr = channelDefs.stream() - .filter(it -> it.getId().equals("sigstr") - && it.getChannelTypeUID().getAsString().equals("system:signal-strength")) - .collect(Collectors.toList()); - - List lowBat = channelDefs.stream().filter( - it -> it.getId().equals("lowbat") && it.getChannelTypeUID().getAsString().equals("system:low-battery")) - .collect(Collectors.toList()); - - assertThat(myChannel.size(), is(1)); - assertThat(sigStr.size(), is(1)); - assertThat(lowBat.size(), is(1)); + assertThat(myChannel.size(), is(1)); + assertThat(sigStr.size(), is(1)); + assertThat(lowBat.size(), is(1)); + } } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemWideChannelTypesTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemWideChannelTypesTest.java index 393bd20cc..c76984ab0 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemWideChannelTypesTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/SystemWideChannelTypesTest.java @@ -26,12 +26,10 @@ import org.eclipse.smarthome.core.thing.type.ChannelType; import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider; import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; /** * @author Ivan Iliev - Initial contribution @@ -39,11 +37,20 @@ import org.osgi.framework.Bundle; */ public class SystemWideChannelTypesTest extends JavaOSGiTest { - private static final String SYSTEM_CHANNELS_BUNDLE_NAME = "SystemChannels.bundle"; + private LoadedTestBundle loadedSystemChannelsBundle() throws Exception { + return new LoadedTestBundle("SystemChannels.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(1).channelTypes(1)); + } - private static final String SYSTEM_CHANNELS_USER_BUNDLE_NAME = "SystemChannelsUser.bundle"; + private LoadedTestBundle loadedSystemChannelsUserBundle() throws Exception { + return new LoadedTestBundle("SystemChannelsUser.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(1).channelTypes(0)); + } - private static final String SYSTEM_CHANNELS_WITHOUT_THING_TYPES_BUNDLE_NAME = "SystemChannelsNoThingTypes.bundle"; + private LoadedTestBundle loadedSystemChannelsWithoutThingTypesBundle() throws Exception { + return new LoadedTestBundle("SystemChannelsNoThingTypes.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(0).channelTypes(1)); + } private ThingTypeProvider thingTypeProvider; private ChannelTypeRegistry channelTypeRegistry; @@ -62,157 +69,94 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest { systemChannelTypeProvider = provider; } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME); - SyntheticBundleInstaller.uninstall(bundleContext, SYSTEM_CHANNELS_USER_BUNDLE_NAME); - SyntheticBundleInstaller.uninstall(bundleContext, SYSTEM_CHANNELS_WITHOUT_THING_TYPES_BUNDLE_NAME); - } - @Test public void systemChannelsShouldLoadAndUnload() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); - - int initialNumberOfChannelTypes = getChannelTypes().size(); - - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); - - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 1)); - - assertThat(getChannelTypes().size(), is(initialNumberOfChannelTypes + 1)); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); - - thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes)); - - assertThat(getChannelTypes().size(), is(initialNumberOfChannelTypes)); + try (final AutoCloseable unused = loadedSystemChannelsBundle()) { + } } @Test public void systemChannelsShouldBeusedByOtherBinding() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); - int initialNumberOfChannelTypes = getChannelTypes().size(); - - // install test bundle - Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME); - assertThat(sysBundle, is(notNullValue())); - - Bundle sysUserBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_USER_BUNDLE_NAME); - assertThat(sysUserBundle, is(notNullValue())); - - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); - - assertThat(getChannelTypes().size(), is(initialNumberOfChannelTypes + 1)); + try (final AutoCloseable unused1 = loadedSystemChannelsBundle()) { + try (final AutoCloseable unused2 = loadedSystemChannelsUserBundle()) { + } + } } @Test public void thingTyoesShouldHaveProperChannelDefinitions() throws Exception { - // install test bundle - Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME); - assertThat(sysBundle, is(notNullValue())); + try (final AutoCloseable unused = loadedSystemChannelsBundle()) { + ThingType wirelessRouterType = thingTypeProvider.getThingTypes(null).stream() + .filter(it -> it.getUID().getAsString().equals("SystemChannels:wireless-router")).findFirst().get(); + assertThat(wirelessRouterType, is(notNullValue())); - ThingType wirelessRouterType = thingTypeProvider.getThingTypes(null).stream() - .filter(it -> it.getUID().getAsString().equals("SystemChannels:wireless-router")).findFirst().get(); - assertThat(wirelessRouterType, is(notNullValue())); + Collection channelDefs = wirelessRouterType.getChannelDefinitions(); + assertThat(channelDefs.size(), is(3)); - Collection channelDefs = wirelessRouterType.getChannelDefinitions(); - assertThat(channelDefs.size(), is(3)); + ChannelDefinition myChannel = channelDefs.stream().filter( + it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) + .findFirst().get(); + assertThat(myChannel, is(notNullValue())); - ChannelDefinition myChannel = channelDefs.stream().filter( - it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) - .findFirst().get(); - assertThat(myChannel, is(notNullValue())); + ChannelDefinition sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") + && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).findFirst().get(); + assertThat(sigStr, is(notNullValue())); - ChannelDefinition sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") - && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).findFirst().get(); - assertThat(sigStr, is(notNullValue())); - - ChannelDefinition lowBat = channelDefs.stream().filter( - it -> it.getId().equals("lowbat") && it.getChannelTypeUID().getAsString().equals("system:low-battery")) - .findFirst().get(); - assertThat(lowBat, is(notNullValue())); + ChannelDefinition lowBat = channelDefs.stream().filter(it -> it.getId().equals("lowbat") + && it.getChannelTypeUID().getAsString().equals("system:low-battery")).findFirst().get(); + assertThat(lowBat, is(notNullValue())); + } } @Test public void systemChannelsShouldBeAddedWithoutThingTypes() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); - int initialNumberOfChannelTypes = getChannelTypes().size(); - - // install test bundle - Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, - SYSTEM_CHANNELS_WITHOUT_THING_TYPES_BUNDLE_NAME); - assertThat(sysBundle, is(notNullValue())); - - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes)); - - assertThat(getChannelTypes().size(), is(initialNumberOfChannelTypes + 1)); - - // uninstall test bundle - sysBundle.uninstall(); - assertThat(sysBundle.getState(), is(Bundle.UNINSTALLED)); - - assertThat(getChannelTypes().size(), is(initialNumberOfChannelTypes)); + try (final AutoCloseable unused = loadedSystemChannelsWithoutThingTypesBundle()) { + } } @Test public void systemChannelsShouldTranslateProperly() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedSystemChannelsBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME); - assertNotNull(sysBundle); + ThingType wirelessRouterType = thingTypes.stream() + .filter(it -> it.getUID().getAsString().equals("SystemChannels:wireless-router")).findFirst().get(); + assertNotNull(wirelessRouterType); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertEquals(initialNumberOfThingTypes + 1, thingTypes.size()); + List channelDefs = wirelessRouterType.getChannelDefinitions(); + assertEquals(3, channelDefs.size()); - ThingType wirelessRouterType = thingTypes.stream() - .filter(it -> it.getUID().getAsString().equals("SystemChannels:wireless-router")).findFirst().get(); - assertNotNull(wirelessRouterType); + ChannelDefinition myChannel = channelDefs.stream().filter( + it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) + .findFirst().get(); + assertNotNull(myChannel); - List channelDefs = wirelessRouterType.getChannelDefinitions(); - assertEquals(3, channelDefs.size()); + ChannelDefinition sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") + && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).findFirst().get(); + assertNotNull(sigStr); - ChannelDefinition myChannel = channelDefs.stream().filter( - it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")) - .findFirst().get(); - assertNotNull(myChannel); + ChannelDefinition lowBat = channelDefs.stream().filter(it -> it.getId().equals("lowbat") + && it.getChannelTypeUID().getAsString().equals("system:low-battery")).findFirst().get(); + assertNotNull(lowBat); - ChannelDefinition sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") - && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).findFirst().get(); - assertNotNull(sigStr); + ChannelType lowBatType = systemChannelTypeProvider.getChannelType(lowBat.getChannelTypeUID(), + Locale.GERMAN); - ChannelDefinition lowBat = channelDefs.stream().filter( - it -> it.getId().equals("lowbat") && it.getChannelTypeUID().getAsString().equals("system:low-battery")) - .findFirst().get(); - assertNotNull(lowBat); + ChannelType myChannelChannelType = channelTypeRegistry.getChannelType(myChannel.getChannelTypeUID(), + Locale.GERMAN); + assertNotNull(myChannelChannelType); + assertEquals("Mein String My Channel", myChannelChannelType.getLabel()); + assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannelChannelType.getDescription()); - ChannelType lowBatType = systemChannelTypeProvider.getChannelType(lowBat.getChannelTypeUID(), Locale.GERMAN); + assertEquals("Mein String My Channel", myChannel.getLabel()); + assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannel.getDescription()); - ChannelType myChannelChannelType = channelTypeRegistry.getChannelType(myChannel.getChannelTypeUID(), - Locale.GERMAN); - assertNotNull(myChannelChannelType); - assertEquals("Mein String My Channel", myChannelChannelType.getLabel()); - assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannelChannelType.getDescription()); + assertEquals("Meine spezial Signalstärke", sigStr.getLabel()); + assertEquals("Meine spezial Beschreibung für Signalstärke", sigStr.getDescription()); - assertEquals("Mein String My Channel", myChannel.getLabel()); - assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannel.getDescription()); - - assertEquals("Meine spezial Signalstärke", sigStr.getLabel()); - assertEquals("Meine spezial Beschreibung für Signalstärke", sigStr.getDescription()); - - assertEquals("Niedriger Batteriestatus", lowBatType.getLabel()); - assertNull(lowBatType.getDescription()); + assertEquals("Niedriger Batteriestatus", lowBatType.getLabel()); + assertNull(lowBatType.getDescription()); + } } - private List getChannelTypes() { - return getService(ChannelTypeRegistry.class).getChannelTypes(); - } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java index fece0c12c..4bbc75d1c 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java @@ -26,16 +26,17 @@ import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; import org.eclipse.smarthome.core.thing.type.ChannelType; import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; public class ThingTypeI18nTest extends JavaOSGiTest { - private static final String TEST_BUNDLE_NAME = "yahooweather.bundle"; + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("yahooweather.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(2)); + } private ThingTypeProvider thingTypeProvider; private ChannelTypeRegistry channelTypeRegistry; @@ -53,193 +54,161 @@ public class ThingTypeI18nTest extends JavaOSGiTest { assertNotNull(channelGroupTypeRegistry); } - @After - public void tearDown() throws Exception { - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - } - @Test public void thingTypeShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); - - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - - assertThat(weatherType.getLabel(), is("Wetterinformation")); - assertThat(weatherType.getDescription(), is("Stellt verschiedene Wetterdaten vom Yahoo Wetterdienst bereit")); + assertThat(weatherType.getLabel(), is("Wetterinformation")); + assertThat(weatherType.getDescription(), + is("Stellt verschiedene Wetterdaten vom Yahoo Wetterdienst bereit")); + } } @Test public void channelGroupTypeShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); + assertNotNull(weatherGroupType); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); + ChannelGroupType channelGroupType = channelGroupTypeRegistry.getChannelGroupType( + weatherGroupType.getChannelGroupDefinitions().get(0).getTypeUID(), Locale.GERMAN); + assertNotNull(channelGroupType); - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); - assertNotNull(weatherGroupType); - - ChannelGroupType channelGroupType = channelGroupTypeRegistry - .getChannelGroupType(weatherGroupType.getChannelGroupDefinitions().get(0).getTypeUID(), Locale.GERMAN); - assertNotNull(channelGroupType); - - assertThat(channelGroupType.getLabel(), is("Wetterinformation mit Gruppe")); - assertThat(channelGroupType.getDescription(), is("Wetterinformation mit Gruppe Beschreibung.")); + assertThat(channelGroupType.getLabel(), is("Wetterinformation mit Gruppe")); + assertThat(channelGroupType.getDescription(), is("Wetterinformation mit Gruppe Beschreibung.")); + } } @Test public void channelGroupsShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); + assertNotNull(weatherGroupType); + assertThat(weatherGroupType.getChannelGroupDefinitions().size(), is(2)); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); + ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() + .stream().filter(it -> it.getId().equals("forecastToday")).findFirst().get(); + assertNotNull(forecastTodayChannelGroupDefinition); - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); - assertNotNull(weatherGroupType); - assertThat(weatherGroupType.getChannelGroupDefinitions().size(), is(2)); + assertThat(forecastTodayChannelGroupDefinition.getLabel(), is("Wettervorhersage heute")); + assertThat(forecastTodayChannelGroupDefinition.getDescription(), + is("Wettervorhersage für den heutigen Tag.")); - ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() - .stream().filter(it -> it.getId().equals("forecastToday")).findFirst().get(); - assertNotNull(forecastTodayChannelGroupDefinition); + ChannelGroupDefinition forecastTomorrowChannelGroupDefinition = weatherGroupType + .getChannelGroupDefinitions().stream().filter(it -> it.getId().equals("forecastTomorrow")) + .findFirst().get(); + assertNotNull(forecastTomorrowChannelGroupDefinition); - assertThat(forecastTodayChannelGroupDefinition.getLabel(), is("Wettervorhersage heute")); - assertThat(forecastTodayChannelGroupDefinition.getDescription(), is("Wettervorhersage für den heutigen Tag.")); - - ChannelGroupDefinition forecastTomorrowChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() - .stream().filter(it -> it.getId().equals("forecastTomorrow")).findFirst().get(); - assertNotNull(forecastTomorrowChannelGroupDefinition); - - assertThat(forecastTomorrowChannelGroupDefinition.getLabel(), is("Wettervorhersage morgen")); - assertThat(forecastTomorrowChannelGroupDefinition.getDescription(), - is("Wettervorhersage für den morgigen Tag.")); + assertThat(forecastTomorrowChannelGroupDefinition.getLabel(), is("Wettervorhersage morgen")); + assertThat(forecastTomorrowChannelGroupDefinition.getDescription(), + is("Wettervorhersage für den morgigen Tag.")); + } } @Test public void channelsInGroupTypeShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); + assertNotNull(weatherGroupType); + assertEquals(2, weatherGroupType.getChannelGroupDefinitions().size()); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertEquals(initialNumberOfThingTypes + 2, thingTypes.size()); + ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() + .stream().filter(it -> it.getId().equals("forecastToday")).findFirst().get(); + assertNotNull(forecastTodayChannelGroupDefinition); - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); - assertNotNull(weatherGroupType); - assertEquals(2, weatherGroupType.getChannelGroupDefinitions().size()); + ChannelGroupType forecastTodayChannelGroupType = channelGroupTypeRegistry + .getChannelGroupType(forecastTodayChannelGroupDefinition.getTypeUID(), Locale.GERMAN); + assertNotNull(forecastTodayChannelGroupType); + assertEquals(3, forecastTodayChannelGroupType.getChannelDefinitions().size()); - ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() - .stream().filter(it -> it.getId().equals("forecastToday")).findFirst().get(); - assertNotNull(forecastTodayChannelGroupDefinition); + ChannelDefinition temperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions() + .stream().filter(it -> it.getId().equals("temperature")).findFirst().get(); + assertNotNull(temperatureChannelDefinition); - ChannelGroupType forecastTodayChannelGroupType = channelGroupTypeRegistry - .getChannelGroupType(forecastTodayChannelGroupDefinition.getTypeUID(), Locale.GERMAN); - assertNotNull(forecastTodayChannelGroupType); - assertEquals(3, forecastTodayChannelGroupType.getChannelDefinitions().size()); + assertEquals("Temperatur", temperatureChannelDefinition.getLabel()); + assertEquals("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", + temperatureChannelDefinition.getDescription()); - ChannelDefinition temperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("temperature")).findFirst().get(); - assertNotNull(temperatureChannelDefinition); + ChannelDefinition minTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions() + .stream().filter(it -> it.getId().equals("minTemperature")).findFirst().get(); + assertNotNull(minTemperatureChannelDefinition); - assertEquals("Temperatur", temperatureChannelDefinition.getLabel()); - assertEquals("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", - temperatureChannelDefinition.getDescription()); + assertEquals("Min. Temperatur", minTemperatureChannelDefinition.getLabel()); + assertEquals("Minimale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", + minTemperatureChannelDefinition.getDescription()); - ChannelDefinition minTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions() - .stream().filter(it -> it.getId().equals("minTemperature")).findFirst().get(); - assertNotNull(minTemperatureChannelDefinition); + ChannelDefinition maxTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions() + .stream().filter(it -> it.getId().equals("maxTemperature")).findFirst().get(); + assertNotNull(maxTemperatureChannelDefinition); - assertEquals("Min. Temperatur", minTemperatureChannelDefinition.getLabel()); - assertEquals("Minimale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", - minTemperatureChannelDefinition.getDescription()); - - ChannelDefinition maxTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions() - .stream().filter(it -> it.getId().equals("maxTemperature")).findFirst().get(); - assertNotNull(maxTemperatureChannelDefinition); - - assertEquals("Max. Temperatur", maxTemperatureChannelDefinition.getLabel()); - assertEquals("Maximale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", - maxTemperatureChannelDefinition.getDescription()); + assertEquals("Max. Temperatur", maxTemperatureChannelDefinition.getLabel()); + assertEquals("Maximale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", + maxTemperatureChannelDefinition.getDescription()); + } } @Test public void channelTypeShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); + assertThat(weatherType.getChannelDefinitions().size(), is(2)); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); + ChannelType temperatureChannelType = channelTypeRegistry.getChannelType(weatherType.getChannelDefinitions() + .stream().filter(it -> it.getId().equals("temperature")).findFirst().get().getChannelTypeUID(), + Locale.GERMAN); + assertNotNull(temperatureChannelType); - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - assertThat(weatherType.getChannelDefinitions().size(), is(2)); - - ChannelType temperatureChannelType = channelTypeRegistry.getChannelType(weatherType.getChannelDefinitions() - .stream().filter(it -> it.getId().equals("temperature")).findFirst().get().getChannelTypeUID(), - Locale.GERMAN); - assertNotNull(temperatureChannelType); - - assertThat(temperatureChannelType.getLabel(), is("Temperatur")); - assertThat(temperatureChannelType.getDescription(), - is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); - assertThat(temperatureChannelType.getState().getPattern(), is("%d Grad Celsius")); - assertThat(temperatureChannelType.getState().getOptions().get(0).getLabel(), is("Mein String")); + assertThat(temperatureChannelType.getLabel(), is("Temperatur")); + assertThat(temperatureChannelType.getDescription(), + is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); + assertThat(temperatureChannelType.getState().getPattern(), is("%d Grad Celsius")); + assertThat(temperatureChannelType.getState().getOptions().get(0).getLabel(), is("Mein String")); + } } @Test public void channelsShouldBeLocalized() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertNotNull(bundle); + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); + assertThat(weatherType.getChannelDefinitions().size(), is(2)); - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 2)); + ChannelDefinition temperatureChannelDefinition = weatherType.getChannelDefinitions().stream() + .filter(it -> it.getId().equals("temperature")).findFirst().get(); + assertNotNull(temperatureChannelDefinition); - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - assertThat(weatherType.getChannelDefinitions().size(), is(2)); + assertThat(temperatureChannelDefinition.getLabel(), is("Temperatur")); + assertThat(temperatureChannelDefinition.getDescription(), + is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); - ChannelDefinition temperatureChannelDefinition = weatherType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("temperature")).findFirst().get(); - assertNotNull(temperatureChannelDefinition); + ChannelDefinition minTemperatureChannelDefinition = weatherType.getChannelDefinitions().stream() + .filter(it -> it.getId().equals("minTemperature")).findFirst().get(); + assertNotNull(minTemperatureChannelDefinition); - assertThat(temperatureChannelDefinition.getLabel(), is("Temperatur")); - assertThat(temperatureChannelDefinition.getDescription(), - is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); - - ChannelDefinition minTemperatureChannelDefinition = weatherType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("minTemperature")).findFirst().get(); - assertNotNull(minTemperatureChannelDefinition); - - assertThat(minTemperatureChannelDefinition.getLabel(), is("Min. Temperatur")); - assertThat(minTemperatureChannelDefinition.getDescription(), - is("Minimale Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); + assertThat(minTemperatureChannelDefinition.getLabel(), is("Min. Temperatur")); + assertThat(minTemperatureChannelDefinition.getDescription(), + is("Minimale Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); + } } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java index ea3b3daf3..14700f281 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java @@ -27,18 +27,18 @@ import org.eclipse.smarthome.core.thing.type.ChannelDefinition; import org.eclipse.smarthome.core.thing.type.ChannelType; import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; import org.eclipse.smarthome.core.thing.type.ThingType; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; import org.eclipse.smarthome.core.types.StateDescription; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; public class ThingTypesTest extends JavaOSGiTest { - private static final String TEST_BUNDLE_NAME = "ThingTypesTest.bundle"; + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("ThingTypesTest.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(3)); + } private ThingTypeProvider thingTypeProvider; private ChannelTypeRegistry channelTypeRegistry; @@ -52,152 +52,125 @@ public class ThingTypesTest extends JavaOSGiTest { assertThat(channelTypeRegistry, is(notNullValue())); } - @After - public void tearDown() throws BundleException { - SyntheticBundleInstaller.uninstall(bundleContext, TEST_BUNDLE_NAME); - } - @Test public void thingTypesShouldLoad() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(null); - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); + BridgeType bridgeType = (BridgeType) thingTypes.stream().filter(it -> it.toString().equals("hue:bridge")) + .findFirst().get(); + assertThat(bridgeType, is(notNullValue())); + assertThat(bridgeType.getCategory(), is("NetworkAppliance")); + assertThat(bridgeType.isListed(), is(false)); + assertThat(bridgeType.getLabel(), is("HUE Bridge")); + assertThat(bridgeType.getDescription(), is("The hue Bridge represents the Philips hue bridge.")); + assertThat(bridgeType.getProperties().size(), is(1)); + assertThat(bridgeType.getProperties().get("vendor"), is("Philips")); + assertThat(bridgeType.getRepresentationProperty(), is("serialNumber")); - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 3)); + ThingType thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp")).findFirst().get(); - BridgeType bridgeType = (BridgeType) thingTypes.stream().filter(it -> it.toString().equals("hue:bridge")) - .findFirst().get(); - assertThat(bridgeType, is(notNullValue())); - assertThat(bridgeType.getCategory(), is("NetworkAppliance")); - assertThat(bridgeType.isListed(), is(false)); - assertThat(bridgeType.getLabel(), is("HUE Bridge")); - assertThat(bridgeType.getDescription(), is("The hue Bridge represents the Philips hue bridge.")); - assertThat(bridgeType.getProperties().size(), is(1)); - assertThat(bridgeType.getProperties().get("vendor"), is("Philips")); - assertThat(bridgeType.getRepresentationProperty(), is("serialNumber")); + assertThat(thingType, is(notNullValue())); + assertThat(thingType.getCategory(), is("Lightbulb")); + assertThat(thingType.isListed(), is(false)); + assertThat(thingType.getLabel(), is("HUE Lamp")); + assertThat(thingType.getDescription(), is("My own great HUE Lamp.")); + assertThat(thingType.getSupportedBridgeTypeUIDs().size(), is(1)); + assertThat(thingType.getSupportedBridgeTypeUIDs().get(0), is("hue:bridge")); + assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("alarm", "brightness")); + assertThat(thingType.getProperties().size(), is(2)); + assertThat(thingType.getProperties().get("key1"), is("value1")); + assertThat(thingType.getProperties().get("key2"), is("value2")); + assertThat(thingType.getRepresentationProperty(), is("uniqueId")); - ThingType thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp")).findFirst().get(); + List channelDefinitions = thingType.getChannelDefinitions(); - assertThat(thingType, is(notNullValue())); - assertThat(thingType.getCategory(), is("Lightbulb")); - assertThat(thingType.isListed(), is(false)); - assertThat(thingType.getLabel(), is("HUE Lamp")); - assertThat(thingType.getDescription(), is("My own great HUE Lamp.")); - assertThat(thingType.getSupportedBridgeTypeUIDs().size(), is(1)); - assertThat(thingType.getSupportedBridgeTypeUIDs().get(0), is("hue:bridge")); - assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("alarm", "brightness")); - assertThat(thingType.getProperties().size(), is(2)); - assertThat(thingType.getProperties().get("key1"), is("value1")); - assertThat(thingType.getProperties().get("key2"), is("value2")); - assertThat(thingType.getRepresentationProperty(), is("uniqueId")); + assertThat(channelDefinitions.size(), is(3)); + ChannelDefinition colorChannel = channelDefinitions.stream().filter(it -> it.getId().equals("color")) + .findFirst().get(); + assertThat(colorChannel, is(notNullValue())); - List channelDefinitions = thingType.getChannelDefinitions(); + assertThat(colorChannel.getProperties().size(), is(2)); + assertThat(colorChannel.getProperties().get("chan.key1"), is("value1")); + assertThat(colorChannel.getProperties().get("chan.key2"), is("value2")); - assertThat(channelDefinitions.size(), is(3)); - ChannelDefinition colorChannel = channelDefinitions.stream().filter(it -> it.getId().equals("color")) - .findFirst().get(); - assertThat(colorChannel, is(notNullValue())); + ChannelType colorChannelType = channelTypeRegistry.getChannelType(colorChannel.getChannelTypeUID()); + assertThat(colorChannelType, is(notNullValue())); + assertThat(colorChannelType.toString(), is("hue:color")); + assertThat(colorChannelType.getItemType(), is("ColorItem")); + assertThat(colorChannelType.getLabel(), is("HUE Lamp Color")); + assertThat(colorChannelType.getDescription(), is( + "The color channel allows to control the color of the hue lamp. It is also possible to dim values and switch the lamp on and off.")); - assertThat(colorChannel.getProperties().size(), is(2)); - assertThat(colorChannel.getProperties().get("chan.key1"), is("value1")); - assertThat(colorChannel.getProperties().get("chan.key2"), is("value2")); + Set tags = colorChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("ColorLamp"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(false)); + assertThat(tags.contains("AlarmSystem"), is(false)); - ChannelType colorChannelType = channelTypeRegistry.getChannelType(colorChannel.getChannelTypeUID()); - assertThat(colorChannelType, is(notNullValue())); - assertThat(colorChannelType.toString(), is("hue:color")); - assertThat(colorChannelType.getItemType(), is("ColorItem")); - assertThat(colorChannelType.getLabel(), is("HUE Lamp Color")); - assertThat(colorChannelType.getDescription(), is( - "The color channel allows to control the color of the hue lamp. It is also possible to dim values and switch the lamp on and off.")); + ChannelDefinition colorTemperatureChannel = channelDefinitions.stream() + .filter(it -> it.getId().equals("color_temperature")).findFirst().get(); - Set tags = colorChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("ColorLamp"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(false)); - assertThat(tags.contains("AlarmSystem"), is(false)); + assertThat(colorTemperatureChannel, is(notNullValue())); + assertThat(colorTemperatureChannel.getProperties().size(), is(0)); + ChannelType colorTemperatureChannelType = channelTypeRegistry + .getChannelType(colorTemperatureChannel.getChannelTypeUID()); + assertThat(colorTemperatureChannelType, is(notNullValue())); - ChannelDefinition colorTemperatureChannel = channelDefinitions.stream() - .filter(it -> it.getId().equals("color_temperature")).findFirst().get(); + assertThat(colorTemperatureChannelType.toString(), is("hue:color_temperature")); + assertThat(colorTemperatureChannelType.getItemType(), is("DimmerItem")); + assertThat(colorTemperatureChannelType.getLabel(), is("HUE Lamp Color Temperature")); + assertThat(colorTemperatureChannelType.getDescription(), is( + "The color temperature channel allows to set the color temperature from 0 (cold) to 100 (warm).")); - assertThat(colorTemperatureChannel, is(notNullValue())); - assertThat(colorTemperatureChannel.getProperties().size(), is(0)); - ChannelType colorTemperatureChannelType = channelTypeRegistry - .getChannelType(colorTemperatureChannel.getChannelTypeUID()); - assertThat(colorTemperatureChannelType, is(notNullValue())); + tags = colorTemperatureChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(true)); + assertThat(tags.contains("ColorLamp"), is(false)); + assertThat(tags.contains("AlarmSystem"), is(false)); - assertThat(colorTemperatureChannelType.toString(), is("hue:color_temperature")); - assertThat(colorTemperatureChannelType.getItemType(), is("DimmerItem")); - assertThat(colorTemperatureChannelType.getLabel(), is("HUE Lamp Color Temperature")); - assertThat(colorTemperatureChannelType.getDescription(), - is("The color temperature channel allows to set the color temperature from 0 (cold) to 100 (warm).")); + ChannelDefinition alarmChannel = channelDefinitions.stream().filter(it -> it.getId().equals("alarm")) + .findFirst().get(); + assertThat(alarmChannel, is(notNullValue())); + ChannelType alarmChannelType = channelTypeRegistry.getChannelType(alarmChannel.getChannelTypeUID()); + assertThat(alarmChannelType, is(notNullValue())); - tags = colorTemperatureChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(true)); - assertThat(tags.contains("ColorLamp"), is(false)); - assertThat(tags.contains("AlarmSystem"), is(false)); + assertThat(alarmChannelType.toString(), is("hue:alarm")); + assertThat(alarmChannelType.getItemType(), is("Number")); + assertThat(alarmChannelType.getLabel(), is("Alarm System")); + assertThat(alarmChannelType.getDescription(), is("The light blinks if alarm is set.")); - ChannelDefinition alarmChannel = channelDefinitions.stream().filter(it -> it.getId().equals("alarm")) - .findFirst().get(); - assertThat(alarmChannel, is(notNullValue())); - ChannelType alarmChannelType = channelTypeRegistry.getChannelType(alarmChannel.getChannelTypeUID()); - assertThat(alarmChannelType, is(notNullValue())); + tags = alarmChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("AlarmSystem"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(false)); + assertThat(tags.contains("ColorLamp"), is(false)); + assertThat(alarmChannelType.getCategory(), is(equalTo("ALARM"))); - assertThat(alarmChannelType.toString(), is("hue:alarm")); - assertThat(alarmChannelType.getItemType(), is("Number")); - assertThat(alarmChannelType.getLabel(), is("Alarm System")); - assertThat(alarmChannelType.getDescription(), is("The light blinks if alarm is set.")); + StateDescription state = alarmChannelType.getState(); + assertThat(state.getMinimum(), is(BigDecimal.ZERO)); + assertThat(state.getMaximum(), is(BigDecimal.valueOf(100.0))); + assertThat(state.getStep(), is(BigDecimal.valueOf(10.0))); + assertThat(state.getPattern(), is(equalTo("%d Peek"))); + assertThat(state.isReadOnly(), is(true)); + assertThat(state.getOptions().size(), is(2)); + assertThat(state.getOptions().get(0).getValue(), is(equalTo("SOUND"))); + assertThat(state.getOptions().get(0).getLabel(), is(equalTo("My great sound."))); - tags = alarmChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("AlarmSystem"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(false)); - assertThat(tags.contains("ColorLamp"), is(false)); - assertThat(alarmChannelType.getCategory(), is(equalTo("ALARM"))); - - StateDescription state = alarmChannelType.getState(); - assertThat(state.getMinimum(), is(BigDecimal.ZERO)); - assertThat(state.getMaximum(), is(BigDecimal.valueOf(100.0))); - assertThat(state.getStep(), is(BigDecimal.valueOf(10.0))); - assertThat(state.getPattern(), is(equalTo("%d Peek"))); - assertThat(state.isReadOnly(), is(true)); - assertThat(state.getOptions().size(), is(2)); - assertThat(state.getOptions().get(0).getValue(), is(equalTo("SOUND"))); - assertThat(state.getOptions().get(0).getLabel(), is(equalTo("My great sound."))); - - thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-with-group")).findFirst().get(); - assertThat(thingType.getProperties().size(), is(0)); - assertThat(thingType.getCategory(), is(nullValue())); - assertThat(thingType.isListed(), is(true)); - assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("brightness", "alarm")); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); + thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-with-group")).findFirst().get(); + assertThat(thingType.getProperties().size(), is(0)); + assertThat(thingType.getCategory(), is(nullValue())); + assertThat(thingType.isListed(), is(true)); + assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("brightness", "alarm")); + } } @Test public void thingTypesShouldBeRemoved_whenBundleIsUninstalled() throws Exception { - int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size(); - - // install test bundle - Bundle bundle = SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME); - assertThat(bundle, is(notNullValue())); - - Collection thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 3)); - - // uninstall test bundle - bundle.uninstall(); - assertThat(bundle.getState(), is(Bundle.UNINSTALLED)); - - thingTypes = thingTypeProvider.getThingTypes(null); - assertThat(thingTypes.size(), is(initialNumberOfThingTypes)); + try (final AutoCloseable unused = loadedTestBundle()) { + } } } diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/src/main/resources/ESH-INF/i18n/somebinding.properties b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/i18n/somebinding.properties similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/src/main/resources/ESH-INF/i18n/somebinding.properties rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/i18n/somebinding.properties diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/i18n/SystemChannels_de.properties b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/i18n/SystemChannels_de.properties similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/i18n/SystemChannels_de.properties rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/i18n/SystemChannels_de.properties diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/src/main/resources/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/src/main/resources/ESH-INF/binding/binding.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/src/main/resources/ESH-INF/i18n/yahooweather_de.properties b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/i18n/yahooweather_de.properties similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/src/main/resources/ESH-INF/i18n/yahooweather_de.properties rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/i18n/yahooweather_de.properties diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/src/main/resources/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/thing/thing-types.xml similarity index 100% rename from itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/src/main/resources/ESH-INF/thing/thing-types.xml rename to itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/thing/thing-types.xml diff --git a/itests/pom.xml b/itests/pom.xml index 0fed695e9..3534ad56f 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -53,7 +53,7 @@ org.openhab.core.thing.tests - + org.openhab.core.thing.xml.tests org.openhab.core.transform.tests org.openhab.core.ui.tests org.openhab.core.ui.icon.tests