1 8 9 package com.sleepycat.util.test; 10 11 import junit.framework.Test; 12 import junit.framework.TestCase; 13 import junit.framework.TestSuite; 14 15 import com.sleepycat.collections.test.DbTestUtil; 16 import com.sleepycat.util.FastOutputStream; 17 18 21 public class FastOutputStreamTest extends TestCase { 22 23 public static void main(String [] args) 24 throws Exception { 25 26 junit.framework.TestResult tr = 27 junit.textui.TestRunner.run(suite()); 28 if (tr.errorCount() > 0 || 29 tr.failureCount() > 0) { 30 System.exit(1); 31 } else { 32 System.exit(0); 33 } 34 } 35 36 public static Test suite() 37 throws Exception { 38 39 TestSuite suite = new TestSuite(FastOutputStreamTest.class); 40 return suite; 41 } 42 43 public FastOutputStreamTest(String name) { 44 45 super(name); 46 } 47 48 public void setUp() { 49 50 DbTestUtil.printTestName("FastOutputStreamTest." + getName()); 51 } 52 53 public void testBufferSizing() 54 throws Exception { 55 56 FastOutputStream fos = new FastOutputStream(); 57 assertEquals 58 (FastOutputStream.DEFAULT_INIT_SIZE, fos.getBufferBytes().length); 59 60 61 fos.write(new byte[FastOutputStream.DEFAULT_INIT_SIZE + 1]); 62 assertEquals 63 ((FastOutputStream.DEFAULT_INIT_SIZE * 2) + 1, 64 fos.getBufferBytes().length); 65 66 67 fos.write(new byte[FastOutputStream.DEFAULT_INIT_SIZE + 1]); 68 assertEquals 69 ((FastOutputStream.DEFAULT_INIT_SIZE * 4) + 3, 70 fos.getBufferBytes().length); 71 } 72 } 73 | Popular Tags |