migrate tests for model.thing

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
pull/579/head
Markus Rathgeb 2019-02-13 14:37:41 +01:00 committed by Kai Kreuzer
parent 548c853680
commit e9a3701417
23 changed files with 159 additions and 45 deletions

View File

@ -23,7 +23,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="notestsources">
<classpathentry kind="src" output="target/test-classes" path="src.moved/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>

View File

@ -28,7 +28,7 @@
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>notestsources</testSourceDirectory>
<testSourceDirectory>src.moved/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>

View File

@ -3,7 +3,11 @@
Bundle-SymbolicName: ${project.artifactId}
Fragment-Host: org.openhab.core.model.thing
-runrequires: bnd.identity;id='org.openhab.core.model.thing.tests'
-runrequires: \
bnd.identity;id='org.openhab.core.model.thing.tests',\
bnd.identity;id='org.openhab.core.model.thing.runtime',\
bnd.identity;id='org.openhab.core.model.item.runtime',\
bnd.identity;id='org.openhab.core.thing.xml'
#
# done
@ -25,8 +29,6 @@ Fragment-Host: org.openhab.core.model.thing
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.10,2.1.11)',\
org.apache.servicemix.bundles.commons-codec;version='[1.3.0,1.3.1)',\
org.apache.servicemix.bundles.commons-httpclient;version='[3.1.0,3.1.1)',\
org.apache.xbean.bundleutils;version='[4.6.0,4.6.1)',\
org.apache.xbean.finder;version='[4.6.0,4.6.1)',\
org.eclipse.emf.common;version='[2.12.0,2.12.1)',\
@ -37,7 +39,6 @@ Fragment-Host: org.openhab.core.model.thing
org.eclipse.jetty.client;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.http;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.io;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.proxy;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.security;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.server;version='[9.4.11,9.4.12)',\
org.eclipse.jetty.servlet;version='[9.4.11,9.4.12)',\
@ -58,7 +59,6 @@ Fragment-Host: org.openhab.core.model.thing
org.objectweb.asm;version='[6.1.1,6.1.2)',\
org.objectweb.asm.commons;version='[6.1.1,6.1.2)',\
org.objectweb.asm.tree;version='[6.1.1,6.1.2)',\
org.openhab.core.compat1x;version='[2.5.0,2.5.1)',\
org.ops4j.pax.swissbox.optional.jcl;version='[1.8.2,1.8.3)',\
org.ops4j.pax.web.pax-web-api;version='[7.2.3,7.2.4)',\
org.ops4j.pax.web.pax-web-jetty;version='[7.2.3,7.2.4)',\
@ -72,7 +72,6 @@ Fragment-Host: org.openhab.core.model.thing
osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
org.openhab.core;version='[2.5.0,2.5.1)',\
org.openhab.core.audio;version='[2.5.0,2.5.1)',\
org.openhab.core.compat1x.tests;version='[2.5.0,2.5.1)',\
org.openhab.core.config.core;version='[2.5.0,2.5.1)',\
org.openhab.core.io.console;version='[2.5.0,2.5.1)',\
org.openhab.core.io.http;version='[2.5.0,2.5.1)',\
@ -87,9 +86,19 @@ Fragment-Host: org.openhab.core.model.thing
org.openhab.core.scheduler;version='[2.5.0,2.5.1)',\
org.openhab.core.thing;version='[2.5.0,2.5.1)',\
org.openhab.core.transform;version='[2.5.0,2.5.1)',\
org.openhab.core.ui;version='[2.5.0,2.5.1)',\
org.openhab.core.voice;version='[2.5.0,2.5.1)',\
org.openhab.core.model.persistence.runtime;version='[2.5.0,2.5.1)',\
org.openhab.core.model.rule;version='[2.5.0,2.5.1)',\
org.openhab.core.model.thing;version='[2.5.0,2.5.1)',\
org.openhab.core.storage.json;version='[2.5.0,2.5.1)'
net.bytebuddy.byte-buddy;version='[1.7.9,1.7.10)',\
net.bytebuddy.byte-buddy-agent;version='[1.7.9,1.7.10)',\
org.mockito.mockito-core;version='[2.13.0,2.13.1)',\
org.objenesis;version='[2.6.0,2.6.1)',\
org.openhab.core.model.thing.tests;version='[2.5.0,2.5.1)',\
org.openhab.core.test;version='[2.5.0,2.5.1)',\
org.openhab.core.model.thing.runtime;version='[2.5.0,2.5.1)',\
org.openhab.core.model.item.runtime;version='[2.5.0,2.5.1)',\
org.openhab.core.storage.json;version='[2.5.0,2.5.1)',\
org.apache.servicemix.bundles.xstream;version='[1.4.7,1.4.8)',\
org.openhab.core.config.xml;version='[2.5.0,2.5.1)',\
org.openhab.core.thing.xml;version='[2.5.0,2.5.1)',\
org.openhab.core.model.thing.testsupport;version='[2.5.0,2.5.1)'

View File

@ -19,6 +19,11 @@
<artifactId>org.openhab.core.bom.compile-model</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.openhab.core.itests</groupId>
<artifactId>org.openhab.core.model.thing.testsupport</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -173,13 +173,14 @@ public class GenericItemChannelLinkProviderJavaTest extends JavaOSGiTest {
+ "LCT001 bulb4 [ lightId = \"3\" ]" //
+ "}";
modelRepository.addOrRefreshModel(THINGS_TESTMODEL_NAME, new ByteArrayInputStream(thingsModel.getBytes()));
waitForAssert(() -> {
assertThat(thingRegistry.getAll().size(), is(3));
});
String itemsModel = "Color Light3Color \"Light3 Color\" { channel=\"hue:LCT001:huebridge:bulb3:color\" [ foo=\"bar\", answer=42, always=true ] }"
+ "Group:Switch:MAX TestSwitches";
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
waitForAssert(() -> {
assertThat(thingRegistry.getAll().size(), is(3));
assertThat(itemRegistry.getItems().size(), is(2));
assertThat(itemChannelLinkRegistry.getAll().size(), is(1));
});

View File

@ -23,6 +23,7 @@ import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingRegistry;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.model.core.ModelRepository;
import org.eclipse.smarthome.model.thing.testsupport.hue.TestHueThingHandlerFactoryX;
import org.eclipse.smarthome.test.java.JavaOSGiTest;
import org.junit.After;
import org.junit.Before;

View File

@ -50,6 +50,7 @@ import org.eclipse.smarthome.core.thing.type.ChannelTypeBuilder;
import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider;
import org.eclipse.smarthome.core.thing.type.ChannelTypeUID;
import org.eclipse.smarthome.model.core.ModelRepository;
import org.eclipse.smarthome.model.thing.testsupport.hue.DumbThingHandlerFactory;
import org.eclipse.smarthome.test.java.JavaOSGiTest;
import org.junit.After;
import org.junit.Before;

View File

@ -32,6 +32,8 @@ import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.model.core.ModelRepository;
import org.eclipse.smarthome.model.thing.testsupport.hue.TestHueThingHandlerFactoryX;
import org.eclipse.smarthome.model.thing.testsupport.hue.TestHueThingTypeProvider;
import org.eclipse.smarthome.test.java.JavaOSGiTest;
import org.junit.After;
import org.junit.Before;

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.core.model.thing.testsupport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,19 @@
This content is produced and maintained by the Eclipse SmartHome project.
* Project home: https://eclipse.org/smarthome/
== Declared Project Licenses
This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.
== Source Code
https://github.com/eclipse/smarthome
== Copyright Holders
See the NOTICE file distributed with the source code at
https://github.com/eclipse/smarthome/blob/master/NOTICE
for detailed information regarding copyright ownership.

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.core.itests</groupId>
<artifactId>org.openhab.core.reactor.itests</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.core.model.thing.testsupport</artifactId>
<name>openHAB Core :: Integration Tests :: Model Thing Test Support</name>
</project>

View File

@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.util.Collections;
import java.util.Set;

View File

@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.net.URI;
import java.util.Collection;

View File

@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.net.URI;
import java.util.Arrays;

View File

@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;

View File

@ -10,9 +10,11 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@ -31,8 +33,6 @@ import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.core.types.Command;
import org.osgi.service.component.annotations.Component;
import com.google.common.collect.Sets;
/**
* @author Benedikt Niehues - Fix ESH Bug 450236
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=450236 - Considering
@ -52,10 +52,13 @@ public class TestHueThingHandlerFactory extends BaseThingHandlerFactory {
public final static ThingTypeUID THING_TYPE_LONG_NAME = new ThingTypeUID(BINDING_ID,
"1-thing-id-with-5-dashes_and_3_underscores");
public final static Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES = Sets.newHashSet(THING_TYPE_BRIDGE);
public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES = Sets.newHashSet(THING_TYPE_LCT001, THING_TYPE_SENSOR,
THING_TYPE_TEST, THING_TYPE_LONG_NAME, THING_TYPE_GROUPED);
public final static Set<ThingTypeUID> SUPPORTED_TYPES = Sets.union(SUPPORTED_BRIDGE_TYPES, SUPPORTED_THING_TYPES);
public final static Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES = Stream.of(THING_TYPE_BRIDGE)
.collect(Collectors.toSet());
public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES = Stream
.of(THING_TYPE_LCT001, THING_TYPE_SENSOR, THING_TYPE_TEST, THING_TYPE_LONG_NAME, THING_TYPE_GROUPED)
.collect(Collectors.toSet());
public final static Set<ThingTypeUID> SUPPORTED_TYPES = Stream
.concat(SUPPORTED_BRIDGE_TYPES.stream(), SUPPORTED_THING_TYPES.stream()).collect(Collectors.toSet());
// List all channels
public static final String CHANNEL_COLORTEMPERATURE = "color_temperature";

View File

@ -10,9 +10,11 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.smarthome.config.core.Configuration;
import org.eclipse.smarthome.core.thing.Thing;
@ -23,8 +25,6 @@ import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.ComponentContext;
import com.google.common.collect.Sets;
/**
* @author Benedikt Niehues - Fix ESH Bug 450236
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=450236 - Considering
@ -38,9 +38,12 @@ public class TestHueThingHandlerFactoryX extends BaseThingHandlerFactory impleme
public final static ThingTypeUID THING_TYPE_LCT001 = new ThingTypeUID(BINDING_ID, "XLCT001");
public final static ThingTypeUID THING_TYPE_TEST = new ThingTypeUID(BINDING_ID, "XTEST");
public final static Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES = Sets.newHashSet(THING_TYPE_BRIDGE);
public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES = Sets.newHashSet(THING_TYPE_LCT001, THING_TYPE_TEST);
public final static Set<ThingTypeUID> SUPPORTED_TYPES = Sets.union(SUPPORTED_BRIDGE_TYPES, SUPPORTED_THING_TYPES);
public final static Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES = Stream.of(THING_TYPE_BRIDGE)
.collect(Collectors.toSet());
public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES = Stream.of(THING_TYPE_LCT001, THING_TYPE_TEST)
.collect(Collectors.toSet());
public final static Set<ThingTypeUID> SUPPORTED_TYPES = Stream
.concat(SUPPORTED_BRIDGE_TYPES.stream(), SUPPORTED_THING_TYPES.stream()).collect(Collectors.toSet());
// List all channels
public static final String CHANNEL_COLORTEMPERATURE = "Xcolor_temperature";

View File

@ -13,7 +13,7 @@
/**
*
*/
package org.eclipse.smarthome.model.thing.test.hue;
package org.eclipse.smarthome.model.thing.testsupport.hue;
import java.net.URI;
import java.util.Arrays;

View File

@ -48,7 +48,8 @@
<!-- <module>org.openhab.core.model.persistence.tests</module> -->
<!-- <module>org.openhab.core.model.rule.tests</module> -->
<!-- <module>org.openhab.core.model.script.tests</module> -->
<!-- <module>org.openhab.core.model.thing.tests</module> -->
<module>org.openhab.core.model.thing.testsupport</module>
<module>org.openhab.core.model.thing.tests</module>
<!-- <module>org.openhab.core.semantics.tests</module> -->
<!-- <module>org.openhab.core.storage.json.tests</module> -->
<module>org.openhab.core.thing.tests</module>
@ -87,19 +88,6 @@
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.openhab-core</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile</artifactId>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
@ -188,10 +176,18 @@
</build>
<dependencies>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.openhab-core</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bom</groupId>
<artifactId>org.openhab.core.bom.compile</artifactId>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>