[CJ-dev] commonjava-projects/commonjava-diff/src/test/org/commonjava/diff DiffEngineTest.java,1.2,1.
Brought to you by:
johnqueso
From: John C. <joh...@co...> - 2004-07-09 21:43:22
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-diff/src/test/org/commonjava/diff In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17552/src/test/org/commonjava/diff Modified Files: DiffEngineTest.java Log Message: o Separated Main into subproject called 'cli' to remove requirement for commonjava-console in main diff engine project, o Removed dependency on FileSizeConstants, and hence commonjava-util o Copied DescriptiveStats from commonjava-math to . (commonjava-diff) to remove dependency on that lib. o Re-tested engine, and all's well. Index: DiffEngineTest.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-diff/src/test/org/commonjava/diff/DiffEngineTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- DiffEngineTest.java 20 Feb 2004 21:14:08 -0000 1.2 +++ DiffEngineTest.java 9 Jul 2004 21:43:11 -0000 1.3 @@ -23,7 +23,7 @@ { System.out.println("test for DiffOperation[] compute(ReadableByteChannel, ReadableByteChannel)"); - DiffOperation[] ops = DiffEngine.getInstance().compute( + DiffOperation[] ops = new DiffEngine().compute( ByteBuffer.wrap(OLD_FILE.getBytes()), ByteBuffer.wrap(NEW_FILE.getBytes()) ); System.out.println("Found " + ops.length + " diff operations."); @@ -31,6 +31,8 @@ for (int i = 0; i < ops.length; i++) { System.out.println(ops[i]); } + + assertEquals(4, ops.length); } /* @@ -41,10 +43,12 @@ { System.out.println("test for DiffOperation[] compute(ReadableByteChannel, ReadableByteChannel, int)"); - DiffOperation[] ops = DiffEngine.getInstance().compute( + DiffOperation[] ops = new DiffEngine().compute( ByteBuffer.wrap(OLD_FILE.getBytes()), ByteBuffer.wrap(NEW_FILE.getBytes()), 5 ); System.out.println("Found " + ops.length + " diff operations."); + + assertEquals(4, ops.length); } public void testApply() throws IOException { @@ -58,7 +62,7 @@ ByteBuffer newBuffer = ByteBuffer.wrap(NEW_FILE.getBytes()); ByteBuffer testBuffer = ByteBuffer.wrap(OLD_FILE.getBytes()); - ByteBuffer result = DiffEngine.getInstance().apply(ops, newBuffer); + ByteBuffer result = new DiffEngine().apply(ops, newBuffer); testBuffer.rewind(); result.rewind(); @@ -86,13 +90,13 @@ FileChannel inChannel2 = in2.getChannel(); MappedByteBuffer map2 = inChannel2.map(FileChannel.MapMode.READ_ONLY, 0, inChannel2.size()); - DiffOperation[] ops = DiffEngine.getInstance().compute(map1, map2); + DiffOperation[] ops = new DiffEngine().compute(map1, map2); System.out.println("Found " + ops.length + " diff operations."); map1.rewind(); map2.rewind(); - ByteBuffer result = DiffEngine.getInstance().apply(ops, map2); + ByteBuffer result = new DiffEngine().apply(ops, map2); assertEquals("Re-merged result must equal original file.", map1, result); } @@ -113,16 +117,16 @@ FileChannel inChannel2 = in2.getChannel(); MappedByteBuffer map2 = inChannel2.map(FileChannel.MapMode.READ_ONLY, 0, inChannel2.size()); - DiffOperation[] ops = DiffEngine.getInstance().compute(map1, map2); + DiffOperation[] ops = new DiffEngine().compute(map1, map2); System.out.println("Found " + ops.length + " diff operations."); map1.rewind(); map2.rewind(); - ByteBuffer result = DiffEngine.getInstance().apply(ops, map2); + ByteBuffer result = new DiffEngine().apply(ops, map2); result.rewind(); - DiffOperation[] checkOps = DiffEngine.getInstance().compute(map1, result); + DiffOperation[] checkOps = new DiffEngine().compute(map1, result); System.out.println("found " + checkOps.length + " diffs."); for (int i = 0; i < checkOps.length; i++) { |