poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1751174 - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/hssf/model/ trunk/src/java/org/apache/poi/hssf/record/ trunk/src/java/org/apache/poi/hssf/usermodel/ trunk/src/testcases/org/apache/poi/hssf/model/ trun...
Date Sun, 03 Jul 2016 21:54:18 GMT
Author: kiwiwings
Date: Sun Jul  3 21:54:17 2016
New Revision: 1751174

URL: http://svn.apache.org/viewvc?rev=1751174&view=rev
Log:
#59170 - Remove deprecated classes (POI 3.15) - o.a.p.hssf.model.*Shape classes removed

Removed:
    poi/trunk/src/java/org/apache/poi/hssf/model/AbstractShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/ComboboxShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/CommentShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/LineShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/PictureShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/PolygonShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java
    poi/trunk/src/java/org/apache/poi/hssf/model/TextboxShape.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestShapes.java
Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Sun Jul  3 21:54:17 2016
@@ -39,7 +39,8 @@
         <person id="YK" name="Yegor Kozlov" email="yegor@apache.org" />
     </devs>
 
-    <release version="3.15-beta3" date="2016-09-??">
+    <release version="3.15-beta3" date="2016-08-??">
+        <action dev="PD" type="fix" fixes-bug="59170">Remove deprecated classes (POI
3.15) - o.a.p.hssf.model.*Shape classes removed</action>
         <action dev="PD" type="add" fixes-bug="59781">Common SS: Move PaneInformation
from HSSF to SS package</action>
         <action dev="PD" type="fix" fixes-bug="59766">When setting SAX features, handle
Error too (eg from Google AppEngine)</action>
     </release>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java Sun Jul  3 21:54:17
2016
@@ -160,7 +160,7 @@ public class LbsDataSubRecord extends Su
     /**
      *
      * @return a new instance of LbsDataSubRecord to construct auto-filters
-     * @see org.apache.poi.hssf.model.ComboboxShape#createObjRecord(org.apache.poi.hssf.usermodel.HSSFSimpleShape,
int)
+     * @see org.apache.poi.hssf.usermodel.HSSFCombobox
      */
     public static LbsDataSubRecord newAutoFilterInstance(){
         LbsDataSubRecord lbs = new LbsDataSubRecord();
@@ -330,7 +330,7 @@ public class LbsDataSubRecord extends Su
         /**
          * a string that specifies the current string value in the dropdown
          */
-        private String _str;
+        private final String _str;
 
         /**
          * Optional, undefined and MUST be ignored.

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFShape.java Sun Jul  3 21:54:17 2016
@@ -143,7 +143,12 @@ public abstract class HSSFShape {
         return _objRecord;
     }
 
-    protected EscherOptRecord getOptRecord() {
+    /**
+     * Return the low-level EscherOptRecord to read/modify not yet wrapped escher properties
 
+     *
+     * @return the low-level EscherOptRecord
+     */
+    public EscherOptRecord getOptRecord() {
         return _optRecord;
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java Sun Jul  3
21:54:17 2016
@@ -224,8 +224,7 @@ public class TestDrawingAggregate {
             "H4sIAAAAAAAAAGWOOw7CQAxE32YTsSRIWSgQJSUloqSm5g4ICURBg+iBK3APGi6wBWeh9xGYbEps2WON"+
             "P+OWwpYeIsECMFC8S2jxNvMdlrYQ5xha5N8K6ryHdir6+avwOer5l3hq2NPYWuWN0n1dIsgfbgshuSj1"+
             "+2eqbvLdxQ0ndhy5KJ/lc1ZZK9okY5X/gSbrHZTH1vE/ozagTcwAAAA=";
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
+        byte[] dgBytes = decompress(data);
 
         List<EscherRecord> records = new ArrayList<EscherRecord>();
         EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
@@ -725,8 +724,7 @@ public class TestDrawingAggregate {
             "IppKQdVys+cLtUY6Un0+hI2Z0wMzAxO8Lr0LbaILk8WtNsxpaFYMrTjC22723OH5GFkUi+ux8An2Hi0F"+
             "fvcr1v8aFU6POn+OCqfj4ffS/e+pcOEMKhABrCdUAAPhwB+pQHYGFcT/BBUEz6LC/wGpc+eRNSkAAA==";
 
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
+        byte[] dgBytes = decompress(data);
         List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));
         assertEquals(20, dgRecords.size());
 
@@ -904,8 +902,7 @@ public class TestDrawingAggregate {
             "p9IQmzVDjm0LdSLqeHM8ILiJRsdoNYS93WyEhi7IOdKXZLTCvCLifxTMEi+snNzAtfevk8DpkejvSeB0"+
             "BPza/oPKABD5z4SARKQEELP1WQsFMc+QwP8ATkmhK404AAA=";
 
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
+        byte[] dgBytes = decompress(data);
         List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));
         assertEquals(14, dgRecords.size());
 
@@ -950,4 +947,31 @@ public class TestDrawingAggregate {
         assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes,
dgBytesAfterSave));
     }
 
+
+    /**
+     * Decompress previously gziped/base64ed data
+     *
+     * @param data the gziped/base64ed data
+     * @return the raw bytes
+     * @throws IOException if you copy and pasted the data wrong
+     */
+    public static byte[] decompress(String data) throws IOException {
+        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
+        return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
+    }
+    
+    /**
+     * Compress raw data for test runs - usually called while debugging :)
+     *
+     * @param data the raw data
+     * @return the gziped/base64ed data as String
+     * @throws IOException usually not ...
+     */
+    public static String compress(byte[] data) throws IOException {
+        java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
+        java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);
+        gz.write(data);
+        gz.finish();
+        return DatatypeConverter.printBase64Binary(bos.toByteArray());        
+    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java Sun Jul  3 21:54:17
2016
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.model;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
@@ -103,23 +104,14 @@ public class TestDrawingShapes {
         assertEquals(HSSFShape.LINEWIDTH_DEFAULT, shape.getLineWidth());
         assertEquals(HSSFShape.LINESTYLE_SOLID, shape.getLineStyle());
         assertFalse(shape.isNoFill());
-
-        AbstractShape sp = AbstractShape.createShape(shape, 1);
-        EscherContainerRecord spContainer = sp.getSpContainer();
-        EscherOptRecord opt =
-                spContainer.getChildById(EscherOptRecord.RECORD_ID);
+        
+        EscherOptRecord opt = shape.getOptRecord();
 
         assertEquals(7, opt.getEscherProperties().size());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE)).isTrue());
-        assertEquals(0x00000004,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.GEOMETRY__SHAPEPATH)).getPropertyValue());
-        assertEquals(0x08000009,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.FILL__FILLCOLOR)).getPropertyValue());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.FILL__NOFILLHITTEST)).isTrue());
-        assertEquals(0x08000040,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.LINESTYLE__COLOR)).getPropertyValue());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).isTrue());
         assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.GROUPSHAPE__PRINT)).isTrue());
+        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).isTrue());
+        assertEquals(0x00000004, ((EscherSimpleProperty) opt.lookup(EscherProperties.GEOMETRY__SHAPEPATH)).getPropertyValue());
+        assertNull(opt.lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE));
     }
 
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Jul  3 21:54:17
2016
@@ -51,6 +51,7 @@ import org.apache.poi.hssf.extractor.Exc
 import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.model.InternalWorkbook;
 import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
 import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
 import org.apache.poi.hssf.record.NameRecord;
 import org.apache.poi.hssf.record.Record;
@@ -3009,4 +3010,29 @@ public final class TestBugs extends Base
         assertNotNull(newSheet);
         wb.close();
     }
+
+    /**
+     * Test generator of ids for the CommonObjectDataSubRecord record.
+     */
+    @Test
+    public void test51332() {
+        HSSFClientAnchor anchor = new HSSFClientAnchor();
+        HSSFSimpleShape shape;
+        CommonObjectDataSubRecord cmo;
+        
+        shape = new HSSFTextbox(null, anchor);
+        shape.setShapeId(1025);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(1, cmo.getObjectId());
+
+        shape = new HSSFPicture(null, anchor);
+        shape.setShapeId(1026);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(2, cmo.getObjectId());
+
+        shape = new HSSFComment(null, anchor);
+        shape.setShapeId(1027);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(1027, cmo.getObjectId());
+    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java Sun Jul  3
21:54:17 2016
@@ -16,6 +16,7 @@
 ==================================================================== */
 package org.apache.poi.hssf.usermodel;
 
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -26,8 +27,6 @@ import java.io.IOException;
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.CommentShape;
-import org.apache.poi.hssf.model.HSSFTestModelHelper;
 import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
 import org.apache.poi.hssf.record.EscherAggregate;
 import org.apache.poi.hssf.record.NoteRecord;
@@ -66,7 +65,7 @@ public final class TestHSSFComment exten
      * when matching cells and their cell comments. The correct algorithm is to map
      */
     @Test
-    public void bug47924() {
+    public void bug47924() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("47924.xls");
         HSSFSheet sheet = wb.getSheetAt(0);
         HSSFCell cell;
@@ -95,6 +94,8 @@ public final class TestHSSFComment exten
         cell = sheet.getRow(5).getCell(2);
         comment = cell.getCellComment();
         assertEquals("c6", comment.getString().getString());
+        
+        wb.close();
     }
     
     @Test
@@ -202,7 +203,7 @@ public final class TestHSSFComment exten
     }
     
     @Test
-    public void resultEqualsToAbstractShape() throws IOException {
+    public void resultEqualsToNonExistingAbstractShape() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
@@ -212,59 +213,53 @@ public final class TestHSSFComment exten
         HSSFCell cell = row.createCell(0);
         cell.setCellComment(comment);
 
-        CommentShape commentShape = HSSFTestModelHelper.createCommentShape(1025, comment);
-
         assertEquals(comment.getEscherContainer().getChildRecords().size(), 5);
-        assertEquals(commentShape.getSpContainer().getChildRecords().size(), 5);
 
         //sp record
-        byte[] expected = commentShape.getSpContainer().getChild(0).serialize();
+        byte[] expected = decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");
         byte[] actual = comment.getEscherContainer().getChild(0).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(2).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
         actual = comment.getEscherContainer().getChild(2).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(3).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
         actual = comment.getEscherContainer().getChild(3).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(4).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");
         actual = comment.getEscherContainer().getChild(4).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         ObjRecord obj = comment.getObjRecord();
-        ObjRecord objShape = commentShape.getObjRecord();
 
-        expected = obj.serialize();
-        actual = objShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAItlMGEQZRBikGRgZBF0YEACvAxiDLgBAJZsuoU4AAAA");
+        actual = obj.serialize();
 
         assertEquals(expected.length, actual.length);
         //assertArrayEquals(expected, actual);
 
         TextObjectRecord tor = comment.getTextObjectRecord();
-        TextObjectRecord torShape = commentShape.getTextObjectRecord();
 
-        expected = tor.serialize();
-        actual = torShape.serialize();
+        expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
+        actual = tor.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         NoteRecord note = comment.getNoteRecord();
-        NoteRecord noteShape = commentShape.getNoteRecord();
 
-        expected = note.serialize();
-        actual = noteShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAJNh4GGAAEYWEAkAS0KXuRAAAAA=");
+        actual = note.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
@@ -376,7 +371,7 @@ public final class TestHSSFComment exten
     }
 
     @Test
-    public void existingFileWithComment(){
+    public void existingFileWithComment() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
         HSSFSheet sheet = wb.getSheet("comments");
         HSSFPatriarch drawing = sheet.getDrawingPatriarch();
@@ -386,6 +381,7 @@ public final class TestHSSFComment exten
         assertEquals(comment.getString().getString(), "evgeniy:\npoi test");
         assertEquals(comment.getColumn(), 1);
         assertEquals(comment.getRow(), 2);
+        wb.close();
     }
 
     @Test
@@ -399,8 +395,6 @@ public final class TestHSSFComment exten
         HSSFCell cell = row.createCell(4);
         cell.setCellComment(comment);
 
-        HSSFTestModelHelper.createCommentShape(0, comment);
-
         assertNotNull(sh.findCellComment(5, 4));
         assertNull(sh.findCellComment(5, 5));
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java Sun Jul  3 21:54:17
2016
@@ -17,27 +17,22 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.ddf.EscherArrayProperty;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.HSSFTestModelHelper;
-import org.apache.poi.hssf.model.PolygonShape;
 import org.apache.poi.hssf.record.ObjRecord;
+import org.junit.Test;
 
-/**
- * @author Evgeniy Berlog
- * @date 28.06.12
- */
-public class TestPolygon extends TestCase{
-
+public class TestPolygon {
+    @Test
     public void testResultEqualsToAbstractShape() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
@@ -46,42 +41,42 @@ public class TestPolygon extends TestCas
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
         polygon.setPolygonDrawArea( 100, 100 );
         polygon.setPoints( new int[]{0, 90, 50}, new int[]{5, 5, 44} );
-        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(1024, polygon);
         polygon.setShapeId(1024);
 
         assertEquals(polygon.getEscherContainer().getChildRecords().size(), 4);
-        assertEquals(polygonShape.getSpContainer().getChildRecords().size(), 4);
 
         //sp record
-        byte[] expected = polygonShape.getSpContainer().getChild(0).serialize();
+        byte[] expected = decompress("H4sIAAAAAAAAAGNi4PrAwQAELEDMxcAAAAU6ZlwQAAAA");
         byte[] actual = polygon.getEscherContainer().getChild(0).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = polygonShape.getSpContainer().getChild(2).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
         actual = polygon.getEscherContainer().getChild(2).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = polygonShape.getSpContainer().getChild(3).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
         actual = polygon.getEscherContainer().getChild(3).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         ObjRecord obj = polygon.getObjRecord();
-        ObjRecord objShape = polygonShape.getObjRecord();
 
-        expected = obj.serialize();
-        actual = objShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAItlkGIQZRBikGNgYBBMYEADAOAV/ZkeAAAA");
+        actual = obj.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
+        
+        wb.close();
     }
 
-    public void testPolygonPoints(){
+    @Test
+    public void testPolygonPoints() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
@@ -90,31 +85,46 @@ public class TestPolygon extends TestCas
         polygon.setPolygonDrawArea( 100, 100 );
         polygon.setPoints( new int[]{0, 90, 50, 90}, new int[]{5, 5, 44, 88} );
 
-        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
-
         EscherArrayProperty verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
-        EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
-                .lookup(EscherProperties.GEOMETRY__VERTICES);
 
-        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
-        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
+        String expected =
+            "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">"+
+            "<Element>[00, 00, 05, 00]</Element>"+
+            "<Element>[5A, 00, 05, 00]</Element>"+
+            "<Element>[32, 00, 2C, 00]</Element>"+
+            "<Element>[5A, 00, 58, 00]</Element>"+
+            "<Element>[00, 00, 05, 00]</Element>"+
+            "</EscherArrayProperty>";
+        String actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
+        
+        assertEquals(verticesProp1.getNumberOfElementsInArray(), 5);
+        assertEquals(expected, actual);
         
         polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});
         assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});
         assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});
 
-        polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
         verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
-        verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
-                .lookup(EscherProperties.GEOMETRY__VERTICES);
 
-        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
-        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
+        expected =
+            "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">"
+
+            "<Element>[01, 00, 04, 00]</Element>" +
+            "<Element>[02, 00, 05, 00]</Element>" +
+            "<Element>[03, 00, 06, 00]</Element>" +
+            "<Element>[01, 00, 04, 00]</Element>" +
+            "</EscherArrayProperty>";
+        actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
+        
+        assertEquals(verticesProp1.getNumberOfElementsInArray(), 4);
+        assertEquals(expected, actual);
+        
+        wb.close();
     }
 
-    public void testSetGetProperties(){
-        HSSFWorkbook wb = new HSSFWorkbook();
-        HSSFSheet sh = wb.createSheet();
+    @Test
+    public void testSetGetProperties() throws IOException {
+        HSSFWorkbook wb1 = new HSSFWorkbook();
+        HSSFSheet sh = wb1.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
 
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
@@ -126,8 +136,9 @@ public class TestPolygon extends TestCas
         assertEquals(polygon.getDrawAreaHeight(), 101);
         assertEquals(polygon.getDrawAreaWidth(), 102);
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
+        sh = wb2.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         polygon = (HSSFPolygon) patriarch.getChildren().get(0);
@@ -144,8 +155,9 @@ public class TestPolygon extends TestCas
         assertEquals(polygon.getDrawAreaHeight(), 1011);
         assertEquals(polygon.getDrawAreaWidth(), 1021);
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
+        wb2.close();
+        sh = wb3.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         polygon = (HSSFPolygon) patriarch.getChildren().get(0);
@@ -154,11 +166,14 @@ public class TestPolygon extends TestCas
         assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});
         assertEquals(polygon.getDrawAreaHeight(), 1011);
         assertEquals(polygon.getDrawAreaWidth(), 1021);
+        
+        wb3.close();
     }
 
-    public void testAddToExistingFile(){
-        HSSFWorkbook wb = new HSSFWorkbook();
-        HSSFSheet sh = wb.createSheet();
+    @Test
+    public void testAddToExistingFile() throws IOException {
+        HSSFWorkbook wb1 = new HSSFWorkbook();
+        HSSFSheet sh = wb1.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
 
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
@@ -169,8 +184,9 @@ public class TestPolygon extends TestCas
         polygon1.setPolygonDrawArea( 103, 104 );
         polygon1.setPoints( new int[]{11,12,13}, new int[]{14,15,16} );
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
+        sh = wb2.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         assertEquals(patriarch.getChildren().size(), 2);
@@ -179,8 +195,9 @@ public class TestPolygon extends TestCas
         polygon2.setPolygonDrawArea( 203, 204 );
         polygon2.setPoints( new int[]{21,22,23}, new int[]{24,25,26} );
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
+        wb2.close();
+        sh = wb3.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         assertEquals(patriarch.getChildren().size(), 3);
@@ -203,8 +220,11 @@ public class TestPolygon extends TestCas
         assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26});
         assertEquals(polygon2.getDrawAreaHeight(), 204);
         assertEquals(polygon2.getDrawAreaWidth(), 203);
+        
+        wb3.close();
     }
 
+    @Test
     public void testExistingFile() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
         HSSFSheet sheet = wb.getSheet("polygon");
@@ -216,19 +236,23 @@ public class TestPolygon extends TestCas
         assertEquals(polygon.getDrawAreaWidth(), 3686175);
         assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502});
         assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18});
+        
+        wb.close();
     }
 
-    public void testPolygonType(){
-        HSSFWorkbook wb = new HSSFWorkbook();
-        HSSFSheet sh = wb.createSheet();
+    @Test
+    public void testPolygonType() throws IOException {
+        HSSFWorkbook wb1 = new HSSFWorkbook();
+        HSSFSheet sh = wb1.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
 
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
         polygon.setPolygonDrawArea( 102, 101 );
         polygon.setPoints( new int[]{1,2,3}, new int[]{4,5,6} );
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
+        sh = wb2.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         HSSFPolygon polygon1 = patriarch.createPolygon(new HSSFClientAnchor());
@@ -239,12 +263,14 @@ public class TestPolygon extends TestCas
 
         spRecord.setShapeType((short)77/**RANDOM**/);
 
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-        sh = wb.getSheetAt(0);
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
+        wb2.close();
+        sh = wb3.getSheetAt(0);
         patriarch = sh.getDrawingPatriarch();
 
         assertEquals(patriarch.getChildren().size(), 2);
         assertTrue(patriarch.getChildren().get(0) instanceof HSSFPolygon);
         assertTrue(patriarch.getChildren().get(1) instanceof HSSFPolygon);
+        wb3.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java?rev=1751174&r1=1751173&r2=1751174&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java Sun Jul  3 21:54:17
2016
@@ -17,12 +17,13 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
+import java.io.IOException;
+
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.HSSFTestModelHelper;
-import org.apache.poi.hssf.model.TextboxShape;
 import org.apache.poi.hssf.record.ObjRecord;
 import org.apache.poi.hssf.record.TextObjectRecord;
 import org.junit.Test;
@@ -31,56 +32,54 @@ import org.junit.Test;
  * @author Evgeniy Berlog
  * @date 25.06.12
  */
-@SuppressWarnings("deprecation")
 public class TestText {
 
     @Test
-    public void testResultEqualsToAbstractShape() throws Exception {
+    public void testResultEqualsToNonExistingAbstractShape() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
         HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor());
-        TextboxShape textboxShape = HSSFTestModelHelper.createTextboxShape(1025, textbox);
 
         assertEquals(textbox.getEscherContainer().getChildRecords().size(), 5);
-        assertEquals(textboxShape.getSpContainer().getChildRecords().size(), 5);
 
         //sp record
-        byte[] expected = textboxShape.getSpContainer().getChild(0).serialize();
+        byte[] expected = decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");
         byte[] actual = textbox.getEscherContainer().getChild(0).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = textboxShape.getSpContainer().getChild(2).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
         actual = textbox.getEscherContainer().getChild(2).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = textboxShape.getSpContainer().getChild(3).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
         actual = textbox.getEscherContainer().getChild(3).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = textboxShape.getSpContainer().getChild(4).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");
         actual = textbox.getEscherContainer().getChild(4).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         ObjRecord obj = textbox.getObjRecord();
-        ObjRecord objShape = textboxShape.getObjRecord();
 
-        expected = obj.serialize();
-        actual = objShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAItlkGIQZRBiYGNgZBBMYEADAOdCLuweAAAA");
+        actual = obj.serialize();
 
+        assertEquals(expected.length, actual.length);
+        assertArrayEquals(expected, actual);
+        
         TextObjectRecord tor = textbox.getTextObjectRecord();
-        TextObjectRecord torShape = textboxShape.getTextObjectRecord();
 
-        expected = tor.serialize();
-        actual = torShape.serialize();
+        expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
+        actual = tor.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message