001/* 002 * jDTAUS Core Utilities 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.io.util.test; 022 023import java.io.IOException; 024import org.jdtaus.core.io.StructuredFile; 025import org.jdtaus.core.io.it.StructuredFileTest; 026import org.jdtaus.core.io.util.MemoryFileOperations; 027import org.jdtaus.core.io.util.ReadAheadFileOperations; 028import org.jdtaus.core.io.util.StructuredFileOperations; 029 030/** 031 * Testcase for {@code StructuredFileOperations} implementations. 032 * 033 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 034 * @version $JDTAUS: StructuredFileOperationsReadAheadUnevenTest.java 8641 2012-09-27 06:45:17Z schulte $ 035 */ 036public class StructuredFileOperationsReadAheadUnevenTest 037 extends StructuredFileTest 038{ 039 //--StructuredFileTest------------------------------------------------------ 040 041 /** {@code FileOperations} backing the {@code StructuredFile}. */ 042 private final MemoryFileOperations memOps = new MemoryFileOperations(); 043 044 /** {@code StructuredFile} implementation being tested. */ 045 private StructuredFileOperations structuredFile; 046 047 protected byte[] getStructuredData() 048 { 049 try 050 { 051 this.structuredFile.flush(); 052 return this.memOps.getData(); 053 } 054 catch ( IOException e ) 055 { 056 throw new AssertionError( e ); 057 } 058 } 059 060 protected StructuredFile getStructuredFile() 061 { 062 try 063 { 064 if ( this.structuredFile == null ) 065 { 066 this.structuredFile = new StructuredFileOperations( 067 StructuredFileTest.BLOCK_SIZE, 068 new ReadAheadFileOperations( this.memOps, 3 ) ); 069 070 } 071 072 return this.structuredFile; 073 } 074 catch ( IOException e ) 075 { 076 throw new AssertionError( e ); 077 } 078 } 079 080 //------------------------------------------------------StructuredFileTest-- 081}