Package com.dianping.cat.report.task.utilization

Source Code of com.dianping.cat.report.task.utilization.UtilizationReportMergerTest

package com.dianping.cat.report.task.utilization;

import org.junit.Assert;
import org.junit.Test;
import org.unidal.helper.Files;

import com.dianping.cat.home.utilization.entity.UtilizationReport;
import com.dianping.cat.home.utilization.transform.DefaultSaxParser;

public class UtilizationReportMergerTest {
  @Test
  public void testUtilizationReportMerge() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("UtilizationReportOld.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("UtilizationReportNew.xml"), "utf-8");
    UtilizationReport reportOld = DefaultSaxParser.parse(oldXml);
    UtilizationReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("UtilizationReportResult.xml"),
          "utf-8");
    UtilizationReportMerger merger = new UtilizationReportMerger(new UtilizationReport(reportOld.getDomain()));

    reportOld.accept(merger);
    reportNew.accept(merger);

    Assert.assertEquals("Check the merge result!", expected.replace("\r", ""), merger.getUtilizationReport()
          .toString().replace("\r", ""));
    Assert.assertEquals("Source report is changed!", newXml.replace("\r", ""), reportNew.toString().replace("\r", ""));
  }

}
TOP

Related Classes of com.dianping.cat.report.task.utilization.UtilizationReportMergerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.