FileDocCategorySizeDatePackage
TestTextBytesAtom.javaAPI DocApache Poi 3.0.13037Mon Jan 01 18:56:12 GMT 2007org.apache.poi.hslf.record

TestTextBytesAtom

public class TestTextBytesAtom extends TestCase
Tests that TextBytesAtom works properly
author
Nick Burch (nick at torchbox dot com)

Fields Summary
private byte[]
data
private String
data_text
private byte[]
alt_data
private String
alt_text
Constructors Summary
Methods Summary
public voidtestChangeText()

		TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
		tba.setText(alt_text.getBytes("ISO-8859-1"));

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		tba.writeOut(baos);
		byte[] b = baos.toByteArray();

		// Compare the header and the text
		assertEquals(alt_data.length, b.length);
		for(int i=0; i<alt_data.length; i++) {
			assertEquals(alt_data[i],b[i]);
		}
	
public voidtestRecordType()


         
		TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
		assertEquals(4008l, tba.getRecordType());
	
public voidtestTextA()

		TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
		assertEquals(data_text, tba.getText());
	
public voidtestTextB()

		TextBytesAtom tba = new TextBytesAtom(alt_data,0,alt_data.length);
		assertEquals(alt_text, tba.getText());
	
public voidtestWrite()

		TextBytesAtom tba = new TextBytesAtom(data,0,data.length);
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		tba.writeOut(baos);
		byte[] b = baos.toByteArray();

		assertEquals(data.length, b.length);
		for(int i=0; i<data.length; i++) {
			assertEquals(data[i],b[i]);
		}