aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/apache/poi/ddf
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test/java/org/apache/poi/ddf')
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherBSERecord.java113
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherBlipRecord.java165
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherBoolProperty.java39
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherChildAnchorRecord.java94
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherClientAnchorRecord.java112
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherClientDataRecord.java77
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java234
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherDgRecord.java83
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherDggRecord.java112
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherDump.java137
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java320
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherProperty.java55
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherPropertyFactory.java52
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherSpRecord.java85
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherSpgrRecord.java93
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java93
-rw-r--r--main/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java165
17 files changed, 0 insertions, 2029 deletions
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherBSERecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherBSERecord.java
deleted file mode 100644
index 43edb89d0c..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherBSERecord.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.poi.poifs.storage.RawDataUtil;
-import org.apache.poi.sl.usermodel.PictureData;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherBSERecord {
- @Test
- void testFillFields() {
- String data = "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";
- EscherBSERecord r = new EscherBSERecord();
- int bytesWritten = r.fillFields( HexRead.readFromString( data ), 0, new DefaultEscherRecordFactory() );
- assertEquals( 44, bytesWritten );
- assertEquals( (short) 0x0001, r.getOptions() );
- assertEquals( PictureData.PictureType.JPEG.nativeId, r.getBlipTypeWin32() );
- assertEquals( PictureData.PictureType.JPEG.nativeId, r.getBlipTypeMacOS() );
- 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( (byte) 4, r.getUsage() );
- assertEquals( (byte) 5, r.getName() );
- assertEquals( (byte) 6, r.getUnused2() );
- assertEquals( (byte) 7, r.getUnused3() );
- assertEquals( 0, r.getRemainingData().length );
- }
-
- @Test
- void testSerialize() throws IOException {
- EscherBSERecord r = createRecord();
- String exp64 = "H4sIAAAAAAAAAGNkYP+gwsDAwMrKyMTMwsrGzsHJxc3Dy8fPwMgAAkxAzAzEICkAgs9OoSwAAAA=";
- byte[] expected = RawDataUtil.decompress(exp64);
-
- byte[] data = new byte[8 + 36];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals(data.length, bytesWritten);
- assertArrayEquals(expected, data);
- }
-
- private EscherBSERecord createRecord() {
- EscherBSERecord r = new EscherBSERecord();
- r.setOptions( (short) 0x0001 );
- r.setBlipTypeWin32( (byte)PictureData.PictureType.JPEG.nativeId );
- r.setBlipTypeMacOS( (byte)PictureData.PictureType.JPEG.nativeId );
- r.setUid( HexRead.readFromString( "01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00" ) );
- r.setTag( (short) 1 );
- r.setRef( 2 );
- r.setOffset( 3 );
- r.setUsage( (byte) 4 );
- r.setName( (byte) 5 );
- r.setUnused2( (byte) 6 );
- r.setUnused3( (byte) 7 );
- r.setRemainingData( new byte[0] );
- return r;
-
- }
-
- @Test
- void testToString() {
- EscherBSERecord record = createRecord();
- String expected =
- "{ /* BSE */\n" +
- "\t \"recordId\": -4089 /* 0xf007 */\n" +
- "\t, \"version\": 1\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 1\n" +
- "\t, \"recordSize\": 44 /* 0x0000002c */\n" +
- "\t, \"blipTypeWin32\": 5\n" +
- "\t, \"pictureTypeWin32\": \"JPEG\"\n" +
- "\t, \"blipTypeMacOS\": 5\n" +
- "\t, \"pictureTypeMacOS\": \"JPEG\"\n" +
- "\t, \"suid\": \"AQIDBAUGBwgJCgsMDQ4PAA==\"\n" +
- "\t, \"tag\": 1\n" +
- "\t, \"size\": 0\n" +
- "\t, \"ref\": 2\n" +
- "\t, \"offset\": 3\n" +
- "\t, \"usage\": 4\n" +
- "\t, \"name\": 5\n" +
- "\t, \"unused2\": 6\n" +
- "\t, \"unused3\": 7\n" +
- "\t, \"blipRecord\": null\n" +
- "\t, \"remainingData\": \"\"\n" +
- "}";
- String actual = record.toString().replace("\r", "");
- assertEquals( expected, actual );
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherBlipRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherBlipRecord.java
deleted file mode 100644
index a081f61c65..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherBlipRecord.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.poi.POIDataSamples;
-import org.apache.poi.sl.usermodel.PictureData;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test read/serialize of escher blip records
-*/
-final class TestEscherBlipRecord {
- private static final POIDataSamples _samples = POIDataSamples.getDDFInstance();
-
- //test reading/serializing of a PNG blip
- @Test
- void testReadPNG() {
- //provided in bug-44886
- byte[] data = _samples.readFile("Container.dat");
-
- EscherContainerRecord record = new EscherContainerRecord();
- record.fillFields(data, 0, new DefaultEscherRecordFactory());
- EscherContainerRecord bstore = (EscherContainerRecord)record.getChild(1);
- EscherBSERecord bse1 = (EscherBSERecord)bstore.getChild(0);
- assertEquals(PictureData.PictureType.PNG.nativeId, bse1.getBlipTypeWin32());
- assertEquals(PictureData.PictureType.PNG.nativeId, bse1.getBlipTypeMacOS());
- assertArrayEquals(new byte[]{
- 0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
- 0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
- }, bse1.getUid());
- assertEquals(255, bse1.getTag());
- assertEquals(32308, bse1.getSize());
-
- EscherBitmapBlip blip1 = (EscherBitmapBlip)bse1.getBlipRecord();
- assertEquals(0x6E00, blip1.getOptions());
- assertEquals(EscherBitmapBlip.RECORD_ID_PNG, blip1.getRecordId());
- assertArrayEquals(new byte[]{
- 0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC,
- 0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2
- }, blip1.getUID());
-
- //serialize and read again
- byte[] ser = bse1.serialize();
- EscherBSERecord bse2 = new EscherBSERecord();
- bse2.fillFields(ser, 0, new DefaultEscherRecordFactory());
- assertEquals(bse1.getRecordId(), bse2.getRecordId());
- assertEquals(bse1.getBlipTypeWin32(), bse2.getBlipTypeWin32());
- assertEquals(bse1.getBlipTypeMacOS(), bse2.getBlipTypeMacOS());
- assertArrayEquals(bse1.getUid(), bse2.getUid());
- assertEquals(bse1.getTag(), bse2.getTag());
- assertEquals(bse1.getSize(), bse2.getSize());
-
- EscherBitmapBlip blip2 = (EscherBitmapBlip)bse1.getBlipRecord();
- assertEquals(blip1.getOptions(), blip2.getOptions());
- assertEquals(blip1.getRecordId(), blip2.getRecordId());
- assertEquals(blip1.getUID(), blip2.getUID());
-
- assertArrayEquals(blip1.getPicturedata(), blip1.getPicturedata());
- }
-
- //test reading/serializing of a PICT metafile
- @Test
- void testReadPICT() {
- //provided in bug-44886
- byte[] data = _samples.readFile("Container.dat");
-
- EscherContainerRecord record = new EscherContainerRecord();
- record.fillFields(data, 0, new DefaultEscherRecordFactory());
- EscherContainerRecord bstore = (EscherContainerRecord)record.getChild(1);
- EscherBSERecord bse1 = (EscherBSERecord)bstore.getChild(1);
- //System.out.println(bse1);
- assertEquals(PictureData.PictureType.WMF.nativeId, bse1.getBlipTypeWin32());
- assertEquals(PictureData.PictureType.PICT.nativeId, bse1.getBlipTypeMacOS());
- assertArrayEquals(new byte[]{
- (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
- 0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
- }, bse1.getUid());
- assertEquals(255, bse1.getTag());
- assertEquals(1133, bse1.getSize());
-
- EscherMetafileBlip blip1 = (EscherMetafileBlip)bse1.getBlipRecord();
- assertEquals(0x5430, blip1.getOptions());
- assertEquals(EscherMetafileBlip.RECORD_ID_PICT, blip1.getRecordId());
- assertArrayEquals(new byte[]{
- 0x57, 0x32, 0x7B, (byte)0x91, 0x23, 0x5D, (byte)0xDB, 0x36,
- 0x7A, (byte)0xDB, (byte)0xFF, 0x17, (byte)0xFE, (byte)0xF3, (byte)0xA7, 0x05
- }, blip1.getUID());
- assertArrayEquals(new byte[]{
- (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F,
- 0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13
- }, blip1.getPrimaryUID());
-
- //serialize and read again
- byte[] ser = bse1.serialize();
- EscherBSERecord bse2 = new EscherBSERecord();
- bse2.fillFields(ser, 0, new DefaultEscherRecordFactory());
- assertEquals(bse1.getRecordId(), bse2.getRecordId());
- assertEquals(bse1.getOptions(), bse2.getOptions());
- assertEquals(bse1.getBlipTypeWin32(), bse2.getBlipTypeWin32());
- assertEquals(bse1.getBlipTypeMacOS(), bse2.getBlipTypeMacOS());
- assertArrayEquals(bse1.getUid(), bse2.getUid());
- assertEquals(bse1.getTag(), bse2.getTag());
- assertEquals(bse1.getSize(), bse2.getSize());
-
- EscherMetafileBlip blip2 = (EscherMetafileBlip)bse1.getBlipRecord();
- assertEquals(blip1.getOptions(), blip2.getOptions());
- assertEquals(blip1.getRecordId(), blip2.getRecordId());
- assertEquals(blip1.getUID(), blip2.getUID());
- assertEquals(blip1.getPrimaryUID(), blip2.getPrimaryUID());
-
- assertArrayEquals(blip1.getPicturedata(), blip1.getPicturedata());
- }
-
- //integral test: check that the read-write-read round trip is consistent
- @Test
- void testContainer() {
- byte[] data = _samples.readFile("Container.dat");
-
- EscherContainerRecord record = new EscherContainerRecord();
- record.fillFields(data, 0, new DefaultEscherRecordFactory());
-
- byte[] ser = record.serialize();
- assertArrayEquals(data, ser);
- }
-
- /**
- * The test data was created from pl031405.xls attached to Bugzilla #47143
- */
- @Test
- void test47143() {
- byte[] data = _samples.readFile("47143.dat");
- EscherBSERecord bse = new EscherBSERecord();
- bse.fillFields(data, 0, new DefaultEscherRecordFactory());
- bse.toString(); //assert that toString() works
- assertTrue(bse.getBlipRecord() instanceof EscherMetafileBlip);
-
- EscherMetafileBlip blip = (EscherMetafileBlip)bse.getBlipRecord();
- blip.toString(); //assert that toString() works
- byte[] remaining = blip.getRemainingData();
- assertNotNull(remaining);
-
- byte[] ser = bse.serialize(); //serialize and assert against the source data
- assertArrayEquals(data, ser);
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherBoolProperty.java b/main/src/test/java/org/apache/poi/ddf/TestEscherBoolProperty.java
deleted file mode 100644
index 4957c063d5..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherBoolProperty.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-final class TestEscherBoolProperty {
- @Test
- void testToString() {
- EscherBoolProperty p = new EscherBoolProperty(EscherPropertyTypes.GEOMETRY__FILLOK, 1);
- String expected =
- "{ /* GEOMETRY__FILLOK */\n" +
- "\t \"id\": 383 /* 0x017f */\n" +
- "\t, \"name\": \"geometry.fillok\"\n" +
- "\t, \"propertyNumber\": 383 /* 0x017f */\n" +
- "\t, \"propertySize\": 6\n" +
- "\t, \"flags\": 383 /* */ \n" +
- "\t, \"value\": 1\n" +
- "}";
- assertEquals(expected, p.toString().replace("\r", ""));
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherChildAnchorRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherChildAnchorRecord.java
deleted file mode 100644
index 9f24b6d18d..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherChildAnchorRecord.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherChildAnchorRecord {
- @Test
- void testSerialize() {
- EscherChildAnchorRecord r = createRecord();
-
- byte[] data = new byte[8 + 16];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( data.length, bytesWritten );
- assertEquals( "[01, 00, " +
- "0F, F0, " +
- "10, 00, 00, 00, " +
- "01, 00, 00, 00, " +
- "02, 00, 00, 00, " +
- "03, 00, 00, 00, " +
- "04, 00, 00, 00]", HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "01 00 " +
- "0F F0 " +
- "10 00 00 00 " +
- "01 00 00 00 " +
- "02 00 00 00 " +
- "03 00 00 00 " +
- "04 00 00 00 ";
-
- byte[] data = HexRead.readFromString( hexData );
- EscherChildAnchorRecord r = new EscherChildAnchorRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 24, bytesWritten );
- assertEquals( 1, r.getDx1() );
- assertEquals( 2, r.getDy1() );
- assertEquals( 3, r.getDx2() );
- assertEquals( 4, r.getDy2() );
- assertEquals( (short) 0x0001, r.getOptions() );
- }
-
- @Test
- void testToString(){
- String expected =
- "{ /* CHILD_ANCHOR */\n" +
- "\t \"recordId\": -4081 /* 0xf00f */\n" +
- "\t, \"version\": 1\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 1\n" +
- "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
- "\t, \"x1\": 1\n" +
- "\t, \"y1\": 2\n" +
- "\t, \"x2\": 3\n" +
- "\t, \"y2\": 4\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherChildAnchorRecord createRecord() {
- EscherChildAnchorRecord r = new EscherChildAnchorRecord();
- r.setRecordId( EscherChildAnchorRecord.RECORD_ID );
- r.setOptions( (short) 0x0001 );
- r.setDx1( 1 );
- r.setDy1( 2 );
- r.setDx2( 3 );
- r.setDy2( 4 );
- return r;
- }
-}
-
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherClientAnchorRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherClientAnchorRecord.java
deleted file mode 100644
index b931359e54..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherClientAnchorRecord.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-class TestEscherClientAnchorRecord {
- @Test
- void testSerialize() {
- EscherClientAnchorRecord r = createRecord();
-
- byte[] data = new byte[8 + 18 + 2];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 28, bytesWritten );
- assertEquals( "[01, 00, " +
- "10, F0, " +
- "14, 00, 00, 00, " +
- "4D, 00, 37, 00, 21, 00, 58, 00, " +
- "0B, 00, 2C, 00, 16, 00, 63, 00, " +
- "42, 00, " +
- "FF, DD]", HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "01 00 " +
- "10 F0 " +
- "14 00 00 00 " +
- "4D 00 37 00 21 00 58 00 " +
- "0B 00 2C 00 16 00 63 00 " +
- "42 00 " +
- "FF DD";
- byte[] data = HexRead.readFromString( hexData );
- EscherClientAnchorRecord r = new EscherClientAnchorRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 28, bytesWritten );
- assertEquals( (short) 55, r.getCol1() );
- assertEquals( (short) 44, r.getCol2() );
- assertEquals( (short) 33, r.getDx1() );
- assertEquals( (short) 22, r.getDx2() );
- assertEquals( (short) 11, r.getDy1() );
- assertEquals( (short) 66, r.getDy2() );
- assertEquals( (short) 77, r.getFlag() );
- assertEquals( (short) 88, r.getRow1() );
- assertEquals( (short) 99, r.getRow2() );
- assertEquals( (short) 0x0001, r.getOptions() );
- assertEquals( (byte) 0xFF, r.getRemainingData()[0] );
- assertEquals( (byte) 0xDD, r.getRemainingData()[1] );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* CLIENT_ANCHOR */\n" +
- "\t \"recordId\": -4080 /* 0xf010 */\n" +
- "\t, \"version\": 1\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 1\n" +
- "\t, \"recordSize\": 28 /* 0x0000001c */\n" +
- "\t, \"flag\": 77 /* 0x004d */\n" +
- "\t, \"col1\": 55 /* 0x0037 */\n" +
- "\t, \"dx1\": 33 /* 0x0021 */\n" +
- "\t, \"row1\": 88 /* 0x0058 */\n" +
- "\t, \"dy1\": 11 /* 0x000b */\n" +
- "\t, \"col2\": 44 /* 0x002c */\n" +
- "\t, \"dx2\": 22 /* 0x0016 */\n" +
- "\t, \"row2\": 99 /* 0x0063 */\n" +
- "\t, \"dy2\": 66 /* 0x0042 */\n" +
- "\t, \"remainingData\": \"/90=\"\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private EscherClientAnchorRecord createRecord()
- {
- EscherClientAnchorRecord r = new EscherClientAnchorRecord();
- r.setCol1( (short) 55 );
- r.setCol2( (short) 44 );
- r.setDx1( (short) 33 );
- r.setDx2( (short) 22 );
- r.setDy1( (short) 11 );
- r.setDy2( (short) 66 );
- r.setFlag( (short) 77 );
- r.setRow1( (short) 88 );
- r.setRow2( (short) 99 );
- r.setOptions( (short) 0x0001 );
- r.setRemainingData( new byte[]{(byte) 0xFF, (byte) 0xDD} );
- return r;
- }
-
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherClientDataRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherClientDataRecord.java
deleted file mode 100644
index f9ee5eaca1..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherClientDataRecord.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-class TestEscherClientDataRecord {
- @Test
- void testSerialize() {
- EscherClientDataRecord r = createRecord();
-
- byte[] data = new byte[8];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 8, bytesWritten );
- assertEquals( "[02, 00, " +
- "11, F0, " +
- "00, 00, 00, 00]",
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "02 00 " +
- "11 F0 " +
- "00 00 00 00 ";
- byte[] data = HexRead.readFromString( hexData );
- EscherClientDataRecord r = new EscherClientDataRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 8, bytesWritten );
- assertEquals( (short)0xF011, r.getRecordId() );
- assertEquals( "[]", HexDump.toHex(r.getRemainingData()) );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* CLIENT_DATA */\n" +
- "\t \"recordId\": -4079 /* 0xf011 */\n" +
- "\t, \"version\": 2\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 2\n" +
- "\t, \"recordSize\": 8\n" +
- "\t, \"remainingData\": \"\"\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherClientDataRecord createRecord()
- {
- EscherClientDataRecord r = new EscherClientDataRecord();
- r.setOptions( (short) 0x0002 );
- r.setRecordId( EscherClientDataRecord.RECORD_ID );
- r.setRemainingData( new byte[] {} );
- return r;
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java
deleted file mode 100644
index df13975197..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherContainerRecord.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-
-import org.apache.poi.POIDataSamples;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests for {@link EscherContainerRecord}
- */
-final class TestEscherContainerRecord {
- private static final POIDataSamples _samples = POIDataSamples.getDDFInstance();
-
- @Test
- void testFillFields() {
- EscherRecordFactory f = new DefaultEscherRecordFactory();
- byte[] data = HexRead.readFromString("0F 02 11 F1 00 00 00 00");
- EscherRecord r = f.createRecord(data, 0);
- r.fillFields(data, 0, f);
- assertTrue(r instanceof EscherContainerRecord);
- assertEquals((short) 0x020F, r.getOptions());
- assertEquals((short) 0xF111, r.getRecordId());
-
- data = HexRead.readFromString("0F 02 11 F1 08 00 00 00" +
- " 02 00 22 F2 00 00 00 00");
- r = f.createRecord(data, 0);
- r.fillFields(data, 0, f);
- EscherRecord c = r.getChild(0);
- assertFalse(c instanceof EscherContainerRecord);
- assertEquals((short) 0x0002, c.getOptions());
- assertEquals((short) 0xF222, c.getRecordId());
- }
-
- @Test
- 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));
-
- EscherRecord childRecord = new UnknownEscherRecord();
- childRecord.setOptions((short) 0x9999);
- childRecord.setRecordId((short) 0xFF01);
- r.addChildRecord(childRecord);
- 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));
-
- }
-
- @Test
- void testToString() {
- EscherContainerRecord r = new EscherContainerRecord();
- r.setRecordId(EscherContainerRecord.SP_CONTAINER);
- r.setOptions((short) 0x000F);
- String expected =
- "{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 8\n" +
- "\t, \"isContainer\": true\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
-
- EscherOptRecord r2 = new EscherOptRecord();
- // don't try to shoot in foot, please -- vlsergey
- // r2.setOptions((short) 0x9876);
- r2.setRecordId(EscherOptRecord.RECORD_ID);
-
- r.addChildRecord(r2);
- expected =
- "{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 16 /* 0x00000010 */\n" +
- "\t, \"isContainer\": true\n" +
- "\t, \"children\": [\n" +
- "\t\t{ /* OPT */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t]\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
-
- r.addChildRecord(r2);
- expected =
- "{ /* SP_CONTAINER */\n" +
- "\t \"recordId\": -4092 /* 0xf004 */\n" +
- "\t, \"version\": 15 /* 0x000f */\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 15 /* 0x000f */\n" +
- "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
- "\t, \"isContainer\": true\n" +
- "\t, \"children\": [\n" +
- "\t\t{ /* OPT */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t},\t\t{ /* OPT - index: 1 */\n" +
- "\t\t\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t\t\t, \"version\": 3\n" +
- "\t\t\t, \"instance\": 0\n" +
- "\t\t\t, \"options\": 3\n" +
- "\t\t\t, \"recordSize\": 8\n" +
- "\t\t\t, \"isContainer\": false\n" +
- "\t\t\t, \"properties\": [\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t]\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString());
- }
-
- private static final class DummyEscherRecord extends EscherRecord {
- public DummyEscherRecord() { }
- @Override
- public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) { return 0; }
- @Override
- public int serialize(int offset, byte[] data, EscherSerializationListener listener) { return 0; }
- @Override
- public int getRecordSize() { return 10; }
- @Override
- public String getRecordName() { return ""; }
- @Override
- public Enum getGenericRecordType() { return EscherRecordTypes.UNKNOWN; }
- @Override
- public DummyEscherRecord copy() { return null; }
- }
-
- @Test
- void testGetRecordSize() {
- EscherContainerRecord r = new EscherContainerRecord();
- r.addChildRecord(new DummyEscherRecord());
- assertEquals(18, r.getRecordSize());
- }
-
- /**
- * We were having problems with reading too much data on an UnknownEscherRecord,
- * but hopefully we now read the correct size.
- */
- @Test
- void testBug44857() {
- byte[] data = _samples.readFile("Container.dat");
-
- // This used to fail with an OutOfMemory
- EscherContainerRecord record = new EscherContainerRecord();
- record.fillFields(data, 0, new DefaultEscherRecordFactory());
-
- Class<?>[] exp = { EscherDggRecord.class, EscherContainerRecord.class, EscherOptRecord.class, EscherSplitMenuColorsRecord.class };
- Class<?>[] act = record.getChildRecords().stream().map(Object::getClass).toArray(Class[]::new);
- assertArrayEquals(exp, act);
- }
-
- /**
- * Ensure {@link EscherContainerRecord} doesn't spill its guts everywhere
- */
- @Test
- void testChildren() {
- EscherContainerRecord ecr = new EscherContainerRecord();
- List<EscherRecord> children0 = ecr.getChildRecords();
- assertEquals(0, children0.size());
-
- EscherRecord chA = new DummyEscherRecord();
- EscherRecord chB = new DummyEscherRecord();
- EscherRecord chC = new DummyEscherRecord();
-
- ecr.addChildRecord(chA);
- ecr.addChildRecord(chB);
- children0.add(chC);
-
- List<EscherRecord> children1 = ecr.getChildRecords();
- assertNotSame(children0, children1);
- assertEquals(2, children1.size());
- assertEquals(chA, children1.get(0));
- assertEquals(chB, children1.get(1));
-
- assertEquals(1, children0.size()); // first copy unchanged
-
- ecr.setChildRecords(children0);
- ecr.addChildRecord(chA);
- List<EscherRecord> children2 = ecr.getChildRecords();
- assertEquals(2, children2.size());
- assertEquals(chC, children2.get(0));
- assertEquals(chA, children2.get(1));
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherDgRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherDgRecord.java
deleted file mode 100644
index ad84a54585..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherDgRecord.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherDgRecord {
- @Test
- void testSerialize() {
- EscherDgRecord r = createRecord();
-
- byte[] data = new byte[16];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 16, bytesWritten );
- assertEquals( "[10, 00, " +
- "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
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "10 00 " +
- "08 F0 " +
- "08 00 00 00 " +
- "02 00 00 00 " +
- "01 04 00 00 ";
- byte[] data = HexRead.readFromString( hexData );
- EscherDgRecord r = new EscherDgRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 16, bytesWritten );
- assertEquals( 2, r.getNumShapes() );
- assertEquals( 1025, r.getLastMSOSPID() );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* DG */\n" +
- "\t \"recordId\": -4088 /* 0xf008 */\n" +
- "\t, \"version\": 0\n" +
- "\t, \"instance\": 1\n" +
- "\t, \"options\": 16 /* 0x0010 */\n" +
- "\t, \"recordSize\": 16 /* 0x00000010 */\n" +
- "\t, \"numShapes\": 2\n" +
- "\t, \"lastMSOSPID\": 1025 /* 0x00000401 */\n" +
- "\t, \"drawingGroupId\": 1\n" +
- "}";
- assertEquals( expected, createRecord().toString().replace("\r", "") );
- }
-
- private static EscherDgRecord createRecord()
- {
- EscherDgRecord r = new EscherDgRecord();
- r.setOptions( (short) 0x0010 );
- r.setRecordId( EscherDgRecord.RECORD_ID );
- r.setNumShapes(2);
- r.setLastMSOSPID(1025);
- return r;
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherDggRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherDggRecord.java
deleted file mode 100644
index f8f8b58115..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherDggRecord.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherDggRecord {
- @Test
- void testSerialize() {
- EscherDggRecord r = createRecord();
-
- byte[] data = new byte[32];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 32, bytesWritten );
- assertEquals( "[00, 00, " +
- "06, F0, " +
- "18, 00, 00, 00, " +
- "02, 04, 00, 00, " +
- "02, 00, 00, 00, " +
- "02, 00, 00, 00, " +
- "01, 00, 00, 00, " +
- "01, 00, 00, 00, 02, 00, 00, 00]",
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "00 00 " +
- "06 F0 " +
- "18 00 00 00 " +
- "02 04 00 00 " +
- "02 00 00 00 " +
- "02 00 00 00 " +
- "01 00 00 00 " +
- "01 00 00 00 02 00 00 00";
- byte[] data = HexRead.readFromString( hexData );
- EscherDggRecord r = new EscherDggRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 32, bytesWritten );
- assertEquals( 0x402, r.getShapeIdMax() );
- assertEquals( 0x02, r.getNumIdClusters() );
- assertEquals( 0x02, r.getNumShapesSaved() );
- assertEquals( 0x01, r.getDrawingsSaved() );
- assertEquals( 1, r.getFileIdClusters().length );
- assertEquals( 0x01, r.getFileIdClusters()[0].getDrawingGroupId());
- assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed());
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* DGG */\n" +
- "\t \"recordId\": -4090 /* 0xf006 */\n" +
- "\t, \"version\": 0\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 0\n" +
- "\t, \"recordSize\": 32 /* 0x00000020 */\n" +
- "\t, \"fileIdClusters\": [\n" +
- "\t{ /* FileIdCluster */\n" +
- "\t\t \"drawingGroupId\": 1\n" +
- "\t\t, \"numShapeIdUsed\": 2\n" +
- "\t}\t]\n" +
- "\t, \"shapeIdMax\": 1026 /* 0x00000402 */\n" +
- "\t, \"numIdClusters\": 2\n" +
- "\t, \"numShapesSaved\": 2\n" +
- "\t, \"drawingsSaved\": 1\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherDggRecord createRecord()
- {
- EscherDggRecord r = new EscherDggRecord();
- r.setOptions( (short) 0x0000 );
- r.setRecordId( EscherDggRecord.RECORD_ID );
- r.setShapeIdMax( 0x402 );
- r.setNumShapesSaved( 0x02 );
- r.setDrawingsSaved( 0x01 );
- r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] {
- new EscherDggRecord.FileIdCluster( 1, 2 )
- });
- return r;
- }
-
- @Test
- void testGetRecordSize() {
- EscherDggRecord r = new EscherDggRecord();
- r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
- assertEquals(32,r.getRecordSize());
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherDump.java b/main/src/test/java/org/apache/poi/ddf/TestEscherDump.java
deleted file mode 100644
index 088d346bae..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherDump.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.poi.POIDataSamples;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.poifs.storage.RawDataUtil;
-import org.apache.poi.util.IOUtils;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-class TestEscherDump {
- private static final String recordData =
- "H4sIAAAAAAAAAL2UaVCSWxjHX0SBChABLRXM1FxSEzXTzHK7dpVIcMmwxXCP9KaGTaWlGYLrtGmGmYEmYmqF2qIt4ppmjNG+" +
- "2dWulUtOUdq1NHjva8v90HT7eM+Z5znP/M9/zpk5v3mONgAoc5AANBDKeVDW0gQAjZkVCti3mKnpAExpB/m8AKTyEiTCNd2J" +
- "Z+O0o6W+srDCyH3DhzkgUAD76v86QNA4mKTMg4QfnUew/5qA29CZz6ALqGcSgNzOICB05gD1rhODJR2AZu3Ox3YOKAfVUPhH" +
- "ULtbpdVJ0ccdijw0pY1A56M3Jup7U15jp7X4PPTTecx92/MT9eZwtUICrLJvsB6z0fHG5qbw7mRpFRaOnPYJ6SqXd5AQMSKM" +
- "jceyMD4NsULkj1OwHncz5cO3pPvCXXPTMNdNa+kDfwku4q0RnFL8YGBI6N+oXHlgzCkGWGRdONJPK1PbusJrhBltylPBMm3e" +
- "G0kw6DGdLhoU3pmgJ6n1maC1fXrs0uUL6cWG/kGVm3MWHh3pALq4+PH55k7Uu3d+x85u9zxwIzfQuU+3TIG5SkOgrS1tCJb3" +
- "3nqHrxcx3XlJA6vZJ6Oi1ctaXppQyBQLbLLrPJaKKq+zIexFLrVdZM+r34pJJpNN1hSrWbM/lIyRmKpYRIi7CybTTUzBWt49" +
- "11HRM/VbCiZ6Gyt9TZmhGXPS75xYjpH366vhgLJu4ZoZfM+/4FvGaBZIE9aZ2SduMrUT4mJA4NpP8F2AhB+dT+D/jY/7DZ84" +
- "ULbaK4C4crJvZ4qej2+em2+Vni4mPluh2e5xyoGUWYRaoFnWubHcaX+L09Ya0ta4KrP13C2ozMyicr4ovY0fNhT2wfMF7ip8" +
- "/tD0u96myXcn92gtTnEuGfBJxY0lFG0mJxPWpknjNxmzWvzKj18rpjO4hhQXAtaRVSmJu+D8egI3RdQVXYxzRhs1+HE2iNvM" +
- "fVe2DsSjqJQbBdUajcaECC3/58MP97Q0Eo+GNTdKbhk1r7UJadrVj0rLplmAqU/BlGeXDObGLtl69vITp9tD25vVY9vUT17u" +
- "WTGW8idcxUDMMX2PHa8X6xzG0C5cGJcVth40m3ycwCpcfuP4OClu6IpysV/9QuvrdW/Yb3Qj6Ul7e3nybqemdkvLXsXG2N3v" +
- "qeVE0woXb06pLduuFWUv7NxY8jq1k63fcD5jvG/w/IE8eUNh0Pohz0WRx6tdOlf4XhlbF5pgfYYzn8w6cjYx/8rBXvtWNz8L" +
- "6uu+ig35t+dgOc4jOpLirmFPtjQdKHovGZ4Bff4LaIPLnx6cbnKFo8JHDoGpJ1+BwKGfgM6GhB+d+F/0acj3PiVEABoProzN" +
- "1dcsVo9TPoPIF+r9EQI0qtveV4WEI1YhFjfmLxDsyFJptHvx/0BD3bfKJY/XqlFTReyIko4tQSzFFRyGRbkyg7MyuCqTmsiA" +
- "mAgs3FGB0BOR7LzNuUYMC9QWaXyUTcxELLOFQvaRIQZ1HlgkJtE25Ohym/xzkqxqbFI1fWKsGgKq0m/q9kwkVDJAvdKM+7c8" +
- "wj8GVPdneU0GVaeLVO6Kd3T2lMQFRNeCRwUyx5LSIxI5RmIFNc2RnuSIfYOeOZ+0CwzE7BFTJO+5cVeUz2nDN7mMYUSYOZyv" +
- "SyyaRRydLKPYMmqFbS5K8RJ6vQNIGtiuI8AKCEgXsqV9Vz1tgvzovKiD2FPtpNgRlb0keoprdS+hnsP6ICwLBrE9dz26g2YP" +
- "DszibWNE7zW5xndwlsoqFRh87XTFw8BXiFdv0SDsGBnfNcOu/Qu7y7SLppfzLJq714byzYQ590BA+BN2xyDhR+fZX7CL/s5u" +
- "Q9f/8ccWX28U3BaGw9qTiSqDfOtHmXXZq8XiHXAYoz901c5V2lVulTXZEMqwnLq8+8ds95s0FFrdl73saRntr/UuUxFHY0WU" +
- "z5b333qXTe/NagSRrmqkqypoNG12Oz3nE5Yzyt7d05eY66Ci2oTR+rNS3K4OiClGK+07HWtFFLvAqv6sNkpFsLs4Wp8XfRp/" +
- "11oPk3uTQB0ftHg1C16KRTBl+AbCzVaYfx6VFlJ7GL7Jme8bVOku8FKZL0eGgMVk4qhEnpZogNrtFU5yEyswJ+LbHOKsOPCn" +
- "cT19LR+PfTgjN4CKCS5Es4LS+7nLt9hQ7ejwGQnEyxebOgJzlHjotWUACpoZsFkAgGqBeUDZAzB6h4N2MFCNhmIuFJMAgPsH" +
- "eJr+iZEHAAA=";
-
- private EscherDump dumper = new EscherDump();
- private ByteArrayOutputStream baos = new ByteArrayOutputStream();
- private PrintStream stream;
-
- @BeforeEach
- void setup() throws UnsupportedEncodingException {
- stream = new PrintStream(baos, true, StandardCharsets.UTF_8.name());
- }
-
- // simple test to at least cover some parts of the class
- @Test
- void testSimple() throws Exception {
- // Decode the stream to bytes
- byte[] bytes = RawDataUtil.decompress(recordData);
- // Dump the contents of escher to stream.
- dumper.dump(bytes, 0, bytes.length, stream);
- assertEquals(216, countProperties());
-
- baos.reset();
- dumper.dump(0, new byte[0], stream);
- assertEquals(0, countProperties());
-
- baos.reset();
- dumper.dump(new byte[0], 0, 0, stream);
- assertEquals(0, countProperties());
- }
-
- @Test
- void testWithData() {
- dumper.dump(8, new byte[] {0, 0, 0, 0, 0, 0, 0, 0}, stream);
- assertEquals(6, countProperties());
- }
-
- @Test
- void testWithSamplefile() throws Exception {
- //InputStream stream = HSSFTestDataSamples.openSampleFileStream(")
- byte[] data = POIDataSamples.getDDFInstance().readFile("Container.dat");
- dumper.dump(data.length, data, stream);
- assertEquals(127, countProperties());
-
- data = new byte[2586114];
- try (InputStream is = HSSFTestDataSamples.openSampleFileStream("44593.xls")) {
- int bytes = IOUtils.readFully(is, data);
- assertNotEquals(-1, bytes);
- dumper.dump(data, 0, bytes, stream);
- assertEquals(163, countProperties());
- }
- }
-
- @Test
- void testCopy() throws Exception {
- byte[] data1 = RawDataUtil.decompress(recordData);
-
- EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
- EscherRecord r = recordFactory.createRecord(data1, 0);
- r.fillFields(data1, recordFactory);
- EscherRecord r2 = r.copy();
- byte[] data2 = r2.serialize();
-
- assertArrayEquals(data1, data2);
- }
-
- private int countProperties() {
- String data = new String(baos.toByteArray(), StandardCharsets.UTF_8);
- Matcher matcher = Pattern.compile(",? \"[^\"]+\": ").matcher(data);
- int count = 0;
- while (matcher.find()) {
- count++;
- }
- return count;
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java
deleted file mode 100644
index c09dc223c2..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherOptRecord.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.io.IOException;
-
-import org.apache.poi.poifs.storage.RawDataUtil;
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherOptRecord {
-
- @Test
- void testFillFields() {
- checkFillFieldsSimple();
- checkFillFieldsComplex();
- }
-
- private void checkFillFieldsComplex() {
- String dataStr = "33 00 " +
- "0B F0 " +
- "14 00 00 00 " +
- "BF 00 01 00 00 00 " +
- "01 80 02 00 00 00 " +
- "BF 00 01 00 00 00 " +
- "01 02";
-
- EscherOptRecord r = new EscherOptRecord();
- r.fillFields( HexRead.readFromString( dataStr ), new DefaultEscherRecordFactory() );
- assertEquals( (short) 0x0033, r.getOptions() );
- assertEquals( (short) 0xF00B, r.getRecordId() );
- assertEquals( 3, r.getEscherProperties().size() );
- EscherBoolProperty prop1 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
- EscherComplexProperty prop2 = new EscherComplexProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, false, 2);
- prop2.setComplexData(new byte[] { 0x01, 0x02 });
- EscherBoolProperty prop3 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
- assertEquals( prop1, r.getEscherProperty( 0 ) );
- assertEquals( prop2, r.getEscherProperty( 1 ) );
- assertEquals( prop3, r.getEscherProperty( 2 ) );
-
- }
-
- private void checkFillFieldsSimple() {
- String dataStr = "33 00 " + // options
- "0B F0 " + // recordid
- "12 00 00 00 " + // remaining bytes
- "BF 00 08 00 08 00 " +
- "81 01 09 00 00 08 " +
- "C0 01 40 00 00 08";
-
- EscherOptRecord r = new EscherOptRecord();
- r.fillFields( HexRead.readFromString( dataStr ), new DefaultEscherRecordFactory() );
- assertEquals( (short) 0x0033, r.getOptions() );
- assertEquals( (short) 0xF00B, r.getRecordId() );
- assertEquals( 3, r.getEscherProperties().size() );
- EscherBoolProperty prop1 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296 );
- EscherRGBProperty prop2 = new EscherRGBProperty( EscherPropertyTypes.FILL__FILLCOLOR, 0x08000009 );
- EscherRGBProperty prop3 = new EscherRGBProperty( EscherPropertyTypes.LINESTYLE__COLOR, 0x08000040 );
- assertEquals( prop1, r.getEscherProperty( 0 ) );
- assertEquals( prop2, r.getEscherProperty( 1 ) );
- assertEquals( prop3, r.getEscherProperty( 2 ) );
- }
-
- @Test
- void testSerialize() {
- checkSerializeSimple();
- checkSerializeComplex();
- }
-
- private void checkSerializeComplex()
- {
- //Complex escher record
- EscherOptRecord r = new EscherOptRecord();
- r.setOptions( (short) 0x0033 );
- r.setRecordId( (short) 0xF00B );
- EscherBoolProperty prop1 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
- EscherComplexProperty prop2 = new EscherComplexProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, false, 2);
- prop2.setComplexData(new byte[] { 0x01, 0x02 });
- EscherBoolProperty prop3 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
- r.addEscherProperty( prop1 );
- r.addEscherProperty( prop2 );
- r.addEscherProperty( prop3 );
-
- byte[] data = new byte[28];
- int bytesWritten = r.serialize(0, data, new NullEscherSerializationListener() );
- assertEquals( 28, bytesWritten );
- String dataStr = "[33, 00, " +
- "0B, F0, " +
- "14, 00, 00, 00, " +
- "BF, 00, 01, 00, 00, 00, " +
- "BF, 80, 02, 00, 00, 00, " +
- "BF, 00, 01, 00, 00, 00, " +
- "01, 02]";
- assertEquals( dataStr, HexDump.toHex(data) );
-
- }
-
- private void checkSerializeSimple()
- {
- EscherOptRecord r = new EscherOptRecord();
- r.setOptions( (short) 0x0033 );
- r.setRecordId( (short) 0xF00B );
- EscherBoolProperty prop1 = new EscherBoolProperty( EscherPropertyTypes.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
- EscherRGBProperty prop2 = new EscherRGBProperty( EscherPropertyTypes.FILL__FILLCOLOR, 0x08000009 );
- EscherRGBProperty prop3 = new EscherRGBProperty( EscherPropertyTypes.LINESTYLE__COLOR, 0x08000040 );
- r.addEscherProperty( prop1 );
- r.addEscherProperty( prop2 );
- r.addEscherProperty( prop3 );
-
- byte[] data = new byte[26];
- int bytesWritten = r.serialize(0, data, new NullEscherSerializationListener() );
- String dataStr = "[33, 00, " +
- "0B, F0, " +
- "12, 00, 00, 00, " +
- "BF, 00, 01, 00, 00, 00, " +
- "81, 01, 09, 00, 00, 08, " +
- "C0, 01, 40, 00, 00, 08]";
- assertEquals( dataStr, HexDump.toHex(data) );
- assertEquals( 26, bytesWritten );
- }
-
- @Test
- void testToString() {
- EscherOptRecord r = new EscherOptRecord();
- // don't try to shoot in foot, please -- vlsergey
- // r.setOptions((short)0x000F);
- r.setRecordId(EscherOptRecord.RECORD_ID);
- EscherProperty prop1 = new EscherBoolProperty(EscherPropertyTypes.GEOMETRY__FILLOK, 1);
- r.addEscherProperty(prop1);
- String expected =
- "{ /* OPT */\n" +
- "\t \"recordId\": -4085 /* 0xf00b */\n" +
- "\t, \"version\": 3\n" +
- "\t, \"instance\": 1\n" +
- "\t, \"options\": 19 /* 0x0013 */\n" +
- "\t, \"recordSize\": 14 /* 0x0000000e */\n" +
- "\t, \"isContainer\": false\n" +
- "\t, \"properties\": [\n" +
- "\t{ /* GEOMETRY__FILLOK */\n" +
- "\t\t \"id\": 383 /* 0x017f */\n" +
- "\t\t, \"name\": \"geometry.fillok\"\n" +
- "\t\t, \"propertyNumber\": 383 /* 0x017f */\n" +
- "\t\t, \"propertySize\": 6\n" +
- "\t\t, \"flags\": 383 /* */ \n" +
- "\t\t, \"value\": 1\n" +
- "\t}\t]\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, r.toString());
- }
-
- /**
- * Test serialization of a particularly complex example
- * This test is currently broken!
- */
- @Test
- 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
- 0x43, 0x01, 0x85-256, 0x00, 0x00, 0x00, // SP @ 14
- 0x44, 0x01, 0x04, 0x00, 0x00, 0x00, // SP @ 20
- 0x45, 0xC1-256, 0x88-256, 0x00, 0x00, 0x00, // SP @ 26
- 0x46, 0xC1-256, 0x90-256, 0x00, 0x00, 0x00, // SP @ 32
- 0x7F, 0x01, 0x01, 0x00, 0x01, 0x00,
- 0x80-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x81-256, 0x01, 0x02, 0x00, 0x00, 0x08,
- 0xBF-256, 0x01, 0x10, 0x00, 0x10, 0x00,
- 0xC0-256, 0x01, 0x01, 0x00, 0x00, 0x08, // SP 10
- 0xC1-256, 0x01, 0x00, 0x00, 0x01, 0x00,
- 0xC4-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xCB-256, 0x01, 0x38, 0x63, 0x00, 0x00,
- 0xCD-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xCE-256, 0x01, 0x00, 0x00, 0x00, 0x00, // SP 15
- 0xD0-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD1-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xD7-256, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0xFF-256, 0x01, 0x18, 0x00, 0x18, 0x00,
- 0x01, 0x02, 0x02, 0x00, 0x00, 0x08,
- 0x3F, 0x02, 0x00, 0x00, 0x02, 0x00, // SP 21
-
- // Complex data follows
-
- // Complex data for Array #325
- // Array header
- 0x22, 0x00, 0x22, 0x00, 0xF0-256, 0xFF-256,
- // Array data
- 0x18, 0x00, 0x28, 0x00, 0x04, 0x00, 0x34,
- 0x00, 0x04, 0x00, 0x28, 0x00, 0x04, 0x00,
- 0x1C, 0x00, 0x04, 0x00, 0x10, 0x00, 0x04, 0x00, 0x04, 0x00, 0x10,
- 0x00, 0x00, 0x00, 0x1C, 0x00,
- 0x04, 0x00, 0x28, 0x00, 0x10, 0x00, 0x34, 0x00, 0x18, 0x00, 0x3C,
- 0x00, 0x24, 0x00, 0x44, 0x00,
- 0x30, 0x00, 0x48, 0x00, 0x3C, 0x00, 0x44, 0x00, 0x48, 0x00, 0x3C,
- 0x00, 0x54, 0x00, 0x38, 0x00,
- 0x60, 0x00, 0x2C, 0x00, 0x70, 0x00, 0x20, 0x00, 0x78, 0x00,
- 0x14, 0x00, 0x80-256, 0x00, 0x08, 0x00,
- 0x84-256, 0x00, 0x04, 0x00, 0x78, 0x00, 0x04, 0x00, 0x6C, 0x00,
- 0x04, 0x00, 0x60, 0x00, 0x04, 0x00,
- 0x54, 0x00, 0x08, 0x00, 0x48, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0x0C,
- 0x00, 0x30, 0x00, 0x08, 0x00,
- 0x3C, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00, 0x54, 0x00, 0x00,
- 0x00, 0x48, 0x00, 0x00, 0x00,
- 0x3C, 0x00, 0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x24, 0x00,
- // Complex data for Array #326
- // Array header
- 0x45, 0x00, 0x48, 0x00, 0x02, 0x00,
- // Array data
- 0x00, 0x40, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00,
- 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256,
- 0x01, 0x00, 0x00, 0xB0-256, 0x01, 0x00, 0x00, 0xB0-256, 0x00, 0x80-256
- };
-
- // Create the record
- EscherOptRecord r = new EscherOptRecord();
- int filled = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- // Check it's the right length
- assertEquals(data.length, filled);
- assertEquals(data.length, r.getRecordSize());
-
- // Serialize it
- byte[] dest = new byte[data.length];
- int written = r.serialize(0, dest);
-
- // Check it serialised it back to the same data
- assertEquals(data.length, written);
- assertArrayEquals(data, dest);
- }
-
- /**
- * Test read/write against an OPT record from a real ppt file.
- * In PowerPoint it is legal to have array properties with empty complex part.
- * In Glen's original implementation complex part is always 6 bytes which resulted
- * in +6 extra bytes when writing back out. As the result the ppt becomes unreadable.
- *
- * Make sure we write back the original empty complex part.
- *
- * See Bug 41946 for details.
- */
- @Test
- void test41946() throws IOException {
- String data64 =
- "H4sIAAAAAAAAAB3SuW5TQRjF8TPfOOZCHMeARAluEKIzSEgUSCQsLaLgDYCehgIJCe8L+xIgQB6"+
- "AEvEAOI6zOwlhX54BpBRIiGqY+Vvy7x6d+3k8nmufje/ISzVVrjrVNftWapCb5JbSqyMX7ZJ72I"+
- "/vSRXcH6k0kW6Wi1hNquZyUlaP2amRmqxJbjHTnmbNQbLLfA9v4x28i/fwPj7Ah/gIH+MTnMGn+"+
- "Ayfs/4s+QW+xFc45+KPnuq7gg5q3sUqG7DDBRdC0JB9LjK5xG6XWW2FZhXXcB1H7sRhaSMto02a"+
- "LXzPp745iwaXV1FKUc7iJTMbjUbyqSnnLH37mJ28LOVxF5MZ7ubuHvI4FmgmyEWctPSQSuS9eDr"+
- "qVSXXmK/bWMwNmzsmNelbtvMvrza5Y3/jAl320zcXn+88/QAX7Ep0SF7EJVzGFVzFNVy3yvV4Mr"+
- "a9b782rPL7V9i0qUs9bZmq8WSiIWzHyRvhgx2P8x+tfEH6ZBeH0mdW+GKlI9JXuzYTz9DenArhO"+
- "/0P+p/0wQ7okHI+Hfe0f33U6YxPM2d9upzzN985nae55dM/tknTommTO+T/V9IPpAgDAAA=";
-
- EscherOptRecord r = new EscherOptRecord();
- byte[] data = RawDataUtil.decompress(data64);
- r.fillFields( data, 0, new DefaultEscherRecordFactory() );
- assertEquals( (short) 0xF00B, r.getRecordId() );
-
- byte[] data1 = r.serialize();
- EscherOptRecord opt2 = new EscherOptRecord();
- opt2.fillFields( data1, new DefaultEscherRecordFactory() );
-
- byte[] data2 = opt2.serialize();
- assertArrayEquals(data1, data2);
- }
-
- /**
- * Test that EscherOptRecord can properly read/write array properties
- * with empty complex part.
- */
- @Test
- void testEmptyArrayProperty() {
- EscherOptRecord r = new EscherOptRecord();
- EscherArrayProperty p = new EscherArrayProperty(EscherPropertyTypes.FILL__SHADECOLORS, false, 0);
- assertEquals(0, p.getNumberOfElementsInArray());
- r.addEscherProperty(p);
-
- byte[] data1 = r.serialize();
- EscherOptRecord opt2 = new EscherOptRecord();
- opt2.fillFields( data1, new DefaultEscherRecordFactory() );
- p = (EscherArrayProperty)opt2.getEscherProperties().get(0);
- assertEquals(0, p.getNumberOfElementsInArray());
-
- byte[] data2 = opt2.serialize();
- assertArrayEquals(data1, data2);
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherProperty.java b/main/src/test/java/org/apache/poi/ddf/TestEscherProperty.java
deleted file mode 100644
index 99f508224f..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherProperty.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.junit.jupiter.api.Test;
-
-
-class TestEscherProperty {
- /**
- * assure that EscherProperty.getName() returns correct name for complex properties
- * See Bugzilla 50401
- */
- @Test
- void testPropertyNames() throws Exception {
- EscherProperty p1 = new EscherSimpleProperty( EscherPropertyTypes.GROUPSHAPE__SHAPENAME, 0);
- assertEquals("groupshape.shapename", p1.getName());
- assertEquals(EscherPropertyTypes.GROUPSHAPE__SHAPENAME.propNumber, p1.getPropertyNumber());
- assertFalse(p1.isComplex());
-
- EscherComplexProperty p2 = new EscherComplexProperty(
- EscherPropertyTypes.GROUPSHAPE__SHAPENAME, false, 10);
- p2.setComplexData(new byte[10]);
- assertEquals("groupshape.shapename", p2.getName());
- assertEquals(EscherPropertyTypes.GROUPSHAPE__SHAPENAME.propNumber, p2.getPropertyNumber());
- assertTrue(p2.isComplex());
- assertFalse(p2.isBlipId());
-
- EscherComplexProperty p3 = new EscherComplexProperty(
- EscherPropertyTypes.GROUPSHAPE__SHAPENAME, true, 10);
- p2.setComplexData(new byte[10]);
- assertEquals("groupshape.shapename", p3.getName());
- assertEquals(EscherPropertyTypes.GROUPSHAPE__SHAPENAME.propNumber, p3.getPropertyNumber());
- assertTrue(p3.isComplex());
- assertTrue(p3.isBlipId());
- }
-} \ No newline at end of file
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherPropertyFactory.java b/main/src/test/java/org/apache/poi/ddf/TestEscherPropertyFactory.java
deleted file mode 100644
index ec94ba15d4..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherPropertyFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.List;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-class TestEscherPropertyFactory {
- @Test
- void testCreateProperties() {
- String dataStr = "41 C1 " + // propid, complex ind
- "03 00 00 00 " + // size of complex property
- "01 00 " + // propid, complex ind
- "00 00 00 00 " + // value
- "41 C1 " + // propid, complex ind
- "03 00 00 00 " + // size of complex property
- "01 02 03 " +
- "01 02 03 "
- ;
- byte[] data = HexRead.readFromString( dataStr );
- EscherPropertyFactory f = new EscherPropertyFactory();
- List<EscherProperty> 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() ) );
-
- EscherComplexProperty p3 = (EscherComplexProperty) props.get( 2 );
- assertEquals( (short)0xC141, p3.getId() );
- assertEquals( "[01, 02, 03]", HexDump.toHex( p3.getComplexData() ) );
- }
-}
-
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherSpRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherSpRecord.java
deleted file mode 100644
index 4e18b641d3..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherSpRecord.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-class TestEscherSpRecord {
- @Test
- void testSerialize() {
- EscherSpRecord r = createRecord();
-
- byte[] data = new byte[16];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 16, bytesWritten );
- assertEquals( "[02, 00, " +
- "0A, F0, " +
- "08, 00, 00, 00, " +
- "00, 04, 00, 00, " +
- "05, 00, 00, 00]",
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "02 00 " +
- "0A F0 " +
- "08 00 00 00 " +
- "00 04 00 00 " +
- "05 00 00 00 ";
- byte[] data = HexRead.readFromString( hexData );
- EscherSpRecord r = new EscherSpRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 16, bytesWritten );
- assertEquals( 0x0400, r.getShapeId() );
- assertEquals( 0x05, r.getFlags() );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* SP */\n" +
- "\t \"recordId\": -4086 /* 0xf00a */\n" +
- "\t, \"version\": 2\n" +
- "\t, \"instance\": 0\n" +
- "\t, \"options\": 2\n" +
- "\t, \"recordSize\": 16 /* 0x00000010 */\n" +
- "\t, \"shapeType\": 0\n" +
- "\t, \"shapeId\": 1024 /* 0x00000400 */\n" +
- "\t, \"flags\": 5 /* GROUP | PATRIARCH */ \n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherSpRecord createRecord()
- {
- EscherSpRecord r = new EscherSpRecord();
- r.setOptions( (short) 0x0002 );
- r.setRecordId( EscherSpRecord.RECORD_ID );
- r.setShapeId(0x0400);
- r.setFlags(0x05);
- return r;
- }
-
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherSpgrRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherSpgrRecord.java
deleted file mode 100644
index 8aa7aa86d9..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherSpgrRecord.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherSpgrRecord {
- @Test
- void testSerialize() {
- EscherSpgrRecord r = createRecord();
-
- byte[] data = new byte[24];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 24, bytesWritten );
- assertEquals( "[10, 00, " +
- "09, F0, " +
- "10, 00, 00, 00, " +
- "01, 00, 00, 00, " + // x
- "02, 00, 00, 00, " + // y
- "03, 00, 00, 00, " + // width
- "04, 00, 00, 00]", // height
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "10 00 " +
- "09 F0 " +
- "10 00 00 00 " +
- "01 00 00 00 " +
- "02 00 00 00 " +
- "03 00 00 00 " +
- "04 00 00 00 ";
- byte[] data = HexRead.readFromString( hexData );
- EscherSpgrRecord r = new EscherSpgrRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 24, bytesWritten );
- assertEquals( 1, r.getRectX1() );
- assertEquals( 2, r.getRectY1() );
- assertEquals( 3, r.getRectX2() );
- assertEquals( 4, r.getRectY2() );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* SPGR */\n" +
- "\t \"recordId\": -4087 /* 0xf009 */\n" +
- "\t, \"version\": 0\n" +
- "\t, \"instance\": 1\n" +
- "\t, \"options\": 16 /* 0x0010 */\n" +
- "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
- "\t, \"rectX1\": 1\n" +
- "\t, \"rectY1\": 2\n" +
- "\t, \"rectX2\": 3\n" +
- "\t, \"rectY2\": 4\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherSpgrRecord createRecord()
- {
- EscherSpgrRecord r = new EscherSpgrRecord();
- r.setOptions( (short) 0x0010 );
- r.setRecordId( EscherSpgrRecord.RECORD_ID );
- r.setRectX1(1);
- r.setRectY1(2);
- r.setRectX2(3);
- r.setRectY2(4);
- return r;
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java b/main/src/test/java/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java
deleted file mode 100644
index 1aa96edc5c..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestEscherSplitMenuColorsRecord {
- @Test
- void testSerialize() {
- EscherSplitMenuColorsRecord r = createRecord();
-
- byte[] data = new byte[24];
- int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
- assertEquals( 24, bytesWritten );
- assertEquals( "[40, 00, " +
- "1E, F1, " +
- "10, 00, 00, 00, " +
- "02, 04, 00, 00, " +
- "02, 00, 00, 00, " +
- "02, 00, 00, 00, " +
- "01, 00, 00, 00]",
- HexDump.toHex( data ) );
- }
-
- @Test
- void testFillFields() {
- String hexData = "40 00 " +
- "1E F1 " +
- "10 00 00 00 " +
- "02 04 00 00 " +
- "02 00 00 00 " +
- "02 00 00 00 " +
- "01 00 00 00 ";
- byte[] data = HexRead.readFromString( hexData );
- EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
- int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
-
- assertEquals( 24, bytesWritten );
- assertEquals( 0x0402, r.getColor1() );
- assertEquals( 0x02, r.getColor2() );
- assertEquals( 0x02, r.getColor3() );
- assertEquals( 0x01, r.getColor4() );
- }
-
- @Test
- void testToString() {
- String expected =
- "{ /* SPLIT_MENU_COLORS */\n" +
- "\t \"recordId\": -3810 /* 0xf11e */\n" +
- "\t, \"version\": 0\n" +
- "\t, \"instance\": 4\n" +
- "\t, \"options\": 64 /* 0x0040 */\n" +
- "\t, \"recordSize\": 24 /* 0x00000018 */\n" +
- "\t, \"color1\": 1026 /* 0x00000402 */\n" +
- "\t, \"color2\": 2\n" +
- "\t, \"color3\": 2\n" +
- "\t, \"color4\": 1\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals( expected, createRecord().toString() );
- }
-
- private static EscherSplitMenuColorsRecord createRecord()
- {
- EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
- r.setOptions( (short) 0x0040 );
- r.setRecordId( EscherSplitMenuColorsRecord.RECORD_ID );
- r.setColor1( 0x402 );
- r.setColor2( 0x2 );
- r.setColor3( 0x2 );
- r.setColor4( 0x1 );
- return r;
- }
-}
diff --git a/main/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java b/main/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java
deleted file mode 100644
index d84f8bccee..0000000000
--- a/main/src/test/java/org/apache/poi/ddf/TestUnknownEscherRecord.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ddf;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.poi.util.HexDump;
-import org.apache.poi.util.HexRead;
-import org.junit.jupiter.api.Test;
-
-final class TestUnknownEscherRecord {
- @Test
- void testFillFields() {
- String testData =
- "0F 02 " + // options
- "11 F1 " + // record id
- "00 00 00 00"; // remaining bytes
-
- UnknownEscherRecord r = new UnknownEscherRecord();
- EscherRecordFactory factory = new DefaultEscherRecordFactory();
- r.fillFields( HexRead.readFromString( testData ), factory );
-
- assertEquals( 0x020F, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertTrue( r.isContainerRecord() );
- assertEquals( 8, r.getRecordSize() );
- assertEquals( 0, r.getChildRecords().size() );
- assertEquals( 0, r.getData().length );
-
- testData =
- "00 02 " + // options
- "11 F1 " + // record id
- "04 00 00 00 " + // remaining bytes
- "01 02 03 04";
-
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
-
- assertEquals( 0x0200, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 12, r.getRecordSize() );
- assertFalse( r.isContainerRecord() );
- assertEquals( 0, r.getChildRecords().size() );
- assertEquals( 4, r.getData().length );
- assertEquals( 1, r.getData()[0] );
- assertEquals( 2, r.getData()[1] );
- assertEquals( 3, r.getData()[2] );
- assertEquals( 4, r.getData()[3] );
-
- testData =
- "0F 02 " + // options
- "11 F1 " + // record id
- "08 00 00 00 " + // remaining bytes
- "00 02 " + // options
- "FF FF " + // record id
- "00 00 00 00"; // remaining bytes
-
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
-
- assertEquals( 0x020F, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 8, r.getRecordSize() );
- assertTrue( r.isContainerRecord() );
- assertEquals( 1, r.getChildRecords().size() );
- assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
-
- //Add by Zhang Zhang test error situation when remaining bytes > avalible bytes
- testData =
- "00 02 " + // options
- "11 F1 " + // record id
- "05 00 00 00 " + // remaining bytes
- "01 02 03 04";
-
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
-
- assertEquals( 0x0200, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 12, r.getRecordSize() );
- assertFalse( r.isContainerRecord() );
- assertEquals( 0, r.getChildRecords().size() );
- assertEquals( 4, r.getData().length );
- assertEquals( 1, r.getData()[0] );
- assertEquals( 2, r.getData()[1] );
- assertEquals( 3, r.getData()[2] );
- assertEquals( 4, r.getData()[3] );
-
- testData =
- "0F 02 " + // options
- "11 F1 " + // record id
- "09 00 00 00 " + // remaining bytes
- "00 02 " + // options
- "FF FF " + // record id
- "00 00 00 00"; // remaining bytes
-
- r = new UnknownEscherRecord();
- r.fillFields( HexRead.readFromString( testData ), factory );
-
- assertEquals( 0x020F, r.getOptions() );
- assertEquals( (short) 0xF111, r.getRecordId() );
- assertEquals( 8, r.getRecordSize() );
- assertTrue( r.isContainerRecord() );
- assertEquals( 1, r.getChildRecords().size() );
- assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
- }
-
- @Test
- 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 ) );
-
- EscherRecord childRecord = new UnknownEscherRecord();
- childRecord.setOptions( (short) 0x9999 );
- childRecord.setRecordId( (short) 0xFF01 );
- r.addChildRecord( childRecord );
- r.setOptions( (short) 0x123F );
- 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 ) );
- }
-
- @Test
- void testToString() {
- UnknownEscherRecord r = new UnknownEscherRecord();
- r.setOptions( (short) 0x1234 );
- r.setRecordId( (short) 0xF112 );
- byte[] data = new byte[8];
- r.serialize( 0, data, new NullEscherSerializationListener() );
- String expected =
- "{ /* UNKNOWN */\n" +
- "\t \"recordId\": -3822 /* 0xf112 */\n" +
- "\t, \"version\": 4\n" +
- "\t, \"instance\": 291 /* 0x0123 */\n" +
- "\t, \"options\": 4660 /* 0x1234 */\n" +
- "\t, \"recordSize\": 8\n" +
- "\t, \"data\": \"\"\n" +
- "}";
- expected = expected.replace("\n", System.getProperty("line.separator"));
- assertEquals(expected, r.toString() );
- }
-}