mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
migrate tests for storage.json (#624)
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
This commit is contained in:
parent
4c9a5aa291
commit
bf4eac7d78
@ -19,6 +19,12 @@
|
||||
<artifactId>org.openhab.core.config.core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* @author Chris Jackson - Initial Contribution
|
||||
*/
|
||||
@Component(name = "org.eclipse.smarthome.storage.json", immediate = true, property = { //
|
||||
@Component(name = "org.eclipse.smarthome.storage.json", property = { //
|
||||
"service.pid=org.eclipse.smarthome.storage.json", //
|
||||
"service.config.description.uri=system:json_storage", //
|
||||
"service.config.label=Json Storage", //
|
||||
|
@ -9,8 +9,6 @@ Fragment-Host: org.openhab.core.storage.json
|
||||
# done
|
||||
#
|
||||
-runbundles: \
|
||||
ch.qos.logback.classic;version='[1.2.0,1.2.1)',\
|
||||
ch.qos.logback.core;version='[1.2.0,1.2.1)',\
|
||||
com.google.gson;version='[2.7.0,2.7.1)',\
|
||||
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
|
||||
org.apache.commons.io;version='[2.2.0,2.2.1)',\
|
||||
@ -32,6 +30,8 @@ Fragment-Host: org.openhab.core.storage.json
|
||||
org.osgi.service.event;version='[1.4.0,1.4.1)',\
|
||||
osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
|
||||
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)'
|
||||
tec.uom.se;version='[1.0.8,1.0.9)',\
|
||||
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
|
||||
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
|
||||
slf4j.api;version='[1.7.25,1.7.26)'
|
@ -21,13 +21,16 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.smarthome.config.core.ConfigConstants;
|
||||
import org.eclipse.smarthome.config.core.Configuration;
|
||||
import org.eclipse.smarthome.core.storage.Storage;
|
||||
import org.eclipse.smarthome.core.storage.StorageService;
|
||||
import org.eclipse.smarthome.test.java.JavaOSGiTest;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -44,15 +47,19 @@ public class JsonStorageServiceOSGiTest extends JavaOSGiTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
storageService = getService(StorageService.class);
|
||||
storage = storageService.getStorage("TestStorage", this.getClass().getClassLoader());
|
||||
storage = storageService.getStorage(UUID.randomUUID().toString(), this.getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
unregisterService(storageService);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws IOException {
|
||||
// clean up database files ...
|
||||
FileUtils.deleteDirectory(new File("./runtime"));
|
||||
FileUtils.deleteDirectory(new File(ConfigConstants.getUserDataFolder()));
|
||||
FileUtils.deleteDirectory(new File(ConfigConstants.getConfigFolder()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -98,7 +105,7 @@ public class JsonStorageServiceOSGiTest extends JavaOSGiTest {
|
||||
assertThat(pItem, is(nullValue()));
|
||||
|
||||
pItem = storage.get("Key1");
|
||||
Assert.assertNotNull(pItem);
|
||||
assertThat(pItem, is(notNullValue()));
|
||||
assertThat(pItem.itemType, is("String"));
|
||||
|
||||
pItem = storage.put("Key1", new PersistedItem("Number", Arrays.asList("TEMPERATURE")));
|
||||
@ -142,6 +149,14 @@ public class JsonStorageServiceOSGiTest extends JavaOSGiTest {
|
||||
public List<String> groupNames;
|
||||
public String baseItemType;
|
||||
|
||||
/**
|
||||
* Package protected default constructor to allow reflective instantiation.
|
||||
*
|
||||
* !!! DO NOT REMOVE - Gson needs it !!!
|
||||
*/
|
||||
PersistedItem() {
|
||||
}
|
||||
|
||||
public PersistedItem(String itemType, List<String> groupNames) {
|
||||
this(itemType, groupNames, null);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
<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.storage.json.tests</module>
|
||||
<module>org.openhab.core.thing.tests</module>
|
||||
<module>org.openhab.core.thing.xml.tests</module>
|
||||
<module>org.openhab.core.transform.tests</module>
|
||||
|
Loading…
Reference in New Issue
Block a user