Removed trailing comma from output of HexDump.toHex()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@694619 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-09-12 06:58:52 +00:00
parent a34edb4936
commit 64aed897ea
18 changed files with 110 additions and 178 deletions

View File

@ -255,8 +255,10 @@ public class HexDump {
retVal.append('['); retVal.append('[');
for(int x = 0; x < value.length; x++) for(int x = 0; x < value.length; x++)
{ {
if (x>0) {
retVal.append(", ");
}
retVal.append(toHex(value[x])); retVal.append(toHex(value[x]));
retVal.append(", ");
} }
retVal.append(']'); retVal.append(']');
return retVal.toString(); return retVal.toString();

View File

@ -172,9 +172,12 @@ public class HexRead
return rval; return rval;
} }
static public byte[] readFromString(String data) throws IOException static public byte[] readFromString(String data) {
{ try {
return readData(new ByteArrayInputStream( data.getBytes() ), -1); return readData(new ByteArrayInputStream( data.getBytes() ), -1);
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
static private void readToEOL( InputStream stream ) throws IOException static private void readToEOL( InputStream stream ) throws IOException

View File

@ -37,7 +37,7 @@ public class TestEscherBSERecord extends TestCase
assertEquals( (short) 0x0001, r.getOptions() ); assertEquals( (short) 0x0001, r.getOptions() );
assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeWin32() ); assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeWin32() );
assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeMacOS() ); 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( (short) 1, r.getTag() );
assertEquals( 2, r.getRef() ); assertEquals( 2, r.getRef() );
assertEquals( 3, r.getOffset() ); assertEquals( 3, r.getOffset() );
@ -57,7 +57,7 @@ public class TestEscherBSERecord extends TestCase
assertEquals( 44, bytesWritten ); assertEquals( 44, bytesWritten );
assertEquals( "[01, 00, 00, 00, 24, 00, 00, 00, 05, 05, 01, 02, 03, 04, " + 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, " + "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 ) ); HexDump.toHex( data ) );
} }
@ -90,7 +90,7 @@ public class TestEscherBSERecord extends TestCase
" Options: 0x0001" + nl + " Options: 0x0001" + nl +
" BlipTypeWin32: 5" + nl + " BlipTypeWin32: 5" + nl +
" BlipTypeMacOS: 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 + " Tag: 1" + nl +
" Size: 0" + nl + " Size: 0" + nl +
" Ref: 2" + nl + " Ref: 2" + nl +

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -36,8 +35,7 @@ public class TestEscherBlipWMFRecord extends TestCase
data = HexRead.readFromString(dataStr); data = HexRead.readFromString(dataStr);
} }
public void testSerialize() throws Exception public void testSerialize() {
{
EscherBlipWMFRecord r = new EscherBlipWMFRecord(); EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.setBoundaryLeft(1); r.setBoundaryLeft(1);
r.setBoundaryHeight(2); r.setBoundaryHeight(2);
@ -72,14 +70,13 @@ public class TestEscherBlipWMFRecord extends TestCase
"05, 00, 00, 00, " + // field_9_cacheOfSavedSize "05, 00, 00, 00, " + // field_9_cacheOfSavedSize
"08, " + // field_10_compressionFlag "08, " + // field_10_compressionFlag
"07, " + // field_11_filter "07, " + // field_11_filter
"01, 02, ]", // field_12_data "01, 02]", // field_12_data
HexDump.toHex(buf)); HexDump.toHex(buf));
assertEquals(60, r.getRecordSize() ); assertEquals(60, r.getRecordSize() );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
EscherBlipWMFRecord r = new EscherBlipWMFRecord(); EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.fillFields( data, 0, new DefaultEscherRecordFactory()); r.fillFields( data, 0, new DefaultEscherRecordFactory());
@ -92,15 +89,14 @@ public class TestEscherBlipWMFRecord extends TestCase
assertEquals( 6, r.getCacheOfSize() ); assertEquals( 6, r.getCacheOfSize() );
assertEquals( 7, r.getFilter() ); assertEquals( 7, r.getFilter() );
assertEquals( 8, r.getCompressionFlag() ); 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( 10, r.getWidth() );
assertEquals( 11, r.getHeight() ); assertEquals( 11, r.getHeight() );
assertEquals( (short)5420, r.getOptions() ); 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(); EscherBlipWMFRecord r = new EscherBlipWMFRecord();
r.fillFields( data, 0, new DefaultEscherRecordFactory() ); r.fillFields( data, 0, new DefaultEscherRecordFactory() );
@ -109,7 +105,7 @@ public class TestEscherBlipWMFRecord extends TestCase
assertEquals( "org.apache.poi.ddf.EscherBlipWMFRecord:" + nl + assertEquals( "org.apache.poi.ddf.EscherBlipWMFRecord:" + nl +
" RecordId: 0xF018" + nl + " RecordId: 0xF018" + nl +
" Options: 0x152C" + 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 + " CacheOfSize: 6" + nl +
" BoundaryTop: 3" + nl + " BoundaryTop: 3" + nl +
" BoundaryLeft: 1" + nl + " BoundaryLeft: 1" + nl +
@ -124,5 +120,5 @@ public class TestEscherBlipWMFRecord extends TestCase
"00000000 01 02 .." + nl "00000000 01 02 .." + nl
, r.toString() ); , r.toString() );
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherChildAnchorRecord extends TestCase public class TestEscherChildAnchorRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherChildAnchorRecord r = createRecord(); EscherChildAnchorRecord r = createRecord();
byte[] data = new byte[8 + 16]; byte[] data = new byte[8 + 16];
@ -37,7 +35,7 @@ public class TestEscherChildAnchorRecord extends TestCase
"01, 00, 00, 00, " + "01, 00, 00, 00, " +
"02, 00, 00, 00, " + "02, 00, 00, 00, " +
"03, 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 public void testFillFields() throws Exception
@ -62,8 +60,7 @@ public class TestEscherChildAnchorRecord extends TestCase
assertEquals( (short) 0x0001, r.getOptions() ); assertEquals( (short) 0x0001, r.getOptions() );
} }
public void testToString() throws Exception public void testToString(){
{
String nl = System.getProperty( "line.separator" ); String nl = System.getProperty( "line.separator" );
String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl + String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl +
@ -76,7 +73,7 @@ public class TestEscherChildAnchorRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherChildAnchorRecord createRecord() private static EscherChildAnchorRecord createRecord()
{ {
EscherChildAnchorRecord r = new EscherChildAnchorRecord(); EscherChildAnchorRecord r = new EscherChildAnchorRecord();
r.setRecordId( EscherChildAnchorRecord.RECORD_ID ); r.setRecordId( EscherChildAnchorRecord.RECORD_ID );
@ -87,5 +84,5 @@ public class TestEscherChildAnchorRecord extends TestCase
r.setDy2( 4 ); r.setDy2( 4 );
return r; return r;
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherClientAnchorRecord extends TestCase public class TestEscherClientAnchorRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherClientAnchorRecord r = createRecord(); EscherClientAnchorRecord r = createRecord();
byte[] data = new byte[8 + 18 + 2]; byte[] data = new byte[8 + 18 + 2];
@ -37,11 +35,10 @@ public class TestEscherClientAnchorRecord extends TestCase
"4D, 00, 37, 00, 21, 00, 58, 00, " + "4D, 00, 37, 00, 21, 00, 58, 00, " +
"0B, 00, 2C, 00, 16, 00, 63, 00, " + "0B, 00, 2C, 00, 16, 00, 63, 00, " +
"42, 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 " + String hexData = "01 00 " +
"10 F0 " + "10 F0 " +
"14 00 00 00 " + "14 00 00 00 " +
@ -68,8 +65,7 @@ public class TestEscherClientAnchorRecord extends TestCase
assertEquals( (byte) 0xDD, r.getRemainingData()[1] ); assertEquals( (byte) 0xDD, r.getRemainingData()[1] );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl + String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl +

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherClientDataRecord extends TestCase public class TestEscherClientDataRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherClientDataRecord r = createRecord(); EscherClientDataRecord r = createRecord();
byte[] data = new byte[8]; byte[] data = new byte[8];
@ -33,12 +31,11 @@ public class TestEscherClientDataRecord extends TestCase
assertEquals( 8, bytesWritten ); assertEquals( 8, bytesWritten );
assertEquals( "[02, 00, " + assertEquals( "[02, 00, " +
"11, F0, " + "11, F0, " +
"00, 00, 00, 00, ]", "00, 00, 00, 00]",
HexDump.toHex( data ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "02 00 " + String hexData = "02 00 " +
"11 F0 " + "11 F0 " +
"00 00 00 00 "; "00 00 00 00 ";
@ -51,8 +48,7 @@ public class TestEscherClientDataRecord extends TestCase
assertEquals( "[]", HexDump.toHex(r.getRemainingData()) ); assertEquals( "[]", HexDump.toHex(r.getRemainingData()) );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl + String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl +
@ -63,7 +59,7 @@ public class TestEscherClientDataRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherClientDataRecord createRecord() private static EscherClientDataRecord createRecord()
{ {
EscherClientDataRecord r = new EscherClientDataRecord(); EscherClientDataRecord r = new EscherClientDataRecord();
r.setOptions( (short) 0x0002 ); r.setOptions( (short) 0x0002 );
@ -71,5 +67,4 @@ public class TestEscherClientDataRecord extends TestCase
r.setRemainingData( new byte[] {} ); r.setRemainingData( new byte[] {} );
return r; return r;
} }
} }

View File

@ -30,13 +30,11 @@ public class TestEscherContainerRecord extends TestCase
{ {
private String ESCHER_DATA_PATH; private String ESCHER_DATA_PATH;
protected void setUp() throws Exception { protected void setUp() {
super.setUp();
ESCHER_DATA_PATH = System.getProperty("DDF.testdata.path"); ESCHER_DATA_PATH = System.getProperty("DDF.testdata.path");
} }
public void testFillFields() throws Exception public void testFillFields() {
{
EscherRecordFactory f = new DefaultEscherRecordFactory(); EscherRecordFactory f = new DefaultEscherRecordFactory();
byte[] data = HexRead.readFromString( "0F 02 11 F1 00 00 00 00" ); byte[] data = HexRead.readFromString( "0F 02 11 F1 00 00 00 00" );
EscherRecord r = f.createRecord( data, 0 ); EscherRecord r = f.createRecord( data, 0 );
@ -55,15 +53,14 @@ public class TestEscherContainerRecord extends TestCase
assertEquals( (short) 0xF222, c.getRecordId() ); assertEquals( (short) 0xF222, c.getRecordId() );
} }
public void testSerialize() throws Exception public void testSerialize() {
{
UnknownEscherRecord r = new UnknownEscherRecord(); UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x123F ); r.setOptions( (short) 0x123F );
r.setRecordId( (short) 0xF112 ); r.setRecordId( (short) 0xF112 );
byte[] data = new byte[8]; byte[] data = new byte[8];
r.serialize( 0, data, new NullEscherSerializationListener() ); 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(); EscherRecord childRecord = new UnknownEscherRecord();
childRecord.setOptions( (short) 0x9999 ); childRecord.setOptions( (short) 0x9999 );
@ -72,12 +69,11 @@ public class TestEscherContainerRecord extends TestCase
data = new byte[16]; data = new byte[16];
r.serialize( 0, data, new NullEscherSerializationListener() ); 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(); EscherContainerRecord r = new EscherContainerRecord();
r.setRecordId( EscherContainerRecord.SP_CONTAINER ); r.setRecordId( EscherContainerRecord.SP_CONTAINER );
r.setOptions( (short) 0x000F ); r.setOptions( (short) 0x000F );
@ -134,8 +130,7 @@ public class TestEscherContainerRecord extends TestCase
assertEquals( expected, r.toString() ); assertEquals( expected, r.toString() );
} }
public void testGetRecordSize() throws Exception public void testGetRecordSize() {
{
EscherContainerRecord r = new EscherContainerRecord(); EscherContainerRecord r = new EscherContainerRecord();
r.addChildRecord(new EscherRecord() r.addChildRecord(new EscherRecord()
{ {

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherDgRecord extends TestCase public class TestEscherDgRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherDgRecord r = createRecord(); EscherDgRecord r = createRecord();
byte[] data = new byte[16]; byte[] data = new byte[16];
@ -35,12 +33,11 @@ public class TestEscherDgRecord extends TestCase
"08, F0, " + "08, F0, " +
"08, 00, 00, 00, " + "08, 00, 00, 00, " +
"02, 00, 00, 00, " + // num shapes in drawing "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 ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "10 00 " + String hexData = "10 00 " +
"08 F0 " + "08 F0 " +
"08 00 00 00 " + "08 00 00 00 " +
@ -55,8 +52,7 @@ public class TestEscherDgRecord extends TestCase
assertEquals( 1025, r.getLastMSOSPID() ); assertEquals( 1025, r.getLastMSOSPID() );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl + String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl +
@ -67,7 +63,7 @@ public class TestEscherDgRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherDgRecord createRecord() private static EscherDgRecord createRecord()
{ {
EscherDgRecord r = new EscherDgRecord(); EscherDgRecord r = new EscherDgRecord();
r.setOptions( (short) 0x0010 ); r.setOptions( (short) 0x0010 );
@ -76,5 +72,4 @@ public class TestEscherDgRecord extends TestCase
r.setLastMSOSPID(1025); r.setLastMSOSPID(1025);
return r; return r;
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherDggRecord extends TestCase public class TestEscherDggRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherDggRecord r = createRecord(); EscherDggRecord r = createRecord();
byte[] data = new byte[32]; byte[] data = new byte[32];
@ -38,12 +36,11 @@ public class TestEscherDggRecord extends TestCase
"02, 00, 00, 00, " + "02, 00, 00, 00, " +
"02, 00, 00, 00, " + "02, 00, 00, 00, " +
"01, 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 ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "00 00 " + String hexData = "00 00 " +
"06 F0 " + "06 F0 " +
"18 00 00 00 " + "18 00 00 00 " +
@ -66,8 +63,7 @@ public class TestEscherDggRecord extends TestCase
assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed()); assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed());
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherDggRecord:" + nl + String expected = "org.apache.poi.ddf.EscherDggRecord:" + nl +
@ -82,7 +78,7 @@ public class TestEscherDggRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherDggRecord createRecord() private static EscherDggRecord createRecord()
{ {
EscherDggRecord r = new EscherDggRecord(); EscherDggRecord r = new EscherDggRecord();
r.setOptions( (short) 0x0000 ); r.setOptions( (short) 0x0000 );
@ -96,12 +92,9 @@ public class TestEscherDggRecord extends TestCase
return r; return r;
} }
public void testGetRecordSize() throws Exception public void testGetRecordSize() {
{
EscherDggRecord r = new EscherDggRecord(); EscherDggRecord r = new EscherDggRecord();
r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } ); r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
assertEquals(32,r.getRecordSize()); assertEquals(32,r.getRecordSize());
} }
} }

View File

@ -24,20 +24,16 @@ import org.apache.poi.util.HexDump;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
public class TestEscherOptRecord extends TestCase public class TestEscherOptRecord extends TestCase
{ {
public void testFillFields() throws Exception public void testFillFields() {
{
checkFillFieldsSimple(); checkFillFieldsSimple();
checkFillFieldsComplex(); checkFillFieldsComplex();
} }
private void checkFillFieldsComplex() throws IOException private void checkFillFieldsComplex() {
{
String dataStr = "33 00 " + String dataStr = "33 00 " +
"0B F0 " + "0B F0 " +
"14 00 00 00 " + "14 00 00 00 " +
@ -60,9 +56,7 @@ public class TestEscherOptRecord extends TestCase
} }
private void checkFillFieldsSimple() private void checkFillFieldsSimple() {
throws IOException
{
String dataStr = "33 00 " + // options String dataStr = "33 00 " + // options
"0B F0 " + // recordid "0B F0 " + // recordid
"12 00 00 00 " + // remaining bytes "12 00 00 00 " + // remaining bytes
@ -83,8 +77,7 @@ public class TestEscherOptRecord extends TestCase
assertEquals( prop3, r.getEscherProperty( 2 ) ); assertEquals( prop3, r.getEscherProperty( 2 ) );
} }
public void testSerialize() throws Exception public void testSerialize() {
{
checkSerializeSimple(); checkSerializeSimple();
checkSerializeComplex(); checkSerializeComplex();
} }
@ -111,7 +104,7 @@ public class TestEscherOptRecord extends TestCase
"BF, 00, 01, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " +
"01, 80, 02, 00, 00, 00, " + "01, 80, 02, 00, 00, 00, " +
"BF, 00, 01, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " +
"01, 02, ]"; "01, 02]";
assertEquals( dataStr, HexDump.toHex(data) ); assertEquals( dataStr, HexDump.toHex(data) );
} }
@ -135,13 +128,12 @@ public class TestEscherOptRecord extends TestCase
"12, 00, 00, 00, " + "12, 00, 00, 00, " +
"BF, 00, 01, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " +
"81, 01, 09, 00, 00, 08, " + "81, 01, 09, 00, 00, 08, " +
"C0, 01, 40, 00, 00, 08, ]"; "C0, 01, 40, 00, 00, 08]";
assertEquals( dataStr, HexDump.toHex(data) ); assertEquals( dataStr, HexDump.toHex(data) );
assertEquals( 26, bytesWritten ); assertEquals( 26, bytesWritten );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
EscherOptRecord r = new EscherOptRecord(); EscherOptRecord r = new EscherOptRecord();
r.setOptions((short)0x000F); r.setOptions((short)0x000F);
@ -162,8 +154,8 @@ public class TestEscherOptRecord extends TestCase
* Test serialisation of a particually complex example * Test serialisation of a particually complex example
* This test is currently broken! * This test is currently broken!
*/ */
public void testComplexSerialise() throws Exception { public void testComplexSerialise() {
byte[] data = new byte[] { byte[] data = {
0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00, 0x53, 0x01, 0x0B, 0xF0-256, 0x9C-256, 0x01, 0x00, 0x00,
// Simple data follows // Simple data follows
0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8 0x42, 0x01, 0x49, 0x00, 0x00, 0x00, // SP @ 8
@ -263,7 +255,7 @@ public class TestEscherOptRecord extends TestCase
* *
* See Bug 41946 for details. * See Bug 41946 for details.
*/ */
public void test41946() throws IOException { public void test41946() {
String dataStr1 = 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 " + "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 " + "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 " +
@ -315,7 +307,7 @@ public class TestEscherOptRecord extends TestCase
* Test that EscherOptRecord can properly read/write array properties * Test that EscherOptRecord can properly read/write array properties
* with empty complex part. * with empty complex part.
*/ */
public void testEmptyArrayProperty() throws IOException { public void testEmptyArrayProperty() {
EscherOptRecord r = new EscherOptRecord(); EscherOptRecord r = new EscherOptRecord();
EscherArrayProperty p = new EscherArrayProperty((short)(EscherProperties.FILL__SHADECOLORS + 0x8000), new byte[0] ); EscherArrayProperty p = new EscherArrayProperty((short)(EscherProperties.FILL__SHADECOLORS + 0x8000), new byte[0] );
assertEquals(0, p.getNumberOfElementsInArray()); assertEquals(0, p.getNumberOfElementsInArray());

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -30,8 +29,7 @@ import org.apache.poi.util.HexDump;
*/ */
public class TestEscherPropertyFactory extends TestCase public class TestEscherPropertyFactory extends TestCase
{ {
public void testCreateProperties() throws Exception public void testCreateProperties() {
{
String dataStr = "41 C1 " + // propid, complex ind String dataStr = "41 C1 " + // propid, complex ind
"03 00 00 00 " + // size of complex property "03 00 00 00 " + // size of complex property
"01 00 " + // propid, complex ind "01 00 " + // propid, complex ind
@ -46,15 +44,11 @@ public class TestEscherPropertyFactory extends TestCase
List props = f.createProperties( data, 0, (short)3 ); List props = f.createProperties( data, 0, (short)3 );
EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 ); EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 );
assertEquals( (short)0xC141, p1.getId() ); 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 ); EscherComplexProperty p3 = (EscherComplexProperty) props.get( 2 );
assertEquals( (short)0xC141, p3.getId() ); assertEquals( (short)0xC141, p3.getId() );
assertEquals( "[01, 02, 03, ]", HexDump.toHex( p3.getComplexData() ) ); assertEquals( "[01, 02, 03]", HexDump.toHex( p3.getComplexData() ) );
} }
} }

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherSpRecord extends TestCase public class TestEscherSpRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherSpRecord r = createRecord(); EscherSpRecord r = createRecord();
byte[] data = new byte[16]; byte[] data = new byte[16];
@ -35,12 +33,11 @@ public class TestEscherSpRecord extends TestCase
"0A, F0, " + "0A, F0, " +
"08, 00, 00, 00, " + "08, 00, 00, 00, " +
"00, 04, 00, 00, " + "00, 04, 00, 00, " +
"05, 00, 00, 00, ]", "05, 00, 00, 00]",
HexDump.toHex( data ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "02 00 " + String hexData = "02 00 " +
"0A F0 " + "0A F0 " +
"08 00 00 00 " + "08 00 00 00 " +
@ -55,8 +52,7 @@ public class TestEscherSpRecord extends TestCase
assertEquals( 0x05, r.getFlags() ); assertEquals( 0x05, r.getFlags() );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl + String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl +
@ -67,7 +63,7 @@ public class TestEscherSpRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherSpRecord createRecord() private static EscherSpRecord createRecord()
{ {
EscherSpRecord r = new EscherSpRecord(); EscherSpRecord r = new EscherSpRecord();
r.setOptions( (short) 0x0002 ); r.setOptions( (short) 0x0002 );

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with contributor license agreements. See the NOTICE file distributed with
@ -15,7 +14,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== */ ==================================================================== */
package org.apache.poi.ddf; package org.apache.poi.ddf;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -24,8 +23,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherSpgrRecord extends TestCase public class TestEscherSpgrRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherSpgrRecord r = createRecord(); EscherSpgrRecord r = createRecord();
byte[] data = new byte[24]; byte[] data = new byte[24];
@ -37,12 +35,11 @@ public class TestEscherSpgrRecord extends TestCase
"01, 00, 00, 00, " + // x "01, 00, 00, 00, " + // x
"02, 00, 00, 00, " + // y "02, 00, 00, 00, " + // y
"03, 00, 00, 00, " + // width "03, 00, 00, 00, " + // width
"04, 00, 00, 00, ]", // height "04, 00, 00, 00]", // height
HexDump.toHex( data ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "10 00 " + String hexData = "10 00 " +
"09 F0 " + "09 F0 " +
"10 00 00 00 " + "10 00 00 00 " +
@ -61,8 +58,7 @@ public class TestEscherSpgrRecord extends TestCase
assertEquals( 4, r.getRectY2() ); assertEquals( 4, r.getRectY2() );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + nl + String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + nl +
@ -72,11 +68,10 @@ public class TestEscherSpgrRecord extends TestCase
" RectY: 2" + nl + " RectY: 2" + nl +
" RectWidth: 3" + nl + " RectWidth: 3" + nl +
" RectHeight: 4" + nl; " RectHeight: 4" + nl;
;
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherSpgrRecord createRecord() private static EscherSpgrRecord createRecord()
{ {
EscherSpgrRecord r = new EscherSpgrRecord(); EscherSpgrRecord r = new EscherSpgrRecord();
r.setOptions( (short) 0x0010 ); r.setOptions( (short) 0x0010 );
@ -87,5 +82,4 @@ public class TestEscherSpgrRecord extends TestCase
r.setRectY2(4); r.setRectY2(4);
return r; return r;
} }
} }

View File

@ -24,8 +24,7 @@ import org.apache.poi.util.HexRead;
public class TestEscherSplitMenuColorsRecord extends TestCase public class TestEscherSplitMenuColorsRecord extends TestCase
{ {
public void testSerialize() throws Exception public void testSerialize() {
{
EscherSplitMenuColorsRecord r = createRecord(); EscherSplitMenuColorsRecord r = createRecord();
byte[] data = new byte[24]; byte[] data = new byte[24];
@ -37,12 +36,11 @@ public class TestEscherSplitMenuColorsRecord extends TestCase
"02, 04, 00, 00, " + "02, 04, 00, 00, " +
"02, 00, 00, 00, " + "02, 00, 00, 00, " +
"02, 00, 00, 00, " + "02, 00, 00, 00, " +
"01, 00, 00, 00, ]", "01, 00, 00, 00]",
HexDump.toHex( data ) ); HexDump.toHex( data ) );
} }
public void testFillFields() throws Exception public void testFillFields() {
{
String hexData = "40 00 " + String hexData = "40 00 " +
"1E F1 " + "1E F1 " +
"10 00 00 00 " + "10 00 00 00 " +
@ -61,8 +59,7 @@ public class TestEscherSplitMenuColorsRecord extends TestCase
assertEquals( 0x01, r.getColor4() ); assertEquals( 0x01, r.getColor4() );
} }
public void testToString() throws Exception public void testToString() {
{
String nl = System.getProperty("line.separator"); String nl = System.getProperty("line.separator");
String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + nl + String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + nl +
@ -76,7 +73,7 @@ public class TestEscherSplitMenuColorsRecord extends TestCase
assertEquals( expected, createRecord().toString() ); assertEquals( expected, createRecord().toString() );
} }
private EscherSplitMenuColorsRecord createRecord() private static EscherSplitMenuColorsRecord createRecord()
{ {
EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord(); EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
r.setOptions( (short) 0x0040 ); r.setOptions( (short) 0x0040 );
@ -87,5 +84,4 @@ public class TestEscherSplitMenuColorsRecord extends TestCase
r.setColor4( 0x1 ); r.setColor4( 0x1 );
return r; return r;
} }
} }

View File

@ -24,8 +24,7 @@ import org.apache.poi.util.HexDump;
public class TestUnknownEscherRecord extends TestCase public class TestUnknownEscherRecord extends TestCase
{ {
public void testFillFields() throws Exception public void testFillFields() {
{
String testData = String testData =
"0F 02 " + // options "0F 02 " + // options
"11 F1 " + // record id "11 F1 " + // record id
@ -82,15 +81,14 @@ public class TestUnknownEscherRecord extends TestCase
} }
public void testSerialize() throws Exception public void testSerialize() {
{
UnknownEscherRecord r = new UnknownEscherRecord(); UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x1234 ); r.setOptions( (short) 0x1234 );
r.setRecordId( (short) 0xF112 ); r.setRecordId( (short) 0xF112 );
byte[] data = new byte[8]; byte[] data = new byte[8];
r.serialize( 0, data, new NullEscherSerializationListener() ); 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(); EscherRecord childRecord = new UnknownEscherRecord();
childRecord.setOptions( (short) 0x9999 ); childRecord.setOptions( (short) 0x9999 );
@ -100,11 +98,10 @@ public class TestUnknownEscherRecord extends TestCase
data = new byte[16]; data = new byte[16];
r.serialize( 0, data, new NullEscherSerializationListener() ); 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(); UnknownEscherRecord r = new UnknownEscherRecord();
r.setOptions( (short) 0x1234 ); r.setOptions( (short) 0x1234 );
r.setRecordId( (short) 0xF112 ); r.setRecordId( (short) 0xF112 );
@ -119,6 +116,4 @@ public class TestUnknownEscherRecord extends TestCase
" numchildren: 0" + nl " numchildren: 0" + nl
, r.toString() ); , r.toString() );
} }
} }

View File

@ -22,14 +22,11 @@ import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.util.HexDump; import org.apache.poi.util.HexDump;
public class TestDrawingGroupRecord extends TestCase public final class TestDrawingGroupRecord extends TestCase {
{ private static final int MAX_RECORD_SIZE = 8228;
static final int MAX_RECORD_SIZE = 8228;
private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4; private static final int MAX_DATA_SIZE = MAX_RECORD_SIZE - 4;
public void testGetRecordSize() public void testGetRecordSize() {
throws Exception
{
DrawingGroupRecord r = new DrawingGroupRecord(); DrawingGroupRecord r = new DrawingGroupRecord();
assertEquals(4, r.getRecordSize()); assertEquals(4, r.getRecordSize());
@ -48,7 +45,7 @@ public class TestDrawingGroupRecord extends TestCase
byte[] data = new byte[28]; byte[] data = new byte[28];
int size = r.serialize(0, data); 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(28, size);
assertEquals(24, dggContainer.getRecordSize()); assertEquals(24, dggContainer.getRecordSize());
@ -65,8 +62,7 @@ public class TestDrawingGroupRecord extends TestCase
assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() ); assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() );
} }
public void testSerialize() throws Exception public void testSerialize() {
{
// Check under max record size // Check under max record size
DrawingGroupRecord r = new DrawingGroupRecord(); DrawingGroupRecord r = new DrawingGroupRecord();
byte[] rawData = new byte[100]; byte[] rawData = new byte[100];
@ -76,7 +72,7 @@ public class TestDrawingGroupRecord extends TestCase
byte[] buffer = new byte[r.getRecordSize()]; byte[] buffer = new byte[r.getRecordSize()];
int size = r.serialize( 0, buffer ); int size = r.serialize( 0, buffer );
assertEquals( 104, size ); 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 // check at max record size
rawData = new byte[MAX_DATA_SIZE]; rawData = new byte[MAX_DATA_SIZE];
@ -92,8 +88,8 @@ public class TestDrawingGroupRecord extends TestCase
buffer = new byte[r.getRecordSize()]; buffer = new byte[r.getRecordSize()];
size = r.serialize( 0, buffer ); size = r.serialize( 0, buffer );
assertEquals( MAX_RECORD_SIZE + 5, size ); assertEquals( MAX_RECORD_SIZE + 5, size );
assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, 0, 4) )); 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( "[00, EB, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5) ));
// check continue record // check continue record
rawData = new byte[MAX_DATA_SIZE * 2 + 1]; rawData = new byte[MAX_DATA_SIZE * 2 + 1];
@ -103,9 +99,9 @@ public class TestDrawingGroupRecord extends TestCase
size = r.serialize( 0, buffer ); size = r.serialize( 0, buffer );
assertEquals( MAX_RECORD_SIZE * 2 + 5, size ); assertEquals( MAX_RECORD_SIZE * 2 + 5, size );
assertEquals( MAX_RECORD_SIZE * 2 + 5, r.getRecordSize() ); 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, 0, 4) ));
assertEquals( "[EB, 00, 20, 20, ]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 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( "[3C, 00, 01, 00, FF]", HexDump.toHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5) ));
// check continue record // check continue record
rawData = new byte[664532]; rawData = new byte[664532];
@ -116,7 +112,7 @@ public class TestDrawingGroupRecord extends TestCase
assertEquals( 664856, r.getRecordSize() ); 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; int length = toExclusive - fromInclusive;
byte[] result = new byte[length]; byte[] result = new byte[length];
@ -124,8 +120,7 @@ public class TestDrawingGroupRecord extends TestCase
return result; return result;
} }
public void testGrossSizeFromDataSize() throws Exception public void testGrossSizeFromDataSize() {
{
for (int i = 0; i < MAX_RECORD_SIZE * 4; i += 11) for (int i = 0; i < MAX_RECORD_SIZE * 4; i += 11)
{ {
//System.out.print( "data size = " + i + ", gross size = " + DrawingGroupRecord.grossSizeFromDataSize( i ) ); //System.out.print( "data size = " + i + ", gross size = " + DrawingGroupRecord.grossSizeFromDataSize( i ) );
@ -139,6 +134,4 @@ public class TestDrawingGroupRecord extends TestCase
assertEquals( MAX_RECORD_SIZE * 2, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 ) ); assertEquals( MAX_RECORD_SIZE * 2, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 ) );
assertEquals( MAX_RECORD_SIZE * 2 + 5, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 + 1 ) ); assertEquals( MAX_RECORD_SIZE * 2 + 5, DrawingGroupRecord.grossSizeFromDataSize( MAX_DATA_SIZE * 2 + 1 ) );
} }
} }

View File

@ -133,7 +133,7 @@ public class TestEscherAggregate extends TestCase
byte[] data = new byte[112]; byte[] data = new byte[112];
int bytesWritten = aggregate.serialize( 0, data ); int bytesWritten = aggregate.serialize( 0, data );
assertEquals( 112, bytesWritten ); 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 ) ); HexDump.toHex( data ) );
} }