summaryrefslogtreecommitdiffstats
path: root/src/testcases/org
diff options
context:
space:
mode:
authorGlen Stampoultzis <glens@apache.org>2002-02-10 04:32:07 +0000
committerGlen Stampoultzis <glens@apache.org>2002-02-10 04:32:07 +0000
commit35ed88b7c1318ec48989247acee98086dd564389 (patch)
tree420ef73622e3157d6511cff4c1bb9e1a764895de /src/testcases/org
parente8bdf9d9596a5e4c603a501ad3f979140bb0b31a (diff)
downloadpoi-35ed88b7c1318ec48989247acee98086dd564389.tar.gz
poi-35ed88b7c1318ec48989247acee98086dd564389.zip
Added support for automatic record generation
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352078 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java111
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestBarRecord.java119
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestDatRecord.java113
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java117
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java113
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java129
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java119
-rw-r--r--src/testcases/org/apache/poi/util/TestHexDump.java11
8 files changed, 832 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java
new file mode 100644
index 0000000000..decbedc77c
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java
@@ -0,0 +1,111 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the AreaRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestAreaRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x02,(byte)0x00 // format flags
+ };
+
+ public TestAreaRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ AreaRecord record = new AreaRecord((short)0x101A, (short)data.length, data);
+ assertEquals( 2, record.getFormatFlags());
+ assertEquals( false, record.isStacked() );
+ assertEquals( true, record.isDisplayAsPercentage() );
+ assertEquals( false, record.isShadow() );
+
+
+ assertEquals( 6, record.getRecordSize() );
+
+ record.validateSid((short)0x101A);
+ }
+
+ public void testStore()
+ {
+ AreaRecord record = new AreaRecord();
+ record.setStacked( false );
+ record.setDisplayAsPercentage( true );
+ record.setShadow( false );
+
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java b/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java
new file mode 100644
index 0000000000..9d9b78cc76
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java
@@ -0,0 +1,119 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the BarRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestBarRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x00,(byte)0x00, // bar space
+ (byte)0x96,(byte)0x00, // category space
+ (byte)0x00,(byte)0x00 // format flags
+ };
+
+ public TestBarRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ BarRecord record = new BarRecord((short)0x1017, (short)data.length, data);
+ assertEquals( 0, record.getBarSpace());
+ assertEquals( 0x96, record.getCategorySpace());
+ assertEquals( 0, record.getFormatFlags());
+ assertEquals( false, record.isHorizontal() );
+ assertEquals( false, record.isStacked() );
+ assertEquals( false, record.isDisplayAsPercentage() );
+ assertEquals( false, record.isShadow() );
+
+
+ assertEquals( 10, record.getRecordSize() );
+
+ record.validateSid((short)0x1017);
+ }
+
+ public void testStore()
+ {
+ BarRecord record = new BarRecord();
+ record.setBarSpace( (short)0 );
+ record.setCategorySpace( (short)0x96 );
+ record.setHorizontal( false );
+ record.setStacked( false );
+ record.setDisplayAsPercentage( false );
+ record.setShadow( false );
+
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java
new file mode 100644
index 0000000000..3c6bdc7ba0
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java
@@ -0,0 +1,113 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the DatRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestDatRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x0D,(byte)0x00 // options
+ };
+
+ public TestDatRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ DatRecord record = new DatRecord((short)0x1063, (short)data.length, data);
+ assertEquals( 0xD, record.getOptions());
+ assertEquals( true, record.isHorizontalBorder() );
+ assertEquals( false, record.isVerticalBorder() );
+ assertEquals( true, record.isBorder() );
+ assertEquals( true, record.isShowSeriesKey() );
+
+
+ assertEquals( 6, record.getRecordSize() );
+
+ record.validateSid((short)0x1063);
+ }
+
+ public void testStore()
+ {
+ DatRecord record = new DatRecord();
+ record.setHorizontalBorder( true );
+ record.setVerticalBorder( false );
+ record.setBorder( true );
+ record.setShowSeriesKey( true );
+
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java
new file mode 100644
index 0000000000..36f07c14fc
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java
@@ -0,0 +1,117 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the DataFormatRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestDataFormatRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0xFF,(byte)0xFF, // point number
+ (byte)0x00,(byte)0x00, // series index
+ (byte)0x00,(byte)0x00, // series number
+ (byte)0x00,(byte)0x00 // format flags
+ };
+
+ public TestDataFormatRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ DataFormatRecord record = new DataFormatRecord((short)0x1006, (short)data.length, data);
+ assertEquals( (short)0xFFFF, record.getPointNumber());
+ assertEquals( 0, record.getSeriesIndex());
+ assertEquals( 0, record.getSeriesNumber());
+ assertEquals( 0, record.getFormatFlags());
+ assertEquals( false, record.isUseExcel4Colors() );
+
+
+ assertEquals( 12, record.getRecordSize() );
+
+ record.validateSid((short)0x1006);
+ }
+
+ public void testStore()
+ {
+ DataFormatRecord record = new DataFormatRecord();
+ record.setPointNumber( (short)0xFFFF );
+ record.setSeriesIndex( (short)0 );
+ record.setSeriesNumber( (short)0 );
+ record.setFormatFlags( (short)0 );
+ record.setUseExcel4Colors( false );
+
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java
new file mode 100644
index 0000000000..ffa47d41b6
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java
@@ -0,0 +1,113 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the FrameRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestFrameRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x00,(byte)0x00, // border type
+ (byte)0x02,(byte)0x00 // options
+ };
+
+ public TestFrameRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ FrameRecord record = new FrameRecord((short)0x1032, (short)data.length, data);
+ assertEquals( FrameRecord.BORDER_TYPE_REGULAR, record.getBorderType());
+ assertEquals( 2, record.getOptions());
+ assertEquals( false, record.isAutoSize() );
+ assertEquals( true, record.isAutoPosition() );
+
+
+ assertEquals( 8, record.getRecordSize() );
+
+ record.validateSid((short)0x1032);
+ }
+
+ public void testStore()
+ {
+ FrameRecord record = new FrameRecord();
+ record.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
+ record.setOptions( (short)2 );
+ record.setAutoSize( false );
+ record.setAutoPosition( true );
+
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java b/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java
new file mode 100644
index 0000000000..ca719e0484
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java
@@ -0,0 +1,129 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.record;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the LegendRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestLegendRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0xB2,(byte)0x0D,(byte)0x00,(byte)0x00, //field_1_xPosition
+ (byte)0x39,(byte)0x06,(byte)0x00,(byte)0x00, //field_2_yPosition
+ (byte)0xD9,(byte)0x01,(byte)0x00,(byte)0x00, //field_3_xSize
+ (byte)0x34,(byte)0x02,(byte)0x00,(byte)0x00, //field_4_ySize
+ (byte)0x03, //field_5_type
+ (byte)0x01, //field_6_spacing
+ (byte)0x1F,(byte)0x00 //field_7_options
+ };
+
+ public TestLegendRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ LegendRecord legendRecord = new LegendRecord((short)0x1015, (short)data.length, data);
+ assertEquals(3506, legendRecord.getXPosition());
+ assertEquals(1593, legendRecord.getYPosition());
+ assertEquals(473, legendRecord.getXSize());
+ assertEquals(564, legendRecord.getYSize());
+ assertEquals(LegendRecord.TYPE_RIGHT, legendRecord.getType());
+ assertEquals(LegendRecord.SPACING_MEDIUM, legendRecord.getSpacing());
+ assertEquals(31, legendRecord.getOptions());
+ assertEquals(true, legendRecord.isAutoPosition());
+ assertEquals(true, legendRecord.isAutoSeries());
+ assertEquals(true, legendRecord.isAutoPosX());
+ assertEquals(true, legendRecord.isAutoPosY());
+ assertEquals(true, legendRecord.isVert());
+ assertEquals(false, legendRecord.isContainsDataTable());
+
+ assertEquals(24, legendRecord.getRecordSize());
+
+ legendRecord.validateSid((short)0x1015);
+ }
+
+ public void testStore()
+ {
+ LegendRecord legendRecord = new LegendRecord();
+ legendRecord.setXPosition(3506);
+ legendRecord.setYPosition(1593);
+ legendRecord.setXSize(473);
+ legendRecord.setYSize(564);
+ legendRecord.setType(LegendRecord.TYPE_RIGHT);
+ legendRecord.setSpacing(LegendRecord.SPACING_MEDIUM);
+ legendRecord.setAutoPosition(true);
+ legendRecord.setAutoSeries(true);
+ legendRecord.setAutoPosX(true);
+ legendRecord.setAutoPosY(true);
+ legendRecord.setVert(true);
+ legendRecord.setContainsDataTable(false);
+
+ byte [] recordBytes = legendRecord.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java
new file mode 100644
index 0000000000..2d1881f4e2
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java
@@ -0,0 +1,119 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the SeriesRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestSeriesRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x01,(byte)0x00, // category data type
+ (byte)0x01,(byte)0x00, // values data type
+ (byte)0x1B,(byte)0x00, // num categories
+ (byte)0x1B,(byte)0x00, // num values
+ (byte)0x01,(byte)0x00, // bubble series type
+ (byte)0x00,(byte)0x00 // num bubble values
+ };
+
+ public TestSeriesRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ SeriesRecord record = new SeriesRecord((short)0x1003, (short)data.length, data);
+ assertEquals( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, record.getCategoryDataType());
+ assertEquals( SeriesRecord.VALUES_DATA_TYPE_NUMERIC, record.getValuesDataType());
+ assertEquals( 27, record.getNumCategories());
+ assertEquals( 27, record.getNumValues());
+ assertEquals( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC, record.getBubbleSeriesType());
+ assertEquals( 0, record.getNumBubbleValues());
+
+
+ assertEquals( 16, record.getRecordSize() );
+
+ record.validateSid((short)0x1003);
+ }
+
+ public void testStore()
+ {
+ SeriesRecord record = new SeriesRecord();
+ record.setCategoryDataType( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC );
+ record.setValuesDataType( SeriesRecord.VALUES_DATA_TYPE_NUMERIC );
+ record.setNumCategories( (short)27 );
+ record.setNumValues( (short)27 );
+ record.setBubbleSeriesType( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC );
+ record.setNumBubbleValues( (short)0 );
+
+ byte [] recordBytes = record.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
diff --git a/src/testcases/org/apache/poi/util/TestHexDump.java b/src/testcases/org/apache/poi/util/TestHexDump.java
index 841d66873a..1170283813 100644
--- a/src/testcases/org/apache/poi/util/TestHexDump.java
+++ b/src/testcases/org/apache/poi/util/TestHexDump.java
@@ -316,6 +316,17 @@ public class TestHexDump
}
}
+ public void testToHex()
+ throws Exception
+ {
+ assertEquals( "000A", HexDump.toHex((short)0xA));
+ assertEquals( "0A", HexDump.toHex((byte)0xA));
+ assertEquals( "0000000A", HexDump.toHex((int)0xA));
+
+ assertEquals( "FFFF", HexDump.toHex((short)0xFFFF));
+
+ }
+
private char toAscii(final int c)
{
char rval = '.';