Lines 55-66
Link Here
|
55 |
|
55 |
|
56 |
package org.apache.poi.hssf.record; |
56 |
package org.apache.poi.hssf.record; |
57 |
|
57 |
|
|
|
58 |
import java.io.ByteArrayInputStream; |
59 |
|
58 |
import junit.framework.TestCase; |
60 |
import junit.framework.TestCase; |
59 |
|
61 |
|
60 |
/** |
62 |
/** |
61 |
* Tests the record factory |
63 |
* Tests the record factory |
62 |
* @author Glen Stampoultzis (glens at apache.org) |
64 |
* @author Glen Stampoultzis (glens at apache.org) |
63 |
* @author Andrew C. Oliver (acoliver at apache dot org) |
65 |
* @author Andrew C. Oliver (acoliver at apache dot org) |
|
|
66 |
* @author Csaba Nagy (ncsaba at yahoo dot com) |
64 |
*/ |
67 |
*/ |
65 |
|
68 |
|
66 |
public class TestRecordFactory |
69 |
public class TestRecordFactory |
Lines 156-161
Link Here
|
156 |
assertEquals(515, numberRecord.getSid()); |
159 |
assertEquals(515, numberRecord.getSid()); |
157 |
assertEquals(0.0, numberRecord.getValue(), 0.001); |
160 |
assertEquals(0.0, numberRecord.getValue(), 0.001); |
158 |
assertEquals(21, numberRecord.getXFIndex()); |
161 |
assertEquals(21, numberRecord.getXFIndex()); |
|
|
162 |
} |
163 |
|
164 |
/** |
165 |
* TEST NAME: Test Creating ContinueRecords After Unknown Records From An InputStream <P> |
166 |
* OBJECTIVE: Test that the RecordFactory given an InputStream |
167 |
* constructs the expected array of records.<P> |
168 |
* SUCCESS: Record factory creates the expected records.<P> |
169 |
* FAILURE: The wrong records are created or contain the wrong values <P> |
170 |
* |
171 |
*/ |
172 |
public void testContinuedUnknownRecord() |
173 |
{ |
174 |
byte[] data = new byte[] |
175 |
{ |
176 |
0, -1, 0, 0, // an unknown record with 0 length |
177 |
0x3C , 0, 3, 0, 1, 2, 3, // a continuation record with 3 bytes of data |
178 |
0x3C , 0, 1, 0, 4 // one more continuation record with 1 byte of data |
179 |
}; |
180 |
|
181 |
ByteArrayInputStream bois = new ByteArrayInputStream(data); |
182 |
Record[] records = (Record[]) |
183 |
RecordFactory.createRecords(bois).toArray(new Record[0]); |
184 |
assertEquals("Created record count", 3, records.length); |
185 |
assertEquals("1st record's type", |
186 |
UnknownRecord.class.getName(), |
187 |
records[ 0 ].getClass().getName()); |
188 |
assertEquals("1st record's sid", (short)-256, records[0].getSid()); |
189 |
assertEquals("2nd record's type", |
190 |
ContinueRecord.class.getName(), |
191 |
records[ 1 ].getClass().getName()); |
192 |
ContinueRecord record = (ContinueRecord) records[1]; |
193 |
assertEquals("2nd record's sid", 0x3C, record.getSid()); |
194 |
assertEquals("1st data byte", 1, record.getData()[ 0 ]); |
195 |
assertEquals("2nd data byte", 2, record.getData()[ 1 ]); |
196 |
assertEquals("3rd data byte", 3, record.getData()[ 2 ]); |
197 |
assertEquals("3rd record's type", |
198 |
ContinueRecord.class.getName(), |
199 |
records[ 2 ].getClass().getName()); |
200 |
record = (ContinueRecord) records[2]; |
201 |
assertEquals("3nd record's sid", 0x3C, record.getSid()); |
202 |
assertEquals("4th data byte", 4, record.getData()[ 0 ]); |
159 |
} |
203 |
} |
160 |
|
204 |
|
161 |
public static void main(String [] ignored_args) |
205 |
public static void main(String [] ignored_args) |