├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── cronn-diff-to-html_outputExample1.png ├── cronn-diff-to-html_outputExample1_hiRes.png ├── cronn-diff-to-html_outputExample2.png ├── cronn-diff-to-html_outputExample2_hiRes.png ├── data └── test │ ├── input │ ├── bigdir │ │ ├── testfile1 │ │ ├── testfile10 │ │ ├── testfile11 │ │ ├── testfile12 │ │ ├── testfile13 │ │ ├── testfile14 │ │ ├── testfile15 │ │ ├── testfile16 │ │ ├── testfile17 │ │ ├── testfile18 │ │ ├── testfile19 │ │ ├── testfile2 │ │ ├── testfile20 │ │ ├── testfile3 │ │ ├── testfile4 │ │ ├── testfile5 │ │ ├── testfile6 │ │ ├── testfile7 │ │ ├── testfile8 │ │ └── testfile9 │ ├── bigfile │ ├── binaryFile1_1 │ ├── binaryFile1_2 │ ├── binaryFile_differ_oldDiffVersion.unix.diff │ ├── code1.unix.diff │ ├── code1_1.java.example │ ├── code1_2.java.example │ ├── code2.unix.diff │ ├── code2_1.java.example │ ├── code2_2.java.example │ ├── code3_1.java.example │ ├── code3_2.java.example │ ├── dir1.diff │ ├── dir1_1 │ │ ├── FarFarAway.txt │ │ ├── emptyNotBinaryTest │ │ ├── subdir1 │ │ │ ├── ssubdir1 │ │ │ │ ├── Cicero.txt │ │ │ │ └── CronnDiffToHtml.java │ │ │ ├── ssubdir2 │ │ │ │ └── CiceroEn.txt │ │ │ └── ssubdir3 │ │ │ │ └── HtmlBuilder.java │ │ ├── subdir2 │ │ │ ├── DiffToHtmlParameters.java │ │ │ ├── ssubdir1 │ │ │ │ ├── sssubdir1 │ │ │ │ │ ├── UnifiedDiffValues.java │ │ │ │ │ └── UnixDirectoryDiffToHtmlConverter.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── UnixFileDiffToHtmlConverter.java │ │ │ │ │ ├── binary1 │ │ │ │ │ └── binary2 │ │ │ ├── ssubdir2 │ │ │ │ ├── sssubdir1 │ │ │ │ │ └── DirectoryDiffHtmlBuilder.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── FileHelper.java │ │ │ │ │ └── Pangram.txt │ │ │ └── ssubdir3 │ │ │ │ └── loremIpsum.txt │ │ └── subdir3 │ │ │ ├── JavaDiffToHtml.java │ │ │ ├── ssubdir1 │ │ │ └── azAz123_2.txt │ │ │ ├── ssubdir2 │ │ │ └── SimpleFileInfo.java │ │ │ └── ssubdir3 │ │ │ ├── sssubdir1 │ │ │ ├── FileDiffHtmlBuilder.java │ │ │ └── binary3 │ │ │ ├── sssubdir2 │ │ │ └── azAz123.txt │ │ │ └── sssubdir3 │ │ │ ├── HelloWorldException.java │ │ │ └── Main.java │ ├── dir1_2 │ │ ├── FarFarAway.txt │ │ ├── subdir1 │ │ │ ├── ssubdir1 │ │ │ │ ├── Cicero.txt │ │ │ │ └── CronnDiffToHtml.java │ │ │ ├── ssubdir2 │ │ │ │ └── CiceroEn.txt │ │ │ └── ssubdir3 │ │ │ │ └── HtmlBuilder.java │ │ ├── subdir2 │ │ │ ├── DiffToHtmlParameters.java │ │ │ ├── ssubdir1 │ │ │ │ ├── sssubdir1 │ │ │ │ │ ├── UnifiedDiffValues.java │ │ │ │ │ └── UnixDirectoryDiffToHtmlConverter.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── UnixFileDiffToHtmlConverter.java │ │ │ │ │ ├── binary1 │ │ │ │ │ └── binary2 │ │ │ ├── ssubdir2 │ │ │ │ ├── sssubdir1 │ │ │ │ │ └── DirectoryDiffHtmlBuilder.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── FileHelper.java │ │ │ │ │ └── Pangram.txt │ │ │ └── ssubdir3 │ │ │ │ └── loremIpsum.txt │ │ └── subdir3 │ │ │ ├── JavaDiffToHtml.java │ │ │ ├── ssubdir1 │ │ │ └── azAz123_2.txt │ │ │ ├── ssubdir2 │ │ │ └── SimpleFileInfo.java │ │ │ └── ssubdir3 │ │ │ ├── sssibdur2 │ │ │ └── azAz123.txt │ │ │ ├── sssubdir1 │ │ │ ├── FileDiffHtmlBuilder.java │ │ │ └── binary3 │ │ │ └── sssubdir3 │ │ │ ├── HelloWorldException.java │ │ │ └── Main.java │ ├── dir1_3 │ │ ├── FarFarAway.txt │ │ ├── emptyNotBinaryTest │ │ ├── subdir1 │ │ │ ├── ssubdir2 │ │ │ │ └── CiceroEn.txt │ │ │ ├── ssubdir3 │ │ │ │ └── HtmlBuilder.java │ │ │ └── ssuubbddiirr11 │ │ │ │ ├── Cicero.txt │ │ │ │ └── CronnDiffToHtml.java │ │ ├── subdir2 │ │ │ ├── DiffToHtmlParameters.java │ │ │ ├── ssubdir1 │ │ │ │ ├── sssubdir1 │ │ │ │ │ ├── UnifiedDiffValues.java │ │ │ │ │ └── UnixDirectoryDiffToHtmlConverter.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── UnixFileDiffToHtmlConverter.java │ │ │ │ │ ├── binary1 │ │ │ │ │ └── binary2 │ │ │ ├── ssubdir2 │ │ │ │ ├── sssubdir1 │ │ │ │ │ └── DirectoryDiffHtmlBuilder.java │ │ │ │ └── sssubdir2 │ │ │ │ │ ├── FileHelper.java │ │ │ │ │ └── Pangram.txt │ │ │ └── ssubdir3 │ │ │ │ └── loremIpsum.txt │ │ └── subdir3 │ │ │ ├── JavaDiffToHtml.java │ │ │ ├── ssubdir1 │ │ │ └── azAz123_2.txt │ │ │ ├── ssubdir2 │ │ │ ├── SimpleFileInfo.java │ │ │ └── someUniqueFile1 │ │ │ └── ssubdir3 │ │ │ ├── sssubdir1 │ │ │ └── FileDiffHtmlBuilder.java │ │ │ ├── sssubdir2 │ │ │ └── azAz123.txt │ │ │ └── sssubdir3 │ │ │ ├── HelloWorldException.java │ │ │ └── Main.java │ ├── dirWithSpaces1 │ │ ├── dir │ │ │ └── AnotherTextFile │ │ └── textFile │ ├── dirWithSpaces2 │ │ ├── dir │ │ │ └── AnotherTextFile │ │ └── textFile │ ├── dirWithoutSpaces │ │ ├── dir │ │ │ └── AnotherTextFile │ │ └── textFile │ ├── emptyFile │ ├── iso88591textfile │ ├── mediumdir │ │ ├── testfile1 │ │ ├── testfile10 │ │ ├── testfile11 │ │ ├── testfile12 │ │ ├── testfile13 │ │ ├── testfile14 │ │ ├── testfile15 │ │ ├── testfile2 │ │ ├── testfile3 │ │ ├── testfile4 │ │ ├── testfile5 │ │ ├── testfile6 │ │ ├── testfile7 │ │ ├── testfile8 │ │ └── testfile9 │ ├── not_so_empty_output │ │ └── here_lies_a_file │ ├── smalldir │ │ ├── testfile1 │ │ ├── testfile2 │ │ ├── testfile3 │ │ ├── testfile4 │ │ └── testfile5 │ ├── smallfile │ ├── text1.unix.diff │ ├── text1_1.example │ ├── text1_2.example │ ├── textWithSpaces1 │ ├── textWithSpaces2 │ ├── textWithoutSpaces │ ├── utf16betextfile │ ├── utf16letextfile │ └── utf8textfile │ └── validation │ ├── testFileNumberToDiffNotTooDifferent_tooSmallLeftDir.html │ ├── testFileNumberToDiffNotTooDifferent_tooSmallLeftDir.sysouterr │ ├── testFileNumberToDiffNotTooDifferent_tooSmallRightDir.html │ ├── testFileNumberToDiffNotTooDifferent_tooSmallRightDir.sysouterr │ ├── testFileNumberToDiffNotTooDifferent_true.html │ ├── testFileNumberToDiffNotTooDifferent_true.sysouterr │ ├── testGenerateDiffToHtmlReportJavaBasedBinary1.html │ ├── testGenerateDiffToHtmlReportJavaBasedBinary2Identical.html │ ├── testGenerateDiffToHtmlReportJavaBasedCode1.html │ ├── testGenerateDiffToHtmlReportJavaBasedCode2.html │ ├── testGenerateDiffToHtmlReportJavaBasedCodeIdentical.html │ ├── testGenerateDiffToHtmlReportJavaBasedText1.html │ ├── testHelp.sysouterr │ ├── testMainInvalidArgs.sysouterr │ ├── testMainInvalidOptionalArg.sysouterr │ ├── testMainJAVADiffDirsToHtml.html │ ├── testMainJAVADiffDirsToHtml.sysouterr │ ├── testMainJAVADiffDirsToHtmlIgnoreSpaceChange_False.html │ ├── testMainJAVADiffDirsToHtmlIgnoreSpaceChange_False.sysouterr │ ├── testMainJAVADiffDirsToHtmlIgnoreSpaceChange_True.html │ ├── testMainJAVADiffDirsToHtmlIgnoreSpaceChange_True.sysouterr │ ├── testMainJAVADiffDirsToHtmlIgnoreUniqueFiles.html │ ├── testMainJAVADiffDirsToHtmlIgnoreUniqueFiles.sysouterr │ ├── testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_False.html │ ├── testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_False.sysouterr │ ├── testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_True.html │ ├── testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_True.sysouterr │ ├── testMainJAVADiffDirsToHtml_emptyLeftDir.html │ ├── testMainJAVADiffDirsToHtml_emptyLeftDir.sysouterr │ ├── testMainJAVADiffDirsToHtml_emptyRightDir.html │ ├── testMainJAVADiffDirsToHtml_emptyRightDir.sysouterr │ ├── testMainJAVADiffDirsToHtml_noOutputProvided.sysouterr │ ├── testMainJAVADiffDirsToHtml_outputPathOnlyFilename.sysouterr │ ├── testMainJAVADiffDirsToHtml_pathWithMultipleSlashes.html │ ├── testMainJAVADiffDirsToHtml_pathWithMultipleSlashes.sysouterr │ ├── testMainJAVADiffFilesToHtml.html │ ├── testMainJAVADiffFilesToHtml.sysouterr │ ├── testMainJAVADiffFilesToHtmlIdentical.html │ ├── testMainJAVADiffFilesToHtmlIdentical.sysouterr │ ├── testMainJAVADiffFilesToHtmlIgnoreSpaceChange_False.html │ ├── testMainJAVADiffFilesToHtmlIgnoreSpaceChange_False.sysouterr │ ├── testMainJAVADiffFilesToHtmlIgnoreSpaceChange_True.html │ ├── testMainJAVADiffFilesToHtmlIgnoreSpaceChange_True.sysouterr │ ├── testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_False.html │ ├── testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_False.sysouterr │ ├── testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_True.html │ ├── testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_True.sysouterr │ ├── testMainJAVADiffFilesToHtmlOnlyReports.html │ ├── testMainJAVADiffFilesToHtmlOnlyReports.sysouterr │ ├── testMainJAVADiffFilesToHtmlUnifiedContext16.html │ ├── testMainJAVADiffFilesToHtmlUnifiedContext16.sysouterr │ ├── testMainJAVADiffFilesToHtml_linewiseDiff.html │ ├── testMainJAVADiffFilesToHtml_linewiseDiff.sysouterr │ ├── testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_false.html │ ├── testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_false.sysouterr │ ├── testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_true.html │ ├── testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_true.sysouterr │ ├── testMainJAVADiffFilesToHtml_pathWithMultipleSlashes.html │ ├── testMainJAVADiffFilesToHtml_pathWithMultipleSlashes.sysouterr │ ├── testMainJAVADiffIdenticalDirs.html │ ├── testMainJAVADiffIdenticalDirs.sysouterr │ ├── testMainJavaDiffDirsToHtmlIgnoreLineEndings_False.html │ ├── testMainJavaDiffDirsToHtmlIgnoreLineEndings_False.sysouterr │ ├── testMainJavaDiffDirsToHtmlIgnoreLineEndings_True.html │ ├── testMainJavaDiffDirsToHtmlIgnoreLineEndings_True.sysouterr │ ├── testMainWrongNumberOfArgs1.sysouterr │ ├── testMainWrongNumberOfArgs2.sysouterr │ ├── testMainWrongTypeOfInputs.sysouterr │ ├── testParse_Exception_help │ ├── testParse_Exception_inputsDifferentType │ ├── testParse_Exception_inputsMissing │ ├── testParse_Exception_inputsTooMany │ ├── testParse_Exception_unkownOption │ ├── testParse_OK_allCliArgs │ ├── testParse_OK_inputsAreDirs │ ├── testParse_OK_inputsAreDirs_noOutputSupplied │ └── testParse_OK_inputsAreFiles ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs └── java-diff-utils-4.1-SNAPSHOT.jar ├── release.sh └── src ├── main ├── java │ └── de │ │ └── cronn │ │ └── diff │ │ ├── CronnDiffToHtml.java │ │ ├── Main.java │ │ ├── html │ │ ├── DirectoryDiffHtmlBuilder.java │ │ ├── FileDiffHtmlBuilder.java │ │ └── HtmlBuilder.java │ │ ├── impl │ │ ├── DiffToHtmlResult.java │ │ ├── JavaDiffToHtmlGenerator.java │ │ └── java │ │ │ ├── JavaDirDiffToHtmlImpl.java │ │ │ ├── JavaFileDiffToHtmlImpl.java │ │ │ └── wrapper │ │ │ └── JavaDiffUtils2HtmlWrapper.java │ │ └── util │ │ ├── DiffToHtmlParameters.java │ │ ├── DiffToHtmlRuntimeException.java │ │ ├── FileHelper.java │ │ ├── SimpleFileInfo.java │ │ └── cli │ │ ├── CliParser.java │ │ └── DiffToHtmlCommandLine.java └── resources │ ├── diffToHtml.css │ └── diffToHtmlJSScripts.js └── test └── java └── de └── cronn └── diff ├── CronnDiffToHtmlTest.java ├── MainLineEndingsTest.java ├── MainNoOutputTest.java ├── MainTest.java ├── MainTestBase.java ├── TestBase.java ├── impl └── java │ └── wrapper │ └── JavaDiffUtils2HtmlWrapperTest.java └── util ├── FileHelperTest.java └── cli └── CliParserTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-detectable=false 2 | *.htm linguist-detectable=false 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | bin/ 3 | output/ 4 | tmp/ 5 | generated/ 6 | extlibs/ 7 | testlibs/ 8 | plugins/ 9 | 10 | .settings/ 11 | .gradle/ 12 | 13 | .project 14 | .classpath 15 | 16 | *.bin 17 | *.lock 18 | *.log 19 | 20 | /*.css 21 | /*.html 22 | .idea 23 | *.iml -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/cronn-de/diff-to-html.svg?branch=master)](https://travis-ci.org/cronn-de/diff-to-html) 2 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.cronn/diff-to-html/badge.svg)](http://maven-badges.herokuapp.com/maven-central/de.cronn/diff-to-html) 3 | [![Apache 2.0](https://img.shields.io/github/license/cronn-de/diff-to-html.svg)](http://www.apache.org/licenses/LICENSE-2.0) 4 | 5 | 6 | # diff-to-html # 7 | 8 | Displays diffs in a convenient html page. 9 | 10 | * Useful when dealing with large validation text files or directory structures in automated builds, e.g. on Jenkins. 11 | * Collapsible diff sections for each file make the result easy to read when comparing directories 12 | * Inline-diff (character-wise) helps you to easily identify changes (optionally line-wise) 13 | * Pure Java solution 14 | 15 | ##### Example outputs: 16 | --- 17 | [![cronn-diff-to-html_outputExample3](cronn-diff-to-html_outputExample1.png)](cronn-diff-to-html_outputExample1_hiRes.png) 18 | [![cronn-diff-to-html_outputExample2](cronn-diff-to-html_outputExample2.png)](cronn-diff-to-html_outputExample2_hiRes.png) 19 | --- 20 | 21 | ### Usage 22 | 23 | Install: 24 | ``` 25 | $ ./gradlew installDist 26 | ``` 27 | To compare two directories (or files), e.g. dir1 and dir2, use the fat jar 28 | 29 | ``` 30 | $ java -jar build/libs/diff-to-html-1.1.jar dir1 dir2 31 | ``` 32 | or the start script 33 | ``` 34 | $ ./build/install/diff-to-html/scripts/diff-to-html dir1 dir2 35 | ``` 36 | which will give you something like 37 | ``` 38 | Output written to: file:///home/maurice/Git-Projects/openSource/diff-to-html/diff_dir1_dir2.html 39 | 40 | Directories differ! 41 | ``` 42 | Call without arguments for help 43 | ``` 44 | $ java -jar build/libs/diff-to-html-1.4.jar -h 45 | usage: cronn-diff-to-html [] [-h] 46 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 47 | -h,--help print this help 48 | -w,--ignore-white-spaces ignore all white spaces 49 | -b,--ignore-space-change ignore changes in the amount of white space 50 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 51 | LF while comparing files 52 | -or,--only-reports always exits with zero 53 | -iu,--ignore-unique ignore unique files 54 | -de,--detect-encoding tries to determine encoding type 55 | -u,--unified output (default 3) lines of unified 56 | context 57 | -fs,--max-size-diff no textual diff if file size differs too 58 | much 59 | -id,--line-diff generate line-wise diffs (default: inline / 60 | character-wise) 61 | ``` 62 | Generate your tar (or zip) to take wherever you want 63 | ``` 64 | $ ./gradlew distTar distZip 65 | $ ls build/distributions/ 66 | diff-to-html-1.1.tar diff-to-html-1.1.zip 67 | ``` 68 | 69 | ### Prerequisites 70 | - Java 8 71 | 72 | ### Related 73 | - [java-diff-utils](https://github.com/java-diff-utils/java-diff-utils) 74 | - [j2html](https://j2html.com/) 75 | - [System Rules](http://stefanbirkner.github.io/system-rules/) -------------------------------------------------------------------------------- /cronn-diff-to-html_outputExample1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/cronn-diff-to-html_outputExample1.png -------------------------------------------------------------------------------- /cronn-diff-to-html_outputExample1_hiRes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/cronn-diff-to-html_outputExample1_hiRes.png -------------------------------------------------------------------------------- /cronn-diff-to-html_outputExample2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/cronn-diff-to-html_outputExample2.png -------------------------------------------------------------------------------- /cronn-diff-to-html_outputExample2_hiRes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/cronn-diff-to-html_outputExample2_hiRes.png -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile1 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile10 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile11 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile12 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile13 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile14 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile15 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile16 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile17 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile18: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile18 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile19 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile2 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile20 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile3 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile4 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile5 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile6 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile7 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile8 -------------------------------------------------------------------------------- /data/test/input/bigdir/testfile9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/bigdir/testfile9 -------------------------------------------------------------------------------- /data/test/input/bigfile: -------------------------------------------------------------------------------- 1 | This is a test file not a smallfile 2 | -------------------------------------------------------------------------------- /data/test/input/binaryFile1_1: -------------------------------------------------------------------------------- 1 | HI -------------------------------------------------------------------------------- /data/test/input/binaryFile1_2: -------------------------------------------------------------------------------- 1 | (I -------------------------------------------------------------------------------- /data/test/input/binaryFile_differ_oldDiffVersion.unix.diff: -------------------------------------------------------------------------------- 1 | Files data/test/input/binaryFile1_1 and data/test/input/binaryFile1_2 differ 2 | -------------------------------------------------------------------------------- /data/test/input/code1.unix.diff: -------------------------------------------------------------------------------- 1 | --- data/test/input/code1_1.java.example 2018-02-26 16:05:51.341346222 +0100 2 | +++ data/test/input/code1_2.java.example 2018-02-26 16:05:51.337346221 +0100 3 | @@ -4,9 +4,9 @@ 4 | */ 5 | package de.cronn.diff.util; 6 | 7 | -public class SimpleFileInfo { 8 | +public class SimpleFileInformation { 9 | private String path = ""; 10 | - private String lastModified = ""; 11 | + private String lastModifiet = ""; 12 | 13 | public SimpleFileInfo() {} 14 | 15 | @@ -14,9 +14,11 @@ 16 | this(path, ""); 17 | } 18 | 19 | - public SimpleFileInfo(String path, String lastModified) { 20 | + //TODO: do something 21 | + 22 | + public SimpleFileInformation(String path, String lastModifiet) { 23 | this.path = path; 24 | - this.lastModified = lastModified; 25 | + this.lastModifiet = lastModifiet 26 | } 27 | 28 | public String getPath() { 29 | @@ -24,14 +26,14 @@ 30 | } 31 | 32 | public String getLastModified() { 33 | - return lastModified; 34 | + return lastModified; return lastModified; 35 | } 36 | 37 | public void setPath(String path) { 38 | this.path = path; 39 | } 40 | 41 | - public void setLastModified(String lastModified) { 42 | + public void setLastModified(String lastMod) { 43 | this.lastModified = lastModified; 44 | } 45 | } 46 | \ No newline at end of file 47 | -------------------------------------------------------------------------------- /data/test/input/code1_1.java.example: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Aug 10, 2016 3 | * Project: cronn-diff-to-html 4 | */ 5 | package de.cronn.diff.util; 6 | 7 | public class SimpleFileInfo { 8 | private String path = ""; 9 | private String lastModified = ""; 10 | 11 | public SimpleFileInfo() {} 12 | 13 | public SimpleFileInfo(String path) { 14 | this(path, ""); 15 | } 16 | 17 | public SimpleFileInfo(String path, String lastModified) { 18 | this.path = path; 19 | this.lastModified = lastModified; 20 | } 21 | 22 | public String getPath() { 23 | return path; 24 | } 25 | 26 | public String getLastModified() { 27 | return lastModified; 28 | } 29 | 30 | public void setPath(String path) { 31 | this.path = path; 32 | } 33 | 34 | public void setLastModified(String lastModified) { 35 | this.lastModified = lastModified; 36 | } 37 | } -------------------------------------------------------------------------------- /data/test/input/code1_2.java.example: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Aug 10, 2016 3 | * Project: cronn-diff-to-html 4 | */ 5 | package de.cronn.diff.util; 6 | 7 | public class SimpleFileInformation { 8 | private String path = ""; 9 | private String lastModifiet = ""; 10 | 11 | public SimpleFileInfo() {} 12 | 13 | public SimpleFileInfo(String path) { 14 | this(path, ""); 15 | } 16 | 17 | //TODO: do something 18 | 19 | public SimpleFileInformation(String path, String lastModifiet) { 20 | this.path = path; 21 | this.lastModifiet = lastModifiet 22 | } 23 | 24 | public String getPath() { 25 | return path; 26 | } 27 | 28 | public String getLastModified() { 29 | return lastModified; return lastModified; 30 | } 31 | 32 | public void setPath(String path) { 33 | this.path = path; 34 | } 35 | 36 | public void setLastModified(String lastMod) { 37 | this.lastModified = lastModified; 38 | } 39 | } -------------------------------------------------------------------------------- /data/test/input/code2.unix.diff: -------------------------------------------------------------------------------- 1 | --- data/test/input/code2_1.java.example 2018-02-26 16:05:51.337346221 +0100 2 | +++ data/test/input/code2_2.java.example 2018-02-26 16:05:51.333346221 +0100 3 | @@ -8,7 +8,6 @@ 4 | import static de.cronn.diff.util.UnifiedDiffValues.BINARY_FILES_SUFFIX; 5 | import static de.cronn.diff.util.UnifiedDiffValues.BINARY_LINE_SPLIT_STR; 6 | import static de.cronn.diff.util.UnifiedDiffValues.DELETION_PREFIX; 7 | -import static de.cronn.diff.util.UnifiedDiffValues.DIFF_FILE_LEFT_PREFIX; 8 | import static de.cronn.diff.util.UnifiedDiffValues.DIFF_FILE_RIGHT_PREFIX; 9 | import static de.cronn.diff.util.UnifiedDiffValues.IDENTICAL_FILES_PREFIX; 10 | import static de.cronn.diff.util.UnifiedDiffValues.IDENTICAL_FILES_SUFFIX; 11 | @@ -117,7 +116,7 @@ 12 | private SimpleFileInfo[] getBinaryFileInfos(String line) { 13 | String binaryFilesDifferPrefix = UnifiedDiffValues.getBinaryFilesDifferPrefix(line); 14 | String[] paths = StringUtils.substringBeforeLast( 15 | - StringUtils.substringAfter(line, binaryFilesDifferPrefix), 16 | + StringUtils.substringafter(line, binaryFilesDifferPrefix), 17 | BINARY_FILES_SUFFIX).split(BINARY_LINE_SPLIT_STR); 18 | return createFileInfoPair(paths); 19 | } 20 | @@ -129,7 +128,7 @@ 21 | return createFileInfoPair(paths); 22 | } 23 | 24 | - private SimpleFileInfo[] createFileInfoPair(String[] paths) { 25 | + private SimpleFileInfo[] createFileInfoPaiirr(String[] paths) { 26 | if (paths.length == 2) { 27 | SimpleFileInfo fileInfoLeft = new SimpleFileInfo(paths[0].trim()); 28 | SimpleFileInfo fileInfoRight = new SimpleFileInfo(paths[1].trim()); 29 | @@ -142,8 +141,8 @@ 30 | String substringAfter = StringUtils.substringAfter(line, identifierPrefix); 31 | String[] fileInfos = substringAfter.split("\t"); 32 | SimpleFileInfo fInfo = new SimpleFileInfo(); 33 | - fInfo.setPath(fileInfos.length > 0 ? fileInfos[0].trim() : ""); 34 | - fInfo.setLastModified(fileInfos.length > 1 ? fileInfos[1] : ""); 35 | + fInfo.setPath(fileInfos.length < 0 ? fileInfos[0].trim() : ""); 36 | + fInfo.setLastModified(fileInfos.length < 1 ? fileInfos[1] : ""); 37 | return fInfo; 38 | } 39 | 40 | @@ -166,7 +165,7 @@ 41 | } 42 | } 43 | 44 | - String getUniqueFileNameFromCurrentDiffLine() { 45 | + String getUniqueNameFromCurrentDiffLine() { 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /data/test/input/code3_1.java.example: -------------------------------------------------------------------------------- 1 | public class HelloWorld 2 | { 3 | public static void main(String[] args) { 4 | System.out.println("Hello World!"); 5 | } 6 | } -------------------------------------------------------------------------------- /data/test/input/code3_2.java.example: -------------------------------------------------------------------------------- 1 | public class HelloWorld 2 | { 3 | public static void main(String[] args) { 4 | System.out.println("Ahoi!"); 5 | } 6 | } -------------------------------------------------------------------------------- /data/test/input/dir1_1/FarFarAway.txt: -------------------------------------------------------------------------------- 1 | Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 2 | 3 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. 4 | 5 | A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. 6 | 7 | Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. 8 | 9 | The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. 10 | 11 | She packed her seven versalia, put her initial into the belt and made herself on the way. 12 | 13 | When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. 14 | 15 | Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. 16 | 17 | The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. 18 | 19 | But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. 20 | 21 | And if she hasn’t been rewritten, then they are still using her. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 22 | 23 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. 24 | 25 | It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One -------------------------------------------------------------------------------- /data/test/input/dir1_1/emptyNotBinaryTest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_1/emptyNotBinaryTest -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir1/ssubdir1/Cicero.txt: -------------------------------------------------------------------------------- 1 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 2 | 3 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 4 | 5 | Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 6 | 7 | Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? 8 | 9 | Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? 10 | 11 | At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. 12 | 13 | Et harum quidem rerum facilis est et expedita distinctio. 14 | 15 | Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. 16 | 17 | Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. 18 | 19 | Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. 20 | 21 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 22 | 23 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir1/ssubdir1/CronnDiffToHtml.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | 7 | import org.apache.commons.io.FilenameUtils; 8 | 9 | import de.cronn.diff.impl.JavaDiffToHtml; 10 | import de.cronn.diff.impl.OSDiffToHtml; 11 | import de.cronn.diff.util.DiffToHtmlParameters; 12 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 13 | import de.cronn.diff.util.FileHelper; 14 | 15 | public class CronnDiffToHtml { 16 | 17 | private static final String NEWLINE = System.lineSeparator(); 18 | 19 | private static final String SYSOUT_MSG_DIRECTORIES_IDENTICAL = NEWLINE + "Directories are identical!"; 20 | 21 | private static final String SYSOUT_MSG_FILES_IDENTICAL = NEWLINE + "Files are identical!"; 22 | 23 | private static final String SYSOUT_MSG_DIRECTORIES_DIFFER = NEWLINE + "Directories differ!"; 24 | 25 | private static final String SYSOUT_MSG_FILES_DIFFER = NEWLINE + "Files differ!"; 26 | 27 | private static final String SYSOUT_MSG_OUTPUT_WRITTEN_TO = NEWLINE + "Output written to: "; 28 | 29 | private boolean isUseOSDiffTool = true; 30 | 31 | private DiffToHtmlParameters params = null; 32 | 33 | public boolean isUseOSDiffTool() { 34 | return isUseOSDiffTool; 35 | } 36 | 37 | public void setUseOSDiffTool(boolean isUseOSDiffTool) { 38 | this.isUseOSDiffTool = isUseOSDiffTool; 39 | } 40 | 41 | public int generateDiffToHtmlReport(DiffToHtmlParameters params) throws IOException { 42 | this.params = params; 43 | String outputDirPath = FilenameUtils.getFullPath(params.getOutputPath()); 44 | FileHelper.copyCssFileToDir(outputDirPath); 45 | 46 | if (isUseOSDiffTool) { 47 | return generateOSDiffToHtml(params); 48 | 49 | } else { 50 | return generateJavaDiffToHtml(params); 51 | } 52 | } 53 | 54 | private int generateOSDiffToHtml(DiffToHtmlParameters params) throws IOException { 55 | OSDiffToHtml osDiffToHtml = new OSDiffToHtml(); 56 | String html = osDiffToHtml.generateHtml(params); 57 | writeToDisk(html); 58 | int resultCode = osDiffToHtml.getResultCode(); 59 | printResultMessage(resultCode); 60 | return resultCode; 61 | } 62 | 63 | private int generateJavaDiffToHtml(DiffToHtmlParameters params) throws IOException { 64 | JavaDiffToHtml javaDiffToHtml = new JavaDiffToHtml(); 65 | String html = javaDiffToHtml.generateDiff2Html(params); 66 | writeToDisk(html); 67 | int resultCode = javaDiffToHtml.getResultCode(); 68 | printResultMessage(resultCode); 69 | return resultCode; 70 | } 71 | 72 | private void writeToDisk(String html) throws IOException { 73 | String path = params.getOutputPath(); 74 | Files.write(Paths.get(path), html.getBytes()); 75 | System.out.println(SYSOUT_MSG_OUTPUT_WRITTEN_TO + params.getOutputPath()); 76 | } 77 | 78 | private void printResultMessage(int resultCode) { 79 | if (params.getDiffType() == DiffType.DIRECTORIES) { 80 | printDirDiffResultMessage(resultCode); 81 | } else { 82 | printFileDiffResultMessage(resultCode); 83 | } 84 | } 85 | 86 | private void printDirDiffResultMessage(int resultCode) { 87 | if (resultCode == Main.EXIT_CODE_OK) { 88 | System.out.println(SYSOUT_MSG_DIRECTORIES_IDENTICAL); 89 | } else { 90 | System.out.println(SYSOUT_MSG_DIRECTORIES_DIFFER); 91 | } 92 | } 93 | 94 | private void printFileDiffResultMessage(int resultCode) { 95 | if (resultCode == Main.EXIT_CODE_OK) { 96 | System.out.println(SYSOUT_MSG_FILES_IDENTICAL); 97 | } else { 98 | System.out.println(SYSOUT_MSG_FILES_DIFFER); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir1/ssubdir2/CiceroEn.txt: -------------------------------------------------------------------------------- 1 | But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. 2 | 3 | No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. 4 | 5 | Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. 6 | 7 | To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? 8 | 9 | But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? 10 | 11 | On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. 12 | 13 | These cases are perfectly simple and easy to distinguish. 14 | 15 | In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. 16 | 17 | But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir1/ssubdir3/HtmlBuilder.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.html; 2 | 3 | import static j2html.TagCreator.html; 4 | import static j2html.TagCreator.link; 5 | 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Paths; 8 | 9 | import org.apache.commons.io.FilenameUtils; 10 | 11 | import de.cronn.diff.util.DiffToHtmlParameters; 12 | import de.cronn.diff.util.FileHelper; 13 | import j2html.tags.EmptyTag; 14 | import j2html.tags.Tag; 15 | 16 | public abstract class HtmlBuilder { 17 | 18 | protected static final String EMPTY_LINE_HEIGHT = "16"; 19 | 20 | protected static final String CSS_CLASS_LINE_NUMBER = "line-number"; 21 | 22 | protected static final String CSS_ID_WRAPPER = "wrapper"; 23 | 24 | protected static final String CSS_CLASS_DELETE = "delete"; 25 | 26 | protected static final String CSS_CLASS_INSERT = "insert"; 27 | 28 | protected static final String CSS_CLASS_CONTEXT = "context"; 29 | 30 | protected static final String CSS_CLASS_INFO = "info"; 31 | 32 | protected static final String CSS_CLASS_ATTENTION = "attention"; 33 | 34 | public static boolean useSimpleFormatOnHtmls = false; 35 | 36 | protected String outputDirForRelativePaths = null; 37 | 38 | public abstract Tag createHead(); 39 | 40 | public abstract Tag createBody(); 41 | 42 | public static final String preferedEncoding = StandardCharsets.UTF_8.toString(); 43 | 44 | public HtmlBuilder(DiffToHtmlParameters params) { 45 | this.outputDirForRelativePaths = FilenameUtils.getFullPath(params.getOutputPath()); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | String renderedHtml = html().with( 51 | createHead(), 52 | createBody()) 53 | .render(); 54 | if (useSimpleFormatOnHtmls) { 55 | return newlineAllHtmlTags(renderedHtml); 56 | } else { 57 | return renderedHtml; 58 | } 59 | } 60 | 61 | protected String getRelativePath(String absolutePath) { 62 | if(absolutePath.isEmpty()) { 63 | return ""; 64 | } 65 | if (outputDirForRelativePaths != null) { 66 | return Paths.get(outputDirForRelativePaths).relativize(Paths.get(absolutePath)).toString(); 67 | } 68 | return absolutePath; 69 | } 70 | 71 | protected String newlineAllHtmlTags(String html) { 72 | return html.replaceAll("(<.*?>)", System.lineSeparator() + "$1") 73 | .replaceAll(System.lineSeparator() + "()", "$1"); 74 | } 75 | 76 | protected EmptyTag createStyleTag() { 77 | return link().withRel("stylesheet").withType("text/css").withHref(FileHelper.CSS_FILE); 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir2/DiffToHtmlParameters.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class DiffToHtmlParameters { 4 | public enum DiffType { 5 | FILES, DIRECTORIES; 6 | } 7 | 8 | private DiffType diffType; 9 | private String inputLeftPath; 10 | private String inputRightPath; 11 | private String outputPath; 12 | 13 | private String diffCommandLineAsString; 14 | private boolean ignoreUniqueFiles = false; 15 | private boolean ignoreWhiteSpaces = false; 16 | private boolean detectTextFileEncoding = false; 17 | 18 | public DiffToHtmlParameters withDiffType(DiffType diffType) { 19 | this.diffType = diffType; 20 | return this; 21 | } 22 | 23 | public DiffType getDiffType() { 24 | return diffType; 25 | } 26 | 27 | public DiffToHtmlParameters withInputLeftPath(String inputLeftPath) { 28 | this.inputLeftPath = inputLeftPath; 29 | return this; 30 | } 31 | 32 | public String getInputLeftPath() { 33 | return inputLeftPath; 34 | } 35 | 36 | public DiffToHtmlParameters withInputRightPath(String inputRightPath) { 37 | this.inputRightPath = inputRightPath; 38 | return this; 39 | } 40 | 41 | public String getInputRightPath() { 42 | return inputRightPath; 43 | } 44 | 45 | public DiffToHtmlParameters withOutputPath(String outputPath) { 46 | this.outputPath = outputPath; 47 | return this; 48 | } 49 | 50 | public String getOutputPath() { 51 | return outputPath; 52 | } 53 | 54 | public String getDiffCommandLineAsString() { 55 | return diffCommandLineAsString; 56 | } 57 | 58 | 59 | public void setDiffCommandLineAsString(String diffCommandLineAsString) { 60 | this.diffCommandLineAsString = diffCommandLineAsString; 61 | } 62 | 63 | public DiffToHtmlParameters withIgnoreUniqueFiles(boolean ignoreUniqueFiles) { 64 | this.ignoreUniqueFiles = ignoreUniqueFiles; 65 | return this; 66 | } 67 | 68 | public boolean isIgnoreUniqueFiles() { 69 | return ignoreUniqueFiles; 70 | } 71 | 72 | public DiffToHtmlParameters withDetectTextFileEncoding(boolean detectTextFileEncoding) { 73 | this.detectTextFileEncoding = detectTextFileEncoding; 74 | return this; 75 | } 76 | 77 | public boolean isIgnoreWhiteSpaces() { 78 | return ignoreWhiteSpaces; 79 | } 80 | 81 | public DiffToHtmlParameters withIgnoreWhiteSpaces(boolean ignoreWhiteSpaces) { 82 | this.ignoreWhiteSpaces = ignoreWhiteSpaces; 83 | return this; 84 | } 85 | 86 | public boolean isDetectTextFileEncoding() { 87 | return detectTextFileEncoding; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir2/ssubdir1/sssubdir1/UnifiedDiffValues.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public final class UnifiedDiffValues { 4 | 5 | public static final String BLANK = " "; 6 | 7 | public static final String UNIQUE_FILE_PREFIX = "Only in "; 8 | 9 | public static final String UNIQUE_LINE_SPLIT_STR = ": "; 10 | 11 | public static final String BINARY_FILES_DIFFER_PREFIX = "Binary files "; 12 | 13 | public static final String BINARY_FILES_DIFFER_OLD_VERSION_PREFIX = "Files "; 14 | 15 | public static final String NO_NEWLINE_AT_END_OF_FILE_WARNING = "\\ No newline at end of file"; 16 | 17 | public static final String DIFF_FILE_LEFT_PREFIX = "---"; 18 | 19 | public static final String DIFF_FILE_RIGHT_PREFIX = "+++"; 20 | 21 | public static final String INSERTION_PREFIX = "+"; 22 | 23 | public static final String DELETION_PREFIX = "-"; 24 | 25 | public static final String INFO_PREFIX_SUFFIX = "@@"; 26 | 27 | public static final String BINARY_FILES_SUFFIX = " differ"; 28 | 29 | public static final String BINARY_LINE_SPLIT_STR = " and "; 30 | 31 | public static final String IDENTICAL_FILES_PREFIX = "Files "; 32 | 33 | public static final String IDENTICAL_FILES_SUFFIX = " are identical"; 34 | 35 | public static final String IDENTICAL_LINE_SPLIT_STR = " and "; 36 | 37 | /*** 38 | * Gets the correct prefix/identifier for a message about differing binary files. 39 | * Older diff versions use the message 'Files ... differ' instead of 'Binary files ... differ' 40 | */ 41 | public static String getBinaryFilesDifferPrefix(String line) { 42 | if(isOlderVersionBinaryFilesDifferMessag(line)) { 43 | return BINARY_FILES_DIFFER_OLD_VERSION_PREFIX; 44 | } 45 | return BINARY_FILES_DIFFER_PREFIX; 46 | } 47 | 48 | private static boolean isOlderVersionBinaryFilesDifferMessag(String line) { 49 | return line.startsWith(BINARY_FILES_DIFFER_OLD_VERSION_PREFIX) && line.endsWith(BINARY_FILES_SUFFIX); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir2/ssubdir1/sssubdir2/binary1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_1/subdir2/ssubdir1/sssubdir2/binary1 -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir2/ssubdir1/sssubdir2/binary2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_1/subdir2/ssubdir1/sssubdir2/binary2 -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir2/ssubdir3/loremIpsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. 2 | 3 | Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. 4 | 5 | Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. 6 | 7 | Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. 8 | 9 | Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. 10 | 11 | Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. 12 | 13 | Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. 14 | 15 | Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. 16 | 17 | Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. 18 | 19 | Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. 20 | 21 | Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. 22 | 23 | Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. 24 | 25 | Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. 26 | 27 | Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. 28 | 29 | Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. 30 | 31 | Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir3/ssubdir1/azAz123_2.txt: -------------------------------------------------------------------------------- 1 | abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 2 | 3 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 4 | 5 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 6 | 7 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 8 | 9 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 10 | 11 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 12 | 13 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 14 | 15 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 16 | 17 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 18 | 19 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 20 | 21 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 22 | 23 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 24 | 25 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 26 | 27 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 28 | 29 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 30 | 31 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 32 | 33 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 34 | 35 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 36 | 37 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 38 | 39 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir3/ssubdir2/SimpleFileInfo.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class SimpleFileInfo { 4 | private String path = ""; 5 | private String lastModified = ""; 6 | 7 | public SimpleFileInfo() {} 8 | 9 | public SimpleFileInfo(String path) { 10 | this(path, ""); 11 | } 12 | 13 | public SimpleFileInfo(String path, String lastModified) { 14 | this.path = path; 15 | this.lastModified = lastModified; 16 | } 17 | 18 | public String getPath() { 19 | return path; 20 | } 21 | 22 | public String getLastModified() { 23 | return lastModified; 24 | } 25 | 26 | public void setPath(String path) { 27 | this.path = path; 28 | } 29 | 30 | public void setLastModified(String lastModified) { 31 | this.lastModified = lastModified; 32 | } 33 | } -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir3/ssubdir3/sssubdir1/binary3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_1/subdir3/ssubdir3/sssubdir1/binary3 -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir3/ssubdir3/sssubdir3/HelloWorldException.java: -------------------------------------------------------------------------------- 1 | public class HelloWorldException { 2 | public static void main (String[] args) throws Exception { 3 | System.out.println("Bienvenitos!"); 4 | throw new Exception("Generic Exception"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /data/test/input/dir1_1/subdir3/ssubdir3/sssubdir3/Main.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import static de.cronn.diff.util.cli.CliParser.OPT_DETECT_ENCODING; 4 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_SPACE_CHANGE; 5 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_UNIQUE_FILES; 6 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_WHITESPACES; 7 | import static de.cronn.diff.util.cli.CliParser.OPT_OS_DIFF; 8 | import static de.cronn.diff.util.cli.CliParser.OPT_UNIFIED_CONTEXT; 9 | 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Paths; 13 | 14 | import org.apache.commons.cli.ParseException; 15 | 16 | import de.cronn.diff.util.DiffToHtmlParameters; 17 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 18 | import de.cronn.diff.util.cli.CliParser; 19 | import de.cronn.diff.util.cli.DiffToHtmlCommandLine; 20 | 21 | public class Main { 22 | 23 | public static final int EXIT_CODE_ERROR = 1; 24 | 25 | public static final int EXIT_CODE_OK = 0; 26 | 27 | public static final int UNIFIED_CONTEXT_LINES = 3; 28 | 29 | public static final String PROGRAM_NAME = "cronn-diff-to-html"; 30 | 31 | public static boolean terminateVMOnExit = true; 32 | 33 | public static void main(String args[]) throws Exception { 34 | Main m = new Main(); 35 | int status = m.processDiffToHtml(args); 36 | exitProgram(status); 37 | } 38 | 39 | private static void exitProgram(int status) throws Exception { 40 | if (terminateVMOnExit) { 41 | System.exit(status); 42 | } 43 | } 44 | 45 | 46 | private int processDiffToHtml(String[] args) throws IOException, ParseException { 47 | int status = EXIT_CODE_OK; 48 | 49 | CronnDiffToHtml cronnDiffer = new CronnDiffToHtml(); 50 | DiffToHtmlCommandLine cli = new CliParser().parse(args); 51 | cronnDiffer.setUseOSDiffTool(cli.hasOption(OPT_OS_DIFF)); 52 | boolean inputsAreFiles = inputsAreTypeFile(args); 53 | boolean inputsAreDirs = inputsAreTypeDir(args); 54 | 55 | if (inputsAreFiles) { 56 | status = cronnDiffer.generateDiffToHtmlReport(createParams(cli, DiffType.FILES)); 57 | 58 | } else if (inputsAreDirs) { 59 | status = cronnDiffer.generateDiffToHtmlReport(createParams(cli, DiffType.DIRECTORIES)); 60 | } 61 | 62 | return cli.hasOption(CliParser.OPT_ONLY_REPORTS) ? EXIT_CODE_OK : status; 63 | } 64 | 65 | private DiffToHtmlParameters createParams(DiffToHtmlCommandLine cli, DiffType diffType) { 66 | DiffToHtmlParameters params = new DiffToHtmlParameters() 67 | .withDiffType(diffType) 68 | .withInputLeftPath(cli.getInputLeft()) 69 | .withInputRightPath(cli.getInputRight()) 70 | .withOutputPath(cli.getOutput()) 71 | .withIgnoreUniqueFiles(cli.hasOption(OPT_IGNORE_UNIQUE_FILES)) 72 | .withIgnoreWhiteSpaces(cli.hasOption(OPT_IGNORE_WHITESPACES)) 73 | .withIgnoreSpaceChange(cli.hasOption(OPT_IGNORE_SPACE_CHANGE)) 74 | .withDetectTextFileEncoding(cli.hasOption(OPT_DETECT_ENCODING)) 75 | .withUnifiedContext(Integer.parseInt(cli.getOptionValue(OPT_UNIFIED_CONTEXT, Integer.toString(UNIFIED_CONTEXT_LINES)))); 76 | return params; 77 | } 78 | 79 | private boolean inputsAreTypeFile(String[] args) { 80 | return Files.isRegularFile(Paths.get(args[0])) && Files.isRegularFile(Paths.get(args[1])); 81 | } 82 | 83 | private boolean inputsAreTypeDir(String[] args) { 84 | return Files.isDirectory(Paths.get(args[0])) && Files.isDirectory(Paths.get(args[1])); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /data/test/input/dir1_2/FarFarAway.txt: -------------------------------------------------------------------------------- 1 | Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 2 | 3 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. 4 | 5 | A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. 6 | 7 | Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. 8 | 9 | The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. 10 | 11 | She packed her seven versalia, put her initial into the belt and made herself on the way. 12 | 13 | When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. 14 | 15 | Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. 16 | 17 | The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. 18 | 19 | But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. 20 | 21 | And if she hasn’t been rewritten, then they are still using her. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 22 | 23 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. 24 | 25 | It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir1/ssubdir1/Cicero.txt: -------------------------------------------------------------------------------- 1 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 2 | 3 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 4 | 5 | Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 6 | 7 | Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? 8 | 9 | Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? 10 | 11 | At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. 12 | 13 | Et harum quidem rerum facilis est et expedita distinctio. 14 | 15 | Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. 16 | 17 | Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. 18 | 19 | Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. 20 | 21 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 22 | 23 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir1/ssubdir1/CronnDiffToHtml.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | 7 | import org.apache.commons.io.FilenameUtils; 8 | 9 | import de.cronn.diff.impl.JavaDiffToHtml; 10 | import de.cronn.diff.impl.OSDiffToHtml; 11 | import de.cronn.diff.util.DiffToHtmlParameters; 12 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 13 | import de.cronn.diff.util.FileHelper; 14 | 15 | public class CronnDiffToHtml { 16 | 17 | private static final String SYSOUT_MSG_DIRECTORIES_IDENTICAL = "\nDirectories are identical!"; 18 | 19 | private static final String SYSOUT_MSG_FILES_IDENTICAL = "\nFiles are identical!"; 20 | 21 | private static final String SYSOUT_MSG_DIRECTORIES_DIFFER = "\nDirectories differ!"; 22 | 23 | private static final String SYSOUT_MSG_FILES_DIFFER = "\nFiles differ!"; 24 | 25 | private static final String SYSOUT_MSG_OUTPUT_WRITTEN_TO = "\nOutput written to: "; 26 | 27 | private static final int NUMBER_OF_DIFF_CONTEXT_LINES = 3; 28 | 29 | private boolean isUseOSDiffTool = true; 30 | 31 | private DiffToHtmlParameters params = null; 32 | 33 | public boolean isUseOSDiffTool() { 34 | return isUseOSDiffTool; 35 | } 36 | 37 | public void setUseOSDiffTool(boolean isUseOSDiffTool) { 38 | this.isUseOSDiffTool = isUseOSDiffTool; 39 | } 40 | 41 | public int generateDiffToHtmlReport(DiffToHtmlParameters params) throws IOException { 42 | this.params = params; 43 | String outputDirUri = FilenameUtils.getFullPath(params.getOutputUri()); 44 | FileHelper.copyCssFileToDir(outputDirUri); 45 | 46 | if (isUseOSDiffTool) { 47 | return generateOSDiffToHtml(params); 48 | 49 | } else { 50 | return generateJavaDiffToHtml(params); 51 | } 52 | } 53 | 54 | private int generateOSDiffToHtml(DiffToHtmlParameters params) throws IOException { 55 | OSDiffToHtml osDiffToHtml = new OSDiffToHtml(); 56 | String html = osDiffToHtml.generateHtml(params, NUMBER_OF_DIFF_CONTEXT_LINES); 57 | writeToDisk(html); 58 | int resultCode = osDiffToHtml.getResultCode(); 59 | printResultMessage(resultCode); 60 | return resultCode; 61 | } 62 | 63 | private int generateJavaDiffToHtml(DiffToHtmlParameters params) throws IOException { 64 | JavaDiffToHtml javaDiffToHtml = new JavaDiffToHtml(); 65 | String html = javaDiffToHtml.generateDiff2Html(params, NUMBER_OF_DIFF_CONTEXT_LINES); 66 | writeToDisk(html); 67 | int resultCode = javaDiffToHtml.getResultCode(); 68 | printResultMessage(resultCode); 69 | return resultCode; 70 | } 71 | 72 | private void writeToDisk(String html) throws IOException { 73 | String uri = params.getOutputUri(); 74 | Files.write(Paths.get(uri), html.getBytes()); 75 | System.out.println(SYSOUT_MSG_OUTPUT_WRITTEN_TO + params.getOutputUri()); 76 | } 77 | 78 | private void printResultMessage(int resultCode) { 79 | if (params.getDiffType() == DiffType.DIRECTORIES) { 80 | printDirDiffResultMessage(resultCode); 81 | } else { 82 | printFileDiffResultMessage(resultCode); 83 | } 84 | } 85 | 86 | private void printDirDiffResultMessage(int resultCode) { 87 | if (resultCode == Main.EXIT_CODE_OK) { 88 | System.out.println(SYSOUT_MSG_DIRECTORIES_IDENTICAL); 89 | } else { 90 | System.out.println(SYSOUT_MSG_DIRECTORIES_DIFFER); 91 | } 92 | } 93 | 94 | private void printFileDiffResultMessage(int resultCode) { 95 | if (resultCode == Main.EXIT_CODE_OK) { 96 | System.out.println(SYSOUT_MSG_FILES_IDENTICAL); 97 | } else { 98 | System.out.println(SYSOUT_MSG_FILES_DIFFER); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir1/ssubdir2/CiceroEn.txt: -------------------------------------------------------------------------------- 1 | But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. 2 | 3 | No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. 4 | 5 | Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. 6 | 7 | To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? 8 | 9 | But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? 10 | 11 | On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. 12 | 13 | These cases are perfectly simple and easy to distinguish. 14 | 15 | In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. 16 | 17 | But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir1/ssubdir3/HtmlBuilder.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.html; 2 | 3 | import static j2html.TagCreator.html; 4 | import static j2html.TagCreator.link; 5 | 6 | import java.nio.file.Paths; 7 | 8 | import org.apache.commons.io.FilenameUtils; 9 | 10 | import de.cronn.diff.util.DiffToHtmlParameters; 11 | import de.cronn.diff.util.FileHelper; 12 | import j2html.tags.EmptyTag; 13 | import j2html.tags.Tag; 14 | 15 | public abstract class HtmlBuilder { 16 | 17 | protected static final String EMPTY_LINE_HEIGHT = "16"; 18 | 19 | protected static final String CSS_CLASS_LINE_NUMBER = "line-number"; 20 | 21 | protected static final String CSS_ID_WRAPPER = "wrapper"; 22 | 23 | protected static final String CSS_CLASS_DELETE = "delete"; 24 | 25 | protected static final String CSS_CLASS_INSERT = "insert"; 26 | 27 | protected static final String CSS_CLASS_CONTEXT = "context"; 28 | 29 | protected static final String CSS_CLASS_INFO = "info"; 30 | 31 | protected static final String CSS_CLASS_ATTENTION = "attention"; 32 | 33 | public static boolean useSimpleFormatOnHtmls = false; 34 | 35 | protected String outputDirForRelativePaths = null; 36 | 37 | public abstract Tag createHead(); 38 | 39 | public abstract Tag createBody(); 40 | 41 | public HtmlBuilder(DiffToHtmlParameters params) { 42 | this.outputDirForRelativePaths = FilenameUtils.getFullPath(params.getOutputUri()); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | String renderedHtml = html().with( 48 | createHead(), 49 | createBody()) 50 | .render(); 51 | if (useSimpleFormatOnHtmls) { 52 | return newlineAllHtmlTags(renderedHtml); 53 | } else { 54 | return renderedHtml; 55 | } 56 | } 57 | 58 | protected String getRelativePath(String absolutePath) { 59 | if(absolutePath.isEmpty()) { 60 | return ""; 61 | } 62 | if (outputDirForRelativePaths != null) { 63 | return Paths.get(outputDirForRelativePaths).relativize(Paths.get(absolutePath)).toString(); 64 | } 65 | return absolutePath; 66 | } 67 | 68 | protected String newlineAllHtmlTags(String html) { 69 | return html.replaceAll("(<.*?>)", System.lineSeparator() + "$1") 70 | .replaceAll(System.lineSeparator() + "()", "$1"); 71 | } 72 | 73 | protected EmptyTag createStyleTag() { 74 | return link().withRel("stylesheet").withType("text/css").withHref(FileHelper.CSS_FILE); 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir2/DiffToHtmlParameters.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class DiffToHtmlParameters { 4 | public enum DiffType { 5 | FILES, DIRECTORIES; 6 | } 7 | 8 | private DiffType diffType; 9 | private String inputLeftPath; 10 | private String inputRightPath; 11 | private String outputPath; 12 | 13 | private String diffCommandLineAsString; 14 | private boolean ignoreUniqueFiles = false; 15 | private boolean ignoreWhiteSpaces = false; 16 | private boolean detectTextFileEncoding = false; 17 | 18 | public DiffToHtmlParameters withDiffType(DiffType diffType) { 19 | this.diffType = diffType; 20 | return this; 21 | } 22 | 23 | public DiffType getDiffType() { 24 | return diffType; 25 | } 26 | 27 | public DiffToHtmlParameters withInputLeftPath(String inputLeftPath) { 28 | this.inputLeftPath = inputLeftPath; 29 | return this; 30 | } 31 | 32 | public String getInputLeftPath() { 33 | return inputLeftPath; 34 | } 35 | 36 | public DiffToHtmlParameters withInputRightPath(String inputRightPath) { 37 | this.inputRightPath = inputRightPath; 38 | return this; 39 | } 40 | 41 | public String getInputRightPath() { 42 | return inputRightPath; 43 | } 44 | 45 | public DiffToHtmlParameters withOutputPath(String outputPath) { 46 | this.outputPath = outputPath; 47 | return this; 48 | } 49 | 50 | public String getOutputPath() { 51 | return outputPath; 52 | } 53 | 54 | public String getDiffCommandLineAsString() { 55 | return diffCommandLineAsString; 56 | } 57 | 58 | 59 | public void setDiffCommandLineAsString(String diffCommandLineAsString) { 60 | this.diffCommandLineAsString = diffCommandLineAsString; 61 | } 62 | 63 | public DiffToHtmlParameters withIgnoreUniqueFiles(boolean ignoreUniqueFiles) { 64 | this.ignoreUniqueFiles = ignoreUniqueFiles; 65 | return this; 66 | } 67 | 68 | public boolean isIgnoreUniqueFiles() { 69 | return ignoreUniqueFiles; 70 | } 71 | 72 | public DiffToHtmlParameters withDetectTextFileEncoding(boolean detectTextFileEncoding) { 73 | this.detectTextFileEncoding = detectTextFileEncoding; 74 | return this; 75 | } 76 | 77 | public boolean isIgnoreWhiteSpaces() { 78 | return ignoreWhiteSpaces; 79 | } 80 | 81 | public DiffToHtmlParameters withIgnoreWhiteSpaces(boolean ignoreWhiteSpaces) { 82 | this.ignoreWhiteSpaces = ignoreWhiteSpaces; 83 | return this; 84 | } 85 | 86 | public boolean isDetectTextFileEncoding() { 87 | return detectTextFileEncoding; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir2/ssubdir1/sssubdir1/UnifiedDiffValues.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public final class UnifiedDiffValues { 4 | 5 | public static final String BLANK = " "; 6 | 7 | public static final String UNIQUE_FILE_PREFIX = "Only in "; 8 | 9 | public static final String UNIQUE_LINE_SPLIT_STR = ": "; 10 | 11 | public static final String BINARY_FILES_DIFFER_PREFIX = "Binary files "; 12 | 13 | public static final String BINARY_FILES_DIFFER_OLD_VERSION_PREFIX = "Files "; 14 | 15 | public static final String NO_NEWLINE_AT_END_OF_FILE_WARNING = "\\ No newline at end of file"; 16 | 17 | public static final String DIFF_FILE_LEFT_PREFIX = "---"; 18 | 19 | public static final String DIFF_FILE_RIGHT_PREFIX = "+++"; 20 | 21 | public static final String INSERTION_PREFIX = "+"; 22 | 23 | public static final String DELETION_PREFIX = "-"; 24 | 25 | public static final String INFO_PREFIX_SUFFIX = "@@"; 26 | 27 | public static final String BINARY_FILES_SUFFIX = " differ"; 28 | 29 | public static final String BINARY_LINE_SPLIT_STR = " and "; 30 | 31 | public static final String IDENTICAL_FILES_PREFIX = "Files "; 32 | 33 | public static final String IDENTICAL_FILES_SUFFIX = " are identical"; 34 | 35 | public static final String IDENTICAL_LINE_SPLIT_STR = " and "; 36 | 37 | /*** 38 | * Gets the correct prefix/identifier for a message about differing binary files. 39 | * Older diff versions use the message 'Files ... differ' instead of 'Binary files ... differ' 40 | */ 41 | public static String getBinaryFilesDifferPrefix(String line) { 42 | if(isOlderVersionBinaryFilesDifferMessag(line)) { 43 | return BINARY_FILES_DIFFER_OLD_VERSION_PREFIX; 44 | } 45 | return BINARY_FILES_DIFFER_PREFIX; 46 | } 47 | 48 | private static boolean isOlderVersionBinaryFilesDifferMessag(String line) { 49 | return line.startsWith(BINARY_FILES_DIFFER_OLD_VERSION_PREFIX) && line.endsWith(BINARY_FILES_SUFFIX); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir2/ssubdir1/sssubdir2/binary1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_2/subdir2/ssubdir1/sssubdir2/binary1 -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir2/ssubdir1/sssubdir2/binary2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_2/subdir2/ssubdir1/sssubdir2/binary2 -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir2/ssubdir3/loremIpsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. 2 | 3 | Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. 4 | 5 | Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. 6 | 7 | Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. 8 | 9 | Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. 10 | 11 | Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. 12 | 13 | Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. 14 | 15 | Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. 16 | 17 | Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. 18 | 19 | Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. 20 | 21 | Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. 22 | 23 | Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. 24 | 25 | Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. 26 | 27 | Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. 28 | 29 | Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. 30 | 31 | Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir3/ssubdir1/azAz123_2.txt: -------------------------------------------------------------------------------- 1 | abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRSdsdUV Wddfg!!XYZ ! "§ $%& /() =? * '<> 2 | 3 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 4 | 5 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 6 | 7 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 8 | 9 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 10 | 11 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 12 | 13 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 14 | 15 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 16 | 17 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 18 | 19 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs abcsefd wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 20 | 21 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 22 | 23 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 24 | 25 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 26 | 27 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 28 | 29 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 30 | 31 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 32 | 33 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 34 | 35 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 36 | 37 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 38 | 39 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir3/ssubdir2/SimpleFileInfo.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class SimpleFileInfo { 4 | private String path = ""; 5 | private String lastModified = ""; 6 | 7 | public SimpleFileInfo() {} 8 | 9 | public SimpleFileInfo(String path) { 10 | this(path, ""); 11 | } 12 | 13 | public SimpleFileInfo(String path, String lastModified) { 14 | this.path = path; 15 | this.lastModified = lastModified; 16 | } 17 | 18 | public String getPath() { 19 | return path; 20 | } 21 | 22 | public String getLastModified() { 23 | return lastModified; 24 | } 25 | 26 | public void setPath(String path) { 27 | this.path = path; 28 | } 29 | 30 | public void setLastModified(String lastModified) { 31 | this.lastModified = lastModified; 32 | } 33 | } -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir3/ssubdir3/sssubdir1/binary3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_2/subdir3/ssubdir3/sssubdir1/binary3 -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir3/ssubdir3/sssubdir3/HelloWorldException.java: -------------------------------------------------------------------------------- 1 | public class HelloWorldException { 2 | public static void main (String[] args) throws Exception { 3 | System.out.println("Boa tarde, companheiros!"); 4 | throw new Exception("Generic Exception"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /data/test/input/dir1_2/subdir3/ssubdir3/sssubdir3/Main.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import static de.cronn.diff.util.cli.CliParser.OPT_DETECT_ENCODING; 4 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_SPACE_CHANGE; 5 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_UNIQUE_FILES; 6 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_WHITESPACES; 7 | import static de.cronn.diff.util.cli.CliParser.OPT_OS_DIFF; 8 | import static de.cronn.diff.util.cli.CliParser.OPT_UNIFIED_CONTEXT; 9 | 10 | import java.io.IOException; 11 | import java.nio.file.Files; 12 | import java.nio.file.Paths; 13 | 14 | import org.apache.commons.cli.ParseException; 15 | 16 | import de.cronn.diff.util.DiffToHtmlParameters; 17 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 18 | import de.cronn.diff.util.cli.CliParser; 19 | import de.cronn.diff.util.cli.DiffToHtmlCommandLine; 20 | 21 | public class Main { 22 | 23 | public static final int EXIT_CODE_ERROR = 1; 24 | 25 | public static final int EXIT_CODE_OK = 0; 26 | 27 | public static final int UNIFIED_CONTEXT_LINES = 3; 28 | 29 | public static final String PROGRAM_NAME = "cronn-diff-to-html"; 30 | 31 | public static boolean terminateVMOnExit = true; 32 | 33 | public static void main(String args[]) throws Exception { 34 | Main m = new Main(); 35 | int status = m.processDiffToHtml(args); 36 | exitProgram(status); 37 | } 38 | 39 | private static void exitProgram(int status) throws Exception { 40 | if (terminateVMOnExit) { 41 | System.exit(status); 42 | } 43 | } 44 | 45 | 46 | private int processDiffToHtml(String[] args) throws IOException, ParseException { 47 | int status = EXIT_CODE_OK; 48 | 49 | CronnDiffToHtml cronnDiffer = new CronnDiffToHtml(); 50 | DiffToHtmlCommandLine cli = new CliParser().parse(args); 51 | cronnDiffer.setUseOSDiffTool(cli.hasOption(OPT_OS_DIFF)); 52 | boolean inputsAreFiles = inputsAreTypeFile(args); 53 | boolean inputsAreDirs = inputsAreTypeDir(args); 54 | 55 | if (inputsAreFiles) { 56 | status = cronnDiffer.generateDiffToHtmlReport(createParams(cli, DiffType.FILES)); 57 | 58 | } else if (inputsAreDirs) { 59 | status = cronnDiffer.generateDiffToHtmlReport(createParams(cli, DiffType.DIRECTORIES)); 60 | } 61 | 62 | return cli.hasOption(CliParser.OPT_ONLY_REPORTS) ? EXIT_CODE_OK : status; 63 | } 64 | 65 | private DiffToHtmlParameters createParams(DiffToHtmlCommandLine cli, DiffType diffType) { 66 | DiffToHtmlParameters params = new DiffToHtmlParameters() 67 | .withDiffType(diffType) 68 | .withInputLeftPath(cli.getInputLeft()) 69 | .withInputRightPath(cli.getInputRight()) 70 | .withOutputPath(cli.getOutput()) 71 | .withIgnoreUniqueFiles(cli.hasOption(OPT_IGNORE_UNIQUE_FILES)) 72 | .withIgnoreWhiteSpaces(cli.hasOption(OPT_IGNORE_WHITESPACES)) 73 | .withIgnoreSpaceChange(cli.hasOption(OPT_IGNORE_SPACE_CHANGE)) 74 | .withDetectTextFileEncoding(cli.hasOption(OPT_DETECT_ENCODING)) 75 | .withUnifiedContext(Integer.parseInt(cli.getOptionValue(OPT_UNIFIED_CONTEXT, Integer.toString(UNIFIED_CONTEXT_LINES)))); 76 | return params; 77 | } 78 | 79 | private boolean inputsAreTypeFile(String[] args) { 80 | return Files.isRegularFile(Paths.get(args[0])) && Files.isRegularFile(Paths.get(args[1])); 81 | } 82 | 83 | private boolean inputsAreTypeDir(String[] args) { 84 | return Files.isDirectory(Paths.get(args[0])) && Files.isDirectory(Paths.get(args[1])); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /data/test/input/dir1_3/FarFarAway.txt: -------------------------------------------------------------------------------- 1 | Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 2 | 3 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. 4 | 5 | A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. 6 | 7 | Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. 8 | 9 | The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. 10 | 11 | When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. 12 | 13 | Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. 14 | 15 | The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. 16 | 17 | But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. 18 | 19 | And if she hasn’t been delayed, then they are still delaying her. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. 20 | 21 | Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. 22 | 23 | It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One -------------------------------------------------------------------------------- /data/test/input/dir1_3/emptyNotBinaryTest: -------------------------------------------------------------------------------- 1 | This file was empty, now there's text. If a file is empty, that doesn't mean it's binary, hence it shouldn't be compared as such! -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir1/ssubdir2/CiceroEn.txt: -------------------------------------------------------------------------------- 1 | But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-destroyer of human happiness. 2 | 3 | No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. 4 | 5 | Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pancake. 6 | 7 | To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? 8 | 9 | But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? 10 | 11 | On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. 12 | 13 | These cases are perfectly simple and easy to distinguish. 14 | 15 | In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. 16 | 17 | But in certain circumstances, and owing to the claims of duty or the obligations of business, it will frequently occur that -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir1/ssubdir3/HtmlBuilder.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.html; 2 | 3 | import static j2html.TagCreator.html; 4 | import static j2html.TagCreator.link; 5 | 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Paths; 8 | 9 | import org.apache.commons.io.FilenameUtils; 10 | 11 | import de.cronn.diff.util.DiffToHtmlParameters; 12 | import de.cronn.diff.util.FileHelper; 13 | import j2html.tags.EmptyTag; 14 | import j2html.tags.Tag; 15 | 16 | public abstract class HtmlBuilder { 17 | 18 | protected static final String EMPTY_LINE_HEIGHT = "16"; 19 | 20 | protected static final String CSS_CLASS_LINE_NUMBER = "line-number"; 21 | 22 | protected static final String CSS_ID_WRAPPER = "wrapper"; 23 | 24 | protected static final String CSS_CLASS_DELETE = "delete"; 25 | 26 | protected static final String CSS_CLASS_INSERT = "insert"; 27 | 28 | protected static final String CSS_CLASS_CONTEXT = "context"; 29 | 30 | protected static final String CSS_CLASS_INFO = "info"; 31 | 32 | protected static final String CSS_CLASS_ATTENTION = "attention"; 33 | 34 | public static boolean useSimpleFormatOnHtmls = false; 35 | 36 | protected String outputDirForRelativePaths = null; 37 | 38 | public abstract Tag createHead(); 39 | 40 | public abstract Tag createBody(); 41 | 42 | public static final String preferedEncoding = StandardCharsets.UTF_8.toString(); 43 | 44 | public HtmlBuilder(DiffToHtmlParameters params) { 45 | this.outputDirForRelativePaths = FilenameUtils.getFullPath(params.getOutputPath()); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | String renderedHtml = html().with( 51 | createHead(), 52 | createBody()) 53 | .render(); 54 | if (useSimpleFormatOnHtmls) { 55 | return newlineAllHtmlTags(renderedHtml); 56 | } else { 57 | return renderedHtml; 58 | } 59 | } 60 | 61 | protected String getRelativePath(String absolutePath) { 62 | if(absolutePath.isEmpty()) { 63 | return ""; 64 | } 65 | if (outputDirForRelativePaths != null) { 66 | return Paths.get(outputDirForRelativePaths).relativize(Paths.get(absolutePath)).toString(); 67 | } 68 | return absolutePath; 69 | } 70 | 71 | protected String newlineAllHtmlTags(String html) { 72 | return html.replaceAll("(<.*?>)", System.lineSeparator() + "$1") 73 | .replaceAll(System.lineSeparator() + "()", "$1"); 74 | } 75 | 76 | protected EmptyTag createStyleTag() { 77 | return link().withRel("stylesheet").withType("text/css").withHref(FileHelper.CSS_FILE); 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir1/ssuubbddiirr11/Cicero.txt: -------------------------------------------------------------------------------- 1 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 2 | 3 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. 4 | 5 | Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. 6 | 7 | Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? 8 | 9 | Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? 10 | 11 | At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. 12 | 13 | Et harum quidem rerum facilis est et expedita distinctio. 14 | 15 | Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. 16 | 17 | Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. 18 | 19 | Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. 20 | 21 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. 22 | 23 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir1/ssuubbddiirr11/CronnDiffToHtml.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | 7 | import org.apache.commons.io.FilenameUtils; 8 | 9 | import de.cronn.diff.impl.JavaDiffToHtml; 10 | import de.cronn.diff.impl.OSDiffToHtml; 11 | import de.cronn.diff.util.DiffToHtmlParameters; 12 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 13 | import de.cronn.diff.util.FileHelper; 14 | 15 | public class CronnDiffToHtml { 16 | 17 | private static final String NEWLINE = System.lineSeparator(); 18 | 19 | private static final String SYSOUT_MSG_DIRECTORIES_IDENTICAL = NEWLINE + "Directories are identical!"; 20 | 21 | private static final String SYSOUT_MSG_FILES_IDENTICAL = NEWLINE + "Files are identical!"; 22 | 23 | private static final String SYSOUT_MSG_DIRECTORIES_DIFFER = NEWLINE + "Directories differ!"; 24 | 25 | private static final String SYSOUT_MSG_FILES_DIFFER = NEWLINE + "Files differ!"; 26 | 27 | private static final String SYSOUT_MSG_OUTPUT_WRITTEN_TO = NEWLINE + "Output written to: "; 28 | 29 | private boolean isUseOSDiffTool = true; 30 | 31 | private DiffToHtmlParameters params = null; 32 | 33 | public boolean isUseOSDiffTool() { 34 | return isUseOSDiffTool; 35 | } 36 | 37 | public void setUseOSDiffTool(boolean isUseOSDiffTool) { 38 | this.isUseOSDiffTool = isUseOSDiffTool; 39 | } 40 | 41 | public int generateDiffToHtmlReport(DiffToHtmlParameters params) throws IOException { 42 | this.params = params; 43 | String outputDirPath = FilenameUtils.getFullPath(params.getOutputPath()); 44 | FileHelper.copyCssFileToDir(outputDirPath); 45 | 46 | if (isUseOSDiffTool) { 47 | return generateOSDiffToHtml(params); 48 | 49 | } else { 50 | return generateJavaDiffToHtml(params); 51 | } 52 | } 53 | 54 | private int generateOSDiffToHtml(DiffToHtmlParameters params) throws IOException { 55 | OSDiffToHtml osDiffToHtml = new OSDiffToHtml(); 56 | String html = osDiffToHtml.generateHtml(params); 57 | writeToDisk(html); 58 | int resultCode = osDiffToHtml.getResultCode(); 59 | printResultMessage(resultCode); 60 | return resultCode; 61 | } 62 | 63 | private int generateJavaDiffToHtml(DiffToHtmlParameters params) throws IOException { 64 | JavaDiffToHtml javaDiffToHtml = new JavaDiffToHtml(); 65 | String html = javaDiffToHtml.generateDiff2Html(params); 66 | writeToDisk(html); 67 | int resultCode = javaDiffToHtml.getResultCode(); 68 | printResultMessage(resultCode); 69 | return resultCode; 70 | } 71 | 72 | private void writeToDisk(String html) throws IOException { 73 | String path = params.getOutputPath(); 74 | Files.write(Paths.get(path), html.getBytes()); 75 | System.out.println(SYSOUT_MSG_OUTPUT_WRITTEN_TO + params.getOutputPath()); 76 | } 77 | 78 | private void printResultMessage(int resultCode) { 79 | if (params.getDiffType() == DiffType.DIRECTORIES) { 80 | printDirDiffResultMessage(resultCode); 81 | } else { 82 | printFileDiffResultMessage(resultCode); 83 | } 84 | } 85 | 86 | private void printDirDiffResultMessage(int resultCode) { 87 | if (resultCode == Main.EXIT_CODE_OK) { 88 | System.out.println(SYSOUT_MSG_DIRECTORIES_IDENTICAL); 89 | } else { 90 | System.out.println(SYSOUT_MSG_DIRECTORIES_DIFFER); 91 | } 92 | } 93 | 94 | private void printFileDiffResultMessage(int resultCode) { 95 | if (resultCode == Main.EXIT_CODE_OK) { 96 | System.out.println(SYSOUT_MSG_FILES_IDENTICAL); 97 | } else { 98 | System.out.println(SYSOUT_MSG_FILES_DIFFER); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir2/DiffToHtmlParameters.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class DiffToHtmlParameters { 4 | public enum DiffType { 5 | FILES, DIRECTORIES; 6 | } 7 | 8 | private DiffType diffType; 9 | private String inputLeftPath; 10 | private String inputRightPath; 11 | private String outputPath; 12 | private String diffCommandLineAsString; 13 | private boolean ignoreUniqueFiles = false; 14 | private boolean ignoreWhiteSpaces = false; 15 | private boolean ignoreSpaceChange = false; 16 | private boolean detectTextFileEncoding = false; 17 | private int unifiedContext = 3; 18 | 19 | public DiffToHtmlParameters() { 20 | } 21 | 22 | public DiffToHtmlParameters(DiffToHtmlParameters other) { 23 | this.diffType = other.getDiffType(); 24 | this.inputLeftPath = other.getInputLeftPath(); 25 | this.inputRightPath = other.getInputRightPath(); 26 | this.outputPath = other.getOutputPath(); 27 | this.diffCommandLineAsString = other.getDiffCommandLineAsString(); 28 | this.ignoreUniqueFiles = other.isIgnoreUniqueFiles(); 29 | this.ignoreWhiteSpaces = other.isIgnoreWhiteSpaces(); 30 | this.ignoreSpaceChange = other.isIgnoreSpaceChange(); 31 | this.detectTextFileEncoding = other.isDetectTextFileEncoding(); 32 | this.unifiedContext = other.unifiedContext; 33 | } 34 | 35 | public DiffToHtmlParameters withDiffType(DiffType diffType) { 36 | this.diffType = diffType; 37 | return this; 38 | } 39 | 40 | public DiffType getDiffType() { 41 | return diffType; 42 | } 43 | 44 | public DiffToHtmlParameters withInputLeftPath(String inputLeftPath) { 45 | this.inputLeftPath = inputLeftPath; 46 | return this; 47 | } 48 | 49 | public String getInputLeftPath() { 50 | return inputLeftPath; 51 | } 52 | 53 | public DiffToHtmlParameters withInputRightPath(String inputRightPath) { 54 | this.inputRightPath = inputRightPath; 55 | return this; 56 | } 57 | 58 | public String getInputRightPath() { 59 | return inputRightPath; 60 | } 61 | 62 | public DiffToHtmlParameters withOutputPath(String outputPath) { 63 | this.outputPath = outputPath; 64 | return this; 65 | } 66 | 67 | public String getOutputPath() { 68 | return outputPath; 69 | } 70 | 71 | public String getDiffCommandLineAsString() { 72 | return diffCommandLineAsString; 73 | } 74 | 75 | 76 | public void setDiffCommandLineAsString(String diffCommandLineAsString) { 77 | this.diffCommandLineAsString = diffCommandLineAsString; 78 | } 79 | 80 | public DiffToHtmlParameters withIgnoreUniqueFiles(boolean ignoreUniqueFiles) { 81 | this.ignoreUniqueFiles = ignoreUniqueFiles; 82 | return this; 83 | } 84 | 85 | public boolean isIgnoreUniqueFiles() { 86 | return ignoreUniqueFiles; 87 | } 88 | 89 | public DiffToHtmlParameters withDetectTextFileEncoding(boolean detectTextFileEncoding) { 90 | this.detectTextFileEncoding = detectTextFileEncoding; 91 | return this; 92 | } 93 | 94 | public boolean isDetectTextFileEncoding() { 95 | return detectTextFileEncoding; 96 | } 97 | 98 | public DiffToHtmlParameters withIgnoreWhiteSpaces(boolean ignoreWhiteSpaces) { 99 | this.ignoreWhiteSpaces = ignoreWhiteSpaces; 100 | return this; 101 | } 102 | 103 | public boolean isIgnoreWhiteSpaces() { 104 | return ignoreWhiteSpaces; 105 | } 106 | 107 | public DiffToHtmlParameters withIgnoreSpaceChange(boolean ignoreSpaceChange) { 108 | this.ignoreSpaceChange = ignoreSpaceChange; 109 | return this; 110 | } 111 | 112 | public boolean isIgnoreSpaceChange() { 113 | return ignoreSpaceChange; 114 | } 115 | 116 | public DiffToHtmlParameters withUnifiedContext(int unifiedContext) { 117 | this.unifiedContext = unifiedContext; 118 | return this; 119 | } 120 | 121 | public int getUnifiedContext() { 122 | return unifiedContext; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir2/ssubdir1/sssubdir1/UnifiedDiffValues.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public final class UnifiedDiffValues { 4 | 5 | public static final String BLANK = " "; 6 | 7 | public static final String UNIQUE_FILE_PREFIX = "Only in "; 8 | 9 | public static final String UNIQUE_LINE_SPLIT_STR = ": "; 10 | 11 | public static final String BINARY_FILES_DIFFER_PREFIX = "Binary files "; 12 | 13 | public static final String BINARY_FILES_DIFFER_OLD_VERSION_PREFIX = "Files "; 14 | 15 | public static final String NO_NEWLINE_AT_END_OF_FILE_WARNING = "\\ No newline at end of file"; 16 | 17 | public static final String DIFF_FILE_LEFT_PREFIX = "---"; 18 | 19 | public static final String DIFF_FILE_RIGHT_PREFIX = "+++"; 20 | 21 | public static final String INSERTION_PREFIX = "+"; 22 | 23 | public static final String DELETION_PREFIX = "-"; 24 | 25 | public static final String INFO_PREFIX_SUFFIX = "@@"; 26 | 27 | public static final String BINARY_FILES_SUFFIX = " differ"; 28 | 29 | public static final String BINARY_LINE_SPLIT_STR = " and "; 30 | 31 | public static final String IDENTICAL_FILES_PREFIX = "Files "; 32 | 33 | public static final String IDENTICAL_FILES_SUFFIX = " are identical"; 34 | 35 | public static final String IDENTICAL_LINE_SPLIT_STR = " and "; 36 | 37 | /*** 38 | * Gets the correct prefix/identifier for a message about differing binary files. 39 | * Older diff versions use the message 'Files ... differ' instead of 'Binary files ... differ' 40 | */ 41 | public static String getBinaryFilesDifferPrefix(String line) { 42 | if(isOlderVersionBinaryFilesDifferMessag(line)) { 43 | return BINARY_FILES_DIFFER_OLD_VERSION_PREFIX; 44 | } 45 | return BINARY_FILES_DIFFER_PREFIX; 46 | } 47 | 48 | private static boolean isOlderVersionBinaryFilesDifferMessag(String line) { 49 | return line.startsWith(BINARY_FILES_DIFFER_OLD_VERSION_PREFIX) && line.endsWith(BINARY_FILES_SUFFIX); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir2/ssubdir1/sssubdir2/binary1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_3/subdir2/ssubdir1/sssubdir2/binary1 -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir2/ssubdir1/sssubdir2/binary2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/dir1_3/subdir2/ssubdir1/sssubdir2/binary2 -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir2/ssubdir3/loremIpsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. 2 | 3 | Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. 4 | 5 | Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. 6 | 7 | Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. 8 | 9 | Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. 10 | 11 | Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. 12 | 13 | Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. 14 | 15 | Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. 16 | 17 | Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. 18 | 19 | Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. 20 | 21 | Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. 22 | 23 | Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. 24 | 25 | Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. 26 | 27 | Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. 28 | 29 | Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. 30 | 31 | Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir3/ssubdir1/azAz123_2.txt: -------------------------------------------------------------------------------- 1 | abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 2 | 3 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 4 | 5 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 6 | 7 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 8 | 9 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 10 | 11 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 12 | 13 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 14 | 15 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 16 | 17 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 18 | 19 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 20 | 21 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 22 | 23 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 24 | 25 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 26 | 27 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 28 | 29 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 30 | 31 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 32 | 33 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 34 | 35 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 36 | 37 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> 38 | 39 | |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! "§ $%& /() =? * '<> |; ²³~ @`´ ©«» ¤¼× {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ ! -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir3/ssubdir2/SimpleFileInfo.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class SimpleFileInfo { 4 | private String path = ""; 5 | private String lastModified = ""; 6 | 7 | public SimpleFileInfo() {} 8 | 9 | public SimpleFileInfo(String path) { 10 | this(path, ""); 11 | } 12 | 13 | public SimpleFileInfo(String path, String lastModified) { 14 | this.path = path; 15 | this.lastModified = lastModified; 16 | } 17 | 18 | public String getPath() { 19 | return path; 20 | } 21 | 22 | public String getLastModified() { 23 | return lastModified; 24 | } 25 | 26 | public void setPath(String path) { 27 | this.path = path; 28 | } 29 | 30 | public void setLastModified(String lastModified) { 31 | this.lastModified = lastModified; 32 | } 33 | } -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir3/ssubdir2/someUniqueFile1: -------------------------------------------------------------------------------- 1 | this is a unique file. -------------------------------------------------------------------------------- /data/test/input/dir1_3/subdir3/ssubdir3/sssubdir3/HelloWorldException.java: -------------------------------------------------------------------------------- 1 | public class HelloWorldException { 2 | public static void main (String[] args) throws Exception { 3 | System.out.println("Bienvenitos!"); 4 | throw new Exception("Generic Exception"); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /data/test/input/dirWithSpaces1/dir/AnotherTextFile: -------------------------------------------------------------------------------- 1 | here for you some text -------------------------------------------------------------------------------- /data/test/input/dirWithSpaces1/textFile: -------------------------------------------------------------------------------- 1 | This is a text . 2 | A text t h i s is. -------------------------------------------------------------------------------- /data/test/input/dirWithSpaces2/dir/AnotherTextFile: -------------------------------------------------------------------------------- 1 | here for you some text -------------------------------------------------------------------------------- /data/test/input/dirWithSpaces2/textFile: -------------------------------------------------------------------------------- 1 | This is a text . 2 | A text t h i s is. -------------------------------------------------------------------------------- /data/test/input/dirWithoutSpaces/dir/AnotherTextFile: -------------------------------------------------------------------------------- 1 | hereforyousometext -------------------------------------------------------------------------------- /data/test/input/dirWithoutSpaces/textFile: -------------------------------------------------------------------------------- 1 | Thisisatext. 2 | Atextthisis. -------------------------------------------------------------------------------- /data/test/input/emptyFile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/emptyFile -------------------------------------------------------------------------------- /data/test/input/iso88591textfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/iso88591textfile -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile1 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile10 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile11 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile12 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile13 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile14 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile15 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile2 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile3 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile4 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile5 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile6 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile7 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile8 -------------------------------------------------------------------------------- /data/test/input/mediumdir/testfile9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/mediumdir/testfile9 -------------------------------------------------------------------------------- /data/test/input/not_so_empty_output/here_lies_a_file: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. -------------------------------------------------------------------------------- /data/test/input/smalldir/testfile1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/smalldir/testfile1 -------------------------------------------------------------------------------- /data/test/input/smalldir/testfile2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/smalldir/testfile2 -------------------------------------------------------------------------------- /data/test/input/smalldir/testfile3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/smalldir/testfile3 -------------------------------------------------------------------------------- /data/test/input/smalldir/testfile4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/smalldir/testfile4 -------------------------------------------------------------------------------- /data/test/input/smalldir/testfile5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/smalldir/testfile5 -------------------------------------------------------------------------------- /data/test/input/smallfile: -------------------------------------------------------------------------------- 1 | smallfile 2 | -------------------------------------------------------------------------------- /data/test/input/text1.unix.diff: -------------------------------------------------------------------------------- 1 | --- data/test/input/text1_1.example 2018-03-02 09:04:36.205132661 +0100 2 | +++ data/test/input/text1_2.example 2018-02-26 16:05:51.333346221 +0100 3 | @@ -8,7 +8,7 @@ 4 | 5 | Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental in fact, it va esser Occidental. 6 | 7 | -A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es. Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. 8 | +A un Anmericano it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es. Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. 9 | 10 | Por scientie, musica, sport etc, litot Europa usa li sam vocabular. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. 11 | 12 | @@ -29,9 +29,9 @@ 13 | It va esser tam simplic quam Occidental in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es. 14 | 15 | Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc, litot Europa usa li sam vocabular. 16 | - 17 | Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilite de un nov lingua franca: On refusa continuar payar custosi traductores. 18 | 19 | + 20 | At solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles. Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. 21 | 22 | Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental in fact, it va esser Occidental. 23 | @@ -54,7 +54,7 @@ 24 | 25 | It va esser tam simplic quam Occidental in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es. Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. 26 | 27 | -Por scientie, musica, sport etc, litot Europa usa li sam vocabular. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilite de un nov lingua franca: On refusa continuar payar custosi traductores. 28 | +Por scientie, musica, sport etc, litot Europa usa soy sam vocabular. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun Bratwurst. Omnicos directe al desirabilite de un nov lingua franca: On refusa continuar payar custosi traductores 29 | 30 | At solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles. Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. 31 | 32 | -------------------------------------------------------------------------------- /data/test/input/textWithSpaces1: -------------------------------------------------------------------------------- 1 | This is a text . 2 | A text t h i s is. -------------------------------------------------------------------------------- /data/test/input/textWithSpaces2: -------------------------------------------------------------------------------- 1 | This is a text . 2 | A text t h i s is. -------------------------------------------------------------------------------- /data/test/input/textWithoutSpaces: -------------------------------------------------------------------------------- 1 | Thisisatext. 2 | Atextthisis. -------------------------------------------------------------------------------- /data/test/input/utf16betextfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/utf16betextfile -------------------------------------------------------------------------------- /data/test/input/utf16letextfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/data/test/input/utf16letextfile -------------------------------------------------------------------------------- /data/test/validation/testFileNumberToDiffNotTooDifferent_tooSmallLeftDir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | 106 |
107 | 108 |
---- 113 |
Empty directory or too many unique files. Abort!
-------------------------------------------------------------------------------- /data/test/validation/testFileNumberToDiffNotTooDifferent_tooSmallLeftDir.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | Empty directory or too many unique files. Abort! 3 | 4 | Output written to: file://[current/working/directory/]data/test/output/testFileNumberToDiffNotTooDifferent_tooSmallLeftDir.html 5 | 6 | Directories differ! 7 | -------------------------------------------------------------------------------- /data/test/validation/testFileNumberToDiffNotTooDifferent_tooSmallRightDir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | 106 |
107 | 108 |
---- 113 |
Empty directory or too many unique files. Abort!
-------------------------------------------------------------------------------- /data/test/validation/testFileNumberToDiffNotTooDifferent_tooSmallRightDir.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | Empty directory or too many unique files. Abort! 3 | 4 | Output written to: file://[current/working/directory/]data/test/output/testFileNumberToDiffNotTooDifferent_tooSmallRightDir.html 5 | 6 | Directories differ! 7 | -------------------------------------------------------------------------------- /data/test/validation/testFileNumberToDiffNotTooDifferent_true.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testFileNumberToDiffNotTooDifferent_true.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testGenerateDiffToHtmlReportJavaBasedBinary1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff binaryFile1_1 binaryFile1_2 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/binaryFile1_1 [DATE]T[TIME]Z 106 |
107 | 108 | ../input/binaryFile1_2 [DATE]T[TIME]Z
---- 113 |
Binary files data/test/input/binaryFile1_1 and data/test/input/binaryFile1_2 differ
-------------------------------------------------------------------------------- /data/test/validation/testGenerateDiffToHtmlReportJavaBasedBinary2Identical.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff binaryFile1_2 binaryFile1_2 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/binaryFile1_2 [DATE]T[TIME]Z 106 |
107 | 108 | ../input/binaryFile1_2 [DATE]T[TIME]Z
---- 113 |
Files data/test/input/binaryFile1_2 and data/test/input/binaryFile1_2 are identical
-------------------------------------------------------------------------------- /data/test/validation/testGenerateDiffToHtmlReportJavaBasedCodeIdentical.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff code1_1.java.example code1_1.java.example 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/code1_1.java.example [DATE]T[TIME]Z 106 |
107 | 108 | ../input/code1_1.java.example [DATE]T[TIME]Z
---- 113 |
Files data/test/input/code1_1.java.example and data/test/input/code1_1.java.example are identical
-------------------------------------------------------------------------------- /data/test/validation/testHelp.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | usage: cronn-diff-to-html [] [-h] 3 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 4 | -h,--help print this help 5 | -w,--ignore-white-spaces ignore all white spaces 6 | -b,--ignore-space-change ignore changes in the amount of white space 7 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 8 | LF while comparing files 9 | -or,--only-reports always exits with zero 10 | -iu,--ignore-unique ignore unique files 11 | -de,--detect-encoding tries to determine encoding type 12 | -u,--unified output (default 3) lines of unified 13 | context 14 | -fs,--max-size-diff no textual diff if file size differs too 15 | much 16 | -id,--line-diff generate line-wise diffs (default: inline / 17 | character-wise) 18 | -------------------------------------------------------------------------------- /data/test/validation/testMainInvalidArgs.sysouterr: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Too many arguments: one, two, three, four 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testMainInvalidOptionalArg.sysouterr: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Unrecognized option: --invalidOptionalArg 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtml.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreSpaceChange_False.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtmlIgnoreSpaceChange_False.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreSpaceChange_True.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diff directories data/test/input/dirWithSpaces1 and data/test/input/dirWithSpaces2 5 | 99 | 100 |

Diff directories data/test/input/dirWithSpaces1 and data/test/input/dirWithSpaces2

101 |

Directories are identical!

-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreSpaceChange_True.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtmlIgnoreSpaceChange_True.html 4 | 5 | Directories are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreUniqueFiles.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtmlIgnoreUniqueFiles.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_False.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_False.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_True.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diff directories data/test/input/dirWithSpaces1 and data/test/input/dirWithoutSpaces 5 | 99 | 100 |

Diff directories data/test/input/dirWithSpaces1 and data/test/input/dirWithoutSpaces

101 |

Directories are identical!

-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_True.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtmlIgnoreWhiteSpaces_True.html 4 | 5 | Directories are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_emptyLeftDir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | 106 |
107 | 108 |
---- 113 |
Empty directory or too many unique files. Abort!
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_emptyLeftDir.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | Empty directory or too many unique files. Abort! 3 | 4 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtml_emptyLeftDir.html 5 | 6 | Directories differ! 7 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_emptyRightDir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | 106 |
107 | 108 |
---- 113 |
Empty directory or too many unique files. Abort!
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_emptyRightDir.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | Empty directory or too many unique files. Abort! 3 | 4 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtml_emptyRightDir.html 5 | 6 | Directories differ! 7 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_noOutputProvided.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://data/test/output/diff_dir1_1_dir1_1.html 4 | 5 | Directories are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_outputPathOnlyFilename.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/someOutputFilename.html 4 | 5 | Directories are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffDirsToHtml_pathWithMultipleSlashes.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffDirsToHtml_pathWithMultipleSlashes.html 4 | 5 | Directories differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtml.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIdentical.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff code3_1.java.example code3_1.java.example 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/code3_1.java.example [DATE]T[TIME]Z 106 |
107 | 108 | ../input/code3_1.java.example [DATE]T[TIME]Z
---- 113 |
Files data/test/input/code3_1.java.example and data/test/input/code3_1.java.example are identical
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIdentical.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlIdentical.html 4 | 5 | Files are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_False.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff textWithSpaces1 textWithSpaces2 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 118 | 119 | 120 | 121 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 133 | 134 | 135 | 136 |
104 | 105 | ../input/textWithSpaces1 [DATE]T[TIME]Z 106 |
107 | 108 | ../input/textWithSpaces2 [DATE]T[TIME]Z
---- 117 |
@@ -1,2 +1,2 @@
11 122 |
-This is a text .
21 127 |
-A text   t h i s is.
11 132 |
+This is   a   text .
12 137 |
+A text t h i s is.
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_False.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_False.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_True.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff textWithSpaces1 textWithSpaces2 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/textWithSpaces1 [DATE]T[TIME]Z 106 |
107 | 108 | ../input/textWithSpaces2 [DATE]T[TIME]Z
---- 113 |
Files data/test/input/textWithSpaces1 and data/test/input/textWithSpaces2 are identical
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_True.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlIgnoreSpaceChange_True.html 4 | 5 | Files are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_False.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_False.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_True.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff textWithSpaces1 textWithoutSpaces 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/textWithSpaces1 [DATE]T[TIME]Z 106 |
107 | 108 | ../input/textWithoutSpaces [DATE]T[TIME]Z
---- 113 |
Files data/test/input/textWithSpaces1 and data/test/input/textWithoutSpaces are identical
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_True.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlIgnoreWhiteSpaces_True.html 4 | 5 | Files are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlOnlyReports.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlOnlyReports.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtmlUnifiedContext16.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtmlUnifiedContext16.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_linewiseDiff.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtml_linewiseDiff.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_false.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff smallfile bigfile 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 118 | 119 | 120 | 121 | 123 | 124 | 125 | 126 |
104 | 105 | ../input/smallfile [DATE]T[TIME]Z 106 |
107 | 108 | ../input/bigfile [DATE]T[TIME]Z
---- 117 |
@@ -1,1 +1,1 @@
11 122 |
-smallfile
11 127 |
+This is a test file not a smallfile
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_false.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_false.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_true.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff smallfile bigfile 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | ../input/smallfile [DATE]T[TIME]Z 106 |
107 | 108 | ../input/bigfile [DATE]T[TIME]Z
---- 113 |
Files differ but filesize difference too big to parse.
-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_true.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtml_maxFileSizeDifferenceTooBig_true.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffFilesToHtml_pathWithMultipleSlashes.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffFilesToHtml_pathWithMultipleSlashes.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffIdenticalDirs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diff directories data/test/input/dir1_1 and data/test/input/dir1_1 5 | 99 | 100 |

Diff directories data/test/input/dir1_1 and data/test/input/dir1_1

101 |

Directories are identical!

-------------------------------------------------------------------------------- /data/test/validation/testMainJAVADiffIdenticalDirs.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJAVADiffIdenticalDirs.html 4 | 5 | Directories are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJavaDiffDirsToHtmlIgnoreLineEndings_False.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff textWithLineEndingsLF textWithLineEndingsCRLF 5 | 99 | 100 |
101 | 102 | 103 |
104 | 105 | textWithLineEndingsLF [DATE]T[TIME]Z 106 |
107 | 108 | textWithLineEndingsCRLF [DATE]T[TIME]Z
-------------------------------------------------------------------------------- /data/test/validation/testMainJavaDiffDirsToHtmlIgnoreLineEndings_False.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJavaDiffDirsToHtmlIgnoreLineEndings_False.html 4 | 5 | Files differ! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainJavaDiffDirsToHtmlIgnoreLineEndings_True.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diff textWithLineEndingsLF textWithLineEndingsCRLF 5 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 | 112 |
104 | 105 | textWithLineEndingsLF [DATE]T[TIME]Z 106 |
107 | 108 | textWithLineEndingsCRLF [DATE]T[TIME]Z
---- 113 |
Files data/test/output/textWithLineEndingsLF and data/test/output/textWithLineEndingsCRLF are identical
-------------------------------------------------------------------------------- /data/test/validation/testMainJavaDiffDirsToHtmlIgnoreLineEndings_True.sysouterr: -------------------------------------------------------------------------------- 1 | 2 | 3 | Output written to: file://[current/working/directory/]data/test/output/testMainJavaDiffDirsToHtmlIgnoreLineEndings_True.html 4 | 5 | Files are identical! 6 | -------------------------------------------------------------------------------- /data/test/validation/testMainWrongNumberOfArgs1.sysouterr: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Input arguments are missing 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testMainWrongNumberOfArgs2.sysouterr: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Input arguments are missing 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testMainWrongTypeOfInputs.sysouterr: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Ambiguous option: 'Inputs must be either both regular files or both directories' (could be: 'data/test/input/dir1_1', 'data/test/input/code3_1.java.example') 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_Exception_help: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Input arguments are missing 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_Exception_inputsDifferentType: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Ambiguous option: 'Inputs must be either both regular files or both directories' (could be: 'data/test/input/dir1_1', 'data/test/input/code1_2.java.example') 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_Exception_inputsMissing: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Input arguments are missing 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_Exception_inputsTooMany: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Too many arguments: data/test/input/dir1_1, data/test/input/code1_2.java.example, data/test/input/dir1_1, fileOut 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_Exception_unkownOption: -------------------------------------------------------------------------------- 1 | Parsing failed. Reason: Unrecognized option: -nothingAtAll 2 | 3 | usage: cronn-diff-to-html [] [-h] 4 | [-w] [-b] [-crlf] [-or] [-iu] [-de] [-u ] [-fs ] [-id] 5 | -h,--help print this help 6 | -w,--ignore-white-spaces ignore all white spaces 7 | -b,--ignore-space-change ignore changes in the amount of white space 8 | -crlf,--ignore-line-endings ignore line endings, i.e. normalize CRLF / 9 | LF while comparing files 10 | -or,--only-reports always exits with zero 11 | -iu,--ignore-unique ignore unique files 12 | -de,--detect-encoding tries to determine encoding type 13 | -u,--unified output (default 3) lines of unified 14 | context 15 | -fs,--max-size-diff no textual diff if file size differs too 16 | much 17 | -id,--line-diff generate line-wise diffs (default: inline / 18 | character-wise) 19 | -------------------------------------------------------------------------------- /data/test/validation/testParse_OK_allCliArgs: -------------------------------------------------------------------------------- 1 | data/test/input/dir1_1 2 | data/test/input/dir1_2 3 | [current/working/directory/]fileOut 4 | 5 | w 6 | ignore-white-spaces 7 | String 8 | ignore all white spaces 9 | 10 | or 11 | only-reports 12 | String 13 | always exits with zero 14 | 15 | iu 16 | ignore-unique 17 | String 18 | ignore unique files 19 | 20 | de 21 | detect-encoding 22 | String 23 | tries to determine encoding type 24 | 25 | -------------------------------------------------------------------------------- /data/test/validation/testParse_OK_inputsAreDirs: -------------------------------------------------------------------------------- 1 | data/test/input/dir1_1 2 | data/test/input/dir1_2 3 | [current/working/directory/]fileOut 4 | 5 | -------------------------------------------------------------------------------- /data/test/validation/testParse_OK_inputsAreDirs_noOutputSupplied: -------------------------------------------------------------------------------- 1 | data/test/input/dir1_1 2 | data/test/input/dir1_2 3 | [current/working/directory/]diff_dir1_1_dir1_2.html 4 | 5 | -------------------------------------------------------------------------------- /data/test/validation/testParse_OK_inputsAreFiles: -------------------------------------------------------------------------------- 1 | data/test/input/code1_1.java.example 2 | data/test/input/code1_2.java.example 3 | [current/working/directory/]fileOut 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip 6 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /libs/java-diff-utils-4.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cronn/diff-to-html/3b230021693bd321ce0b067ae260f9592af9c821/libs/java-diff-utils-4.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ./gradlew bintrayUpload 4 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/CronnDiffToHtml.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Paths; 6 | 7 | import de.cronn.diff.impl.DiffToHtmlResult; 8 | import de.cronn.diff.impl.JavaDiffToHtmlGenerator; 9 | import de.cronn.diff.util.DiffToHtmlParameters; 10 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 11 | 12 | public class CronnDiffToHtml { 13 | 14 | private static final String NEWLINE = System.lineSeparator(); 15 | 16 | private static final String SYSOUT_MSG_DIRECTORIES_IDENTICAL = NEWLINE + "Directories are identical!"; 17 | 18 | private static final String SYSOUT_MSG_FILES_IDENTICAL = NEWLINE + "Files are identical!"; 19 | 20 | private static final String SYSOUT_MSG_DIRECTORIES_DIFFER = NEWLINE + "Directories differ!"; 21 | 22 | private static final String SYSOUT_MSG_FILES_DIFFER = NEWLINE + "Files differ!"; 23 | 24 | private static final String SYSOUT_MSG_OUTPUT_WRITTEN_TO = NEWLINE + "Output written to: file://"; 25 | 26 | private DiffToHtmlParameters params = null; 27 | 28 | public int generateDiffToHtmlReport(DiffToHtmlParameters params) throws IOException { 29 | this.params = params; 30 | int status = generateDiffToHtml(); 31 | return params.isOnlyReports() ? Main.EXIT_CODE_OK : status; 32 | } 33 | 34 | private int generateDiffToHtml() throws IOException { 35 | DiffToHtmlResult res = new JavaDiffToHtmlGenerator().generateHtml(params); 36 | writeToDisk(res.getHtml()); 37 | printResultMessage(res.getResultCode()); 38 | return res.getResultCode(); 39 | } 40 | 41 | private void writeToDisk(String html) throws IOException { 42 | String path = params.getOutputPath(); 43 | Files.write(Paths.get(path), html.getBytes()); 44 | System.out.println(SYSOUT_MSG_OUTPUT_WRITTEN_TO + path); 45 | } 46 | 47 | private void printResultMessage(int resultCode) { 48 | if (params.getDiffType() == DiffType.DIRECTORIES) { 49 | printDirDiffResultMessage(resultCode); 50 | } else { 51 | printFileDiffResultMessage(resultCode); 52 | } 53 | } 54 | 55 | private void printDirDiffResultMessage(int resultCode) { 56 | System.out.println(resultCode == Main.EXIT_CODE_OK ? 57 | SYSOUT_MSG_DIRECTORIES_IDENTICAL : SYSOUT_MSG_DIRECTORIES_DIFFER); 58 | } 59 | 60 | private void printFileDiffResultMessage(int resultCode) { 61 | System.out.println(resultCode == Main.EXIT_CODE_OK ? 62 | SYSOUT_MSG_FILES_IDENTICAL : SYSOUT_MSG_FILES_DIFFER); 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/Main.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import static de.cronn.diff.util.cli.CliParser.OPT_DETECT_ENCODING; 4 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_LINE_ENDINGS; 5 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_SPACE_CHANGE; 6 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_UNIQUE_FILES; 7 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_WHITESPACES; 8 | import static de.cronn.diff.util.cli.CliParser.OPT_LINEWISE_DIFF; 9 | import static de.cronn.diff.util.cli.CliParser.OPT_MAX_ALLOWED_FILESIZE_DIFFERENCE; 10 | import static de.cronn.diff.util.cli.CliParser.OPT_ONLY_REPORTS; 11 | import static de.cronn.diff.util.cli.CliParser.OPT_UNIFIED_CONTEXT; 12 | 13 | import de.cronn.diff.util.DiffToHtmlParameters; 14 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 15 | import de.cronn.diff.util.FileHelper; 16 | import de.cronn.diff.util.cli.CliParser; 17 | import de.cronn.diff.util.cli.DiffToHtmlCommandLine; 18 | 19 | 20 | public final class Main { 21 | 22 | public static final int EXIT_CODE_ERROR = 1; 23 | 24 | public static final int EXIT_CODE_OK = 0; 25 | 26 | private static final int UNIFIED_CONTEXT_LINES = 3; 27 | 28 | public static final String PROGRAM_NAME = "cronn-diff-to-html"; 29 | 30 | private static String workingDir = FileHelper.getWorkingDir(); 31 | 32 | private static final Long MAX_ALLOWED_FILESIZE_DIFFERENCE_IN_BYTES = 500000l; 33 | 34 | private Main() {} 35 | 36 | public static void main(String[] args) throws Exception { 37 | DiffToHtmlCommandLine cli; 38 | cli = new CliParser(workingDir).parse(args); 39 | if(cli.isHelpOnly()) { 40 | System.exit(EXIT_CODE_OK); 41 | } 42 | 43 | DiffToHtmlParameters parameters = DiffToHtmlParameters.builder() 44 | .withDiffType(cli.isInputsFiles() ? DiffType.FILES : DiffType.DIRECTORIES) 45 | .withInputLeftPath(cli.getInputLeft()) 46 | .withInputRightPath(cli.getInputRight()) 47 | .withOutputPath(cli.getOutput()) 48 | .withIgnoreUniqueFiles(cli.hasOption(OPT_IGNORE_UNIQUE_FILES)) 49 | .withIgnoreWhiteSpaces(cli.hasOption(OPT_IGNORE_WHITESPACES)) 50 | .withIgnoreSpaceChange(cli.hasOption(OPT_IGNORE_SPACE_CHANGE)) 51 | .withIgnoreLineEndings(cli.hasOption(OPT_IGNORE_LINE_ENDINGS)) 52 | .withDetectTextFileEncoding(cli.hasOption(OPT_DETECT_ENCODING)) 53 | .withOnlyReports(cli.hasOption(OPT_ONLY_REPORTS)) 54 | .withUnifiedContext(Integer 55 | .parseInt(cli.getOptionValue(OPT_UNIFIED_CONTEXT, Integer.toString(UNIFIED_CONTEXT_LINES)))) 56 | .withMaxAllowedDifferenceInByte(Long.parseLong(cli.getOptionValue(OPT_MAX_ALLOWED_FILESIZE_DIFFERENCE, 57 | Long.toString(MAX_ALLOWED_FILESIZE_DIFFERENCE_IN_BYTES)))) 58 | .withLinewiseDiff(cli.hasOption(OPT_LINEWISE_DIFF)) 59 | .build(); 60 | int status = new CronnDiffToHtml().generateDiffToHtmlReport(parameters); 61 | System.exit(status); 62 | 63 | } 64 | 65 | public static String getWorkingDir() { 66 | return workingDir; 67 | } 68 | 69 | public static void setWorkingDir(String workingDir) { 70 | Main.workingDir = workingDir; 71 | } 72 | 73 | private static int tooManyFilesAmount = 1000; 74 | 75 | public static int getTooManyFilesAmount() { 76 | return tooManyFilesAmount; 77 | } 78 | static void setTooManyFilesAmount(int amount) { 79 | tooManyFilesAmount = amount; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/impl/DiffToHtmlResult.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.impl; 2 | 3 | public final class DiffToHtmlResult { 4 | 5 | private final String html; 6 | 7 | private final int resultCode; 8 | 9 | public DiffToHtmlResult(String html, int resultCode) { 10 | this.html = html; 11 | this.resultCode = resultCode; 12 | } 13 | 14 | public String getHtml() { 15 | return html; 16 | } 17 | 18 | public int getResultCode() { 19 | return resultCode; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/impl/JavaDiffToHtmlGenerator.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.impl; 2 | 3 | import java.io.IOException; 4 | 5 | import de.cronn.diff.impl.java.JavaDirDiffToHtmlImpl; 6 | import de.cronn.diff.impl.java.JavaFileDiffToHtmlImpl; 7 | import de.cronn.diff.util.DiffToHtmlParameters; 8 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 9 | 10 | public class JavaDiffToHtmlGenerator { 11 | 12 | public DiffToHtmlResult generateHtml(DiffToHtmlParameters params) throws IOException { 13 | if (params.getDiffType() == DiffType.DIRECTORIES) { 14 | return new JavaDirDiffToHtmlImpl(params).runDiffToHtml(); 15 | } else { 16 | return new JavaFileDiffToHtmlImpl(params).runDiffToHtml(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/util/DiffToHtmlRuntimeException.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class DiffToHtmlRuntimeException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public DiffToHtmlRuntimeException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/util/SimpleFileInfo.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | public class SimpleFileInfo { 4 | private final String path; 5 | private final String lastModified; 6 | 7 | public SimpleFileInfo() { 8 | this("", ""); 9 | } 10 | 11 | public SimpleFileInfo(String path, String lastModified) { 12 | this.path = path; 13 | this.lastModified = lastModified; 14 | } 15 | 16 | public String getPath() { 17 | return path; 18 | } 19 | 20 | public String getLastModified() { 21 | return lastModified; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/util/cli/CliParser.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util.cli; 2 | 3 | import static java.lang.String.format; 4 | 5 | import org.apache.commons.cli.CommandLine; 6 | import org.apache.commons.cli.DefaultParser; 7 | import org.apache.commons.cli.HelpFormatter; 8 | import org.apache.commons.cli.Option; 9 | import org.apache.commons.cli.Options; 10 | import org.apache.commons.cli.ParseException; 11 | 12 | import de.cronn.diff.Main; 13 | 14 | public class CliParser { 15 | 16 | public static final String OPT_DETECT_ENCODING = "de"; 17 | 18 | public static final String OPT_IGNORE_UNIQUE_FILES = "iu"; 19 | 20 | public static final String OPT_ONLY_REPORTS = "or"; 21 | 22 | public static final String OPT_IGNORE_WHITESPACES = "w"; 23 | 24 | public static final String OPT_IGNORE_SPACE_CHANGE = "b"; 25 | 26 | public static final String OPT_IGNORE_LINE_ENDINGS = "crlf"; 27 | 28 | public static final String OPT_UNIFIED_CONTEXT = "u"; 29 | 30 | public static final String OPT_MAX_ALLOWED_FILESIZE_DIFFERENCE = "fs"; 31 | 32 | public static final String OPT_LINEWISE_DIFF = "id"; 33 | 34 | public static final String OPT_HELP = "h"; 35 | 36 | private final Options options; 37 | 38 | private final HelpFormatter helpFormatter; 39 | 40 | private final String workingDir; 41 | 42 | public CliParser(String workingDir) { 43 | this.workingDir = workingDir; 44 | options = createOptions(); 45 | helpFormatter = createHelpFormatter(); 46 | } 47 | 48 | private Options createOptions() { 49 | Options options = new Options(); 50 | options.addOption(new Option(OPT_HELP, "help", false, "print this help")); 51 | options.addOption(new Option(OPT_IGNORE_WHITESPACES, "ignore-white-spaces", false, "ignore all white spaces")); 52 | options.addOption(new Option(OPT_IGNORE_SPACE_CHANGE, "ignore-space-change", false, "ignore changes in the amount of white space")); 53 | options.addOption(new Option(OPT_IGNORE_LINE_ENDINGS, "ignore-line-endings", false, "ignore line endings, i.e. normalize CRLF / LF while comparing files")); 54 | options.addOption(new Option(OPT_ONLY_REPORTS, "only-reports", false, "always exits with zero")); 55 | options.addOption(new Option(OPT_IGNORE_UNIQUE_FILES, "ignore-unique", false, "ignore unique files")); 56 | options.addOption(new Option(OPT_DETECT_ENCODING, "detect-encoding", false, "tries to determine encoding type")); 57 | options.addOption(Option.builder(OPT_UNIFIED_CONTEXT).longOpt("unified").hasArg() 58 | .desc("output (default 3) lines of unified context").build()); 59 | options.addOption(new Option(OPT_MAX_ALLOWED_FILESIZE_DIFFERENCE, "max-size-diff", true, "no textual diff if file size differs too much")); 60 | options.addOption(new Option(OPT_LINEWISE_DIFF, "line-diff", false, "generate line-wise diffs (default: inline / character-wise)")); 61 | return options; 62 | } 63 | 64 | private HelpFormatter createHelpFormatter() { 65 | HelpFormatter formatter = new HelpFormatter(); 66 | formatter.setOptionComparator((Option o1, Option o2) -> { 67 | if (o1.isRequired() && o2.isRequired()) { 68 | return 0; 69 | } 70 | return o1.isRequired() ? -1 : 1; 71 | }); 72 | return formatter; 73 | } 74 | 75 | public DiffToHtmlCommandLine parse(String[] args) throws ParseException { 76 | try { 77 | CommandLine cli = new DefaultParser().parse(options, args); 78 | if(cli.hasOption(OPT_HELP)) { 79 | printHelp(); 80 | } 81 | return new DiffToHtmlCommandLine(cli, workingDir); 82 | } catch (ParseException e) { 83 | printHelp(); 84 | System.err.println(format("Parsing failed. Reason: %1$s", e.getMessage())); 85 | throw e; 86 | } 87 | } 88 | 89 | public void printHelp() { 90 | helpFormatter.printHelp(Main.PROGRAM_NAME + " [] ", options, true); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/de/cronn/diff/util/cli/DiffToHtmlCommandLine.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util.cli; 2 | 3 | import static de.cronn.diff.util.cli.CliParser.OPT_HELP; 4 | 5 | import java.io.File; 6 | import java.nio.file.Files; 7 | import java.nio.file.Paths; 8 | import java.util.Arrays; 9 | 10 | import org.apache.commons.cli.AmbiguousOptionException; 11 | import org.apache.commons.cli.CommandLine; 12 | import org.apache.commons.cli.MissingArgumentException; 13 | import org.apache.commons.cli.Option; 14 | import org.apache.commons.cli.ParseException; 15 | import org.apache.commons.cli.UnrecognizedOptionException; 16 | import org.apache.commons.io.FilenameUtils; 17 | 18 | public class DiffToHtmlCommandLine extends CommandLine { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | private String inputLeft; 23 | 24 | private String inputRight; 25 | 26 | private String output; 27 | 28 | private boolean inputsAreFiles; 29 | 30 | private final String workingDir; 31 | 32 | private boolean helpOnly = false; 33 | 34 | public DiffToHtmlCommandLine(CommandLine cli, String workingDir) throws ParseException { 35 | for(Option opt : cli.getOptions()) { 36 | this.addOption(opt); 37 | } 38 | for(String arg : cli.getArgs()) { 39 | this.addArg(arg); 40 | } 41 | 42 | this.workingDir = workingDir; 43 | 44 | if (hasOption(OPT_HELP)) { 45 | helpOnly = true; 46 | } else { 47 | checkCliArguments(); 48 | setupInputs(); 49 | setupOutput(); 50 | } 51 | } 52 | 53 | private void checkCliArguments() throws ParseException { 54 | String[] noOptArgs = getArgs(); 55 | if(noOptArgs.length < 2) { 56 | throw new MissingArgumentException("Input arguments are missing"); 57 | } else if(noOptArgs.length > 3) { 58 | throw new UnrecognizedOptionException("Too many arguments: " + String.join(", ", noOptArgs)); 59 | } 60 | inputsAreFiles = isBothInputsFiles(noOptArgs); 61 | if(!inputsAreFiles && !isBothInputsDirs(noOptArgs)) { 62 | throw new AmbiguousOptionException("Inputs must be either both regular files or both directories", 63 | Arrays.asList(noOptArgs[0], noOptArgs[1])); 64 | } 65 | } 66 | 67 | private boolean isBothInputsFiles(String[] noOptArgs) { 68 | return Files.isRegularFile(Paths.get(noOptArgs[0])) && Files.isRegularFile(Paths.get(noOptArgs[1])); 69 | } 70 | 71 | private boolean isBothInputsDirs(String[] noOptArgs) { 72 | return Files.isDirectory(Paths.get(noOptArgs[0])) && Files.isDirectory(Paths.get(noOptArgs[1])); 73 | } 74 | 75 | private void setupInputs() { 76 | String[] args = getArgs(); 77 | if (args.length >= 2) { 78 | inputLeft = args[0]; 79 | inputRight = args[1]; 80 | } 81 | } 82 | 83 | private void setupOutput() { 84 | if(outputPathSupplied()) { 85 | output = new File(getArgs()[2]).getAbsolutePath(); 86 | } else { 87 | output = createOutputHtmlPath(); 88 | } 89 | } 90 | 91 | private boolean outputPathSupplied() { 92 | return getArgs().length >= 3; 93 | } 94 | 95 | private String createOutputHtmlPath() { 96 | return workingDir + "diff_" + getShortFileName(inputLeft) + "_" + getShortFileName(inputRight) + ".html"; 97 | } 98 | 99 | private String getShortFileName(String f) { 100 | return FilenameUtils.getBaseName(FilenameUtils.normalizeNoEndSeparator(f)); 101 | } 102 | 103 | public String getInputLeft() { 104 | return inputLeft; 105 | } 106 | 107 | public String getInputRight() { 108 | return inputRight; 109 | } 110 | 111 | public boolean isInputsFiles() { 112 | return inputsAreFiles; 113 | } 114 | 115 | public String getOutput() { 116 | return output; 117 | } 118 | 119 | public boolean isHelpOnly() { 120 | return helpOnly; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/resources/diffToHtml.css: -------------------------------------------------------------------------------- 1 | body { 2 | text-align: center; 3 | } 4 | #wrapper { 5 | display: inline-block; 6 | margin-top: 1em; 7 | min-width: 800px; 8 | } 9 | #wrapper2 { 10 | font-family: sans-serif; 11 | text-align: left; 12 | display: inline-block; 13 | margin-top: 1em; 14 | min-width: 800px; 15 | } 16 | h1 { 17 | font-family: sans-serif; 18 | color: #505050; 19 | } 20 | h2 { 21 | font-family: sans-serif; 22 | color: #5c5c5c; 23 | } 24 | table th { 25 | border: 1px solid #d8d8d8; 26 | background: #fafafa; 27 | background: -moz-linear-gradient(#fafafa, #eaeaea); 28 | background: -webkit-linear-gradient(#fafafa, #eaeaea); 29 | -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafa',endColorstr='#eaeaea')"; 30 | color: #555; 31 | font: 14px sans-serif; 32 | overflow: hidden; 33 | padding: 16px 6px; 34 | text-shadow: 0 1px 0 white; 35 | } 36 | table tr { 37 | font-family: "Lucida Console", "Courier New", "Courier", monospace; 38 | font-size: 12px; 39 | line-height: 1.5em; 40 | } 41 | table { 42 | border: 1px solid #d8d8d8; 43 | margin-bottom: 1em; 44 | margin: 0; 45 | overflow: auto; 46 | padding: 0; 47 | text-align: left; 48 | } 49 | table > div { 50 | width: 100%: 51 | } 52 | a { 53 | color: #000099; 54 | text-decoration: none; 55 | } 56 | 57 | a:hover 58 | { 59 | color:#0000cc; 60 | font-weight: bold; 61 | text-decoration:underline; 62 | cursor:pointer; 63 | } 64 | .delete { 65 | background-color: #ffeef0; 66 | } 67 | .insert { 68 | background-color: #e5ffee; 69 | } 70 | .info { 71 | color: #808080; 72 | } 73 | .attention { 74 | color: #990000; 75 | } 76 | .line-number { 77 | background: #f5f5f0; 78 | border-right: 1px solid #ccccb3; 79 | } 80 | .one-line-header { 81 | display: inline; 82 | } 83 | .expand-all-link { 84 | font-family: monospace; 85 | } 86 | .deleteChar { 87 | background-color: #ffb8c0; 88 | text-decoration: none; 89 | } 90 | .insertChar { 91 | background-color: #a9f2c0; 92 | text-decoration: none; 93 | } 94 | -------------------------------------------------------------------------------- /src/main/resources/diffToHtmlJSScripts.js: -------------------------------------------------------------------------------- 1 | function showElement(id) { 2 | var divElement = document.getElementById(id); 3 | v = divElement.style.display; 4 | divElement.style.display = v == "inline" ? "none" : "inline" 5 | } 6 | 7 | function showElements(elemIds) { 8 | var atLeastOneCollapsed = false; 9 | for(var i = 0; i < elemIds.length; i++) { 10 | if(document.getElementById(elemIds[i]).style.display == "none") { 11 | atLeastOneCollapsed = true; 12 | } 13 | } 14 | 15 | if(atLeastOneCollapsed == true) { 16 | for(var i = 0; i < elemIds.length; i++) { 17 | document.getElementById(elemIds[i]).style.display = "inline"; 18 | } 19 | } else { 20 | for(var i = 0; i < elemIds.length; i++) { 21 | document.getElementById(elemIds[i]).style.display = "none"; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/java/de/cronn/diff/CronnDiffToHtmlTest.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | import de.cronn.diff.util.DiffToHtmlParameters; 7 | import de.cronn.diff.util.DiffToHtmlParameters.DiffType; 8 | 9 | public class CronnDiffToHtmlTest extends TestBase { 10 | 11 | private static final String INPUT_CODE_1_1 = TEST_DATA_INPUT_DIR + "code1_1.java.example"; 12 | private static final String INPUT_CODE_1_2 = TEST_DATA_INPUT_DIR + "code1_2.java.example"; 13 | private static final String INPUT_CODE_2_1 = TEST_DATA_INPUT_DIR + "code2_1.java.example"; 14 | private static final String INPUT_CODE_2_2 = TEST_DATA_INPUT_DIR + "code2_2.java.example"; 15 | private static final String INPUT_TEXT_1_1 = TEST_DATA_INPUT_DIR + "text1_1.example"; 16 | private static final String INPUT_TEXT_1_2 = TEST_DATA_INPUT_DIR + "text1_2.example"; 17 | private static final String INPUT_BINARY_1_1 = TEST_DATA_INPUT_DIR + "binaryFile1_1"; 18 | private static final String INPUT_BINARY_1_2 = TEST_DATA_INPUT_DIR + "binaryFile1_2"; 19 | 20 | private CronnDiffToHtml diffToHtml = null; 21 | 22 | @Override 23 | @Before 24 | public void setUp() { 25 | super.setUp(); 26 | diffToHtml = new CronnDiffToHtml(); 27 | } 28 | 29 | @Test 30 | public void testGenerateDiffToHtmlReportJavaBasedCode1() throws Exception { 31 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_CODE_1_1, INPUT_CODE_1_2)); 32 | assertOutputEqualToValidation(); 33 | } 34 | 35 | @Test 36 | public void testGenerateDiffToHtmlReportJavaBasedCode2() throws Exception { 37 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_CODE_2_1, INPUT_CODE_2_2)); 38 | assertOutputEqualToValidation(); 39 | } 40 | 41 | @Test 42 | public void testGenerateDiffToHtmlReportJavaBasedText1() throws Exception { 43 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_TEXT_1_1, INPUT_TEXT_1_2)); 44 | assertOutputEqualToValidation(); 45 | } 46 | 47 | @Test 48 | public void testGenerateDiffToHtmlReportJavaBasedBinary1() throws Exception { 49 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_BINARY_1_1, INPUT_BINARY_1_2)); 50 | assertOutputEqualToValidation(); 51 | } 52 | 53 | @Test 54 | public void testGenerateDiffToHtmlReportJavaBasedBinary2Identical() throws Exception { 55 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_BINARY_1_2, INPUT_BINARY_1_2)); 56 | assertOutputEqualToValidation(); 57 | } 58 | 59 | @Test 60 | public void testGenerateDiffToHtmlReportJavaBasedCodeIdentical() throws Exception { 61 | diffToHtml.generateDiffToHtmlReport(createParameters(INPUT_CODE_1_1, INPUT_CODE_1_1)); 62 | assertOutputEqualToValidation(); 63 | } 64 | 65 | private DiffToHtmlParameters createParameters(String inputFileLeft, String inputFileRight) { 66 | return DiffToHtmlParameters.builder() 67 | .withDiffType(DiffType.FILES) 68 | .withInputLeftPath(inputFileLeft) 69 | .withInputRightPath(inputFileRight) 70 | .withOutputPath(getOutHtmlFilePath()) 71 | .build(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/de/cronn/diff/MainLineEndingsTest.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import static de.cronn.diff.util.cli.CliParser.OPT_IGNORE_LINE_ENDINGS; 4 | import static org.apache.commons.lang3.StringUtils.CR; 5 | import static org.apache.commons.lang3.StringUtils.LF; 6 | 7 | import java.io.IOException; 8 | import java.nio.file.Files; 9 | import java.nio.file.Paths; 10 | 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | 14 | public class MainLineEndingsTest extends MainTestBase { 15 | 16 | private static final String TEXT_LINE_ENDINGS_LF = TEST_DATA_OUTPUT_DIR + "textWithLineEndingsLF"; 17 | private static final String TEXT_LINE_ENDINGS_CRLF = TEST_DATA_OUTPUT_DIR + "textWithLineEndingsCRLF"; 18 | 19 | @BeforeClass 20 | public static void createTestInput() throws IOException { 21 | createFileWithLineEndings(LF, TEXT_LINE_ENDINGS_LF); 22 | createFileWithLineEndings(CR + LF, TEXT_LINE_ENDINGS_CRLF); 23 | } 24 | 25 | @Test 26 | public void testMainJavaDiffDirsToHtmlIgnoreLineEndings_True() throws Exception { 27 | exit.expectSystemExitWithStatus(Main.EXIT_CODE_OK); 28 | exit.checkAssertionAfterwards(new DefaultAssertion()); 29 | Main.main(new String[] { TEXT_LINE_ENDINGS_LF, TEXT_LINE_ENDINGS_CRLF, getOutHtmlFilePath(), "-" + OPT_IGNORE_LINE_ENDINGS }); 30 | } 31 | 32 | @Test 33 | public void testMainJavaDiffDirsToHtmlIgnoreLineEndings_False() throws Exception { 34 | exit.expectSystemExitWithStatus(Main.EXIT_CODE_ERROR); 35 | exit.checkAssertionAfterwards(new DefaultAssertion()); 36 | Main.main(new String[] { TEXT_LINE_ENDINGS_LF, TEXT_LINE_ENDINGS_CRLF, getOutHtmlFilePath() }); 37 | } 38 | 39 | private static void createFileWithLineEndings(String lineEndings, String pathToFile) throws IOException { 40 | if (!Files.exists(Paths.get(pathToFile))) { 41 | Files.write(Paths.get(pathToFile), ("Some text. " + lineEndings + "Some more text." + lineEndings).getBytes()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/de/cronn/diff/MainNoOutputTest.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | public class MainNoOutputTest extends MainTestBase { 8 | 9 | private String workingDirBkp; 10 | 11 | @Before 12 | public void backupMainWorkingDir() { 13 | workingDirBkp = Main.getWorkingDir(); 14 | } 15 | 16 | @After 17 | public void resetMainWorkingDir() { 18 | Main.setWorkingDir(workingDirBkp); 19 | } 20 | 21 | @Test 22 | public void testMainJAVADiffDirsToHtml_noOutputProvided() throws Exception { 23 | exit.expectSystemExitWithStatus(Main.EXIT_CODE_OK); 24 | exit.checkAssertionAfterwards(new SystemMessageAssertion()); 25 | Main.setWorkingDir(TestBase.TEST_DATA_OUTPUT_DIR); 26 | Main.main(new String[] { INPUT_DIR_1, INPUT_DIR_1 }); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/de/cronn/diff/impl/java/wrapper/JavaDiffUtils2HtmlWrapperTest.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.impl.java.wrapper; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; 5 | import static org.assertj.core.api.Assumptions.assumeThat; 6 | 7 | import java.io.IOException; 8 | import java.nio.charset.MalformedInputException; 9 | 10 | import org.apache.commons.lang3.SystemUtils; 11 | import org.junit.Test; 12 | 13 | import de.cronn.diff.TestBase; 14 | import de.cronn.diff.html.FileDiffHtmlBuilder; 15 | import de.cronn.diff.util.DiffToHtmlParameters; 16 | import de.cronn.diff.util.DiffToHtmlRuntimeException; 17 | 18 | public class JavaDiffUtils2HtmlWrapperTest { 19 | 20 | private static final String UTF_8_FILE = TestBase.TEST_DATA_INPUT_DIR + "utf8textfile"; 21 | 22 | private static final String UTF_16_BE_FILE = TestBase.TEST_DATA_INPUT_DIR + "utf16betextfile"; 23 | 24 | private static final String UTF_16_LE_FILE = TestBase.TEST_DATA_INPUT_DIR + "utf16letextfile"; 25 | 26 | private static final String ISO_8859_FILE = TestBase.TEST_DATA_INPUT_DIR + "iso88591textfile"; 27 | 28 | @Test 29 | public void testAppendDiffToBuilder_Exception_ISO_8859_1() { 30 | // on windows the default charset is windows-1252 which is close to ISO 8859 31 | assumeThat(SystemUtils.IS_OS_WINDOWS).isFalse(); 32 | 33 | DiffToHtmlParameters paramWithDetectEncoding = DiffToHtmlParameters.builder() 34 | .withInputLeftPath(ISO_8859_FILE) 35 | .withInputRightPath(ISO_8859_FILE) 36 | .build(); 37 | 38 | assertThatExceptionOfType(DiffToHtmlRuntimeException.class) 39 | .isThrownBy(() -> new JavaDiffUtils2HtmlWrapper() 40 | .appendDiffToBuilder(new FileDiffHtmlBuilder(paramWithDetectEncoding), paramWithDetectEncoding)) 41 | .withCauseExactlyInstanceOf(MalformedInputException.class); 42 | } 43 | 44 | @Test 45 | public void testAppendDiffToBuilder_detectEncoding_OK_UTF_8() throws Exception { 46 | DiffToHtmlParameters paramWithDetectEncoding = createParams(UTF_8_FILE); 47 | assertNoExceptionReadAllLines(paramWithDetectEncoding); 48 | } 49 | 50 | @Test 51 | public void testAppendDiffToBuilder_detectEncoding_OK_UTF_16_BE() throws Exception { 52 | DiffToHtmlParameters paramWithDetectEncoding = createParams(UTF_16_BE_FILE); 53 | assertNoExceptionReadAllLines(paramWithDetectEncoding); 54 | } 55 | 56 | @Test 57 | public void testAppendDiffToBuilder_detectEncoding_OK_UTF_16_LE() throws Exception { 58 | DiffToHtmlParameters paramWithDetectEncoding = createParams(UTF_16_LE_FILE); 59 | assertNoExceptionReadAllLines(paramWithDetectEncoding); 60 | } 61 | 62 | @Test 63 | public void testAppendDiffToBuilder_detectEncoding_OK_ISO_8859_1() throws Exception { 64 | DiffToHtmlParameters paramWithDetectEncoding = createParams(ISO_8859_FILE); 65 | assertNoExceptionReadAllLines(paramWithDetectEncoding); 66 | } 67 | 68 | private void assertNoExceptionReadAllLines(DiffToHtmlParameters params) throws IOException { 69 | FileDiffHtmlBuilder htmlBuilder = new JavaDiffUtils2HtmlWrapper() 70 | .appendDiffToBuilder(new FileDiffHtmlBuilder(params), params); 71 | assertThat(htmlBuilder.toString()).isNotNull(); 72 | } 73 | 74 | private DiffToHtmlParameters createParams(String filePath) { 75 | return DiffToHtmlParameters.builder() 76 | .withDetectTextFileEncoding(true) 77 | .withInputLeftPath(filePath) 78 | .withInputRightPath(filePath) 79 | .build(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/test/java/de/cronn/diff/util/FileHelperTest.java: -------------------------------------------------------------------------------- 1 | package de.cronn.diff.util; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; 5 | 6 | import java.nio.charset.IllegalCharsetNameException; 7 | import java.nio.charset.MalformedInputException; 8 | import java.nio.charset.StandardCharsets; 9 | 10 | import org.junit.Test; 11 | 12 | import de.cronn.diff.TestBase; 13 | 14 | public class FileHelperTest extends TestBase { 15 | 16 | @Test 17 | public void testIsFileBinary_isBinary() throws Exception { 18 | boolean isBinary = FileHelper.isFileBinary(TEST_DATA_INPUT_DIR + "binaryFile1_1"); 19 | assertThat(isBinary).isTrue(); 20 | } 21 | 22 | @Test 23 | public void testIsFileBinary_isNotBinary() throws Exception { 24 | boolean isBinary = FileHelper.isFileBinary(TEST_DATA_INPUT_DIR + "text1_1.example"); 25 | assertThat(isBinary).isFalse(); 26 | } 27 | 28 | @Test 29 | public void testIsFileBinary_emptyFileIsNotBinary() throws Exception { 30 | boolean isBinary = FileHelper.isFileBinary(TEST_DATA_INPUT_DIR + "emptyFile"); 31 | assertThat(isBinary).isFalse(); 32 | } 33 | 34 | @Test 35 | public void testReadAllLines_notReadableWithCharset_exception() { 36 | assertThatExceptionOfType(UnsupportedOperationException.class) 37 | .isThrownBy(() -> FileHelper.readAllLines( TEST_DATA_INPUT_DIR + "iso88591textfile", 38 | StandardCharsets.UTF_8)) 39 | .withCauseExactlyInstanceOf(MalformedInputException.class); 40 | } 41 | 42 | @Test 43 | public void testReadLinesWithEncoding_illegalCharsetName_exception() { 44 | assertThatExceptionOfType(UnsupportedOperationException.class) 45 | .isThrownBy(() -> FileHelper.readLinesWithEncoding("", "this is an illegal charset name")) 46 | .withCauseExactlyInstanceOf(IllegalCharsetNameException.class); 47 | } 48 | 49 | @Test 50 | public void testIsFileSizeDifferenceTooBig_true() { 51 | boolean isTooBig = FileHelper.isFileSizeDifferenceTooBig(TEST_DATA_INPUT_DIR + "smallfile", TEST_DATA_INPUT_DIR + "bigfile", 5l); 52 | assertThat(isTooBig).isTrue(); 53 | } 54 | @Test 55 | public void testIsFileSizeDifferenceTooBig_false() { 56 | boolean isTooBig = FileHelper.isFileSizeDifferenceTooBig(TEST_DATA_INPUT_DIR + "smallfile", TEST_DATA_INPUT_DIR + "bigfile", 5l); 57 | assertThat(!isTooBig).isFalse(); 58 | } 59 | } 60 | --------------------------------------------------------------------------------