retVal.append('[');
for(int x = 0; x < value.length; x++)
{
+ if (x>0) {
+ retVal.append(", ");
+ }
retVal.append(toHex(value[x]));
- retVal.append(", ");
}
retVal.append(']');
return retVal.toString();
return rval;
}
- static public byte[] readFromString(String data) throws IOException
- {
- return readData(new ByteArrayInputStream( data.getBytes() ), -1);
+ static public byte[] readFromString(String data) {
+ try {
+ return readData(new ByteArrayInputStream( data.getBytes() ), -1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
static private void readToEOL( InputStream stream ) throws IOException
assertEquals( (short) 0x0001, r.getOptions() );
assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeWin32() );
assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeMacOS() );
- assertEquals( "[01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]", HexDump.toHex( r.getUid() ) );
+ assertEquals( "[01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00]", HexDump.toHex( r.getUid() ) );
assertEquals( (short) 1, r.getTag() );
assertEquals( 2, r.getRef() );
assertEquals( 3, r.getOffset() );
assertEquals( 44, bytesWritten );
assertEquals( "[01, 00, 00, 00, 24, 00, 00, 00, 05, 05, 01, 02, 03, 04, " +
"05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, 01, 00, 00, 00, " +
- "00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07, ]",
+ "00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07]",
HexDump.toHex( data ) );
}
" Options: 0x0001" + nl +
" BlipTypeWin32: 5" + nl +
" BlipTypeMacOS: 5" + nl +
- " SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]" + nl +
+ " SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00]" + nl +
" Tag: 1" + nl +
" Size: 0" + nl +
" Ref: 2" + nl +
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
data = HexRead.readFromString(dataStr);
}
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.setBoundaryLeft(1);
r.setBoundaryHeight(2);
"05, 00, 00, 00, " + // field_9_cacheOfSavedSize
"08, " + // field_10_compressionFlag
"07, " + // field_11_filter
- "01, 02, ]", // field_12_data
+ "01, 02]", // field_12_data
HexDump.toHex(buf));
assertEquals(60, r.getRecordSize() );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.fillFields( data, 0, new DefaultEscherRecordFactory());
assertEquals( 6, r.getCacheOfSize() );
assertEquals( 7, r.getFilter() );
assertEquals( 8, r.getCompressionFlag() );
- assertEquals( "[01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]", HexDump.toHex(r.getSecondaryUID() ) );
+ assertEquals( "[01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01]", HexDump.toHex(r.getSecondaryUID() ) );
assertEquals( 10, r.getWidth() );
assertEquals( 11, r.getHeight() );
assertEquals( (short)5420, r.getOptions() );
- assertEquals( "[01, 02, ]", HexDump.toHex( r.getData() ) );
+ assertEquals( "[01, 02]", HexDump.toHex( r.getData() ) );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.fillFields( data, 0, new DefaultEscherRecordFactory() );
assertEquals( "org.apache.poi.ddf.EscherBlipWMFRecord:" + nl +
" RecordId: 0xF018" + nl +
" Options: 0x152C" + nl +
- " Secondary UID: [01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]" + nl +
+ " Secondary UID: [01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01]" + nl +
" CacheOfSize: 6" + nl +
" BoundaryTop: 3" + nl +
" BoundaryLeft: 1" + nl +
"00000000 01 02 .." + nl
, r.toString() );
}
-
}
+
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherChildAnchorRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherChildAnchorRecord r = createRecord();
byte[] data = new byte[8 + 16];
"01, 00, 00, 00, " +
"02, 00, 00, 00, " +
"03, 00, 00, 00, " +
- "04, 00, 00, 00, ]", HexDump.toHex( data ) );
+ "04, 00, 00, 00]", HexDump.toHex( data ) );
}
public void testFillFields() throws Exception
assertEquals( (short) 0x0001, r.getOptions() );
}
- public void testToString() throws Exception
- {
+ public void testToString(){
String nl = System.getProperty( "line.separator" );
String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherChildAnchorRecord createRecord()
+ private static EscherChildAnchorRecord createRecord()
{
EscherChildAnchorRecord r = new EscherChildAnchorRecord();
r.setRecordId( EscherChildAnchorRecord.RECORD_ID );
r.setDy2( 4 );
return r;
}
-
}
+
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherClientAnchorRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherClientAnchorRecord r = createRecord();
byte[] data = new byte[8 + 18 + 2];
"4D, 00, 37, 00, 21, 00, 58, 00, " +
"0B, 00, 2C, 00, 16, 00, 63, 00, " +
"42, 00, " +
- "FF, DD, ]", HexDump.toHex( data ) );
+ "FF, DD]", HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "01 00 " +
"10 F0 " +
"14 00 00 00 " +
assertEquals( (byte) 0xDD, r.getRemainingData()[1] );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl +
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherClientDataRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherClientDataRecord r = createRecord();
byte[] data = new byte[8];
assertEquals( 8, bytesWritten );
assertEquals( "[02, 00, " +
"11, F0, " +
- "00, 00, 00, 00, ]",
+ "00, 00, 00, 00]",
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "02 00 " +
"11 F0 " +
"00 00 00 00 ";
assertEquals( "[]", HexDump.toHex(r.getRemainingData()) );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherClientDataRecord createRecord()
+ private static EscherClientDataRecord createRecord()
{
EscherClientDataRecord r = new EscherClientDataRecord();
r.setOptions( (short) 0x0002 );
r.setRemainingData( new byte[] {} );
return r;
}
-
}
{
private String ESCHER_DATA_PATH;
- protected void setUp() throws Exception {
- super.setUp();
+ protected void setUp() {
ESCHER_DATA_PATH = System.getProperty("DDF.testdata.path");
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
EscherRecordFactory f = new DefaultEscherRecordFactory();
byte[] data = HexRead.readFromString( "0F 02 11 F1 00 00 00 00" );
EscherRecord r = f.createRecord( data, 0 );
assertEquals( (short) 0xF222, c.getRecordId() );
}
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x123F );
r.setRecordId( (short) 0xF112 );
byte[] data = new byte[8];
r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( "[3F, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+ assertEquals( "[3F, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex( data ) );
EscherRecord childRecord = new UnknownEscherRecord();
childRecord.setOptions( (short) 0x9999 );
data = new byte[16];
r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+ assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex( data ) );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
EscherContainerRecord r = new EscherContainerRecord();
r.setRecordId( EscherContainerRecord.SP_CONTAINER );
r.setOptions( (short) 0x000F );
assertEquals( expected, r.toString() );
}
- public void testGetRecordSize() throws Exception
- {
+ public void testGetRecordSize() {
EscherContainerRecord r = new EscherContainerRecord();
r.addChildRecord(new EscherRecord()
{
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherDgRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherDgRecord r = createRecord();
byte[] data = new byte[16];
"08, F0, " +
"08, 00, 00, 00, " +
"02, 00, 00, 00, " + // num shapes in drawing
- "01, 04, 00, 00, ]", // The last MSOSPID given to an SP in this DG
+ "01, 04, 00, 00]", // The last MSOSPID given to an SP in this DG
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "10 00 " +
"08 F0 " +
"08 00 00 00 " +
assertEquals( 1025, r.getLastMSOSPID() );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherDgRecord createRecord()
+ private static EscherDgRecord createRecord()
{
EscherDgRecord r = new EscherDgRecord();
r.setOptions( (short) 0x0010 );
r.setLastMSOSPID(1025);
return r;
}
-
}
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherDggRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherDggRecord r = createRecord();
byte[] data = new byte[32];
"02, 00, 00, 00, " +
"02, 00, 00, 00, " +
"01, 00, 00, 00, " +
- "01, 00, 00, 00, 02, 00, 00, 00, ]",
+ "01, 00, 00, 00, 02, 00, 00, 00]",
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "00 00 " +
"06 F0 " +
"18 00 00 00 " +
assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed());
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherDggRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherDggRecord createRecord()
+ private static EscherDggRecord createRecord()
{
EscherDggRecord r = new EscherDggRecord();
r.setOptions( (short) 0x0000 );
return r;
}
- public void testGetRecordSize() throws Exception
- {
+ public void testGetRecordSize() {
EscherDggRecord r = new EscherDggRecord();
r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
assertEquals(32,r.getRecordSize());
-
}
-
}
import java.io.IOException;
import java.util.Arrays;
-import java.util.List;
-import java.util.Iterator;
public class TestEscherOptRecord extends TestCase
{
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
checkFillFieldsSimple();
checkFillFieldsComplex();
}
- private void checkFillFieldsComplex() throws IOException
- {
+ private void checkFillFieldsComplex() {
String dataStr = "33 00 " +
"0B F0 " +
"14 00 00 00 " +
}
- private void checkFillFieldsSimple()
- throws IOException
- {
+ private void checkFillFieldsSimple() {
String dataStr = "33 00 " + // options
"0B F0 " + // recordid
"12 00 00 00 " + // remaining bytes
assertEquals( prop3, r.getEscherProperty( 2 ) );
}
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
checkSerializeSimple();
checkSerializeComplex();
}
"BF, 00, 01, 00, 00, 00, " +
"01, 80, 02, 00, 00, 00, " +
"BF, 00, 01, 00, 00, 00, " +
- "01, 02, ]";
+ "01, 02]";
assertEquals( dataStr, HexDump.toHex(data) );
}
"12, 00, 00, 00, " +
"BF, 00, 01, 00, 00, 00, " +
"81, 01, 09, 00, 00, 08, " +
- "C0, 01, 40, 00, 00, 08, ]";
+ "C0, 01, 40, 00, 00, 08]";
assertEquals( dataStr, HexDump.toHex(data) );
assertEquals( 26, bytesWritten );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
EscherOptRecord r = new EscherOptRecord();
r.setOptions((short)0x000F);
* Test serialisation of a particually complex example
* This test is currently broken!
*/
- public void testComplexSerialise() throws Exception {
- byte[] data = new byte[] {
+ public void testComplexSerialise() {
+ byte[] data = {
0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
// Simple data follows
0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8
*
* See Bug 41946 for details.
*/
- public void test41946() throws IOException {
+ public void test41946() {
String dataStr1 =
"03 08 0B F0 00 03 00 00 81 00 30 65 01 00 82 00 98 B2 00 00 83 00 30 65 01 " +
"00 84 00 98 B2 00 00 85 00 00 00 00 00 87 00 01 00 00 00 88 00 00 00 00 00 " +
* Test that EscherOptRecord can properly read/write array properties
* with empty complex part.
*/
- public void testEmptyArrayProperty() throws IOException {
+ public void testEmptyArrayProperty() {
EscherOptRecord r = new EscherOptRecord();
EscherArrayProperty p = new EscherArrayProperty((short)(EscherProperties.FILL__SHADECOLORS + 0x8000), new byte[0] );
assertEquals(0, p.getNumberOfElementsInArray());
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
*/
public class TestEscherPropertyFactory extends TestCase
{
- public void testCreateProperties() throws Exception
- {
+ public void testCreateProperties() {
String dataStr = "41 C1 " + // propid, complex ind
"03 00 00 00 " + // size of complex property
"01 00 " + // propid, complex ind
List props = f.createProperties( data, 0, (short)3 );
EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 );
assertEquals( (short)0xC141, p1.getId() );
- assertEquals( "[01, 02, 03, ]", HexDump.toHex( p1.getComplexData() ) );
+ assertEquals( "[01, 02, 03]", HexDump.toHex( p1.getComplexData() ) );
EscherComplexProperty p3 = (EscherComplexProperty) props.get( 2 );
assertEquals( (short)0xC141, p3.getId() );
- assertEquals( "[01, 02, 03, ]", HexDump.toHex( p3.getComplexData() ) );
-
-
+ assertEquals( "[01, 02, 03]", HexDump.toHex( p3.getComplexData() ) );
}
-
-
-
}
+
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherSpRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherSpRecord r = createRecord();
byte[] data = new byte[16];
"0A, F0, " +
"08, 00, 00, 00, " +
"00, 04, 00, 00, " +
- "05, 00, 00, 00, ]",
+ "05, 00, 00, 00]",
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "02 00 " +
"0A F0 " +
"08 00 00 00 " +
assertEquals( 0x05, r.getFlags() );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherSpRecord createRecord()
+ private static EscherSpRecord createRecord()
{
EscherSpRecord r = new EscherSpRecord();
r.setOptions( (short) 0x0002 );
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.ddf;
import junit.framework.TestCase;
public class TestEscherSpgrRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherSpgrRecord r = createRecord();
byte[] data = new byte[24];
"01, 00, 00, 00, " + // x
"02, 00, 00, 00, " + // y
"03, 00, 00, 00, " + // width
- "04, 00, 00, 00, ]", // height
+ "04, 00, 00, 00]", // height
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "10 00 " +
"09 F0 " +
"10 00 00 00 " +
assertEquals( 4, r.getRectY2() );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + nl +
" RectY: 2" + nl +
" RectWidth: 3" + nl +
" RectHeight: 4" + nl;
- ;
assertEquals( expected, createRecord().toString() );
}
- private EscherSpgrRecord createRecord()
+ private static EscherSpgrRecord createRecord()
{
EscherSpgrRecord r = new EscherSpgrRecord();
r.setOptions( (short) 0x0010 );
r.setRectY2(4);
return r;
}
-
}
public class TestEscherSplitMenuColorsRecord extends TestCase
{
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
EscherSplitMenuColorsRecord r = createRecord();
byte[] data = new byte[24];
"02, 04, 00, 00, " +
"02, 00, 00, 00, " +
"02, 00, 00, 00, " +
- "01, 00, 00, 00, ]",
+ "01, 00, 00, 00]",
HexDump.toHex( data ) );
}
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String hexData = "40 00 " +
"1E F1 " +
"10 00 00 00 " +
assertEquals( 0x01, r.getColor4() );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + nl +
assertEquals( expected, createRecord().toString() );
}
- private EscherSplitMenuColorsRecord createRecord()
+ private static EscherSplitMenuColorsRecord createRecord()
{
EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
r.setOptions( (short) 0x0040 );
r.setColor4( 0x1 );
return r;
}
-
}
public class TestUnknownEscherRecord extends TestCase
{
- public void testFillFields() throws Exception
- {
+ public void testFillFields() {
String testData =
"0F 02 " + // options
"11 F1 " + // record id
}
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x1234 );
r.setRecordId( (short) 0xF112 );
byte[] data = new byte[8];
r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( "[34, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+ assertEquals( "[34, 12, 12, F1, 00, 00, 00, 00]", HexDump.toHex( data ) );
EscherRecord childRecord = new UnknownEscherRecord();
childRecord.setOptions( (short) 0x9999 );
data = new byte[16];
r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+ assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00]", HexDump.toHex( data ) );
}
- public void testToString() throws Exception
- {
+ public void testToString() {
UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x1234 );
r.setRecordId( (short) 0xF112 );
" numchildren: 0" + nl
, r.toString() );
}
-
-
}
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.util.HexDump;
-public class TestDrawingGroupRecord extends TestCase
-{
- static final int MAX_RECORD_SIZE = 8228;
+public final class TestDrawingGroupRecord extends TestCase {
+ private static final int MAX_RECORD_SIZE = 8228;
private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4;
- public void testGetRecordSize()
- throws Exception
- {
+ public void testGetRecordSize() {
DrawingGroupRecord r = new DrawingGroupRecord();
assertEquals(4, r.getRecordSize());
byte[] data = new byte[28];
int size = r.serialize(0, data);
- assertEquals("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF, ]", HexDump.toHex(data));
+ assertEquals("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF]", HexDump.toHex(data));
assertEquals(28, size);
assertEquals(24, dggContainer.getRecordSize());
assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() );
}
- public void testSerialize() throws Exception
- {
+ public void testSerialize() {
// Check under max record size
DrawingGroupRecord r = new DrawingGroupRecord();
byte[] rawData = new byte[100];
byte[] buffer = new byte[r.getRecordSize()];
int size = r.serialize( 0, buffer );
assertEquals( 104, size );
- assertEquals("[EB, 00, 64, 00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, C8, ]", HexDump.toHex(buffer));
+ assertEquals("[EB, 00, 64, 00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, C8]", HexDump.toHex(buffer));
// check at max record size
rawData = new byte[MAX_DATA_SIZE];
buffer = new byte[r.getRecordSize()];
size = r.serialize( 0, buffer );
assertEquals( MAX_RECORD_SIZE + 5, size );
- assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, 0, 4) ));
- assertEquals( "[00, EB, 00, 01, 00, FF, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5) ));
+ assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, 0, 4) ));
+ assertEquals( "[00, EB, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5) ));
// check continue record
rawData = new byte[MAX_DATA_SIZE * 2 + 1];
size = r.serialize( 0, buffer );
assertEquals( MAX_RECORD_SIZE * 2 + 5, size );
assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() );
- assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, 0, 4) ));
- assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 4) ));
- assertEquals( "[3C, 00, 01, 00, FF, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5) ));
+ assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, 0, 4) ));
+ assertEquals( "[EB, 00, 20, 20]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 4) ));
+ assertEquals( "[3C, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5) ));
// check continue record
rawData = new byte[664532];
assertEquals( 664856, r.getRecordSize() );
}
- private byte[] cut( byte[] data, int fromInclusive, int toExclusive )
+ private static byte[] cut( byte[] data, int fromInclusive, int toExclusive )
{
int length = toExclusive - fromInclusive;
byte[] result = new byte[length];
return result;
}
- public void testGrossSizeFromDataSize() throws Exception
- {
+ public void testGrossSizeFromDataSize() {
for (int i = 0; i < MAX_RECORD_SIZE * 4; i += 11)
{
//System.out.print( "data size = " + i + ", gross size = " + DrawingGroupRecord.grossSizeFromDataSize( i ) );
assertEquals( MAX_RECORD_SIZE * 2, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 ) );
assertEquals( MAX_RECORD_SIZE * 2 + 5, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 + 1 ) );
}
-
-
}
byte[] data = new byte[112];
int bytesWritten = aggregate.serialize( 0, data );
assertEquals( 112, bytesWritten );
- assertEquals( "[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, ]",
+ assertEquals( "[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00]",
HexDump.toHex( data ) );
}