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: StructuredFileOperationsReadAheadTest.java 8641 2012-09-27 06:45:17Z schulte $ 035 */ 036public class StructuredFileOperationsReadAheadTest extends StructuredFileTest 037{ 038 //--StructuredFileTest------------------------------------------------------ 039 040 /** {@code FileOperations} backing the {@code StructuredFile}. */ 041 private final MemoryFileOperations memOps = new MemoryFileOperations(); 042 043 /** {@code StructuredFile} implementation being tested. */ 044 private StructuredFileOperations structuredFile; 045 046 protected byte[] getStructuredData() 047 { 048 try 049 { 050 this.structuredFile.flush(); 051 return this.memOps.getData(); 052 } 053 catch ( IOException e ) 054 { 055 throw new AssertionError( e ); 056 } 057 } 058 059 protected StructuredFile getStructuredFile() 060 { 061 try 062 { 063 if ( this.structuredFile == null ) 064 { 065 this.structuredFile = new StructuredFileOperations( 066 StructuredFileTest.BLOCK_SIZE, 067 new ReadAheadFileOperations( this.memOps ) ); 068 069 } 070 071 return this.structuredFile; 072 } 073 catch ( IOException e ) 074 { 075 throw new AssertionError( e ); 076 } 077 } 078 079 //------------------------------------------------------StructuredFileTest-- 080}