|
1 package de.unixwork.uwproj; |
|
2 |
|
3 import org.junit.jupiter.api.Test; |
|
4 |
|
5 import java.io.BufferedWriter; |
|
6 import java.io.ByteArrayOutputStream; |
|
7 import java.io.OutputStreamWriter; |
|
8 import java.nio.charset.StandardCharsets; |
|
9 import java.nio.file.Files; |
|
10 import java.nio.file.Path; |
|
11 import java.util.Objects; |
|
12 |
|
13 import static org.junit.jupiter.api.Assertions.assertEquals; |
|
14 |
|
15 public class RegressionTest { |
|
16 |
|
17 private void goldenSampleTest(String xml, String gs) throws Exception { |
|
18 final var contents = new ByteArrayOutputStream(); |
|
19 try (var out = new BufferedWriter(new OutputStreamWriter(contents))) { |
|
20 Main.writeConfigureScript(out, "test/make/configure.vm", Main.loadProjectFile("test/make/" + xml)); |
|
21 } |
|
22 assertEquals( |
|
23 Files.readString(Path.of( |
|
24 Objects.requireNonNull(RegressionTest.class.getClassLoader().getResource("golden-sample/" + gs)).toURI() |
|
25 )), |
|
26 contents.toString(StandardCharsets.UTF_8) |
|
27 ); |
|
28 } |
|
29 |
|
30 @Test |
|
31 void projectXmlOutput() throws Exception { |
|
32 goldenSampleTest("project.xml", "configure"); |
|
33 } |
|
34 |
|
35 @Test |
|
36 void project2XmlOutput() throws Exception { |
|
37 goldenSampleTest("project2.xml", "configure2"); |
|
38 } |
|
39 } |