Debian Codegraph @

src/test/java/org/freehep/util/io/test/ConditionalInputStreamTest.java

raw
1 // Copyright 2001-2005, FreeHEP.
2 package org.freehep.util.io.test;
3
4 import java.io.File;
5 import java.io.FileInputStream;
6 import java.util.Properties;
7
8 import org.freehep.util.Assert;
9 import org.freehep.util.io.ConditionalInputStream;
10
11 /**
12 * Test for Conditional Input Stream.
13 *
14 * @author Mark Donszelmann
15 * @version $Id: ConditionalInputStreamTest.java 8584 2006-08-10 23:06:37Z duns $
16 */
17 public class ConditionalInputStreamTest extends AbstractStreamTest {
18
19 private File testFile;
20
21 protected void setUp() throws Exception {
22 super.setUp();
23 testFile = new File(testDir, "ConditionalInputStream.txt");
24 }
25
26 /**
27 * Test method for 'org.freehep.util.io.RunLengthInputStream.read()'
28 * @throws Exception if ref file cannot be found
29 */
30 public void testRead1() throws Exception {
31 File refFile = new File(refDir, "ConditionalInputStream.ref1");
32 Properties defines = new Properties();
33
34 ConditionalInputStream in = new ConditionalInputStream(new FileInputStream(testFile), defines);
35 Assert.assertEquals(new FileInputStream(refFile), in, false, refFile.getPath());
36 }
37
38 /**
39 * Test method for 'org.freehep.util.io.RunLengthInputStream.read()'
40 * @throws Exception if ref file cannot be found
41 */
42 public void testRead2() throws Exception {
43 File refFile = new File(refDir, "ConditionalInputStream.ref2");
44 Properties defines = new Properties();
45 defines.setProperty("FREEHEP", "1");
46
47 ConditionalInputStream in = new ConditionalInputStream(new FileInputStream(testFile), defines);
48 Assert.assertEquals(new FileInputStream(refFile), in, false, refFile.getPath());
49 }
50
51
52 /**
53 * Test method for 'org.freehep.util.io.RunLengthInputStream.read()'
54 * @throws Exception if ref file cannot be found
55 */
56 public void testRead3() throws Exception {
57 File refFile = new File(refDir, "ConditionalInputStream.ref3");
58 Properties defines = new Properties();
59 defines.setProperty("FREEHEP", "1");
60 defines.setProperty("WIRED", "1");
61
62 ConditionalInputStream in = new ConditionalInputStream(new FileInputStream(testFile), defines);
63 // OutputStream out = new FileOutputStream("ConditionalInputStream.ref3");
64 // int b;
65 // while ((b = in.read()) >= 0) out.write(b);
66 // out.close();
67 Assert.assertEquals(new FileInputStream(refFile), in, false, refFile.getPath());
68 }
69 }