aboutsummaryrefslogtreecommitdiffstats
path: root/config-application-package/src/test/java/com/yahoo/config/application/TestBase.java
blob: 3a9c1ee3cff2bf5616474bc932d4086a90aa032c (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.application;

import org.w3c.dom.Document;

import javax.xml.transform.TransformerException;
import java.io.Reader;
import java.io.StringReader;

import static org.junit.Assert.assertEquals;

/**
 * Utilities for tests
 *
 * @author hmusum
 */
public class TestBase {

    static void assertDocument(String expected, Document output) {
        try {
            assertEquals(Xml.documentAsString(Xml.getDocument(new StringReader(expected)), true),
                         Xml.documentAsString(output, true));
        }
        catch (TransformerException e) {
            throw new AssertionError(e);
        }
    }

    public static void assertDocument(String expectedDocument, Reader document) {
        Document output = Xml.getDocument(document);
        assertDocument(expectedDocument, output);
    }
}