diff --git a/bundles/org.openhab.core.storage.json/pom.xml b/bundles/org.openhab.core.storage.json/pom.xml
index a5dd7a1ce..d62749e76 100644
--- a/bundles/org.openhab.core.storage.json/pom.xml
+++ b/bundles/org.openhab.core.storage.json/pom.xml
@@ -19,6 +19,12 @@
org.openhab.core.config.core
${project.version}
+
+ org.openhab.core.bundles
+ org.openhab.core.test
+ ${project.version}
+ test
+
diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java b/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java
index 81ef585c6..f0a663eae 100644
--- a/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java
+++ b/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java
@@ -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", //
diff --git a/itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JSonStorageTest.java b/bundles/org.openhab.core.storage.json/src/test/java/org/eclipse/smarthome/storage/json/internal/JSonStorageTest.java
similarity index 100%
rename from itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JSonStorageTest.java
rename to bundles/org.openhab.core.storage.json/src/test/java/org/eclipse/smarthome/storage/json/internal/JSonStorageTest.java
diff --git a/itests/org.openhab.core.storage.json.tests/itest.bndrun b/itests/org.openhab.core.storage.json.tests/itest.bndrun
index b1f67c2fa..bc477a7db 100644
--- a/itests/org.openhab.core.storage.json.tests/itest.bndrun
+++ b/itests/org.openhab.core.storage.json.tests/itest.bndrun
@@ -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)'
\ No newline at end of file
+ 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)'
\ No newline at end of file
diff --git a/itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageServiceOSGiTest.java b/itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageServiceOSGiTest.java
index f450e44d5..d83d048a3 100644
--- a/itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageServiceOSGiTest.java
+++ b/itests/org.openhab.core.storage.json.tests/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageServiceOSGiTest.java
@@ -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 groupNames;
public String baseItemType;
+ /**
+ * Package protected default constructor to allow reflective instantiation.
+ *
+ * !!! DO NOT REMOVE - Gson needs it !!!
+ */
+ PersistedItem() {
+ }
+
public PersistedItem(String itemType, List groupNames) {
this(itemType, groupNames, null);
}
diff --git a/itests/pom.xml b/itests/pom.xml
index 5db4faab6..0c7572945 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -51,7 +51,7 @@
org.openhab.core.model.thing.testsupport
org.openhab.core.model.thing.tests
-
+ org.openhab.core.storage.json.tests
org.openhab.core.thing.tests
org.openhab.core.thing.xml.tests
org.openhab.core.transform.tests