1 18 package org.apache.activemq.util; 19 20 import junit.framework.TestCase; 21 22 import java.io.IOException ; 23 24 public class DataByteArrayOutputStreamTest extends TestCase { 25 26 30 public void testResize() throws IOException { 31 int initSize = 64; 32 DataByteArrayOutputStream out = new DataByteArrayOutputStream(); 33 34 fillOut(out, initSize); 35 out.writeBoolean(true); 37 38 fillOut(out, initSize); 39 out.writeByte(1); 41 42 fillOut(out, initSize); 43 out.writeBytes("test"); 45 46 fillOut(out, initSize); 47 out.writeChar('C'); 49 50 fillOut(out, initSize); 51 out.writeChars("test"); 53 54 fillOut(out, initSize); 55 out.writeDouble(3.1416); 57 58 fillOut(out, initSize); 59 out.writeFloat((float)3.1416); 61 62 fillOut(out, initSize); 63 out.writeInt(12345); 65 66 fillOut(out, initSize); 67 out.writeLong(12345); 69 70 fillOut(out, initSize); 71 out.writeShort(1234); 73 74 fillOut(out, initSize); 75 out.writeUTF("test"); 77 78 fillOut(out, initSize); 79 out.write(1234); 81 82 fillOut(out, initSize); 83 out.write(new byte[10], 5, 5); 85 86 fillOut(out, initSize); 87 out.write(new byte[10]); 89 } 90 91 97 public void fillOut(DataByteArrayOutputStream out, int size) throws IOException { 98 out.restart(size); 99 out.write(new byte[size]); 100 } 101 } 102 | Popular Tags |