aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/files/ProgressInputStreamTest.java
blob: e2ef2ba87cbc77261afd36e03d5362c6677b9cff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package cgeo.geocaching.files;

import org.apache.commons.io.IOUtils;

import junit.framework.TestCase;

public class ProgressInputStreamTest extends TestCase {

    public static void testRead() throws Exception {
        ProgressInputStream stream = new ProgressInputStream(IOUtils.toInputStream("test"));
        assertEquals(0, stream.getProgress());

        int bytesRead = 0;
        while (stream.read() >= 0 && bytesRead < 10000) {
            bytesRead++;
        }
        assertEquals(4, bytesRead);
        assertEquals(4, stream.getProgress());
        IOUtils.closeQuietly(stream);
    }

}