mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +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>
This commit is contained in:
parent
273739f674
commit
2bdce1ccf9
@ -14,8 +14,15 @@ package org.openhab.transform.xslt.internal;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
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.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.openhab.core.OpenHAB;
|
||||||
import org.openhab.core.transform.TransformationException;
|
import org.openhab.core.transform.TransformationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,13 +32,22 @@ public class XsltTransformationServiceTest extends AbstractTransformationService
|
|||||||
|
|
||||||
private XsltTransformationService processor;
|
private XsltTransformationService processor;
|
||||||
|
|
||||||
|
private final Path transformHttpPath = Paths.get(OpenHAB.getConfigFolder()).resolve("transform/http");
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void init() {
|
public void init() throws IOException {
|
||||||
|
if (!Files.exists(transformHttpPath)) {
|
||||||
|
Files.createDirectories(transformHttpPath);
|
||||||
|
}
|
||||||
|
|
||||||
processor = new XsltTransformationService();
|
processor = new XsltTransformationService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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
|
// method under test
|
||||||
String transformedResponse = processor.transform("http/google_weather.xsl", source);
|
String transformedResponse = processor.transform("http/google_weather.xsl", source);
|
||||||
|
|
||||||
|
3
pom.xml
3
pom.xml
@ -419,6 +419,9 @@ Import-Package: \\
|
|||||||
</argLine>
|
</argLine>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<junit.jupiter.execution.timeout.default>15 m</junit.jupiter.execution.timeout.default>
|
<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>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
Loading…
Reference in New Issue
Block a user