1 package org.apache.commons.jcs3.admin;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import junit.framework.TestCase;
25
26
27
28
29 public class CountingStreamUnitTest
30 extends TestCase
31 {
32
33
34
35
36
37
38 public void testSingleByte() throws Exception
39 {
40 final CountingOnlyOutputStream out = new CountingOnlyOutputStream();
41 out.write( 1 );
42 assertEquals( "Wrong number of bytes written.", 1, out.getCount() );
43 out.write( 1 );
44 assertEquals( "Wrong number of bytes written.", 2, out.getCount() );
45 out.close();
46 }
47
48
49
50
51
52
53 public void testByteArray() throws Exception
54 {
55 final CountingOnlyOutputStream out = new CountingOnlyOutputStream();
56 final byte[] array = new byte[]{1,2,3,4,5};
57 out.write( array );
58 assertEquals( "Wrong number of bytes written.", array.length, out.getCount() );
59 out.close();
60 }
61
62
63
64
65
66
67 public void testByteArrayLenCount() throws Exception
68 {
69 final CountingOnlyOutputStream out = new CountingOnlyOutputStream();
70 final byte[] array = new byte[]{1,2,3,4,5};
71 final int len = 3;
72 out.write( array, 0, len );
73 assertEquals( "Wrong number of bytes written.", len, out.getCount() );
74 out.close();
75 }
76 }