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.CoalescingFileOperations;
027import org.jdtaus.core.io.util.MemoryFileOperations;
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: StructuredFileOperationsCoalescingUnevenTest.java 8641 2012-09-27 06:45:17Z schulte $
035 */
036public class StructuredFileOperationsCoalescingUnevenTest
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        }
055        catch ( IOException e )
056        {
057            throw new AssertionError( e );
058        }
059    }
060
061    protected StructuredFile getStructuredFile()
062    {
063        try
064        {
065            if ( this.structuredFile == null )
066            {
067                this.structuredFile = new StructuredFileOperations(
068                    StructuredFileTest.BLOCK_SIZE,
069                    new CoalescingFileOperations( this.memOps, 3 ) );
070
071            }
072
073            return this.structuredFile;
074        }
075        catch ( IOException e )
076        {
077            throw new AssertionError( e );
078        }
079    }
080
081    //------------------------------------------------------StructuredFileTest--
082}