/* ==================================================================== 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.filesystem; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.poifs.common.POIFSBigBlockSize; import org.apache.poi.poifs.storage.HeaderBlock; import org.apache.poi.poifs.storage.RawDataBlockList; /** * Tests for the new NIO POIFSFileSystem implementation */ public final class TestNPOIFSFileSystem extends TestCase { private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance(); public void testBasicOpen() throws Exception { NPOIFSFileSystem fsA, fsB; // With a simple 512 block file fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi")); fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi")); for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { assertEquals(512, fs.getBigBlockSize()); } // Now with a simple 4096 block file fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi")); fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi")); for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { assertEquals(4096, fs.getBigBlockSize()); } } public void testPropertiesAndFatOnRead() throws Exception { NPOIFSFileSystem fsA, fsB; // With a simple 512 block file fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi")); fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi")); for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { // Check the FAT was properly processed // TODO // Check the properties // TODO } // Now with a simple 4096 block file fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi")); fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi")); for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) { // Check the FAT was properly processed // TODO // Check the properties // TODO } } }