aboutsummaryrefslogtreecommitdiffstats
path: root/application-preprocessor/src/test/java/com/yahoo/application/preprocessor/ApplicationPreprocessorTest.java
blob: 0e5d8fb2784f59870fb234d0aa4c9fb89d707586 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.preprocessor;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.IOException;
import java.util.Optional;

public class ApplicationPreprocessorTest {

    @TempDir
    public File outputDir;

    // Basic test just to check that instantiation and run() works. Unit testing is in config-application-package
    @Test
    void basic() throws ParserConfigurationException, TransformerException, SAXException, IOException {
        ApplicationPreprocessor preprocessor = new ApplicationPreprocessor(new File("src/test/resources/simple"),
            Optional.of(newFolder(outputDir, "basic")),
            Optional.empty(),
            Optional.empty());
        preprocessor.run();
    }

    private static File newFolder(File root, String... subDirs) throws IOException {
        String subFolder = String.join("/", subDirs);
        File result = new File(root, subFolder);
        if (!result.mkdirs()) {
            throw new IOException("Couldn't create folders " + root);
        }
        return result;
    }

}