mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Set openHAB system properties during tests (#17592)
* Set openHAB system properties during tests This will make sure tests write data to './target/openhab/userdata' instead of './userdata' etc. Prevents new files from appearing whenever running the Mi IO Binding tests. Signed-off-by: Wouter Born <github@maindrain.net> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
46f3e9aa8c
commit
c8c40d44bd
@ -14,8 +14,15 @@ package org.openhab.transform.xslt.internal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.transform.TransformationException;
|
||||
|
||||
/**
|
||||
@ -25,13 +32,22 @@ public class XsltTransformationServiceTest extends AbstractTransformationService
|
||||
|
||||
private XsltTransformationService processor;
|
||||
|
||||
private final Path transformHttpPath = Paths.get(OpenHAB.getConfigFolder()).resolve("transform/http");
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
public void init() throws IOException {
|
||||
if (!Files.exists(transformHttpPath)) {
|
||||
Files.createDirectories(transformHttpPath);
|
||||
}
|
||||
|
||||
processor = new XsltTransformationService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransformByXSLT() throws TransformationException {
|
||||
public void testTransformByXSLT() throws TransformationException, IOException {
|
||||
Files.copy(getClass().getResourceAsStream("google_weather.xsl"),
|
||||
transformHttpPath.resolve("google_weather.xsl"), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
// method under test
|
||||
String transformedResponse = processor.transform("http/google_weather.xsl", source);
|
||||
|
||||
|
3
pom.xml
3
pom.xml
@ -419,6 +419,9 @@ Import-Package: \\
|
||||
</argLine>
|
||||
<systemPropertyVariables>
|
||||
<junit.jupiter.execution.timeout.default>15 m</junit.jupiter.execution.timeout.default>
|
||||
<openhab.conf>${project.build.directory}/openhab/conf</openhab.conf>
|
||||
<openhab.runtime>${project.build.directory}/openhab/runtime</openhab.runtime>
|
||||
<openhab.userdata>${project.build.directory}/openhab/userdata</openhab.userdata>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
Loading…
Reference in New Issue
Block a user