mirror of https://github.com/apache/poi.git
Finish Comment2000Atom support
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@381168 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6919458a06
commit
a36d020021
|
@ -22,6 +22,8 @@ package org.apache.poi.hslf.record;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that Comment2000 works properly.
|
* Tests that Comment2000 works properly.
|
||||||
|
@ -82,6 +84,8 @@ public class TestComment2000 extends TestCase {
|
||||||
0x0A, 00, 00, 00
|
0x0A, 00, 00, 00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
|
||||||
|
|
||||||
public void testRecordType() throws Exception {
|
public void testRecordType() throws Exception {
|
||||||
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
||||||
assertEquals(12000l, ca.getRecordType());
|
assertEquals(12000l, ca.getRecordType());
|
||||||
|
@ -95,6 +99,16 @@ public class TestComment2000 extends TestCase {
|
||||||
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
||||||
assertEquals("Yes, they certainly are, aren't they!", ca.getText());
|
assertEquals("Yes, they certainly are, aren't they!", ca.getText());
|
||||||
}
|
}
|
||||||
|
public void testCommentAtom() throws Exception {
|
||||||
|
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
||||||
|
Comment2000Atom c2a = ca.getComment2000Atom();
|
||||||
|
|
||||||
|
assertEquals(1, c2a.getNumber());
|
||||||
|
assertEquals(0x92, c2a.getXOffset());
|
||||||
|
assertEquals(0x92, c2a.getYOffset());
|
||||||
|
Date exp_a = sdf.parse("2006-01-24 22:26:15.205");
|
||||||
|
assertEquals(exp_a, c2a.getDate());
|
||||||
|
}
|
||||||
|
|
||||||
public void testWrite() throws Exception {
|
public void testWrite() throws Exception {
|
||||||
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
Comment2000 ca = new Comment2000(data_a, 0, data_a.length);
|
||||||
|
@ -116,8 +130,14 @@ public class TestComment2000 extends TestCase {
|
||||||
ca.setAuthorInitials("H");
|
ca.setAuthorInitials("H");
|
||||||
ca.setText("Comments are fun things to add in, aren't they?");
|
ca.setText("Comments are fun things to add in, aren't they?");
|
||||||
|
|
||||||
// TODO: Make me a proper copy of the Comment2000Atom
|
// Change the Comment2000Atom
|
||||||
ca._children[3] = cb._children[3];
|
Comment2000Atom c2a = ca.getComment2000Atom();
|
||||||
|
c2a.setNumber(1);
|
||||||
|
c2a.setXOffset(0x0a);
|
||||||
|
c2a.setYOffset(0x0a);
|
||||||
|
|
||||||
|
Date new_date = sdf.parse("2006-01-24 22:25:03.725");
|
||||||
|
c2a.setDate(new_date);
|
||||||
|
|
||||||
// Check now the same
|
// Check now the same
|
||||||
assertEquals(ca.getText(), cb.getText());
|
assertEquals(ca.getText(), cb.getText());
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TestComment2000Atom extends TestCase {
|
||||||
|
|
||||||
public void testRecordType() throws Exception {
|
public void testRecordType() throws Exception {
|
||||||
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
||||||
assertEquals(12002l, ca.getRecordType());
|
assertEquals(12001l, ca.getRecordType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetDate() throws Exception {
|
public void testGetDate() throws Exception {
|
||||||
|
@ -89,7 +89,7 @@ public class TestComment2000Atom extends TestCase {
|
||||||
assertEquals(0x0A, cb.getXOffset());
|
assertEquals(0x0A, cb.getXOffset());
|
||||||
assertEquals(0x0E, cb.getYOffset());
|
assertEquals(0x0E, cb.getYOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWrite() throws Exception {
|
public void testWrite() throws Exception {
|
||||||
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
@ -101,7 +101,31 @@ public class TestComment2000Atom extends TestCase {
|
||||||
assertEquals(data_a[i],b[i]);
|
assertEquals(data_a[i],b[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create A from scratch
|
||||||
|
public void testCreate() throws Exception {
|
||||||
|
Comment2000Atom a = new Comment2000Atom();
|
||||||
|
|
||||||
|
// Set number, x and y
|
||||||
|
a.setNumber(1);
|
||||||
|
a.setXOffset(0x92);
|
||||||
|
a.setYOffset(0x92);
|
||||||
|
|
||||||
|
// Set the date
|
||||||
|
Date date_a = sdf.parse("2006-01-24 22:26:15.205");
|
||||||
|
a.setDate(date_a);
|
||||||
|
|
||||||
|
// Check it's now the same as a
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
a.writeOut(baos);
|
||||||
|
byte[] b = baos.toByteArray();
|
||||||
|
|
||||||
|
assertEquals(data_a.length, b.length);
|
||||||
|
for(int i=0; i<data_a.length; i++) {
|
||||||
|
assertEquals(data_a[i],b[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to turn a into b
|
// Try to turn a into b
|
||||||
public void testChange() throws Exception {
|
public void testChange() throws Exception {
|
||||||
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
Comment2000Atom ca = new Comment2000Atom(data_a, 0, data_a.length);
|
||||||
|
|
Loading…
Reference in New Issue