]> source.dussan.org Git - poi.git/commitdiff
SonarCube fix - make members private
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 4 Dec 2016 23:49:49 +0000 (23:49 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 4 Dec 2016 23:49:49 +0000 (23:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1772585 13f79535-47bb-0310-9956-ffa450edef68

17 files changed:
src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java
src/java/org/apache/poi/ddf/EscherArrayProperty.java
src/java/org/apache/poi/ddf/EscherBitmapBlip.java
src/java/org/apache/poi/ddf/EscherBlipRecord.java
src/java/org/apache/poi/ddf/EscherBoolProperty.java
src/java/org/apache/poi/ddf/EscherColorRef.java
src/java/org/apache/poi/ddf/EscherComplexProperty.java
src/java/org/apache/poi/ddf/EscherMetafileBlip.java
src/java/org/apache/poi/ddf/EscherOptRecord.java
src/java/org/apache/poi/ddf/EscherPictBlip.java
src/java/org/apache/poi/ddf/EscherPropertyFactory.java
src/java/org/apache/poi/ddf/EscherRGBProperty.java
src/java/org/apache/poi/ddf/EscherSimpleProperty.java
src/ooxml/java/org/apache/poi/POIXMLRelation.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
src/testcases/org/apache/poi/ddf/AllPOIDDFTests.java
src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java

index c8d2c95c8e18c98039ca8189d6c9eb723a3a7f11..b765fa8381a02b2803095afef8229b15536239b3 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndian;
  */
 public abstract class AbstractEscherOptRecord extends EscherRecord
 {
-    protected List<EscherProperty> properties = new ArrayList<EscherProperty>();
+    private List<EscherProperty> properties = new ArrayList<EscherProperty>();
 
     /**
      * Add a property to this record.
index bf7211d3c0f04407465f6eb3107c92ed955cedfc..0dff27a954e2e7936072bc0dd773f16efbd6c909 100644 (file)
@@ -63,59 +63,47 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
     }
 
     public int getNumberOfElementsInArray() {
-        return (emptyComplexPart) ? 0 : LittleEndian.getUShort(_complexData, 0);
+        return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 0);
     }
 
     public void setNumberOfElementsInArray(int numberOfElements) {
-        int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
-        if (expectedArraySize != _complexData.length) {
-            byte[] newArray = new byte[expectedArraySize];
-            System.arraycopy(_complexData, 0, newArray, 0, _complexData.length);
-            _complexData = newArray;
-        }
-        LittleEndian.putShort(_complexData, 0, (short) numberOfElements);
+        int expectedArraySize = getArraySizeInBytes(numberOfElements, getSizeOfElements());
+        resizeComplexData(expectedArraySize, getComplexData().length);
+        LittleEndian.putShort(getComplexData(), 0, (short)numberOfElements);
     }
 
     public int getNumberOfElementsInMemory() {
-        return (emptyComplexPart) ? 0 : LittleEndian.getUShort(_complexData, 2);
+        return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 2);
     }
 
     public void setNumberOfElementsInMemory(int numberOfElements) {
-        int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
-        if (expectedArraySize != _complexData.length) {
-            byte[] newArray = new byte[expectedArraySize];
-            System.arraycopy(_complexData, 0, newArray, 0, expectedArraySize);
-            _complexData = newArray;
-        }
-        LittleEndian.putShort(_complexData, 2, (short) numberOfElements);
+        int expectedArraySize = getArraySizeInBytes(numberOfElements, getSizeOfElements());
+        resizeComplexData(expectedArraySize, expectedArraySize);
+        LittleEndian.putShort(getComplexData(), 2, (short) numberOfElements);
     }
 
     public short getSizeOfElements() {
-        return (emptyComplexPart) ? 0 : LittleEndian.getShort( _complexData, 4 );
+        return (emptyComplexPart) ? 0 : LittleEndian.getShort( getComplexData(), 4 );
     }
 
     public void setSizeOfElements(int sizeOfElements) {
-        LittleEndian.putShort( _complexData, 4, (short) sizeOfElements );
-
-        int expectedArraySize = getNumberOfElementsInArray() * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
-        if (expectedArraySize != _complexData.length) {
-            // Keep just the first 6 bytes.  The rest is no good to us anyway.
-            byte[] newArray = new byte[expectedArraySize];
-            System.arraycopy( _complexData, 0, newArray, 0, 6 );
-            _complexData = newArray;
-        }
+        LittleEndian.putShort( getComplexData(), 4, (short) sizeOfElements );
+
+        int expectedArraySize = getArraySizeInBytes(getNumberOfElementsInArray(), sizeOfElements);
+        // Keep just the first 6 bytes.  The rest is no good to us anyway.
+        resizeComplexData(expectedArraySize, 6);
     }
 
     public byte[] getElement(int index) {
         int actualSize = getActualSizeOfElements(getSizeOfElements());
         byte[] result = new byte[actualSize];
-        System.arraycopy(_complexData, FIXED_SIZE + index * actualSize, result, 0, result.length );
+        System.arraycopy(getComplexData(), FIXED_SIZE + index * actualSize, result, 0, result.length );
         return result;
     }
 
     public void setElement(int index, byte[] element) {
         int actualSize = getActualSizeOfElements(getSizeOfElements());
-        System.arraycopy( element, 0, _complexData, FIXED_SIZE + index * actualSize, actualSize);
+        System.arraycopy( element, 0, getComplexData(), FIXED_SIZE + index * actualSize, actualSize);
     }
 
     @Override
@@ -152,7 +140,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
 
     /**
      * We have this method because the way in which arrays in escher works
-     * is screwed for seemly arbitary reasons.  While most properties are
+     * is screwed for seemly arbitrary reasons.  While most properties are
      * fairly consistent and have a predictable array size, escher arrays
      * have special cases.
      *
@@ -162,21 +150,25 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
      */
     public int setArrayData(byte[] data, int offset) {
         if (emptyComplexPart){
-            _complexData = new byte[0];
-        } else {
-            short numElements = LittleEndian.getShort(data, offset);
-            // LittleEndian.getShort(data, offset + 2); // numReserved
-            short sizeOfElements = LittleEndian.getShort(data, offset + 4);
-
-            int arraySize = getActualSizeOfElements(sizeOfElements) * numElements;
-            if (arraySize == _complexData.length) {
-                // The stored data size in the simple block excludes the header size
-                _complexData = new byte[arraySize + 6];
-                sizeIncludesHeaderSize = false;
-            }
-            System.arraycopy(data, offset, _complexData, 0, _complexData.length );
+            resizeComplexData(0, 0);
+            return 0;
         }
-        return _complexData.length;
+        
+        short numElements = LittleEndian.getShort(data, offset);
+        // LittleEndian.getShort(data, offset + 2); // numReserved
+        short sizeOfElements = LittleEndian.getShort(data, offset + 4);
+
+        // TODO: this part is strange - it doesn't make sense to compare
+        // the size of the existing data when setting a new data array ...
+        int arraySize = getArraySizeInBytes(numElements, sizeOfElements);
+        if (arraySize - FIXED_SIZE == getComplexData().length) {
+            // The stored data size in the simple block excludes the header size
+            sizeIncludesHeaderSize = false;
+        }
+        int cpySize = Math.min(arraySize, data.length-offset);
+        resizeComplexData(cpySize, 0);
+        System.arraycopy(data, offset, getComplexData(), 0, cpySize);
+        return cpySize;
     }
 
     /**
@@ -188,7 +180,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
     @Override
     public int serializeSimplePart(byte[] data, int pos) {
         LittleEndian.putShort(data, pos, getId());
-        int recordSize = _complexData.length;
+        int recordSize = getComplexData().length;
         if(!sizeIncludesHeaderSize) {
             recordSize -= 6;
         }
@@ -207,10 +199,15 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
         return sizeOfElements;
     }
 
+    private static int getArraySizeInBytes(int numberOfElements, int sizeOfElements) {
+        return numberOfElements * getActualSizeOfElements((short)(sizeOfElements & 0xFFFF)) + FIXED_SIZE;
+    }
+    
+    
     @Override
     public Iterator<byte[]> iterator() {
         return new Iterator<byte[]>(){
-            int idx = 0;
+            private int idx = 0;
             @Override
             public boolean hasNext() {
                 return (idx < getNumberOfElementsInArray());
index cb2eba8fcbb36521987a21291dcf9920ba84c6dc..84a4824b2dba91fedc62f4417c4479cda0d8bcc7 100644 (file)
@@ -38,8 +38,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
         System.arraycopy( data, pos, field_1_UID, 0, 16 ); pos += 16;
         field_2_marker = data[pos]; pos++;
 
-        field_pictureData = new byte[bytesAfterHeader - 17];
-        System.arraycopy( data, pos, field_pictureData, 0, field_pictureData.length );
+        setPictureData(data, pos, bytesAfterHeader - 17);
 
         return bytesAfterHeader + HEADER_SIZE;
     }
@@ -55,15 +54,16 @@ public class EscherBitmapBlip extends EscherBlipRecord {
 
         System.arraycopy( field_1_UID, 0, data, pos, 16 );
         data[pos + 16] = field_2_marker;
-        System.arraycopy( field_pictureData, 0, data, pos + 17, field_pictureData.length );
+        byte pd[] = getPicturedata();
+        System.arraycopy( pd, 0, data, pos + 17, pd.length );
 
         listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this);
-        return HEADER_SIZE + 16 + 1 + field_pictureData.length;
+        return HEADER_SIZE + 16 + 1 + pd.length;
     }
 
     @Override
     public int getRecordSize() {
-        return 8 + 16 + 1 + field_pictureData.length;
+        return 8 + 16 + 1 + getPicturedata().length;
     }
 
     /**
@@ -113,7 +113,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
     public String toString() {
         String nl = System.getProperty( "line.separator" );
 
-        String extraData = HexDump.dump(this.field_pictureData, 0, 0);
+        String extraData = HexDump.dump(getPicturedata(), 0, 0);
 
         return getClass().getName() + ":" + nl +
             "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
@@ -126,7 +126,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
 
     @Override
     public String toXml(String tab) {
-        String extraData = HexDump.dump(this.field_pictureData, 0, 0);
+        String extraData = HexDump.dump(getPicturedata(), 0, 0);
         StringBuilder builder = new StringBuilder();
         builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
             .append(tab).append("\t").append("<UID>0x").append(HexDump.toHex(field_1_UID)).append("</UID>\n")
index 0ea8930013e57b180cb1543c52db86b99163e09b..ccacc7b9c29bdfe2561fa2675e30af3d66713d67 100644 (file)
@@ -27,7 +27,7 @@ public class EscherBlipRecord extends EscherRecord {
 
     private static final int   HEADER_SIZE               = 8;
 
-    protected              byte[] field_pictureData;
+    private byte[] field_pictureData;
 
     public EscherBlipRecord() {
     }
@@ -81,10 +81,22 @@ public class EscherBlipRecord extends EscherRecord {
      * @param pictureData the picture data
      */
     public void setPictureData(byte[] pictureData) {
-        if (pictureData == null) {
+        setPictureData(pictureData, 0, (pictureData == null ? 0 : pictureData.length));
+    }
+
+    /**
+     * Sets the picture data bytes
+     *
+     * @param pictureData the picture data
+     * @param offset the offset into the picture data
+     * @param length the amount of bytes to be used
+     */
+    public void setPictureData(byte[] pictureData, int offset, int length) {
+        if (pictureData == null || offset < 0 || length < 0 || pictureData.length < offset+length) {
             throw new IllegalArgumentException("picture data can't be null");
         }
-        field_pictureData = pictureData.clone();
+        field_pictureData = new byte[length];
+        System.arraycopy(pictureData, offset, field_pictureData, 0, length);
     }
 
     @Override
index 1f44e2343dad7a871fc5057b5a704d3ffd58045e..ce36bc6654a17da3460736f96b1b076f0e68822e 100644 (file)
@@ -49,7 +49,7 @@ public class EscherBoolProperty
      */
     public boolean isTrue()
     {
-        return propertyValue != 0;
+        return getPropertyValue() != 0;
     }
 
     /**
@@ -61,7 +61,7 @@ public class EscherBoolProperty
      */
     public boolean isFalse()
     {
-        return propertyValue == 0;
+        return !isTrue();
     }
 
 //    public String toString()
index 84f94301d33d0d7d05f29654b52736f24b867ae5..33127689e78c1a6ab789331cbc5c9f55d3e7bb1b 100644 (file)
@@ -24,8 +24,9 @@ import org.apache.poi.util.LittleEndian;
  * An OfficeArtCOLORREF structure entry which also handles color extension opid data\r
  */\r
 public class EscherColorRef {\r
-    int opid = -1;\r
-    int colorRef = 0;\r
+    @SuppressWarnings("unused")\r
+    private int opid = -1;\r
+    private int colorRef = 0;\r
 \r
     public enum SysIndexSource {\r
         /** Use the fill color of the shape. */\r
@@ -45,7 +46,7 @@ public class EscherColorRef {
         /** If the shape contains a fill, use the fill color of the shape. Otherwise, use the line color. */\r
         FILL_OR_LINE_COLOR(0xF7)\r
         ;\r
-        int value;\r
+        private int value;\r
         SysIndexSource(int value) { this.value = value; }\r
     }\r
 \r
@@ -102,7 +103,7 @@ public class EscherColorRef {
          */\r
         INVERT_HIGHBIT_AFTER(0x40)\r
         ;\r
-        BitField mask;\r
+        private BitField mask;\r
         SysIndexProcedure(int mask) {\r
             this.mask = new BitField(mask);\r
         }\r
index 9a84e10c1cadda5014f123daf44e981d04a3f5e0..04712be4dfe37100f23401c07a5ad9de8666a173 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
  */
 public class EscherComplexProperty extends EscherProperty {
     // TODO - make private and final
-    protected byte[] _complexData;
+    private byte[] _complexData;
 
     /**
      * Create a complex property using the property id and a byte array containing the complex
@@ -95,6 +95,16 @@ public class EscherComplexProperty extends EscherProperty {
         return _complexData;
     }
 
+    protected void resizeComplexData(int newSize, int bytesToKeep) {
+        if (newSize == _complexData.length) {
+            return;
+        }
+        byte[] newArray = new byte[newSize];
+        System.arraycopy(_complexData, 0, newArray, 0, Math.min(bytesToKeep, newSize));
+        _complexData = newArray;
+    }
+    
+    
     /**
      * Determine whether this property is equal to another property.
      *
index 740df26ddeb6b0aaa00eafbcfe6f27991e95f3e7..ffd740cde83ac05548a49f4fc696ddfc52d8d90d 100644 (file)
@@ -87,9 +87,9 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
         // 0 means DEFLATE compression
         // 0xFE means no compression
         if (field_6_fCompression == 0) {
-            field_pictureData = inflatePictureData(raw_pictureData);
+            super.setPictureData(inflatePictureData(raw_pictureData));
         } else {
-            field_pictureData = raw_pictureData;
+            super.setPictureData(raw_pictureData);
         }
 
         int remaining = bytesAfterHeader - pos + offset + HEADER_SIZE;
index cb6c7ad4ce0a80c595a296924dbbe3009c834f39..94b226b3a86b4fc8e0aa9584866dc8980c194f4b 100644 (file)
@@ -32,7 +32,7 @@ public class EscherOptRecord extends AbstractEscherOptRecord
     @Override
     public short getInstance()
     {
-        setInstance( (short) properties.size() );
+        setInstance( (short) getEscherProperties().size() );
         return super.getInstance();
     }
 
index 7c2acd9a990f88ff2b21bd2d6c429e8d3765192b..1feaf94776929ff7fb0114e12a8f997613bd3767 100644 (file)
@@ -76,11 +76,11 @@ public final class EscherPictBlip extends EscherBlipRecord {
         // 0xFE means no compression
         if (field_6_fCompression == 0)
         {
-            field_pictureData = inflatePictureData(raw_pictureData);
+               super.setPictureData(inflatePictureData(raw_pictureData));
         }
         else
         {
-            field_pictureData = raw_pictureData;
+               super.setPictureData(raw_pictureData);
         }
 
         return bytesAfterHeader + HEADER_SIZE;
@@ -264,7 +264,7 @@ public final class EscherPictBlip extends EscherBlipRecord {
 
     @Override
     public String toString() {
-        String extraData = HexDump.toHex(field_pictureData, 32);
+        String extraData = HexDump.toHex(getPicturedata(), 32);
         return getClass().getName() + ":" + '\n' +
                 "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
                 "  Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
index 059e29ba94216909e869e38afa64c787b268cc14..15c9475cfb26eb38d652c2445ddf2bb5346e7a4e 100644 (file)
@@ -49,24 +49,28 @@ public final class EscherPropertyFactory {
             // boolean isBlipId = ( propId & (short) 0x4000 ) != 0;
 
             byte propertyType = EscherProperties.getPropertyType(propNumber);
-            if ( propertyType == EscherPropertyMetaData.TYPE_BOOLEAN )
-                results.add( new EscherBoolProperty( propId, propData ) );
-            else if ( propertyType == EscherPropertyMetaData.TYPE_RGB )
-                results.add( new EscherRGBProperty( propId, propData ) );
-            else if ( propertyType == EscherPropertyMetaData.TYPE_SHAPEPATH )
-                results.add( new EscherShapePathProperty( propId, propData ) );
-            else
-            {
-                if ( !isComplex )
-                    results.add( new EscherSimpleProperty( propId, propData ) );
-                else
-                {
-                    if ( propertyType == EscherPropertyMetaData.TYPE_ARRAY)
-                        results.add( new EscherArrayProperty( propId, new byte[propData]) );
-                    else
-                        results.add( new EscherComplexProperty( propId, new byte[propData]) );
-                }
+            EscherProperty ep;
+            switch (propertyType) {
+                case EscherPropertyMetaData.TYPE_BOOLEAN:
+                    ep = new EscherBoolProperty( propId, propData );
+                    break;
+                case EscherPropertyMetaData.TYPE_RGB:
+                    ep = new EscherRGBProperty( propId, propData );
+                    break;
+                case EscherPropertyMetaData.TYPE_SHAPEPATH:
+                    ep = new EscherShapePathProperty( propId, propData );
+                    break;
+                default:
+                    if ( !isComplex ) {
+                        ep = new EscherSimpleProperty( propId, propData );
+                    } else if ( propertyType == EscherPropertyMetaData.TYPE_ARRAY) {
+                        ep = new EscherArrayProperty( propId, new byte[propData]);
+                    } else {
+                        ep = new EscherComplexProperty( propId, new byte[propData]);
+                    }
+                    break;
             }
+            results.add( ep );
             pos += 6;
         }
 
index 155db7f4f8a4fe540cee1060139d1db37546d2d5..38b77f4a940c541021f9777bb9c256c3b45658d3 100644 (file)
@@ -36,7 +36,7 @@ public class EscherRGBProperty
      */
     public int getRgbColor()
     {
-        return propertyValue;
+        return getPropertyValue();
     }
 
     /**
@@ -44,7 +44,7 @@ public class EscherRGBProperty
      */
     public byte getRed()
     {
-        return (byte) ( propertyValue & 0xFF );
+        return (byte) ( getRgbColor() & 0xFF );
     }
 
     /**
@@ -52,7 +52,7 @@ public class EscherRGBProperty
      */
     public byte getGreen()
     {
-        return (byte) ( (propertyValue >> 8) & 0xFF );
+        return (byte) ( (getRgbColor() >> 8) & 0xFF );
     }
 
     /**
@@ -60,7 +60,7 @@ public class EscherRGBProperty
      */
     public byte getBlue()
     {
-        return (byte) ( (propertyValue >> 16) & 0xFF );
+        return (byte) ( (getRgbColor() >> 16) & 0xFF );
     }
 
     @Override
@@ -68,7 +68,7 @@ public class EscherRGBProperty
         StringBuilder builder = new StringBuilder();
         builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
                 .append("\" name=\"").append(getName()).append("\" blipId=\"")
-                .append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(propertyValue)).append("\"/>\n");
+                .append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(getRgbColor())).append("\"/>\n");
         return builder.toString();
     }
 }
index 3872aa905136e44ffa60b6af61ad0a7940463004..57b1d9df33a3b3ee87db29a3bc459fbf8edd2e7b 100644 (file)
@@ -27,7 +27,7 @@ import org.apache.poi.util.HexDump;
  */
 public class EscherSimpleProperty extends EscherProperty
 {
-    protected int propertyValue;
+    private int propertyValue;
 
     /**
      * The id is distinct from the actual property number.  The id includes the property number the blip id
index 8578f8025ba09085e088242c019fc8f69530638d..6caa5af928378f3e2f7ca00f226ca1bdc7ec3bd7 100644 (file)
@@ -24,17 +24,17 @@ public abstract class POIXMLRelation {
     /**
      * Describes the content stored in a part.
      */
-    protected String _type;
+    private String _type;
 
     /**
      * The kind of connection between a source part and a target part in a package.
      */
-    protected String _relation;
+    private String _relation;
 
     /**
      * The path component of a pack URI.
      */
-    protected String _defaultName;
+    private String _defaultName;
 
     /**
      * Defines what object is used to construct instances of this relationship
index 9a16f00dc713e7e0b8be7376961f97a3ea5da4cc..0f8b7b32b691c2418eaea9bdc476418f45a702fc 100644 (file)
@@ -368,7 +368,7 @@ public final class XSSFRelation extends POIXMLRelation {
      */
     public InputStream getContents(PackagePart corePart) throws IOException, InvalidFormatException {
         PackageRelationshipCollection prc =
-            corePart.getRelationshipsByType(_relation);
+            corePart.getRelationshipsByType(getRelation());
         Iterator<PackageRelationship> it = prc.iterator();
         if(it.hasNext()) {
             PackageRelationship rel = it.next();
@@ -376,7 +376,7 @@ public final class XSSFRelation extends POIXMLRelation {
             PackagePart part = corePart.getPackage().getPart(relName);
             return part.getInputStream();
         }
-        log.log(POILogger.WARN, "No part " + _defaultName + " found");
+        log.log(POILogger.WARN, "No part " + getDefaultFileName() + " found");
         return null;
     }
 
index 56a436b7508f0b0a042330955d0ec295078c223a..2088e9760e1799681887ae911b0ff0d9caf7f83e 100644 (file)
 
 package org.apache.poi.ddf;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-/**
- * Tests for org.apache.poi.ddf<br/>
- */
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    TestEscherBSERecord.class,
+    TestEscherBlipRecord.class,
+    TestEscherBoolProperty.class,
+    TestEscherChildAnchorRecord.class,
+    TestEscherClientAnchorRecord.class,
+    TestEscherClientDataRecord.class,
+    TestEscherContainerRecord.class,
+    TestEscherDgRecord.class,
+    TestEscherDggRecord.class,
+    TestEscherOptRecord.class,
+    TestEscherPropertyFactory.class,
+    TestEscherSpRecord.class,
+    TestEscherSpgrRecord.class,
+    TestEscherSplitMenuColorsRecord.class,
+    TestUnknownEscherRecord.class
+})
 public final class AllPOIDDFTests {
-    public static Test suite() {
-        TestSuite result = new TestSuite("Tests for org.apache.poi.ddf");
-        result.addTestSuite(TestEscherBSERecord.class);
-        result.addTestSuite(TestEscherBlipRecord.class);
-        result.addTestSuite(TestEscherBoolProperty.class);
-        result.addTestSuite(TestEscherChildAnchorRecord.class);
-        result.addTestSuite(TestEscherClientAnchorRecord.class);
-        result.addTestSuite(TestEscherClientDataRecord.class);
-        result.addTestSuite(TestEscherContainerRecord.class);
-        result.addTestSuite(TestEscherDgRecord.class);
-        result.addTestSuite(TestEscherDggRecord.class);
-        result.addTestSuite(TestEscherOptRecord.class);
-        result.addTestSuite(TestEscherPropertyFactory.class);
-        result.addTestSuite(TestEscherSpRecord.class);
-        result.addTestSuite(TestEscherSpgrRecord.class);
-        result.addTestSuite(TestEscherSplitMenuColorsRecord.class);
-        result.addTestSuite(TestUnknownEscherRecord.class);
-        return result;
-    }
 }
index aef2c72add4753c702e7dd8897685a319beba018..803b3bdf019761cd7055d4a3df207950c39a889c 100644 (file)
 
 package org.apache.poi.ddf;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 import java.util.List;
 
-import org.apache.poi.util.HexRead;
 import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+import org.junit.Test;
 
-/**
- * @author Glen Stampoultzis  (glens @ superlinksoftware.com)
- */
-public class TestEscherPropertyFactory extends TestCase
-{
+public class TestEscherPropertyFactory {
+    @Test
     public void testCreateProperties() {
         String dataStr = "41 C1 " +     // propid, complex ind
                 "03 00 00 00 " +         // size of complex property
@@ -41,7 +39,7 @@ public class TestEscherPropertyFactory extends TestCase
                 ;
         byte[] data = HexRead.readFromString( dataStr );
         EscherPropertyFactory f = new EscherPropertyFactory();
-        List props = f.createProperties( data, 0, (short)3 );
+        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() ) );