Codebase as of c53e4aed26 as an initial commit for the shrunk repo

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2010-02-20 19:23:32 +01:00
committed by Kai Kreuzer
commit bbf1a7fd29
302 changed files with 29726 additions and 0 deletions

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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<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="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="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.persistence.mapdb.tests</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,13 @@
This content is produced and maintained by the openHAB project.
* Project home: https://www.openhab.org
== 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/openhab/openhab-addons

View File

@@ -0,0 +1,49 @@
-include: ../itest-common.bndrun
Bundle-SymbolicName: ${project.artifactId}
Fragment-Host: org.openhab.persistence.mapdb
-runrequires: \
bnd.identity;id='org.openhab.persistence.mapdb.tests',\
bnd.identity;id='org.openhab.core',\
bnd.identity;id='org.openhab.persistence.mapdb'
#
# done
#
-runbundles: \
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
com.google.gson;version='[2.8.2,2.8.3)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
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.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
org.openhab.core;version='[3.0.0,3.0.1)',\
org.openhab.core.config.core;version='[3.0.0,3.0.1)',\
org.openhab.core.persistence;version='[3.0.0,3.0.1)',\
org.openhab.core.test;version='[3.0.0,3.0.1)',\
org.osgi.service.event;version='[1.4.0,1.4.1)',\
slf4j.api;version='[1.7.25,1.7.26)',\
org.apache.servicemix.specs.activation-api-1.1;version='[2.9.0,2.9.1)',\
org.apache.servicemix.specs.jaxb-api-2.2;version='[2.9.0,2.9.1)',\
org.apache.servicemix.specs.stax-api-1.2;version='[2.9.0,2.9.1)',\
tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\
tec.uom.se;version='[1.0.10,1.0.11)',\
org.apache.servicemix.bundles.jaxb-impl;version='[2.2.11,2.2.12)',\
org.eclipse.jetty.http;version='[9.4.20,9.4.21)',\
org.eclipse.jetty.io;version='[9.4.20,9.4.21)',\
org.eclipse.jetty.security;version='[9.4.20,9.4.21)',\
org.eclipse.jetty.server;version='[9.4.20,9.4.21)',\
org.eclipse.jetty.servlet;version='[9.4.20,9.4.21)',\
org.eclipse.jetty.util;version='[9.4.20,9.4.21)',\
org.openhab.persistence.mapdb;version='[3.0.0,3.0.1)',\
org.openhab.persistence.mapdb.tests;version='[3.0.0,3.0.1)',\
biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\
junit-jupiter-api;version='[5.6.2,5.6.3)',\
junit-jupiter-engine;version='[5.6.2,5.6.3)',\
junit-platform-commons;version='[1.6.2,1.6.3)',\
junit-platform-engine;version='[1.6.2,1.6.3)',\
junit-platform-launcher;version='[1.6.2,1.6.3)',\
org.hamcrest;version='[2.2.0,2.2.1)',\
org.opentest4j;version='[1.2.0,1.2.1)'

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.itests</groupId>
<artifactId>org.openhab.addons.reactor.itests</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.persistence.mapdb.tests</artifactId>
<name>openHAB Add-ons :: Integration Tests :: MapDB Persistence Tests</name>
<dependencies>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.persistence.mapdb</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,133 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.persistence.mapdb;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
import static org.hamcrest.collection.IsEmptyIterable.emptyIterable;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.core.items.GenericItem;
import org.openhab.core.library.items.ColorItem;
import org.openhab.core.library.items.DimmerItem;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.persistence.FilterCriteria;
import org.openhab.core.persistence.QueryablePersistenceService;
import org.openhab.core.test.java.JavaOSGiTest;
import org.openhab.core.types.State;
import org.openhab.persistence.mapdb.internal.MapDbPersistenceService;
/**
*
* @author Martin Kühl - Initial contribution
*/
public class MapDbPersistenceServiceOSGiTest extends JavaOSGiTest {
private MapDbPersistenceService persistenceService;
@BeforeEach
public void setUp() {
persistenceService = getService(QueryablePersistenceService.class, MapDbPersistenceService.class);
}
@AfterAll
public static void tearDown() throws IOException {
// clean up database files ...
removeDirRecursive("userdata");
removeDirRecursive("runtime");
}
private static void removeDirRecursive(final String dir) throws IOException {
final Path path = Paths.get(dir);
if (Files.exists(path)) {
Files.walk(path).map(Path::toFile).sorted().forEach(File::delete);
}
}
@Test
public void storeShouldStoreTheItem() {
String name = "switch1";
String alias = "switch2";
State state = OnOffType.ON;
GenericItem item = new SwitchItem(name);
item.setState(state);
assertThat(persistenceService.getItemInfo(), not(hasItem(hasProperty("name", equalTo(name)))));
persistenceService.store(item);
assertThat(persistenceService.getItemInfo(), hasItem(hasProperty("name", equalTo(name))));
persistenceService.store(item, alias);
assertThat(persistenceService.getItemInfo(),
hasItems(hasProperty("name", equalTo(name)), hasProperty("name", equalTo(alias))));
}
@Test
public void queryShouldFindStoredItemsByName() {
String name = "dimmer";
State state = PercentType.HUNDRED;
GenericItem item = new DimmerItem(name);
item.setState(state);
FilterCriteria filter = new FilterCriteria();
filter.setItemName(name);
assertThat(persistenceService.query(filter), is(emptyIterable()));
persistenceService.store(item);
assertThat(persistenceService.query(filter),
contains(allOf(hasProperty("name", equalTo(name)), hasProperty("state", equalTo(state)))));
}
@Test
public void queryShouldFindStoredItemsByAlias() {
String name = "color";
String alias = "alias";
State state = HSBType.GREEN;
GenericItem item = new ColorItem(name);
item.setState(state);
FilterCriteria filterByName = new FilterCriteria();
filterByName.setItemName(name);
FilterCriteria filterByAlias = new FilterCriteria();
filterByAlias.setItemName(alias);
assertThat(persistenceService.query(filterByName), is(emptyIterable()));
assertThat(persistenceService.query(filterByAlias), is(emptyIterable()));
persistenceService.store(item, alias);
assertThat(persistenceService.query(filterByName), is(emptyIterable()));
assertThat(persistenceService.query(filterByAlias),
contains(allOf(hasProperty("name", equalTo(alias)), hasProperty("state", equalTo(state)))));
}
}