mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged WOLF-6 (WOLF.0.0) to 5.1.1 (5.1.1)
122751 mward: UTF-384: wired in comparison tool and HTML formatter to the build. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/services/full-installer/branches/5.1.1@124000 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,16 +41,44 @@ public class FileTreeCompareImpl implements FileTreeCompare
|
|||||||
|
|
||||||
public FileTreeCompareImpl()
|
public FileTreeCompareImpl()
|
||||||
{
|
{
|
||||||
this(new HashSet<String>(), new HashSet<String>());
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileTreeCompareImpl(Set<String> ignorePaths, Set<String> allowedDiffsPath)
|
public FileTreeCompareImpl(Set<String> ignorePaths, Set<String> allowedDiffsPaths)
|
||||||
{
|
{
|
||||||
// This config MUST be present before any TFile objects etc. are created.
|
// This config MUST be present before any TFile objects etc. are created.
|
||||||
TConfig config = TConfig.get();
|
TConfig config = TConfig.get();
|
||||||
config.setArchiveDetector(new TArchiveDetector("war|jar|amp", new ZipDriver(IOPoolLocator.SINGLETON)));
|
config.setArchiveDetector(new TArchiveDetector("war|jar|amp", new ZipDriver(IOPoolLocator.SINGLETON)));
|
||||||
|
if (ignorePaths == null)
|
||||||
|
{
|
||||||
|
// Add default ignores
|
||||||
|
ignorePaths = new HashSet<>();
|
||||||
|
ignorePaths.add("alf_data/postgresql/**");
|
||||||
|
ignorePaths.add("META-INF/MANIFEST.MF");
|
||||||
|
ignorePaths.add("META-INF/maven/**");
|
||||||
|
ignorePaths.add("README.txt");
|
||||||
|
ignorePaths.add("uninstall.app/**");
|
||||||
|
}
|
||||||
|
if (allowedDiffsPaths == null)
|
||||||
|
{
|
||||||
|
// Add default paths where certain differences are allowed, e.g. absolute path references.
|
||||||
|
allowedDiffsPaths = new HashSet<>();
|
||||||
|
allowedDiffsPaths.add("common/bin/**");
|
||||||
|
allowedDiffsPaths.add("common/include/**/*.h");
|
||||||
|
allowedDiffsPaths.add("common/lib/**/*.pc");
|
||||||
|
allowedDiffsPaths.add("common/lib/**/*.la");
|
||||||
|
allowedDiffsPaths.add("libreoffice.app/Contents/Resources/bootstraprc");
|
||||||
|
allowedDiffsPaths.add("postgresql/bin/**");
|
||||||
|
allowedDiffsPaths.add("**/*.sh");
|
||||||
|
allowedDiffsPaths.add("**/*.bat");
|
||||||
|
allowedDiffsPaths.add("**/*.ini");
|
||||||
|
allowedDiffsPaths.add("**/*.properties");
|
||||||
|
allowedDiffsPaths.add("**/*.xml");
|
||||||
|
allowedDiffsPaths.add("**/*.sample");
|
||||||
|
allowedDiffsPaths.add("**/*.txt");
|
||||||
|
}
|
||||||
this.ignorePaths.addAll(ignorePaths);
|
this.ignorePaths.addAll(ignorePaths);
|
||||||
this.allowedDiffsPaths.addAll(allowedDiffsPath);
|
this.allowedDiffsPaths.addAll(allowedDiffsPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -6,20 +6,24 @@
|
|||||||
* agreement is prohibited.
|
* agreement is prohibited.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import org.alfresco.update.tool.dircomp.FileTreeCompare;
|
||||||
|
import org.alfresco.update.tool.dircomp.FileTreeCompareImpl;
|
||||||
import java.io.BufferedReader;
|
import org.alfresco.update.tool.dircomp.HtmlResultFormatter;
|
||||||
import java.io.BufferedWriter;
|
import org.alfresco.update.tool.dircomp.ResultSet;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class EndToEndIntegrationTest
|
public class EndToEndIntegrationTest
|
||||||
{
|
{
|
||||||
private final static String JAR_FILE_NAME = "alfresco-update-tool.jar";
|
private final static String JAR_FILE_NAME = "alfresco-update-tool.jar";
|
||||||
@@ -132,14 +136,47 @@ public class EndToEndIntegrationTest
|
|||||||
/**
|
/**
|
||||||
* Run the diff tool
|
* Run the diff tool
|
||||||
*
|
*
|
||||||
* @param src
|
* @param path1
|
||||||
* @param dest
|
* @param path2
|
||||||
*/
|
*/
|
||||||
public void compare(File src, File dest)
|
public void compare(File path1, File path2) throws IOException
|
||||||
{
|
{
|
||||||
//assertTrue("test not implemented", false);
|
FileTreeCompare comparator = new FileTreeCompareImpl();
|
||||||
|
ResultSet resultSet = comparator.compare(path1.toPath(), path2.toPath());
|
||||||
|
|
||||||
|
File dircompDir = new File(targetDir, "installation-diff");
|
||||||
|
dircompDir.mkdirs();
|
||||||
|
|
||||||
|
// Format the results as an HTML report.
|
||||||
|
File file = new File(dircompDir, "installation-diff-report.html");
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
HtmlResultFormatter formatter = new HtmlResultFormatter();
|
||||||
|
formatter.setDifferencesOnly(true);
|
||||||
|
try(FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
BufferedOutputStream bos = new BufferedOutputStream(fos))
|
||||||
|
{
|
||||||
|
formatter.format(resultSet, bos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility/harness to allow easy testing of {@link #compare(File, File)}.
|
||||||
|
* <p>
|
||||||
|
* Uncomment @Ignore, but do not check in.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
|
@Test
|
||||||
|
public void bigDiff() throws IOException
|
||||||
|
{
|
||||||
|
Path path1 = Paths.get("/Users/MWard/dev2/alf-installs/alf-5.1-b667");
|
||||||
|
Path path2 = Paths.get("/Users/MWard/dev2/alf-installs/alf-5.1-b669");
|
||||||
|
|
||||||
|
compare(path1.toFile(), path2.toFile());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method to execute a command
|
* Method to execute a command
|
||||||
*
|
*
|
||||||
|
@@ -68,51 +68,6 @@ public class HtmlResultFormatterTest
|
|||||||
// System.out.println("File: "+file);
|
// System.out.println("File: "+file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
|
||||||
public void bigDiff() throws IOException
|
|
||||||
{
|
|
||||||
Path path1 = Paths.get("/Users/MWard/dev2/alf-installs/alf-5.1-b667");
|
|
||||||
Path path2 = Paths.get("/Users/MWard/dev2/alf-installs/alf-5.1-b669");
|
|
||||||
|
|
||||||
Set<String> ignores = new HashSet<>();
|
|
||||||
ignores.add("alf_data/postgresql/**");
|
|
||||||
ignores.add("META-INF/MANIFEST.MF");
|
|
||||||
ignores.add("META-INF/maven/**");
|
|
||||||
ignores.add("README.txt");
|
|
||||||
ignores.add("uninstall.app/**");
|
|
||||||
|
|
||||||
// All the patterns will be applied to these files, e.g. they will all have differences
|
|
||||||
// in absolute path references ignored.
|
|
||||||
Set<String> ignoreSpecialDifferences = new HashSet<>();
|
|
||||||
ignoreSpecialDifferences.add("common/bin/**");
|
|
||||||
ignoreSpecialDifferences.add("common/include/**/*.h");
|
|
||||||
ignoreSpecialDifferences.add("common/lib/**/*.pc");
|
|
||||||
ignoreSpecialDifferences.add("common/lib/**/*.la");
|
|
||||||
ignoreSpecialDifferences.add("libreoffice.app/Contents/Resources/bootstraprc");
|
|
||||||
ignoreSpecialDifferences.add("postgresql/bin/**");
|
|
||||||
ignoreSpecialDifferences.add("**/*.sh");
|
|
||||||
ignoreSpecialDifferences.add("**/*.bat");
|
|
||||||
ignoreSpecialDifferences.add("**/*.ini");
|
|
||||||
ignoreSpecialDifferences.add("**/*.properties");
|
|
||||||
ignoreSpecialDifferences.add("**/*.xml");
|
|
||||||
ignoreSpecialDifferences.add("**/*.sample");
|
|
||||||
ignoreSpecialDifferences.add("**/*.txt");
|
|
||||||
|
|
||||||
FileTreeCompare comparator = new FileTreeCompareImpl(ignores, ignoreSpecialDifferences);
|
|
||||||
ResultSet resultSet = comparator.compare(path1, path2);
|
|
||||||
|
|
||||||
Path file = Files.createTempFile(getClass().getSimpleName(), ".html");
|
|
||||||
HtmlResultFormatter formatter = new HtmlResultFormatter();
|
|
||||||
formatter.setDifferencesOnly(true);
|
|
||||||
try(FileOutputStream fos = new FileOutputStream(file.toFile());
|
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(fos))
|
|
||||||
{
|
|
||||||
formatter.format(resultSet, bos);
|
|
||||||
}
|
|
||||||
System.out.println("File: "+file);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addResult(List<Result> results, String p1, String p2, boolean contentMatch)
|
private void addResult(List<Result> results, String p1, String p2, boolean contentMatch)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user