diff options
author | Josh Micich <josh@apache.org> | 2008-10-26 07:18:17 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2008-10-26 07:18:17 +0000 |
commit | 7c0d1fc041746fb337e683c198ed5d618481004e (patch) | |
tree | 147d4a3fd9e28862bcabd46e3124d4856f009075 /src/testcases | |
parent | 063dd2ad03e30263b45167615cddb69dd9189584 (diff) | |
download | poi-7c0d1fc041746fb337e683c198ed5d618481004e.tar.gz poi-7c0d1fc041746fb337e683c198ed5d618481004e.zip |
Merged revisions 707486,707519,707525,707534,707541-707542,707551,707585,707729,707778,707780,707802 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk
........
r707486 | josh | 2008-10-23 15:28:05 -0700 (Thu, 23 Oct 2008) | 1 line
Converted Ptgs to use LittleEndianOutput
........
r707519 | josh | 2008-10-23 17:58:49 -0700 (Thu, 23 Oct 2008) | 1 line
Fix for unicode string bug in StyleRecord. Improvements to WriteAccessRecord.
........
r707525 | josh | 2008-10-23 19:08:47 -0700 (Thu, 23 Oct 2008) | 1 line
Further conversion of Ptg classes to use LittleEndian input/output interfaces
........
r707534 | josh | 2008-10-23 20:47:42 -0700 (Thu, 23 Oct 2008) | 1 line
added LittleEndianByteArrayInputStream
........
r707541 | josh | 2008-10-23 21:30:38 -0700 (Thu, 23 Oct 2008) | 1 line
Removed String methods from LittleEndianInput
........
r707542 | josh | 2008-10-23 21:40:37 -0700 (Thu, 23 Oct 2008) | 1 line
removing unused code
........
r707551 | josh | 2008-10-23 22:46:29 -0700 (Thu, 23 Oct 2008) | 1 line
Simplification and code clean-up
........
r707585 | josh | 2008-10-24 01:58:00 -0700 (Fri, 24 Oct 2008) | 1 line
General clean-up in LittleEndian util class. (Some optimization, some obsolete code removal)
........
r707729 | josh | 2008-10-24 12:25:11 -0700 (Fri, 24 Oct 2008) | 1 line
Fixed test suite name
........
r707778 | josh | 2008-10-24 16:13:44 -0700 (Fri, 24 Oct 2008) | 1 line
Optimisation of RecordInputStream - removed intermediate 8K byte buffer. Expected performance gain was not realised immediately, so LittleEndianInput stuff has been pushed down into DocumentInputStream to help.
........
r707780 | josh | 2008-10-24 16:19:26 -0700 (Fri, 24 Oct 2008) | 1 line
should have been submitted with c707778
........
r707802 | josh | 2008-10-24 18:02:37 -0700 (Fri, 24 Oct 2008) | 1 line
Further simplification to RecordInputStream. Mostly regarding Strings, ContinueRecords and LittleEndianInput
........
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@707945 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
23 files changed, 146 insertions, 470 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java index 5fb6f4aa03..edf62a9ad1 100755 --- a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java +++ b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java @@ -100,6 +100,7 @@ public final class AllRecordTests { result.addTestSuite(TestSheetPropertiesRecord.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); diff --git a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java index 53a49fda0d..8e6e7ce561 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java @@ -37,7 +37,7 @@ public final class TestCommonObjectDataSubRecord extends TestCase { }; public void testLoad() { - CommonObjectDataSubRecord record = new CommonObjectDataSubRecord(TestcaseRecordInputStream.createWithFakeSid(data), data.length); + CommonObjectDataSubRecord record = new CommonObjectDataSubRecord(TestcaseRecordInputStream.createLittleEndian(data), data.length); assertEquals( CommonObjectDataSubRecord.OBJECT_TYPE_LIST_BOX, record.getObjectType()); assertEquals((short) 1, record.getObjectId()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java index deaf779bbb..02875117ec 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java @@ -14,11 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hssf.record;
-import java.io.ByteArrayInputStream;
import java.util.Arrays;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.util.HexRead;
@@ -37,33 +38,43 @@ public final class TestEmbeddedObjectRefSubRecord extends TestCase { public void testStore() {
byte[] src = hr(data1);
- src = TestcaseRecordInputStream.mergeDataAndSid(EmbeddedObjectRefSubRecord.sid, (short)src.length, src);
+// src = TestcaseRecordInputStream.mergeDataAndSid(EmbeddedObjectRefSubRecord.sid, (short)src.length, src);
- RecordInputStream in = new RecordInputStream(new ByteArrayInputStream(src));
- in.nextRecord();
+ RecordInputStream in = TestcaseRecordInputStream.create(EmbeddedObjectRefSubRecord.sid, src);
- EmbeddedObjectRefSubRecord record1 = new EmbeddedObjectRefSubRecord(in, src.length-4);
+ EmbeddedObjectRefSubRecord record1 = new EmbeddedObjectRefSubRecord(in, src.length);
byte[] ser = record1.serialize();
- RecordInputStream in2 = new RecordInputStream(new ByteArrayInputStream(ser));
- in2.nextRecord();
+ RecordInputStream in2 = TestcaseRecordInputStream.create(ser);
EmbeddedObjectRefSubRecord record2 = new EmbeddedObjectRefSubRecord(in2, ser.length-4);
- assertTrue(Arrays.equals(src, ser));
+ confirmData(src, ser);
assertEquals(record1.getOLEClassName(), record2.getOLEClassName());
byte[] ser2 = record1.serialize();
assertTrue(Arrays.equals(ser, ser2));
}
+ /**
+ * @param expectedData does not include sid & size
+ * @param actualFullRecordData includes sid & size
+ */
+ private static void confirmData(byte[] expectedData, byte[] actualFullRecordData) {
+ assertEquals(expectedData.length, actualFullRecordData.length-4);
+ for (int i = 0; i < expectedData.length; i++) {
+ if(expectedData[i] != actualFullRecordData[i+4]) {
+ throw new AssertionFailedError("Difference at offset (" + i + ")");
+ }
+ }
+ }
+
public void testCreate() {
EmbeddedObjectRefSubRecord record1 = new EmbeddedObjectRefSubRecord();
byte[] ser = record1.serialize();
- RecordInputStream in2 = new RecordInputStream(new ByteArrayInputStream(ser));
- in2.nextRecord();
+ RecordInputStream in2 = TestcaseRecordInputStream.create(ser);
EmbeddedObjectRefSubRecord record2 = new EmbeddedObjectRefSubRecord(in2, ser.length-4);
assertEquals(record1.getOLEClassName(), record2.getOLEClassName());
@@ -78,21 +89,17 @@ public final class TestEmbeddedObjectRefSubRecord extends TestCase { * taken from ftPictFmla sub-record in attachment 22645 (offset 0x40AB).
*/
private static final byte[] data45912 = hr(
- "09 00 14 00 " +
"12 00 0B 00 F8 02 88 04 3B 00 " +
"00 00 00 01 00 00 00 01 " +
"00 00");
public void testCameraTool_bug45912() {
byte[] data = data45912;
- RecordInputStream in = new RecordInputStream(new ByteArrayInputStream(data));
- in.nextRecord();
+ RecordInputStream in = TestcaseRecordInputStream.create(EmbeddedObjectRefSubRecord.sid, data);
- EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data.length-4);
+ EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data.length);
byte[] ser2 = rec.serialize();
- assertTrue(Arrays.equals(data, ser2));
-
-
+ confirmData(data, ser2);
}
private static byte[] hr(String string) {
diff --git a/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java index 703664443c..cf8fe0bd2f 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java @@ -119,7 +119,6 @@ public final class TestFormulaRecord extends TestCase { public void testWithConcat() { // =CHOOSE(2,A2,A3,A4) byte[] data = { - 6, 0, 68, 0, 1, 0, 1, 0, 15, 0, 0, 0, 0, 0, 0, 0, 57, 64, 0, 0, 12, 0, 12, -4, 46, 0, 30, 2, 0, // Int - 2 @@ -134,8 +133,7 @@ public final class TestFormulaRecord extends TestCase { 25, 8, 3, 0, // Attr 66, 4, 100, 0 // CHOOSE }; - RecordInputStream inp = new RecordInputStream( new ByteArrayInputStream(data)); - inp.nextRecord(); + RecordInputStream inp = TestcaseRecordInputStream.create(FormatRecord.sid, data); FormulaRecord fr = new FormulaRecord(inp); diff --git a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java index 1919a4b038..ce0e6e2030 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java @@ -239,8 +239,7 @@ public final class TestHyperlinkRecord extends TestCase { RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data); HyperlinkRecord link = new HyperlinkRecord(is); byte[] bytes1 = link.serialize(); - is = new RecordInputStream(new ByteArrayInputStream(bytes1)); - is.nextRecord(); + is = TestcaseRecordInputStream.create(bytes1); link = new HyperlinkRecord(is); byte[] bytes2 = link.serialize(); assertEquals(bytes1.length, bytes2.length); diff --git a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java index 8a52211a6a..7dea16b308 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java @@ -23,6 +23,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.RefPtg; +import org.apache.poi.util.LittleEndianInput; /** * @author Josh Micich @@ -59,7 +60,7 @@ public final class TestSharedFormulaRecord extends TestCase { */ public void testConvertSharedFormulasOperandClasses_bug45123() { - RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(SHARED_FORMULA_WITH_REF_ARRAYS_DATA); + LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(SHARED_FORMULA_WITH_REF_ARRAYS_DATA); int encodedLen = in.readUShort(); Ptg[] sharedFormula = Ptg.readTokens(encodedLen, in); diff --git a/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java new file mode 100644 index 0000000000..bfe11dd3a8 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java @@ -0,0 +1,33 @@ +/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record;
+
+import junit.framework.TestCase;
+/**
+ *
+ */
+public final class TestStyleRecord extends TestCase {
+ public void testUnicodeReadName() {
+ byte[] data = {
+ 17, 0, 9, 0, 1, 56, 94, -60, -119, 95, 0, 83, 0, 104, 0, 101, 0, 101, 0, 116, 0, 49, 0, 92, 40, //92, 36
+ };
+ RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
+ StyleRecord sr = new StyleRecord(in);
+ assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java b/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java index b8f9e86468..9b53cdd339 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestTextObjectBaseRecord.java @@ -55,11 +55,9 @@ public final class TestTextObjectBaseRecord extends TestCase { public void testLoad() { - RecordInputStream in = new RecordInputStream(new ByteArrayInputStream(data)); - in.nextRecord(); + RecordInputStream in = TestcaseRecordInputStream.create(data); TextObjectRecord record = new TextObjectRecord(in); - assertEquals(TextObjectRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED, record.getHorizontalTextAlignment()); assertEquals(TextObjectRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY, record.getVerticalTextAlignment()); assertEquals(true, record.isTextLocked()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java b/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java index b7d45e28b0..19ec07c810 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java @@ -52,8 +52,7 @@ public final class TestTextObjectRecord extends TestCase { public void testRead() {
- RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(simpleData));
- is.nextRecord();
+ RecordInputStream is =TestcaseRecordInputStream.create(simpleData);
TextObjectRecord record = new TextObjectRecord(is);
assertEquals(TextObjectRecord.sid, record.getSid());
@@ -79,8 +78,7 @@ public final class TestTextObjectRecord extends TestCase { assertTrue(Arrays.equals(simpleData, ser));
//read again
- RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(simpleData));
- is.nextRecord();
+ RecordInputStream is = TestcaseRecordInputStream.create(simpleData);
record = new TextObjectRecord(is);
}
@@ -101,8 +99,7 @@ public final class TestTextObjectRecord extends TestCase { assertEquals(22, ser.length); // just the TXO record
//read again
- RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(ser));
- is.nextRecord();
+ RecordInputStream is = TestcaseRecordInputStream.create(ser);
record = new TextObjectRecord(is);
assertEquals(0, record.getStr().length());
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java b/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java index e16eb2022e..1bbc9d7a94 100755 --- a/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java +++ b/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java @@ -23,6 +23,8 @@ import java.io.InputStream; import junit.framework.Assert; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.LittleEndianByteArrayInputStream; +import org.apache.poi.util.LittleEndianInput; /** * A Record Input Stream derivative that makes access to byte arrays used in the @@ -40,8 +42,8 @@ public final class TestcaseRecordInputStream { /** * Prepends a mock record identifier to the supplied data and opens a record input stream */ - public static RecordInputStream createWithFakeSid(byte[] data) { - return create(-5555, data); + public static LittleEndianInput createLittleEndian(byte[] data) { + return new LittleEndianByteArrayInputStream(data); } public static RecordInputStream create(int sid, byte[] data) { diff --git a/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java b/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java index 17a0901040..a72d0e1aed 100644 --- a/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java +++ b/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java @@ -21,11 +21,12 @@ import java.util.Arrays; import junit.framework.TestCase; -import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.TestcaseRecordInputStream; import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.usermodel.HSSFErrorConstants; import org.apache.poi.util.HexRead; +import org.apache.poi.util.LittleEndianByteArrayOutputStream; +import org.apache.poi.util.LittleEndianInput; /** * * @author Josh Micich @@ -52,14 +53,15 @@ public final class TestConstantValueParser extends TestCase { public void testEncode() { int size = ConstantValueParser.getEncodedSize(SAMPLE_VALUES); byte[] data = new byte[size]; - ConstantValueParser.encode(data, 0, SAMPLE_VALUES); + + ConstantValueParser.encode(new LittleEndianByteArrayOutputStream(data, 0), SAMPLE_VALUES); if (!Arrays.equals(data, SAMPLE_ENCODING)) { fail("Encoding differs"); } } public void testDecode() { - RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(SAMPLE_ENCODING); + LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(SAMPLE_ENCODING); Object[] values = ConstantValueParser.parse(in, 4); for (int i = 0; i < values.length; i++) { diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java index 8d2fe631d2..94a16b3829 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java @@ -24,6 +24,8 @@ import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.TestcaseRecordInputStream; import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.util.LittleEndianByteArrayOutputStream; +import org.apache.poi.util.LittleEndianInput; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -54,9 +56,9 @@ public final class TestArrayPtg extends TestCase { */ public void testReadWriteTokenValueBytes() { - ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA)); + ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA)); - ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA)); + ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA)); assertEquals(3, ptg.getColumnCount()); assertEquals(2, ptg.getRowCount()); Object[][] values = ptg.getTokenArrayValues(); @@ -70,7 +72,7 @@ public final class TestArrayPtg extends TestCase { assertEquals(new UnicodeString("FG"), values[1][2]); byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length]; - ptg.writeTokenValueBytes(outBuf, 0); + ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0)); if(outBuf[0] == 4) { throw new AssertionFailedError("Identified bug 42564b"); @@ -82,8 +84,8 @@ public final class TestArrayPtg extends TestCase { * Excel stores array elements column by column. This test makes sure POI does the same. */ public void testElementOrdering() { - ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA)); - ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA)); + ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA)); + ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA)); assertEquals(3, ptg.getColumnCount()); assertEquals(2, ptg.getRowCount()); @@ -113,9 +115,9 @@ public final class TestArrayPtg extends TestCase { } public void testToFormulaString() { - ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createWithFakeSid(ENCODED_PTG_DATA)); + ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.createLittleEndian(ENCODED_PTG_DATA)); - ptg.readTokenValues(TestcaseRecordInputStream.createWithFakeSid(ENCODED_CONSTANT_DATA)); + ptg.readTokenValues(TestcaseRecordInputStream.createLittleEndian(ENCODED_CONSTANT_DATA)); String actualFormula; try { @@ -146,7 +148,7 @@ public final class TestArrayPtg extends TestCase { // Force encoded operand class for tArray fullData[0] = (byte) (ArrayPtg.sid + operandClass); - RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(fullData); + LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData); Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in); assertEquals(1, ptgs.length); diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java index d9342d61c0..7edb3f4fc5 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java @@ -21,9 +21,9 @@ import java.util.Arrays; import junit.framework.AssertionFailedError; -import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.TestcaseRecordInputStream; import org.apache.poi.util.HexRead; +import org.apache.poi.util.LittleEndianInput; /** * Tests for {@link AttrPtg}. @@ -37,7 +37,7 @@ public final class TestAttrPtg extends AbstractPtgTestCase { */ public void testReserializeAttrChoose() { byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00"); - RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(data); + LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data); Ptg[] ptgs = Ptg.readTokens(data.length, in); byte[] data2 = new byte[data.length]; try { diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java index 827bea8332..bbf8c4cfb2 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java @@ -34,7 +34,7 @@ public final class TestFuncPtg extends TestCase { 0, }; - FuncPtg ptg = new FuncPtg(TestcaseRecordInputStream.createWithFakeSid(fakeData) ); + FuncPtg ptg = new FuncPtg(TestcaseRecordInputStream.createLittleEndian(fakeData) ); assertEquals( "Len formula index is not 32(20H)", 0x20, ptg.getFunctionIndex() ); assertEquals( "Number of operands in the len formula", 1, ptg.getNumberOfOperands() ); assertEquals( "Function Name", "LEN", ptg.getName() ); diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java index 6be329ed5a..dc8fd6b9b6 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java @@ -23,10 +23,10 @@ import junit.framework.AssertionFailedError; import junit.framework.TestCase; import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.TestcaseRecordInputStream; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.util.LittleEndianInput; /** * Tests for {@link RefPtg}. @@ -94,7 +94,7 @@ public final class TestReferencePtg extends TestCase { 0x2C, 33, 44, 55, 66, }; public void testReadWrite_tRefN_bug45091() { - RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(tRefN_data); + LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(tRefN_data); Ptg[] ptgs = Ptg.readTokens(tRefN_data.length, in); byte[] outData = new byte[5]; Ptg.serializePtgs(ptgs, outData, 0); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java index b42f7ef71a..751826e3fb 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,18 +14,16 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - package org.apache.poi.poifs.filesystem; -import java.io.*; - -import java.util.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Arrays; -import junit.framework.*; +import junit.framework.TestCase; import org.apache.poi.poifs.property.DirectoryProperty; -import org.apache.poi.poifs.property.DocumentProperty; import org.apache.poi.poifs.storage.RawDataBlock; /** @@ -35,22 +32,9 @@ import org.apache.poi.poifs.storage.RawDataBlock; * @author Marc Johnson */ -public class TestDocumentInputStream - extends TestCase -{ +public final class TestDocumentInputStream extends TestCase { - /** - * Constructor TestDocumentInputStream - * - * @param name - * - * @exception IOException - */ - - public TestDocumentInputStream(String name) - throws IOException - { - super(name); + protected void setUp() throws Exception { int blocks = (_workbook_size + 511) / 512; _workbook_data = new byte[ 512 * blocks ]; @@ -86,13 +70,8 @@ public class TestDocumentInputStream /** * test constructor - * - * @exception IOException */ - - public void testConstructor() - throws IOException - { + public void testConstructor() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); assertEquals(_workbook_size, stream.available()); @@ -100,13 +79,8 @@ public class TestDocumentInputStream /** * test available() behavior - * - * @exception IOException */ - - public void testAvailable() - throws IOException - { + public void testAvailable() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); assertEquals(_workbook_size, stream.available()); @@ -115,9 +89,7 @@ public class TestDocumentInputStream { stream.available(); fail("Should have caught IOException"); - } - catch (IOException ignored) - { + } catch (IllegalStateException ignored) { // as expected } @@ -125,13 +97,8 @@ public class TestDocumentInputStream /** * test mark/reset/markSupported. - * - * @exception IOException */ - - public void testMarkFunctions() - throws IOException - { + public void testMarkFunctions() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); byte[] buffer = new byte[ _workbook_size / 5 ]; @@ -169,13 +136,8 @@ public class TestDocumentInputStream /** * test simple read method - * - * @exception IOException */ - - public void testReadSingleByte() - throws IOException - { + public void testReadSingleByte() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); int remaining = _workbook_size; @@ -205,13 +167,8 @@ public class TestDocumentInputStream /** * Test buffered read - * - * @exception IOException */ - - public void testBufferRead() - throws IOException - { + public void testBufferRead() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); try @@ -275,23 +232,14 @@ public class TestDocumentInputStream /** * Test complex buffered read - * - * @exception IOException */ - - public void testComplexBufferRead() - throws IOException - { + public void testComplexBufferRead() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); - try - { + try { stream.read(null, 0, 1); fail("Should have caught NullPointerException"); - } - catch (NullPointerException ignored) - { - + } catch (IllegalArgumentException ignored) { // as expected } @@ -391,13 +339,8 @@ public class TestDocumentInputStream /** * test skip - * - * @exception IOException */ - - public void testSkip() - throws IOException - { + public void testSkip() throws IOException { DocumentInputStream stream = new DocumentInputStream(_workbook); assertEquals(_workbook_size, stream.available()); @@ -422,17 +365,4 @@ public class TestDocumentInputStream stream.skip(2 + ( long ) Integer.MAX_VALUE)); assertEquals(0, stream.available()); } - - /** - * main method to run the unit tests - * - * @param ignored_args - */ - - public static void main(String [] ignored_args) - { - System.out.println( - "Testing org.apache.poi.poifs.filesystem.DocumentInputStream"); - junit.textui.TestRunner.run(TestDocumentInputStream.class); - } } diff --git a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java index 8c15d389e3..b589922587 100755 --- a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java +++ b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java @@ -26,22 +26,22 @@ import junit.framework.TestSuite; */ public final class AllPOIFSStorageTests { - public static Test suite() { - TestSuite result = new TestSuite("Tests for org.apache.poi.poifs.storage"); - result.addTestSuite(TestBATBlock.class); - result.addTestSuite(TestBlockAllocationTableReader.class); - result.addTestSuite(TestBlockAllocationTableWriter.class); - result.addTestSuite(TestBlockListImpl.class); - result.addTestSuite(TestDocumentBlock.class); - result.addTestSuite(TestHeaderBlockReader.class); - result.addTestSuite(TestHeaderBlockWriter.class); - result.addTestSuite(TestPropertyBlock.class); - result.addTestSuite(TestRawDataBlock.class); - result.addTestSuite(TestRawDataBlockList.class); - result.addTestSuite(TestSmallBlockTableReader.class); - result.addTestSuite(TestSmallBlockTableWriter.class); - result.addTestSuite(TestSmallDocumentBlock.class); - result.addTestSuite(TestSmallDocumentBlockList.class); - return result; - } + public static Test suite() { + TestSuite result = new TestSuite(AllPOIFSStorageTests.class.getName()); + result.addTestSuite(TestBATBlock.class); + result.addTestSuite(TestBlockAllocationTableReader.class); + result.addTestSuite(TestBlockAllocationTableWriter.class); + result.addTestSuite(TestBlockListImpl.class); + result.addTestSuite(TestDocumentBlock.class); + result.addTestSuite(TestHeaderBlockReader.class); + result.addTestSuite(TestHeaderBlockWriter.class); + result.addTestSuite(TestPropertyBlock.class); + result.addTestSuite(TestRawDataBlock.class); + result.addTestSuite(TestRawDataBlockList.class); + result.addTestSuite(TestSmallBlockTableReader.class); + result.addTestSuite(TestSmallBlockTableWriter.class); + result.addTestSuite(TestSmallDocumentBlock.class); + result.addTestSuite(TestSmallDocumentBlockList.class); + return result; + } } diff --git a/src/testcases/org/apache/poi/poifs/storage/TestDocumentBlock.java b/src/testcases/org/apache/poi/poifs/storage/TestDocumentBlock.java index bb0ca8cd6c..3c15e2deae 100644 --- a/src/testcases/org/apache/poi/poifs/storage/TestDocumentBlock.java +++ b/src/testcases/org/apache/poi/poifs/storage/TestDocumentBlock.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,25 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - package org.apache.poi.poifs.storage; -import java.io.*; - -import java.util.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; -import junit.framework.*; +import junit.framework.TestCase; /** * Class to test DocumentBlock functionality * * @author Marc Johnson */ - -public class TestDocumentBlock - extends TestCase -{ +public final class TestDocumentBlock extends TestCase { static final private byte[] _testdata; static @@ -44,25 +39,10 @@ public class TestDocumentBlock _testdata[ j ] = ( byte ) j; } } - ; - - /** - * Constructor TestDocumentBlock - * - * @param name - */ - - public TestDocumentBlock(String name) - { - super(name); - } /** * Test the writing DocumentBlock constructor. - * - * @exception IOException */ - public void testConstructor() throws IOException { @@ -88,46 +68,10 @@ public class TestDocumentBlock assertEquals(_testdata.length, size); } - /** - * test static read method - * - * @exception IOException - */ - - public void testRead() - throws IOException - { - DocumentBlock[] blocks = new DocumentBlock[ 4 ]; - ByteArrayInputStream input = new ByteArrayInputStream(_testdata); - - for (int j = 0; j < 4; j++) - { - blocks[ j ] = new DocumentBlock(input); - } - for (int j = 1; j <= 2000; j += 17) - { - byte[] buffer = new byte[ j ]; - int offset = 0; - - for (int k = 0; k < (2000 / j); k++) - { - DocumentBlock.read(blocks, buffer, offset); - for (int n = 0; n < buffer.length; n++) - { - assertEquals("checking byte " + (k * j) + n, - _testdata[ (k * j) + n ], buffer[ n ]); - } - offset += j; - } - } - } /** * Test 'reading' constructor - * - * @exception IOException */ - public void testReadingConstructor() throws IOException { @@ -164,17 +108,4 @@ public class TestDocumentBlock assertEquals(( byte ) 0xFF, copy[ j ]); } } - - /** - * main method to run the unit tests - * - * @param ignored_args - */ - - public static void main(String [] ignored_args) - { - System.out - .println("Testing org.apache.poi.poifs.storage.DocumentBlock"); - junit.textui.TestRunner.run(TestDocumentBlock.class); - } } diff --git a/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java b/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java index 05e51974f8..dfbfbb4e51 100644 --- a/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java +++ b/src/testcases/org/apache/poi/poifs/storage/TestSmallDocumentBlock.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,25 +14,24 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - package org.apache.poi.poifs.storage; -import java.io.*; - -import java.util.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; -import junit.framework.*; +import junit.framework.TestCase; /** * Class to test SmallDocumentBlock functionality * * @author Marc Johnson */ - -public class TestSmallDocumentBlock - extends TestCase -{ +public final class TestSmallDocumentBlock extends TestCase { static final private byte[] _testdata; static final private int _testdata_size = 2999; @@ -45,25 +43,10 @@ public class TestSmallDocumentBlock _testdata[ j ] = ( byte ) j; } } - ; - - /** - * constructor - * - * @param name - */ - - public TestSmallDocumentBlock(String name) - { - super(name); - } /** * Test conversion from DocumentBlocks - * - * @exception IOException */ - public void testConvert1() throws IOException { @@ -113,12 +96,7 @@ public class TestSmallDocumentBlock /** * Test conversion from byte array - * - * @exception IOException; - * - * @exception IOException */ - public void testConvert2() throws IOException { @@ -155,56 +133,8 @@ public class TestSmallDocumentBlock } /** - * Test read method - * - * @exception IOException - */ - - public void testRead() - throws IOException - { - ByteArrayInputStream stream = new ByteArrayInputStream(_testdata); - List documents = new ArrayList(); - - while (true) - { - DocumentBlock block = new DocumentBlock(stream); - - documents.add(block); - if (block.partiallyRead()) - { - break; - } - } - SmallDocumentBlock[] blocks = - SmallDocumentBlock - .convert(( BlockWritable [] ) documents - .toArray(new DocumentBlock[ 0 ]), _testdata_size); - - for (int j = 1; j <= _testdata_size; j += 38) - { - byte[] buffer = new byte[ j ]; - int offset = 0; - - for (int k = 0; k < (_testdata_size / j); k++) - { - SmallDocumentBlock.read(blocks, buffer, offset); - for (int n = 0; n < buffer.length; n++) - { - assertEquals("checking byte " + (k * j) + n, - _testdata[ (k * j) + n ], buffer[ n ]); - } - offset += j; - } - } - } - - /** * test fill - * - * @exception IOException */ - public void testFill() throws IOException { @@ -294,17 +224,4 @@ public class TestSmallDocumentBlock } } } - - /** - * main method to run the unit tests - * - * @param ignored_args - */ - - public static void main(String [] ignored_args) - { - System.out.println( - "Testing org.apache.poi.poifs.storage.SmallDocumentBlock"); - junit.textui.TestRunner.run(TestSmallDocumentBlock.class); - } } diff --git a/src/testcases/org/apache/poi/util/AllPOIUtilTests.java b/src/testcases/org/apache/poi/util/AllPOIUtilTests.java index bb6d382047..6364c8c354 100755 --- a/src/testcases/org/apache/poi/util/AllPOIUtilTests.java +++ b/src/testcases/org/apache/poi/util/AllPOIUtilTests.java @@ -27,12 +27,11 @@ import junit.framework.TestSuite; public final class AllPOIUtilTests { public static Test suite() { - TestSuite result = new TestSuite("Tests for org.apache.poi.util"); + TestSuite result = new TestSuite(AllPOIUtilTests.class.getName()); result.addTestSuite(TestArrayUtil.class); result.addTestSuite(TestBinaryTree.class); result.addTestSuite(TestBitField.class); result.addTestSuite(TestByteField.class); - result.addTestSuite(TestDoubleList2d.class); result.addTestSuite(TestHexDump.class); result.addTestSuite(TestIntegerField.class); result.addTestSuite(TestIntList.class); diff --git a/src/testcases/org/apache/poi/util/TestDoubleList2d.java b/src/testcases/org/apache/poi/util/TestDoubleList2d.java deleted file mode 100644 index b85e7eb4e5..0000000000 --- a/src/testcases/org/apache/poi/util/TestDoubleList2d.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package org.apache.poi.util; - -import junit.framework.TestCase; - -/** - * @version $Id$ - */ -public class TestDoubleList2d - extends TestCase -{ - public void testAccess() - throws Exception - { - DoubleList2d array = new DoubleList2d(); - assertEquals( 0, array.get( 0, 0 ), 0.00001 ); - assertEquals( 0, array.get( 1, 1 ), 0.00001 ); - assertEquals( 0, array.get( 100, 100 ), 0.00001 ); - array.set( 100, 100, 999 ); - assertEquals( 999, array.get( 100, 100 ), 0.00001 ); - assertEquals( 0, array.get( 0, 0 ), 0.00001 ); - array.set( 0, 0, 999 ); - assertEquals( 999, array.get( 0, 0 ), 0.00001 ); - - try - { - array.get( -1, -1 ); - fail(); - } - catch ( ArrayIndexOutOfBoundsException e ) - { - // pass - } - } -} diff --git a/src/testcases/org/apache/poi/util/TestLittleEndian.java b/src/testcases/org/apache/poi/util/TestLittleEndian.java index 0ffcd189da..bba8a653e3 100644 --- a/src/testcases/org/apache/poi/util/TestLittleEndian.java +++ b/src/testcases/org/apache/poi/util/TestLittleEndian.java @@ -97,13 +97,13 @@ public final class TestLittleEndian extends TestCase { * test the getDouble() method */ public void testGetDouble() { - assertEquals(_doubles[0], LittleEndian.getDouble(_double_array), 0.000001 ); + assertEquals(_doubles[0], LittleEndian.getDouble(_double_array, 0), 0.000001 ); assertEquals(_doubles[1], LittleEndian.getDouble( _double_array, LittleEndian.DOUBLE_SIZE), 0.000001); - assertTrue(Double.isNaN(LittleEndian.getDouble(_nan_double_array))); + assertTrue(Double.isNaN(LittleEndian.getDouble(_nan_double_array, 0))); - double nan = LittleEndian.getDouble(_nan_double_array); + double nan = LittleEndian.getDouble(_nan_double_array, 0); byte[] data = new byte[8]; - LittleEndian.putDouble(data, nan); + LittleEndian.putDouble(data, 0, nan); for ( int i = 0; i < data.length; i++ ) { assertEquals(data[i], _nan_double_array[i]); } @@ -144,7 +144,7 @@ public final class TestLittleEndian extends TestCase { (byte) 0x02, }; - assertEquals(0xFFFFFFFFFFFFFF01L, LittleEndian.getLong(testdata)); + assertEquals(0xFFFFFFFFFFFFFF01L, LittleEndian.getLong(testdata, 0)); assertEquals(0x02FFFFFFFFFFFFFFL, LittleEndian.getLong(testdata, 1)); } @@ -194,7 +194,7 @@ public final class TestLittleEndian extends TestCase { public void testPutDouble() { byte[] received = new byte[ LittleEndian.DOUBLE_SIZE + 1 ]; - LittleEndian.putDouble(received, _doubles[0]); + LittleEndian.putDouble(received, 0, _doubles[0]); assertTrue(compareByteArrays(received, _double_array, 0, LittleEndian.DOUBLE_SIZE)); LittleEndian.putDouble(received, 1, _doubles[1]); byte[] expected = new byte[ LittleEndian.DOUBLE_SIZE + 1 ]; @@ -224,7 +224,7 @@ public final class TestLittleEndian extends TestCase { long testdata0 = 0xFFFFFFFFFFFFFF01L; long testdata1 = 0x02FFFFFFFFFFFFFFL; - LittleEndian.putLong(received, testdata0); + LittleEndian.putLong(received, 0, testdata0); assertTrue(compareByteArrays(received, expected, 0, LittleEndian.LONG_SIZE)); LittleEndian.putLong(received, 1, testdata1); assertTrue(compareByteArrays(received, expected, 1, LittleEndian.LONG_SIZE)); diff --git a/src/testcases/org/apache/poi/util/TestStringUtil.java b/src/testcases/org/apache/poi/util/TestStringUtil.java index b22439cd09..f1b5cfd954 100644 --- a/src/testcases/org/apache/poi/util/TestStringUtil.java +++ b/src/testcases/org/apache/poi/util/TestStringUtil.java @@ -42,43 +42,7 @@ public class TestStringUtil super( name ); } - /** - * test simple form of getFromUnicode - */ - public void testSimpleGetFromUnicode() - { - byte[] test_data = new byte[32]; - int index = 0; - - for ( int k = 0; k < 16; k++ ) - { - test_data[index++] = (byte) 0; - test_data[index++] = (byte) ( 'a' + k ); - } - - assertEquals( "abcdefghijklmnop", - StringUtil.getFromUnicodeBE( test_data ) ); - } - - /** - * test simple form of getFromUnicode with symbols with code below and more 127 - */ - public void testGetFromUnicodeSymbolsWithCodesMoreThan127() - { - byte[] test_data = new byte[]{0x04, 0x22, - 0x04, 0x35, - 0x04, 0x41, - 0x04, 0x42, - 0x00, 0x20, - 0x00, 0x74, - 0x00, 0x65, - 0x00, 0x73, - 0x00, 0x74, - }; - assertEquals( "\u0422\u0435\u0441\u0442 test", - StringUtil.getFromUnicodeBE( test_data ) ); - } /** * test getFromUnicodeHigh for symbols with code below and more 127 @@ -101,62 +65,7 @@ public class TestStringUtil StringUtil.getFromUnicodeLE( test_data ) ); } - /** - * Test more complex form of getFromUnicode - */ - public void testComplexGetFromUnicode() - { - byte[] test_data = new byte[32]; - int index = 0; - for ( int k = 0; k < 16; k++ ) - { - test_data[index++] = (byte) 0; - test_data[index++] = (byte) ( 'a' + k ); - } - assertEquals( "abcdefghijklmno", - StringUtil.getFromUnicodeBE( test_data, 0, 15 ) ); - assertEquals( "bcdefghijklmnop", - StringUtil.getFromUnicodeBE( test_data, 2, 15 ) ); - try - { - StringUtil.getFromUnicodeBE( test_data, -1, 16 ); - fail( "Should have caught ArrayIndexOutOfBoundsException" ); - } - catch ( ArrayIndexOutOfBoundsException ignored ) - { - // as expected - } - try - { - StringUtil.getFromUnicodeBE( test_data, 32, 16 ); - fail( "Should have caught ArrayIndexOutOfBoundsException" ); - } - catch ( ArrayIndexOutOfBoundsException ignored ) - { - // as expected - } - - try - { - StringUtil.getFromUnicodeBE( test_data, 1, 16 ); - fail( "Should have caught IllegalArgumentException" ); - } - catch ( IllegalArgumentException ignored ) - { - // as expected - } - - try - { - StringUtil.getFromUnicodeBE( test_data, 1, -1 ); - fail( "Should have caught IllegalArgumentException" ); - } - catch ( IllegalArgumentException ignored ) - { - // as expected - } - } /** * Test putCompressedUnicode |