summaryrefslogtreecommitdiffstats
path: root/config-application-package/src/test/java/com/yahoo/config/application/TestBase.java
blob: 90e4ede427d3547b8aeb7d0f97533cccb4b2b165 (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 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.application;

import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.w3c.dom.Document;

import java.io.Reader;
import java.io.StringReader;

import static org.junit.Assert.assertTrue;

/**
 * Utilities for tests
 *
 * @author hmusum
 */
public class TestBase {
    static {
        XMLUnit.setIgnoreWhitespace(true);
    }

    static void assertDocument(String expected, Document output) {
        Document expectedDoc = Xml.getDocument(new StringReader(expected));
        Diff diff = new Diff(expectedDoc, output);
        assertTrue(diff.toString(), diff.identical());
    }

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