📄 testpropertytable.java
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -