+++ /dev/null
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
- <xsl:output indent="yes" method="xml" encoding="UTF-8" omit-xml-declaration="yes" />
-
- <xsl:template match="//current_conditions">
- <xsl:value-of select="temp_c/@data" />
- </xsl:template>
-
-</xsl:stylesheet>
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;
/**
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);
--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:output indent="yes" method="xml" encoding="UTF-8" omit-xml-declaration="yes" />
+
+ <xsl:template match="//current_conditions">
+ <xsl:value-of select="temp_c/@data" />
+ </xsl:template>
+
+</xsl:stylesheet>
</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>