| //------------------------------------------------------------------------------ |
| // Copyright (c) 2005, 2006 IBM Corporation and others. |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // which accompanies this distribution, and is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| // |
| // Contributors: |
| // IBM Corporation - initial implementation |
| //------------------------------------------------------------------------------ |
| package org.eclipse.epf.library.tester; |
| |
| import java.io.File; |
| |
| import org.eclipse.epf.common.utils.XMLUtil; |
| import org.eclipse.epf.library.tester.iface.TestTracer; |
| import org.w3c.dom.Document; |
| |
| /** |
| * Class to analyze the differneces between two library tester outputs |
| * |
| * @author Weiping Lu |
| * @since 1.0 |
| * |
| */ |
| public class OutputDiffAnalyzor { |
| |
| private TestTracer tracer; |
| private boolean needToAnalyze = false; |
| private File f1; |
| private File f2; |
| private Document d1; |
| private Document d2; |
| |
| public OutputDiffAnalyzor(TestTracer t, Document d1, Document d2, File f1, File f2) { |
| tracer = t; |
| this.f1 = f1; |
| this.f2 = f2; |
| this.d1 = d1 == null ? getDocument(f1) : d1; |
| this.d2 = d2 == null ? getDocument(f2) : d2; |
| } |
| |
| private Document getDocument(File file) { |
| if (file.exists()) { |
| try { |
| return XMLUtil.loadXml(file); |
| } catch (Exception e) { |
| e.printStackTrace(); |
| } |
| } |
| return null; |
| } |
| |
| private void trace(String line) { |
| tracer.trace(line); |
| } |
| |
| private void analyze() { |
| trace("OutputDiffAnalyzor.analyze ->"); |
| trace("f1: " + f1.getAbsolutePath()); |
| trace("f2: " + f2.getAbsolutePath()); |
| trace(""); |
| analyze_(); |
| trace("OutputDiffAnalyzor.analyze <-"); |
| } |
| |
| private void analyze_() { |
| if (! needToAnalyze) { |
| return; |
| } |
| |
| |
| needToAnalyze = false; |
| } |
| |
| public boolean compare() { |
| analyze(); |
| return true; |
| } |
| |
| |
| |
| } |