Skip to content

Commit

Permalink
Rework XsltTransformationServiceTest
Browse files Browse the repository at this point in the history
Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn committed Oct 20, 2024
1 parent 2cb9797 commit e0ca451
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@

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;

/**
Expand All @@ -25,13 +32,22 @@ public class XsltTransformationServiceTest extends AbstractTransformationService

private XsltTransformationService processor;

private 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);

Expand Down

0 comments on commit e0ca451

Please sign in to comment.