| 1 |
// Copyright 2001, FreeHEP. |
| 2 |
package org.freehep.util.io.test; |
| 3 |
|
| 4 |
import java.io.File; |
| 5 |
import java.io.FileInputStream; |
| 6 |
import java.io.FileOutputStream; |
| 7 |
|
| 8 |
import org.freehep.util.Assert; |
| 9 |
import org.freehep.util.io.RunLengthOutputStream; |
| 10 |
|
| 11 |
/** |
| 12 |
* Test for Run Length Output Stream. |
| 13 |
* |
| 14 |
* @author Mark Donszelmann |
| 15 |
* @version $Id: RunLengthOutputStreamTest.java 8584 2006-08-10 23:06:37Z duns $ |
| 16 |
*/ |
| 17 |
public class RunLengthOutputStreamTest extends AbstractStreamTest { |
| 18 |
|
| 19 |
/** |
| 20 |
* Test method for 'org.freehep.util.io.RunLengthOutputStream.write()' |
| 21 |
* @throws Exception if ref file cannot be found |
| 22 |
*/ |
| 23 |
public void testWrite() throws Exception { |
| 24 |
File testFile = new File(testDir, "TestFile.xml"); |
| 25 |
File outFile = new File(outDir, "TestFile.rnl"); |
| 26 |
File refFile = new File(refDir, "TestFile.rnl"); |
| 27 |
|
| 28 |
RunLengthOutputStream out = new RunLengthOutputStream(new FileOutputStream(outFile)); |
| 29 |
FileInputStream in = new FileInputStream(testFile); |
| 30 |
int b; |
| 31 |
while ((b = in.read()) >= 0) { |
| 32 |
out.write(b); |
| 33 |
} |
| 34 |
in.close(); |
| 35 |
out.close(); |
| 36 |
|
| 37 |
Assert.assertEquals(refFile, outFile, true); |
| 38 |
} |
| 39 |
} |