<classpath refid="@{classpath}"/>
<syspropertyset refid="junit.properties"/>
<jvmarg value="${poi.test.locale}"/>
- <!-- <jvmarg value="-ea"/> -->
+ <jvmarg value="-ea"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="${ooxml.reports.test}">
&& _d3 == other._d3 && _d4 == other._d4;
}
- public int getD1() {
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
+ public int getD1() {
return _d1;
}
package org.apache.poi.hssf.record.common;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.apache.poi.hssf.record.cont.ContinuableRecordInput;
import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.record.cont.ContinuableRecordInput;
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.LittleEndianInput;
+import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.StringUtil;
/**
* Title: Unicode String<p/>
return _character - r._character;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public String toString() {
return "character="+_character+",fontIndex="+_fontIndex;
}
if(result != 0) return result;
result = phRuns[i].realTextFirstCharacterOffset - o.phRuns[i].realTextFirstCharacterOffset;
if(result != 0) return result;
- result = phRuns[i].realTextFirstCharacterOffset - o.phRuns[i].realTextLength;
+ result = phRuns[i].realTextLength - o.phRuns[i].realTextLength;
if(result != 0) return result;
}
- result = extraData.length - o.extraData.length;
- if(result != 0) return result;
+ result = Arrays.hashCode(extraData)-Arrays.hashCode(o.extraData);
- // If we get here, it's the same
- return 0;
+ return result;
}
-
+
+ @Override
+ public int hashCode() {
+ int hash = reserved;
+ hash = 31*hash+formattingFontIndex;
+ hash = 31*hash+formattingOptions;
+ hash = 31*hash+numberOfRuns;
+ hash = 31*hash+phoneticText.hashCode();
+
+ if (phRuns != null) {
+ for (PhRun ph : phRuns) {
+ hash = 31*hash+ph.phoneticTextFirstCharacterOffset;
+ hash = 31*hash+ph.realTextFirstCharacterOffset;
+ hash = 31*hash+ph.realTextLength;
+ }
+ }
+ return hash;
+ }
+
protected ExtRst clone() {
ExtRst ext = new ExtRst();
ext.reserved = reserved;
return anchor.getDx1() == getDx1() && anchor.getDx2() == getDx2() && anchor.getDy1() == getDy1()
&& anchor.getDy2() == getDy2();
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
&& anchor.getRow1() == getRow1() && anchor.getRow2() == getRow2() && anchor.getAnchorType() == getAnchorType();
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
@Override
public int getDx1() {
return _escherClientAnchor.getDx1();
return _string.compareTo(r._string);
}
+ @Override
public boolean equals(Object o) {
if (o instanceof HSSFRichTextString) {
return _string.equals(((HSSFRichTextString)o)._string);
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
+
/**
* @return the plain text representation of this string.
*/
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.util.Configurator;
/**
return -1;
}
+ @Override
public boolean equals(Object obj)
{
if (!(obj instanceof HSSFRow))
}
return false;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
&& _isRowAbs == cr._isColAbs
&& _isColAbs == cr._isColAbs;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
return (compareTo(r) == 0);
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
+
/**
* Compares that the given region is the same less than or greater than this
* region. If any regional coordiant passed in is less than this regions
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
@Override
public String toString(){
return "from : " + cell1.toString() + "; to: " + cell2.toString();
}
- public boolean equals(Object o)
+ @Override
+ public boolean equals(Object o)
{
boolean retVal = true;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
}
+ @Override
public boolean equals(Object o)
{
boolean retVal = true;
return retVal;
}
-
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
-
-
_xst = new Xst(numberText);
}
+ @Override
public boolean equals( Object obj )
{
if ( obj == null )
&& lvl._xst.equals( this._xst );
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* "Alignment (left, right, or centered) of the paragraph number."
*/
return props;
}
+ @Override
public boolean equals(Object o)
{
if (super.equals(o))
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public String toString()
{
return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes "
return infoField == ph.infoField && reserved == ph.reserved &&
dxaCol == ph.dxaCol && dymLineOrHeight == ph.dymLineOrHeight;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
}
return sectionProperties;
}
+ @Override
public boolean equals( Object o )
{
SEPX sepx = (SEPX) o;
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public String toString()
{
return "SEPX from " + getStart() + " to " + getEnd();
this.fcSepx = fc;
}
+ @Override
public boolean equals(Object o)
{
SectionDescriptor sed = (SectionDescriptor)o;
return sed.fn == fn && sed.fnMpr == fnMpr;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public byte[] toByteArray()
{
int offset = 0;
}
}
}
+
+ @Override
public boolean equals(Object o)
{
StyleSheet ss = (StyleSheet)o;
}
return false;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* Creates a PartagraphProperties object from a papx stored in the
* StyleDescription at the index istd in the StyleDescription array. The PAP
return (getEnd() - getStart()) * (_usesUnicode ? 2 : 1);
}
+ @Override
public boolean equals(Object o)
{
if (limitsAreEqual(o))
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* Returns the character position we start at.
return _upx.length;
}
+ @Override
public boolean equals(Object o)
{
UPX upx = (UPX)o;
return Arrays.equals(_upx, upx._upx);
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
@Override
public String toString()
{
_buf = newBuf;
}
}
+
+ @Override
public boolean equals(Object obj)
{
SprmBuffer sprmBuf = (SprmBuffer)obj;
return (Arrays.equals(_buf, sprmBuf._buf));
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public SprmOperation findSprm( short opcode )
{
int operation = SprmOperation.getOperationFromOpcode( opcode );
return _info == 0 && _info2 == 0 || _info == -1;
}
+ @Override
public boolean equals(Object o)
{
BorderCode brc = (BorderCode)o;
return _info == brc._info && _info2 == brc._info2;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public Object clone()
throws CloneNotSupportedException
{
LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2);
}
+ @Override
public boolean equals(Object o)
{
DateAndTime dttm = (DateAndTime)o;
return _info == dttm._info && _info2 == dttm._info2;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public Object clone()
throws CloneNotSupportedException
{
{
_dyaLine = dyaLine;
}
+
+ @Override
public boolean equals(Object o)
{
LineSpacingDescriptor lspd = (LineSpacingDescriptor)o;
return _dyaLine == lspd._dyaLine && _fMultiLinespace == lspd._fMultiLinespace;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public boolean isEmpty()
{
return _dyaLine == 0 && _fMultiLinespace == 0;
return copy;
}
-
+
+ @Override
public boolean equals( Object obj )
{
Field[] fields = SectionProperties.class.getSuperclass()
}
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
package org.apache.poi.hssf.record;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.poi.hssf.record.aggregates.AllRecordAggregateTests;
import org.apache.poi.hssf.record.cf.TestCellRange;
import org.apache.poi.hssf.record.chart.AllChartRecordTests;
import org.apache.poi.hssf.record.common.TestUnicodeString;
-import org.apache.poi.ss.formula.constant.TestConstantValueParser;
import org.apache.poi.hssf.record.crypto.AllHSSFEncryptionTests;
-import org.apache.poi.ss.formula.ptg.AllFormulaTests;
import org.apache.poi.hssf.record.pivot.AllPivotRecordTests;
+import org.apache.poi.ss.formula.constant.TestConstantValueParser;
+import org.apache.poi.ss.formula.ptg.AllFormulaTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Collects all tests for package <tt>org.apache.poi.hssf.record</tt> and sub-packages.
- *
- * @author Josh Micich
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AllChartRecordTests.class,
+ AllHSSFEncryptionTests.class,
+ AllFormulaTests.class,
+ AllPivotRecordTests.class,
+ AllRecordAggregateTests.class,
+ TestArrayRecord.class,
+ TestBOFRecord.class,
+ TestBoolErrRecord.class,
+ TestBoundSheetRecord.class,
+ TestCellRange.class,
+ TestCFHeaderRecord.class,
+ TestCFRuleRecord.class,
+ TestColumnInfoRecord.class,
+ TestCommonObjectDataSubRecord.class,
+ TestConstantValueParser.class,
+ TestDVALRecord.class,
+ TestDrawingGroupRecord.class,
+ TestDrawingRecord.class,
+ TestEmbeddedObjectRefSubRecord.class,
+ TestEndSubRecord.class,
+ TestEscherAggregate.class,
+ TestExtendedFormatRecord.class,
+ TestExternalNameRecord.class,
+ TestFeatRecord.class,
+ TestFontRecord.class,
+ TestFormulaRecord.class,
+ TestHyperlinkRecord.class,
+ TestInterfaceEndRecord.class,
+ TestLabelRecord.class,
+ TestLbsDataSubRecord.class,
+ TestMergeCellsRecord.class,
+ TestNameRecord.class,
+ TestNoteRecord.class,
+ TestNoteStructureSubRecord.class,
+ TestObjRecord.class,
+ TestPaletteRecord.class,
+ TestPaneRecord.class,
+ TestPLVRecord.class,
+ TestRecalcIdRecord.class,
+ TestRecordFactory.class,
+ TestRecordFactoryInputStream.class,
+ TestRecordInputStream.class,
+ TestSCLRecord.class,
+ TestSSTDeserializer.class,
+ TestSSTRecord.class,
+ TestSSTRecordSizeCalculator.class,
+ TestSharedFormulaRecord.class,
+ TestStringRecord.class,
+ TestStyleRecord.class,
+ TestSubRecord.class,
+ TestSupBookRecord.class,
+ TestTableRecord.class,
+ TestTextObjectBaseRecord.class,
+ TestTextObjectRecord.class,
+ TestUnicodeNameRecord.class,
+ TestUnicodeString.class,
+ TestWriteAccessRecord.class,
+ TestDConRefRecord.class
+})
public final class AllRecordTests {
-
- public static Test suite() {
- TestSuite result = new TestSuite(AllRecordTests.class.getName());
-
- result.addTest(AllChartRecordTests.suite());
- result.addTest(AllHSSFEncryptionTests.suite());
- result.addTest(AllFormulaTests.suite());
- result.addTest(AllPivotRecordTests.suite());
- result.addTest(AllRecordAggregateTests.suite());
-
- result.addTestSuite(TestArrayRecord.class);
- result.addTestSuite(TestBOFRecord.class);
- result.addTestSuite(TestBoolErrRecord.class);
- result.addTestSuite(TestBoundSheetRecord.class);
- result.addTestSuite(TestCellRange.class);
- result.addTestSuite(TestCFHeaderRecord.class);
- result.addTestSuite(TestCFRuleRecord.class);
- result.addTestSuite(TestColumnInfoRecord.class);
- result.addTestSuite(TestCommonObjectDataSubRecord.class);
- result.addTestSuite(TestConstantValueParser.class);
- result.addTestSuite(TestDVALRecord.class);
- result.addTestSuite(TestDrawingGroupRecord.class);
- result.addTestSuite(TestDrawingRecord.class);
- result.addTestSuite(TestEmbeddedObjectRefSubRecord.class);
- result.addTestSuite(TestEndSubRecord.class);
- result.addTestSuite(TestEscherAggregate.class);
- result.addTestSuite(TestExtendedFormatRecord.class);
- result.addTestSuite(TestExternalNameRecord.class);
- result.addTestSuite(TestFeatRecord.class);
- result.addTestSuite(TestFontRecord.class);
- result.addTestSuite(TestFormulaRecord.class);
- result.addTestSuite(TestHyperlinkRecord.class);
- result.addTestSuite(TestInterfaceEndRecord.class);
- result.addTestSuite(TestLabelRecord.class);
- result.addTestSuite(TestLbsDataSubRecord.class);
- result.addTestSuite(TestMergeCellsRecord.class);
- result.addTestSuite(TestNameRecord.class);
- result.addTestSuite(TestNoteRecord.class);
- result.addTestSuite(TestNoteStructureSubRecord.class);
- result.addTestSuite(TestObjRecord.class);
- result.addTestSuite(TestPaletteRecord.class);
- result.addTestSuite(TestPaneRecord.class);
- result.addTestSuite(TestPLVRecord.class);
- result.addTestSuite(TestRecalcIdRecord.class);
- result.addTestSuite(TestRecordFactory.class);
- result.addTestSuite(TestRecordFactoryInputStream.class);
- result.addTestSuite(TestRecordInputStream.class);
- result.addTestSuite(TestSCLRecord.class);
- result.addTestSuite(TestSSTDeserializer.class);
- result.addTestSuite(TestSSTRecord.class);
- result.addTestSuite(TestSSTRecordSizeCalculator.class);
- result.addTestSuite(TestSharedFormulaRecord.class);
- result.addTestSuite(TestStringRecord.class);
- result.addTestSuite(TestStyleRecord.class);
- result.addTestSuite(TestSubRecord.class);
- result.addTestSuite(TestSupBookRecord.class);
- result.addTestSuite(TestTableRecord.class);
- result.addTestSuite(TestTextObjectBaseRecord.class);
- result.addTestSuite(TestTextObjectRecord.class);
- result.addTestSuite(TestUnicodeNameRecord.class);
- result.addTestSuite(TestUnicodeString.class);
- result.addTestSuite(TestWriteAccessRecord.class);
- result.addTestSuite(TestDConRefRecord.class);
- return result;
- }
}
package org.apache.poi.hssf.record.common;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import junit.framework.TestCase;
-
import org.apache.poi.hssf.record.ContinueRecord;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.SSTRecord;
import org.apache.poi.hssf.record.common.UnicodeString.ExtRst;
import org.apache.poi.hssf.record.common.UnicodeString.FormatRun;
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
+import org.apache.poi.util.LittleEndianByteArrayInputStream;
+import org.apache.poi.util.LittleEndianByteArrayOutputStream;
+import org.apache.poi.util.LittleEndianConsts;
+import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianInputStream;
import org.apache.poi.util.LittleEndianOutputStream;
+import org.apache.poi.util.StringUtil;
+import org.junit.Test;
/**
* Tests that {@link UnicodeString} record size calculates correctly. The record size
*
* @author Jason Height (jheight at apache.org)
*/
-public final class TestUnicodeString extends TestCase {
+public final class TestUnicodeString {
private static final int MAX_DATA_SIZE = RecordInputStream.MAX_RECORD_DATA_SIZE;
/** a 4 character string requiring 16 bit encoding */
assertEquals(expectedSize, actualSize);
}
- public void testSmallStringSize() {
+ @Test
+ public void smallStringSize() {
//Test a basic string
UnicodeString s = makeUnicodeString("Test");
confirmSize(7, s);
confirmSize(21, s);
}
- public void testPerfectStringSize() {
+ @Test
+ public void perfectStringSize() {
//Test a basic string
UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1);
confirmSize(MAX_DATA_SIZE, s);
confirmSize(MAX_DATA_SIZE-1, s);
}
- public void testPerfectRichStringSize() {
+ @Test
+ public void perfectRichStringSize() {
//Test a rich text string
UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1-8-2);
s.addFormatRun(new UnicodeString.FormatRun((short)1,(short)0));
confirmSize(MAX_DATA_SIZE-1, s);
}
- public void testContinuedStringSize() {
+ @Test
+ public void continuedStringSize() {
//Test a basic string
UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1+20);
confirmSize(MAX_DATA_SIZE+4+1+20, s);
}
/** Tests that a string size calculation that fits neatly in two records, the second being a continue*/
- public void testPerfectContinuedStringSize() {
+ @Test
+ public void perfectContinuedStringSize() {
//Test a basic string
int strSize = MAX_DATA_SIZE*2;
//String overhead
confirmSize(MAX_DATA_SIZE*2, s);
}
- public void testFormatRun() throws Exception {
+ @Test
+ public void formatRun() throws Exception {
FormatRun fr = new FormatRun((short)4, (short)0x15c);
assertEquals(4, fr.getCharacterPos());
assertEquals(0x15c, fr.getFontIndex());
assertEquals(0x15c, fr.getFontIndex());
}
- public void testExtRstFromEmpty() throws Exception {
+ @Test
+ public void extRstFromEmpty() throws Exception {
ExtRst ext = new ExtRst();
assertEquals(0, ext.getNumberOfRuns());
assertEquals(0, ext.getPhRuns().length);
}
- public void testExtRstFromData() throws Exception {
+ @Test
+ public void extRstFromData() throws Exception {
byte[] data = new byte[] {
01, 00, 0x0C, 00,
00, 00, 0x37, 00,
assertEquals(0, ext.getPhRuns().length);
}
- public void testCorruptExtRstDetection() throws Exception {
+ @Test
+ public void corruptExtRstDetection() throws Exception {
byte[] data = new byte[] {
0x79, 0x79, 0x11, 0x11,
0x22, 0x22, 0x33, 0x33,
assertEquals(0, ext.getPhRuns().length);
}
+ @Test
+ public void extRstEqualsAndHashCode() {
+ byte buf[] = new byte[200];
+ LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0);
+ String str = "\u1d02\u1d12\u1d22";
+ bos.writeShort(1);
+ bos.writeShort(5*LittleEndianConsts.SHORT_SIZE+str.length()*2+3*LittleEndianConsts.SHORT_SIZE+2); // data size
+ bos.writeShort(0x4711);
+ bos.writeShort(0x0815);
+ bos.writeShort(1);
+ bos.writeShort(str.length());
+ bos.writeShort(str.length());
+ StringUtil.putUnicodeLE(str, bos);
+ bos.writeShort(1);
+ bos.writeShort(1);
+ bos.writeShort(3);
+ bos.writeShort(42);
+
+ LittleEndianInput in = new LittleEndianByteArrayInputStream(buf, 0, bos.getWriteIndex());
+ UnicodeString.ExtRst extRst1 = new UnicodeString.ExtRst(in, bos.getWriteIndex());
+ in = new LittleEndianByteArrayInputStream(buf, 0, bos.getWriteIndex());
+ UnicodeString.ExtRst extRst2 = new UnicodeString.ExtRst(in, bos.getWriteIndex());
+
+ assertEquals(extRst1, extRst2);
+ assertEquals(extRst1.hashCode(), extRst2.hashCode());
+ }
private static UnicodeString makeUnicodeString(String s) {
UnicodeString st = new UnicodeString(s);