📄 testpropertytable.java
字号:
/* ==================================================================== 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.poifs.property;import java.io.*;import java.util.*;import junit.framework.*;import org.apache.poi.poifs.storage.BlockAllocationTableReader;import org.apache.poi.poifs.storage.RawDataBlockList;/** * Class to test PropertyTable functionality * * @author Marc Johnson */public class TestPropertyTable extends TestCase{ /** * Constructor TestPropertyTable * * @param name */ public TestPropertyTable(String name) { super(name); } /** * Test PropertyTable * <p> * Running individual tests of the PropertyTable methods, which is * the traditional way to write unit tests (at least for me), * seems somewhat useless in this case. Of greater relevance: if * one follows the normal steps of creating a PropertyTable, and * then checking the output, does it make sense? In other words, * more of an integration test. * <p> * So, the test consists of creating a PropertyTable instance, * adding three DocumentProperty instances to it, and then getting * the output (including the preWrite phase first), and comparing * it against a real property table extracted from a file known to * be acceptable to Excel. * * @exception IOException */ public void testWriterPropertyTable() throws IOException { // create the PropertyTable PropertyTable table = new PropertyTable(); // create three DocumentProperty instances and add them to the // PropertyTable DocumentProperty workbook = new DocumentProperty("Workbook", 0x00046777); workbook.setStartBlock(0); DocumentProperty summary1 = new DocumentProperty("\005SummaryInformation", 0x00001000); summary1.setStartBlock(0x00000234); DocumentProperty summary2 = new DocumentProperty("\005DocumentSummaryInformation", 0x00001000); summary2.setStartBlock(0x0000023C); table.addProperty(workbook); RootProperty root = table.getRoot(); root.addChild(workbook); table.addProperty(summary1); root = table.getRoot(); root.addChild(summary1); table.addProperty(summary2); root = table.getRoot(); root.addChild(summary2); table.preWrite(); ByteArrayOutputStream stream = new ByteArrayOutputStream(512); byte[] testblock = { ( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00, ( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00, ( byte ) 0x6e, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00, ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x16, ( byte ) 0x00, ( byte ) 0x05, ( byte ) 0x01, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0x02, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0xfe, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x57, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x6b, ( byte ) 0x00, ( byte ) 0x62, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x6b, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x12, ( byte ) 0x00, ( byte ) 0x02, ( byte ) 0x01, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x77, ( byte ) 0x67, ( byte ) 0x04, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, ( byte ) 0x00, ( byte ) 0x53, ( byte ) 0x00, ( byte ) 0x75, ( byte ) 0x00, ( byte ) 0x6d, ( byte ) 0x00, ( byte ) 0x6d, ( byte ) 0x00, ( byte ) 0x61, ( byte ) 0x00, ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00, ( byte ) 0x49, ( byte ) 0x00, ( byte ) 0x6e, ( byte ) 0x00, ( byte ) 0x66, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x6d, ( byte ) 0x00, ( byte ) 0x61, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00, ( byte ) 0x69, ( byte ) 0x00, ( byte ) 0x6f, ( byte ) 0x00, ( byte ) 0x6e, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x28, ( byte ) 0x00, ( byte ) 0x02, ( byte ) 0x01, ( byte ) 0x01, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x03, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0xff, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x34, ( byte ) 0x02, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -