Sonar fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876157 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2020-04-05 16:23:21 +00:00
parent af890fba13
commit 074d68fedf
12 changed files with 123 additions and 240 deletions

View File

@ -16,14 +16,16 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import java.util.Objects;
import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.util.Internal;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.FontCharset; import org.apache.poi.ss.usermodel.FontCharset;
import org.apache.poi.ss.usermodel.FontFamily; import org.apache.poi.ss.usermodel.FontFamily;
import org.apache.poi.ss.usermodel.FontScheme; import org.apache.poi.ss.usermodel.FontScheme;
import org.apache.poi.ss.usermodel.FontUnderline; import org.apache.poi.ss.usermodel.FontUnderline;
import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.util.Internal;
import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.model.ThemesTable; import org.apache.poi.xssf.model.ThemesTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
@ -39,8 +41,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STFontScheme;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun;
import java.util.Objects;
/** /**
* Represents a font used in a workbook. * Represents a font used in a workbook.
* *
@ -649,7 +649,6 @@ public class XSSFFont implements Font {
&& Objects.equals(this.getBold(), cf.getBold()) && Objects.equals(this.getBold(), cf.getBold())
&& Objects.equals(this.getStrikeout(), cf.getStrikeout()) && Objects.equals(this.getStrikeout(), cf.getStrikeout())
&& Objects.equals(this.getCharSet(), cf.getCharSet()) && Objects.equals(this.getCharSet(), cf.getCharSet())
&& Objects.equals(this.getItalic(), cf.getItalic())
&& Objects.equals(this.getColor(), cf.getColor()) && Objects.equals(this.getColor(), cf.getColor())
&& Objects.equals(this.getFamily(), cf.getFamily()) && Objects.equals(this.getFamily(), cf.getFamily())
&& Objects.equals(this.getFontHeight(), cf.getFontHeight()) && Objects.equals(this.getFontHeight(), cf.getFontHeight())

View File

@ -22,7 +22,6 @@ import org.apache.poi.ss.usermodel.Color;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.FontFormatting; import org.apache.poi.ss.usermodel.FontFormatting;
import org.apache.poi.ss.usermodel.FontUnderline; import org.apache.poi.ss.usermodel.FontUnderline;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize;
@ -84,8 +83,7 @@ public class XSSFFontFormatting implements FontFormatting {
*/ */
@Override @Override
public boolean isStruckout() { public boolean isStruckout() {
for (CTBooleanProperty bProp : _font.getStrikeArray()) return bProp.getVal(); return _font.sizeOfStrikeArray() > 0 && _font.getStrikeArray(0).getVal();
return false;
} }
/** /**

View File

@ -1537,10 +1537,13 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
return new XWPFHyperlinkRun(ctHyperLink, ctHyperLink.addNewR(), this); return new XWPFHyperlinkRun(ctHyperLink, ctHyperLink.addNewR(), this);
}); });
if (newRun != null) {
String rId = getPart().getPackagePart().addExternalRelationship( String rId = getPart().getPackagePart().addExternalRelationship(
uri, XWPFRelation.HYPERLINK.getRelation() uri, XWPFRelation.HYPERLINK.getRelation()
).getId(); ).getId();
newRun.getCTHyperlink().setId(rId); newRun.getCTHyperlink().setId(rId);
}
return newRun; return newRun;
} }

View File

@ -39,7 +39,7 @@ public final class Chunk {
/** May be null */ /** May be null */
private ChunkSeparator separator; private ChunkSeparator separator;
/** The possible different commands we can hold */ /** The possible different commands we can hold */
protected CommandDefinition[] commandDefinitions; private CommandDefinition[] commandDefinitions;
/** The command+value pairs we hold */ /** The command+value pairs we hold */
private Command[] commands; private Command[] commands;
/* The blocks (if any) we hold */ /* The blocks (if any) we hold */
@ -89,10 +89,15 @@ public final class Chunk {
* *
* @return the command definitions * @return the command definitions
*/ */
@SuppressWarnings("unused")
public CommandDefinition[] getCommandDefinitions() { public CommandDefinition[] getCommandDefinitions() {
return commandDefinitions; return commandDefinitions;
} }
void setCommandDefinitions(CommandDefinition[] commandDefinitions) {
this.commandDefinitions = commandDefinitions;
}
public Command[] getCommands() { public Command[] getCommands() {
return commands; return commands;
} }
@ -128,7 +133,7 @@ public final class Chunk {
* our chunk type has, and figure out the * our chunk type has, and figure out the
* values for them. * values for them.
*/ */
protected void processCommands() { void processCommands() {
if(commandDefinitions == null) { if(commandDefinitions == null) {
throw new IllegalStateException("You must supply the command definitions before calling processCommands!"); throw new IllegalStateException("You must supply the command definitions before calling processCommands!");
} }
@ -162,8 +167,8 @@ public final class Chunk {
switch(type) { switch(type) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
case 11: case 21: case 11: case 21:
case 12: case 16: case 17: case 18: case 28: case 29: case 12: case 16: case 17: case 28: case 29:
// Offset is from start of chunk // Offset is from start of chunk (case 18 has been taken care of above)
break; break;
default: default:
// Offset is from start of header! // Offset is from start of header!
@ -183,16 +188,15 @@ public final class Chunk {
try { try {
// Process // Process
switch(type) { switch(type) {
// Types 0->7 = a flat at bit 0->7 // Types 0->7 = a flag at bit 0->7
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
int val = contents[offset] & (1<<type); command.value = ((contents[offset] >>> type) & 1) == 1;
command.value = Boolean.valueOf(val > 0);
break; break;
case 8: case 8:
command.value = Byte.valueOf(contents[offset]); command.value = contents[offset];
break; break;
case 9: case 9:
command.value = Double.valueOf(LittleEndian.getDouble(contents, offset)); command.value = LittleEndian.getDouble(contents, offset);
break; break;
case 12: case 12:
// A Little Endian String // A Little Endian String
@ -221,14 +225,10 @@ public final class Chunk {
command.value = new String(contents, startsAt, strLen, header.getChunkCharset().name()); command.value = new String(contents, startsAt, strLen, header.getChunkCharset().name());
break; break;
case 25: case 25:
command.value = Short.valueOf( command.value = LittleEndian.getShort(contents, offset);
LittleEndian.getShort(contents, offset)
);
break; break;
case 26: case 26:
command.value = Integer.valueOf( command.value = LittleEndian.getInt(contents, offset);
LittleEndian.getInt(contents, offset)
);
break; break;
// Types 11 and 21 hold the offset to the blocks // Types 11 and 21 hold the offset to the blocks
@ -297,12 +297,12 @@ public final class Chunk {
* A special kind of command that holds the offset to * A special kind of command that holds the offset to
* a block * a block
*/ */
private static class BlockOffsetCommand extends Command { private static final class BlockOffsetCommand extends Command {
private BlockOffsetCommand(CommandDefinition definition) { private BlockOffsetCommand(CommandDefinition definition) {
super(definition, null); super(definition, null);
} }
private void setOffset(int offset) { private void setOffset(int offset) {
value = Integer.valueOf(offset); value = offset;
} }
} }
} }

View File

@ -112,7 +112,7 @@ public final class ChunkFactory {
CommandDefinition[] defs = defsL.toArray(new CommandDefinition[0]); CommandDefinition[] defs = defsL.toArray(new CommandDefinition[0]);
// Add to the map // Add to the map
chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs); chunkCommandDefinitions.put(chunkType, defs);
} }
} finally { } finally {
if (inp != null) { if (inp != null) {
@ -193,11 +193,11 @@ public final class ChunkFactory {
Chunk chunk = new Chunk(header, trailer, separator, contents); Chunk chunk = new Chunk(header, trailer, separator, contents);
// Feed in the stuff from chunks_parse_cmds.tbl // Feed in the stuff from chunks_parse_cmds.tbl
CommandDefinition[] defs = chunkCommandDefinitions.get(Integer.valueOf(header.getType())); CommandDefinition[] defs = chunkCommandDefinitions.get(header.getType());
if (defs == null) { if (defs == null) {
defs = new CommandDefinition[0]; defs = new CommandDefinition[0];
} }
chunk.commandDefinitions = defs; chunk.setCommandDefinitions(defs);
// Now get the chunk to process its commands // Now get the chunk to process its commands
chunk.processCommands(); chunk.processCommands();

View File

@ -894,7 +894,7 @@ public final class HemfPlusDraw {
return LittleEndianConsts.BYTE_SIZE; return LittleEndianConsts.BYTE_SIZE;
} }
// ok we've read a EmfPlusInteger15 // ok we've read a EmfPlusInteger15
value[0] = ((value[0] << 8) | leis.readByte()) & 0x7FFF; value[0] = ((value[0] << 8) | (leis.readByte() & 0xFF)) & 0x7FFF;
return LittleEndianConsts.SHORT_SIZE; return LittleEndianConsts.SHORT_SIZE;
} }

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.apache.poi.hslf.util.MutableByteArrayOutputStream;
import org.apache.poi.util.ArrayUtil; import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal; import org.apache.poi.util.Removal;
@ -296,37 +295,6 @@ public abstract class RecordContainer extends Record
* @param out the stream to write to * @param out the stream to write to
*/ */
public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException { public void writeOut(byte headerA, byte headerB, long type, Record[] children, OutputStream out) throws IOException {
// If we have a mutable output stream, take advantage of that
if(out instanceof MutableByteArrayOutputStream) {
MutableByteArrayOutputStream mout =
(MutableByteArrayOutputStream)out;
// Grab current size
int oldSize = mout.getBytesWritten();
// Write out our header, less the size
mout.write(new byte[] {headerA,headerB});
byte[] typeB = new byte[2];
LittleEndian.putShort(typeB, 0, (short)type);
mout.write(typeB);
mout.write(new byte[4]);
// Write out the children
for (Record aChildren : children) {
aChildren.writeOut(mout);
}
// Update our header with the size
// Don't forget to knock 8 more off, since we don't include the
// header in the size
int length = mout.getBytesWritten() - oldSize - 8;
byte[] size = new byte[4];
LittleEndian.putInt(size,0,length);
mout.overwrite(size, oldSize+4);
} else {
// Going to have to do it a slower way, because we have
// to update the length come the end
// Create a ByteArrayOutputStream to hold everything in // Create a ByteArrayOutputStream to hold everything in
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -353,7 +321,6 @@ public abstract class RecordContainer extends Record
// Write out the bytes // Write out the bytes
out.write(toWrite); out.write(toWrite);
} }
}
/** /**
* Find the records that are parent-aware, and tell them who their parent is * Find the records that are parent-aware, and tell them who their parent is

View File

@ -1,41 +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.hslf.util;
import java.io.ByteArrayOutputStream;
/**
* This class doesn't work yet, but is here to show the idea of a
* ByteArrayOutputStream where you can track how many bytes you've
* already written, and go back and write over a previous part of the stream
*
* @author Nick Burch
*/
public final class MutableByteArrayOutputStream extends ByteArrayOutputStream
{
/** Return how many bytes we've stuffed in so far */
public int getBytesWritten() { return -1; }
/** Write some bytes to the array */
public void write(byte[] b) {}
public void write(int b) {}
/** Write some bytes to an earlier bit of the array */
public void overwrite(byte[] b, int startPos) {}
}

View File

@ -325,9 +325,10 @@ public final class PAPFormattedDiskPage extends FormattedDiskPage {
} }
if (papx != null) {
// LittleEndian.putInt(buf, fcOffset, papx.getEndBytes() + fcMin); // LittleEndian.putInt(buf, fcOffset, papx.getEndBytes() + fcMin);
LittleEndian.putInt( buf, fcOffset, LittleEndian.putInt(buf, fcOffset, translator.getByteIndex(papx.getEnd()));
translator.getByteIndex( papx.getEnd() ) ); }
return buf; return buf;
} }

View File

@ -90,6 +90,7 @@ public final class SprmUtils
LittleEndian.putShort(sprm, 2, (short)param); LittleEndian.putShort(sprm, 2, (short)param);
break; break;
case 6: case 6:
assert(varParam != null);
sprm = new byte[3 + varParam.length]; sprm = new byte[3 + varParam.length];
sprm[2] = (byte)varParam.length; sprm[2] = (byte)varParam.length;
System.arraycopy(varParam, 0, sprm, 3, varParam.length); System.arraycopy(varParam, 0, sprm, 3, varParam.length);

View File

@ -48,7 +48,7 @@ public class FieldsImpl implements Fields
{ {
checkIndexForBinarySearch( list.size(), startIndex, endIndex ); checkIndexForBinarySearch( list.size(), startIndex, endIndex );
int low = startIndex, mid = -1, high = endIndex - 1, result = 0; int low = startIndex, mid = -1, high = endIndex - 1;
while ( low <= high ) while ( low <= high )
{ {
mid = ( low + high ) >>> 1; mid = ( low + high ) >>> 1;
@ -79,7 +79,7 @@ public class FieldsImpl implements Fields
} }
return -insertPoint - 1; return -insertPoint - 1;
} }
return -mid - ( result >= 0 ? 1 : 2 ); return -mid - 1;
} }
private static void checkIndexForBinarySearch( int length, int start, private static void checkIndexForBinarySearch( int length, int start,
@ -127,7 +127,7 @@ public class FieldsImpl implements Fields
if ( map == null || map.isEmpty() ) if ( map == null || map.isEmpty() )
return null; return null;
return map.get( Integer.valueOf( offset ) ); return map.get(offset);
} }
private Map<Integer, FieldImpl> parseFieldStructure( private Map<Integer, FieldImpl> parseFieldStructure(
@ -145,12 +145,13 @@ public class FieldsImpl implements Fields
fields.size()); fields.size());
for ( FieldImpl field : fields ) for ( FieldImpl field : fields )
{ {
result.put( Integer.valueOf( field.getFieldStartOffset() ), field ); result.put(field.getFieldStartOffset(), field );
} }
return result; return result;
} }
private void parseFieldStructureImpl( List<PlexOfField> plexOfFields, @SuppressWarnings("UnnecessaryContinue")
private void parseFieldStructureImpl(List<PlexOfField> plexOfFields,
int startOffsetInclusive, int endOffsetExclusive, int startOffsetInclusive, int endOffsetExclusive,
List<FieldImpl> result ) List<FieldImpl> result )
{ {

View File

@ -22,76 +22,31 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.poi.hdgf.chunks.ChunkFactory.CommandDefinition;
import org.apache.poi.poifs.storage.RawDataUtil;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public final class TestChunks { public final class TestChunks {
public static final byte[] data_a = new byte[] { 70, 0, 0, 0, private static byte[] data_a, data_b;
-1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @BeforeClass
-1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, public static void setup() throws IOException {
0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, data_a = RawDataUtil.decompress(
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, "H4sIAAAAAAAAAHNjYGD4DwRMQNqFAQygFAMTWAIbYIBqQqZRARMSOwNKMwOxChAzMoRIACkeNC3MUAwDjEjGTEISb" +
0, 36, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 12, 0, 0, 0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, 0, 0, -73, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
79, 0, 0, 0, 2, 0, 85, 32, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0,
0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
8, 8, 65, 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0,
0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 1, -13, 15, 0, 0, 0, 0,
-56, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 2, 0, 85, 63, 0, 0,
0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 63, 0, 0, 0, 0, 0,
0, -48, 63, 63, 0, 0, 0, 0, 0, 0, -48, 63, 0, 0, 0, 0, 0, 0, -16, 63,
0, 0, 0, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0,
0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 28,
0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0, 85, 5, 0, 0,
0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
-1, -1, -1, -1, 3, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1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, 0, 0, 0, -16, 63, 1, 0, 1, 0, 0, 1, 1, 0,
7, 0, 0, 0, 0, 0, 0, 0, 1, -1, 15, 7, 0, 0, 0, 0, 101, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 0, 28, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0,
85, 5, 0, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, 0, 0, 0, 2, 0, 0, 0,
0, 0, 0, 0, -122, 0, 0, 0, 1, 0, 80, 1, 0, 0, 0, 60, 0, 0, 0, 60, 0, 0,
0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0
};
@Test @Test
public void testChunkHeaderA() throws Exception { public void testChunkHeaderA() {
ChunkHeader h = ChunkHeader h = ChunkHeader.createChunkHeader(11, data_a, 0);
ChunkHeader.createChunkHeader(11, data_a, 0);
assertTrue(h instanceof ChunkHeaderV11); assertTrue(h instanceof ChunkHeaderV11);
ChunkHeaderV11 header = (ChunkHeaderV11)h; ChunkHeaderV11 header = (ChunkHeaderV11)h;
@ -108,9 +63,8 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
} }
@Test @Test
public void testChunkHeaderB() throws Exception { public void testChunkHeaderB() {
ChunkHeader h = ChunkHeader h = ChunkHeader.createChunkHeader(11, data_b, 0);
ChunkHeader.createChunkHeader(11, data_b, 0);
assertTrue(h instanceof ChunkHeaderV11); assertTrue(h instanceof ChunkHeaderV11);
ChunkHeaderV11 header = (ChunkHeaderV11)h; ChunkHeaderV11 header = (ChunkHeaderV11)h;
@ -147,16 +101,16 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
// Should have two virtual chunk commands, a // Should have two virtual chunk commands, a
// 10 (page sheet) and an 18 // 10 (page sheet) and an 18
assertEquals(2, chunk.commandDefinitions.length); assertEquals(2, chunk.getCommandDefinitions().length);
assertEquals(0, chunk.getCommands().length); assertEquals(0, chunk.getCommands().length);
assertEquals(10, chunk.commandDefinitions[0].getType()); assertEquals(10, chunk.getCommandDefinitions()[0].getType());
assertEquals(0, chunk.commandDefinitions[0].getOffset()); assertEquals(0, chunk.getCommandDefinitions()[0].getOffset());
assertEquals("PageSheet", chunk.commandDefinitions[0].getName()); assertEquals("PageSheet", chunk.getCommandDefinitions()[0].getName());
assertEquals(18, chunk.commandDefinitions[1].getType()); assertEquals(18, chunk.getCommandDefinitions()[1].getType());
assertEquals(0, chunk.commandDefinitions[1].getOffset()); assertEquals(0, chunk.getCommandDefinitions()[1].getOffset());
assertEquals("0", chunk.commandDefinitions[1].getName()); assertEquals("0", chunk.getCommandDefinitions()[1].getName());
} }
@Test @Test
@ -183,16 +137,17 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
// Should have two virtual chunk commands, a // Should have two virtual chunk commands, a
// 10 (Unknown) and an 18 // 10 (Unknown) and an 18
assertEquals(2, chunk.commandDefinitions.length); final CommandDefinition[] cdef = chunk.getCommandDefinitions();
assertEquals(2, cdef.length);
assertEquals(0, chunk.getCommands().length); assertEquals(0, chunk.getCommands().length);
assertEquals(10, chunk.commandDefinitions[0].getType()); assertEquals(10, cdef[0].getType());
assertEquals(0, chunk.commandDefinitions[0].getOffset()); assertEquals(0, cdef[0].getOffset());
assertEquals("PropList", chunk.commandDefinitions[0].getName()); assertEquals("PropList", cdef[0].getName());
assertEquals(18, chunk.commandDefinitions[1].getType()); assertEquals(18, cdef[1].getType());
assertEquals(0, chunk.commandDefinitions[1].getOffset()); assertEquals(0, cdef[1].getOffset());
assertEquals("0", chunk.commandDefinitions[1].getName()); assertEquals("0", cdef[1].getName());
} }
@Test @Test
@ -230,6 +185,5 @@ public static final byte[] data_b = new byte[] { 70, 0, 0, 0,
assertNotNull(chunk.getHeader()); assertNotNull(chunk.getHeader());
assertNull(chunk.getTrailer()); assertNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator()); assertNotNull(chunk.getSeparator());
offset += chunk.getOnDiskSize();
} }
} }