/*
 * Approved for Public Release; Distribution Unlimited. Case Number 14-4275
 * Copyright 2014 The MITRE Corporation.  All rights reserved.
 */
package Working.Tests;

import java.io.File;
import java.nio.charset.Charset;
import org.junit.Test;
import static org.junit.Assert.*;
import org.mitre.deluge.DelugeTransformer;
import org.mitre.garriss.utils.io.TextFileComparator;

/**
 *
 * @author James Garriss
 */
public class CompareTest
{
    DelugeTransformer transformer = new DelugeTransformer();
    TextFileComparator comparator = new TextFileComparator();
    Charset UTF8 = Charset.forName("UTF-8");
    
    @Test
    public void testWithFitnessCenter()
    {
        try
        {
            File output = new File("test-rsc/Fitness/FitnessCenterOutput.xml");
            transformer.transform(new File("test-rsc/Fitness/FitnessCenter.xml"),
                                  new File("test-rsc/Fitness/FitnessCenter.xsl"),
                                  output);
            File streamOutput = new File("test-rsc/Fitness/FitnessCenterOutputS.xml");
            transformer.transformStreaming(new File("test-rsc/Fitness/FitnessCenter.xml"),
                                           new File("test-rsc/Fitness/FitnessCenter.xsl"),
                                           streamOutput);
            assertTrue(comparator.compare(output, UTF8, streamOutput, UTF8));
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            fail();
        }
    }
    
    @Test
    public void testIdentityWithFitnessCenter()
    {
        try
        {
            File output = new File("test-rsc/Fitness/FitnessCenterIdentity.xml");
            transformer.transform(new File("test-rsc/Fitness/FitnessCenter.xml"),
                                  new File("rsc/xslt/identity.xsl"),
                                  output);
            File streamOutput = new File("test-rsc/Fitness/FitnessCenterIdentityS.xml");
            transformer.transformStreaming(new File("test-rsc/Fitness/FitnessCenter.xml"),
                                           new File("rsc/xslt/identity.xsl"),
                                           streamOutput);
            assertTrue(comparator.compare(output, UTF8, streamOutput, UTF8));
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            fail();
        }
    }
}
