Changeset 5876 for branches/cleanup


Ignore:
Timestamp:
02/02/10 07:26:43 (10 years ago)
Author:
callan
Message:

#463 ByteArrayHandle changes to use direct buffer manipulations

  • Large overhaul to test buffer "growth" throughout the write tests
  • Separated out alignment write tests into their own class
  • Fixed a bug with WriteDoubleTest
  • Fixed a bug with WriteCharTest
Location:
branches/cleanup/components/common
Files:
2 added
17 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/common/src/loci/common/ByteArrayHandle.java

    r5874 r5876  
    5252 
    5353  /** Length of the file. */ 
    54   protected long length; 
     54  //protected long length; 
    5555 
    5656  // -- Constructors -- 
     
    6262  public ByteArrayHandle(byte[] bytes) { 
    6363    buffer = ByteBuffer.wrap(bytes); 
    64     length = buffer.capacity(); 
     64    buffer.limit(0); 
    6565  } 
    6666 
     
    7171  public ByteArrayHandle(int capacity) { 
    7272    buffer = ByteBuffer.allocate(capacity); 
    73     length = capacity; 
     73    buffer.limit(capacity); 
    7474  } 
    7575 
     
    7777  public ByteArrayHandle() { 
    7878    buffer = ByteBuffer.allocate(INITIAL_LENGTH); 
     79    buffer.limit(0); 
    7980  } 
    8081 
     
    9596      buffer = tmp; 
    9697    } 
    97     this.length = length; 
     98    buffer.limit((int) length); 
    9899  } 
    99100 
     
    110111  /* @see IRandomAccess.length() */ 
    111112  public long length() { 
    112     return length; 
     113    return buffer.limit(); 
    113114  } 
    114115 
     
    147148  /* @see IRandomAccess.seek(long) */ 
    148149  public void seek(long pos) throws IOException { 
     150    validateLength((int) pos); 
    149151    buffer.position((int) pos); 
    150152  } 
  • branches/cleanup/components/common/test/loci/common/utests/BufferAlignmentReadTest.java

    r5836 r5876  
    11// 
    2 // BufferAlignmentTest.java 
     2// BufferAlignmentReadTest.java 
    33// 
    44 
     
    4141 * 
    4242 * <dl><dt><b>Source code:</b></dt> 
    43  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/common/test/loci/common/utests/BufferAlignmentTest.java">Trac</a>, 
    44  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/common/test/loci/common/utests/BufferAlignmentTest.java">SVN</a></dd></dl> 
     43 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/common/test/loci/common/utests/BufferAlignmentReadTest.java">Trac</a>, 
     44 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/common/test/loci/common/utests/BufferAlignmentReadTest.java">SVN</a></dd></dl> 
    4545 * 
    4646 * @see loci.common.IRandomAccess 
    4747 */ 
    4848@Test(groups="readTests") 
    49 public class BufferAlignmentTest { 
     49public class BufferAlignmentReadTest { 
    5050 
    5151  private static final byte[] PAGE = new byte[] { 
  • branches/cleanup/components/common/test/loci/common/utests/WriteByteArrayTest.java

    r5874 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6061 
    6162  private IRandomAccess fileHandle; 
     63   
     64  private boolean checkGrowth; 
    6265 
    63   @Parameters({"provider"}) 
     66  @Parameters({"provider", "checkGrowth"}) 
    6467  @BeforeMethod 
    65   public void setUp(String provider) throws IOException { 
     68  public void setUp(String provider, @Optional("false") String checkGrowth) 
     69    throws IOException { 
     70    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6671    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6772    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6974  } 
    7075 
    71   @Test 
     76  @Test(groups="initialLengthTest") 
    7277  public void testLength() throws IOException { 
    7378    assertEquals(16, fileHandle.length()); 
     
    7883    for (int i = 0; i < 16; i++) { 
    7984      fileHandle.write(new byte[] { (byte) (i + 1) }); 
     85      if (checkGrowth) { 
     86        assertEquals(i + 1, fileHandle.length()); 
     87      } 
    8088    } 
     89    assertEquals(16, fileHandle.length()); 
    8190    fileHandle.seek(0); 
    8291    for (int i = 0; i < 16; i++) { 
     
    8998    fileHandle.write(new byte[] { (byte) 1 }); 
    9099    assertEquals(1, fileHandle.getFilePointer()); 
     100    if (checkGrowth) { 
     101      assertEquals(1, fileHandle.length()); 
     102    } 
    91103    fileHandle.seek(0); 
    92104    assertEquals(1, fileHandle.readByte()); 
     
    94106 
    95107  @Test 
    96   public void testWriteOffEnd() throws IOException { 
    97     fileHandle.seek(16); 
    98     fileHandle.write(new byte[] { (byte) 1 }); 
    99     assertEquals(17, fileHandle.getFilePointer()); 
    100     assertEquals(17, fileHandle.length()); 
    101     fileHandle.seek(16); 
    102     assertEquals(1, fileHandle.readByte()); 
    103   } 
    104  
    105   @Test 
    106   public void testWriteTwiceOffEnd() throws IOException { 
    107     fileHandle.seek(16); 
    108     fileHandle.write(new byte[] { (byte) 1 }); 
    109     assertEquals(17, fileHandle.getFilePointer()); 
    110     assertEquals(17, fileHandle.length()); 
    111     fileHandle.write(new byte[] { (byte) 1 }); 
    112     assertEquals(18, fileHandle.getFilePointer()); 
    113     assertEquals(18, fileHandle.length()); 
    114     fileHandle.seek(16); 
    115     assertEquals(1, fileHandle.readByte()); 
    116     assertEquals(1, fileHandle.readByte()); 
    117   } 
    118    
    119   @Test 
    120108  public void testWriteSequentialSubArray() throws IOException { 
    121109    for (int i = 0; i < 16; i++) { 
    122110      fileHandle.write(new byte[] { (byte) (0), (byte) (i + 1) }, 1, 1); 
     111      if (checkGrowth) { 
     112        assertEquals(i + 1, fileHandle.length()); 
     113      } 
    123114    } 
     115    assertEquals(16, fileHandle.length()); 
    124116    fileHandle.seek(0); 
    125117    for (int i = 0; i < 16; i++) { 
     
    132124    fileHandle.write(new byte[] { (byte) (0), (byte) 1 }, 1, 1); 
    133125    assertEquals(1, fileHandle.getFilePointer()); 
     126    if (checkGrowth) { 
     127      assertEquals(1, fileHandle.length()); 
     128    } 
    134129    fileHandle.seek(0); 
    135130    assertEquals(1, fileHandle.readByte()); 
    136131  } 
    137    
     132 
    138133  @Test 
    139134  public void testWriteTwoByteSubArray() throws IOException { 
     
    141136    fileHandle.write(buf, 1, 2); 
    142137    assertEquals(2, fileHandle.getFilePointer()); 
     138    if (checkGrowth) { 
     139      assertEquals(2, fileHandle.length()); 
     140    } 
    143141    fileHandle.seek(0); 
    144142    assertEquals(2, fileHandle.readByte()); 
    145143    assertEquals(3, fileHandle.readByte()); 
    146     assertEquals(0, fileHandle.readByte()); 
    147   } 
    148  
    149   @Test 
    150   public void testWriteOffEndSubArray() throws IOException { 
    151     fileHandle.seek(16); 
    152     fileHandle.write(new byte[] { (byte) (0), (byte) 1 }, 1, 1); 
    153     assertEquals(17, fileHandle.getFilePointer()); 
    154     assertEquals(17, fileHandle.length()); 
    155     fileHandle.seek(16); 
    156     assertEquals(1, fileHandle.readByte()); 
    157   } 
    158  
    159   @Test 
    160   public void testWriteTwiceOffEndSubArray() throws IOException { 
    161     fileHandle.seek(16); 
    162     fileHandle.write(new byte[] { (byte) (0), (byte) 1 }, 1, 1); 
    163     assertEquals(17, fileHandle.getFilePointer()); 
    164     assertEquals(17, fileHandle.length()); 
    165     fileHandle.write(new byte[] { (byte) (0), (byte) 1 }, 1, 1); 
    166     assertEquals(18, fileHandle.getFilePointer()); 
    167     assertEquals(18, fileHandle.length()); 
    168     fileHandle.seek(16); 
    169     assertEquals(1, fileHandle.readByte()); 
    170     assertEquals(1, fileHandle.readByte()); 
     144    if (fileHandle.length() > 2 
     145        && (fileHandle.readByte() != 0 && fileHandle.readByte() != 0)) 
     146    { 
     147      fail("Incorrect length or trailing bytes."); 
     148    } 
    171149  } 
    172150 
  • branches/cleanup/components/common/test/loci/common/utests/WriteByteBufferTest.java

    r5874 r5876  
    3434 
    3535import org.testng.annotations.BeforeMethod; 
     36import org.testng.annotations.Optional; 
    3637import org.testng.annotations.Parameters; 
    3738import org.testng.annotations.Test; 
     
    6263  private IRandomAccess fileHandle; 
    6364 
    64   @Parameters({"provider"}) 
     65  private boolean checkGrowth; 
     66 
     67  @Parameters({"provider", "checkGrowth"}) 
    6568  @BeforeMethod 
    66   public void setUp(String provider) throws IOException { 
     69  public void setUp(String provider, @Optional("false") String checkGrowth) 
     70    throws IOException { 
     71    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6772    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6873    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7075  } 
    7176 
    72   @Test 
     77  @Test(groups="initialLengthTest") 
    7378  public void testLength() throws IOException { 
    7479    assertEquals(16, fileHandle.length()); 
     
    8085      ByteBuffer b = ByteBuffer.allocate(1).put((byte) (i + 1)); 
    8186      fileHandle.write(b); 
     87      if (checkGrowth) { 
     88        assertEquals(i + 1, fileHandle.length()); 
     89      } 
    8290    } 
     91    assertEquals(16, fileHandle.length()); 
    8392    fileHandle.seek(0); 
    8493    for (int i = 0; i < 16; i++) { 
     
    91100    ByteBuffer b = ByteBuffer.allocate(1).put((byte) 1); 
    92101    fileHandle.write(b); 
     102    if (checkGrowth) { 
     103      assertEquals(1, fileHandle.length()); 
     104    } 
    93105    assertEquals(1, fileHandle.getFilePointer()); 
    94106    fileHandle.seek(0); 
     
    96108  } 
    97109 
    98   @Test 
    99   public void testWriteOffEnd() throws IOException { 
    100     fileHandle.seek(16); 
    101     ByteBuffer b = ByteBuffer.allocate(1).put((byte) 1); 
    102     fileHandle.write(b); 
    103     assertEquals(17, fileHandle.getFilePointer()); 
    104     assertEquals(17, fileHandle.length()); 
    105     fileHandle.seek(16); 
    106     assertEquals(1, fileHandle.readByte()); 
    107   } 
    108  
    109   @Test 
    110   public void testWriteTwiceOffEnd() throws IOException { 
    111     fileHandle.seek(16); 
    112     ByteBuffer b = ByteBuffer.allocate(1).put((byte) 1); 
    113     fileHandle.write(b); 
    114     assertEquals(17, fileHandle.getFilePointer()); 
    115     assertEquals(17, fileHandle.length()); 
    116     b.position(0); 
    117     fileHandle.write(b); 
    118     assertEquals(18, fileHandle.getFilePointer()); 
    119     assertEquals(18, fileHandle.length()); 
    120     fileHandle.seek(16); 
    121     assertEquals(1, fileHandle.readByte()); 
    122     assertEquals(1, fileHandle.readByte()); 
    123   } 
    124    
    125110  @Test 
    126111  public void testWriteSequentialSubBuffer() throws IOException { 
     
    130115      b.put((byte) (i + 1)); 
    131116      fileHandle.write(b, 1, 1); 
     117      if (checkGrowth) { 
     118        assertEquals(i + 1, fileHandle.length()); 
     119      } 
    132120    } 
     121    assertEquals(16, fileHandle.length()); 
    133122    fileHandle.seek(0); 
    134123    for (int i = 0; i < 16; i++) { 
     
    147136    assertEquals(1, fileHandle.readByte()); 
    148137  } 
    149    
     138 
    150139  @Test 
    151140  public void testWriteTwoByteSubBuffer() throws IOException { 
     
    160149    assertEquals(2, fileHandle.readByte()); 
    161150    assertEquals(3, fileHandle.readByte()); 
    162     assertEquals(0, fileHandle.readByte()); 
    163   } 
    164  
    165   @Test 
    166   public void testWriteOffEndSubBuffer() throws IOException { 
    167     fileHandle.seek(16); 
    168     ByteBuffer b = ByteBuffer.allocate(2); 
    169     b.put((byte) 0); 
    170     b.put((byte) 1); 
    171     fileHandle.write(b, 1, 1); 
    172     assertEquals(17, fileHandle.getFilePointer()); 
    173     assertEquals(17, fileHandle.length()); 
    174     fileHandle.seek(16); 
    175     assertEquals(1, fileHandle.readByte()); 
    176   } 
    177  
    178   @Test 
    179   public void testWriteTwiceOffEndSubBuffer() throws IOException { 
    180     fileHandle.seek(16); 
    181     ByteBuffer b = ByteBuffer.allocate(2); 
    182     b.put((byte) 0); 
    183     b.put((byte) 1); 
    184     fileHandle.write(b, 1, 1); 
    185     assertEquals(17, fileHandle.getFilePointer()); 
    186     assertEquals(17, fileHandle.length()); 
    187     fileHandle.write(b, 1, 1); 
    188     assertEquals(18, fileHandle.getFilePointer()); 
    189     assertEquals(18, fileHandle.length()); 
    190     fileHandle.seek(16); 
    191     assertEquals(1, fileHandle.readByte()); 
    192     assertEquals(1, fileHandle.readByte()); 
     151    if (fileHandle.length() > 2 
     152        && (fileHandle.readByte() != 0)) 
     153    { 
     154      fail("Incorrect length or trailing bytes."); 
     155    } 
    193156  } 
    194157 
  • branches/cleanup/components/common/test/loci/common/utests/WriteByteTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6162  private IRandomAccess fileHandle; 
    6263 
    63   @Parameters({"provider"}) 
     64  private boolean checkGrowth; 
     65 
     66  @Parameters({"provider", "checkGrowth"}) 
    6467  @BeforeMethod 
    65   public void setUp(String provider) throws IOException { 
     68  public void setUp(String provider, @Optional("false") String checkGrowth) 
     69    throws IOException { 
     70    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6671    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6772    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6974  } 
    7075 
    71   @Test 
     76  @Test(groups="initialLengthTest") 
    7277  public void testLength() throws IOException { 
    7378    assertEquals(16, fileHandle.length()); 
     
    7883    for (int i = 0; i < 16; i++) { 
    7984      fileHandle.write(i + 1); 
     85      if (checkGrowth) { 
     86        assertEquals(i + 1, fileHandle.length()); 
     87      } 
    8088    } 
     89    assertEquals(16, fileHandle.length()); 
    8190    fileHandle.seek(0); 
    8291    for (int i = 0; i < 16; i++) { 
     
    8998    fileHandle.write(1); 
    9099    assertEquals(1, fileHandle.getFilePointer()); 
     100    if (checkGrowth) { 
     101      assertEquals(1, fileHandle.length()); 
     102    } 
    91103    fileHandle.seek(0); 
    92104    assertEquals(1, fileHandle.readByte()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteBytesTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    5960  private IRandomAccess fileHandle; 
    6061 
    61   @Parameters({"provider"}) 
     62  private boolean checkGrowth; 
     63 
     64  @Parameters({"provider", "checkGrowth"}) 
    6265  @BeforeMethod 
    63   public void setUp(String provider) throws IOException { 
     66  public void setUp(String provider, @Optional("false") String checkGrowth) 
     67    throws IOException { 
     68    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6469    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6570    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6772  } 
    6873 
    69   @Test 
     74  @Test(groups="initialLengthTest") 
    7075  public void testLength() throws IOException { 
    7176    assertEquals(8, fileHandle.length()); 
     
    7580  public void testWriteSequential() throws IOException { 
    7681    fileHandle.writeBytes("ab"); 
     82    if (checkGrowth) { 
     83      assertEquals(2, fileHandle.length()); 
     84    } 
    7785    fileHandle.writeBytes("cd"); 
     86    if (checkGrowth) { 
     87      assertEquals(4, fileHandle.length()); 
     88    } 
    7889    fileHandle.writeBytes("ef"); 
     90    if (checkGrowth) { 
     91      assertEquals(6, fileHandle.length()); 
     92    } 
    7993    fileHandle.writeBytes("gh"); 
     94    assertEquals(8, fileHandle.length()); 
    8095    fileHandle.seek(0); 
    8196    for (byte i = (byte) 0x61; i < 0x69; i++) { 
     
    88103    fileHandle.writeBytes("ab"); 
    89104    assertEquals(2, fileHandle.getFilePointer()); 
     105    if (checkGrowth) { 
     106      assertEquals(2, fileHandle.length()); 
     107    } 
    90108    fileHandle.seek(0); 
    91109    assertEquals((byte) 0x61, fileHandle.readByte()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteCharTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6566  private IRandomAccess fileHandle; 
    6667 
    67   @Parameters({"provider"}) 
     68  private boolean checkGrowth; 
     69 
     70  @Parameters({"provider", "checkGrowth"}) 
    6871  @BeforeMethod 
    69   public void setUp(String provider) throws IOException { 
     72  public void setUp(String provider, @Optional("false") String checkGrowth) 
     73    throws IOException { 
     74    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    7075    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7176    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7378  } 
    7479 
    75   @Test 
     80  @Test(groups="initialLengthTest") 
    7681  public void testLength() throws IOException { 
    7782    assertEquals(32, fileHandle.length()); 
     
    8186  public void testSequential() throws IOException { 
    8287    fileHandle.writeChar('a'); 
     88    if (checkGrowth) { 
     89      assertEquals(2, fileHandle.length()); 
     90    } 
    8391    fileHandle.writeChar('b'); 
     92    if (checkGrowth) { 
     93      assertEquals(4, fileHandle.length()); 
     94    } 
    8495    fileHandle.writeChar('c'); 
     96    if (checkGrowth) { 
     97      assertEquals(6, fileHandle.length()); 
     98    } 
    8599    fileHandle.writeChar('d'); 
     100    if (checkGrowth) { 
     101      assertEquals(8, fileHandle.length()); 
     102    } 
    86103    fileHandle.seek(0); 
    87104    assertEquals('a', fileHandle.readChar()); 
     
    96113    fileHandle.writeChar('e'); 
    97114    fileHandle.writeChar('f'); 
     115    if (checkGrowth) { 
     116      assertEquals(12, fileHandle.length()); 
     117    } 
    98118    fileHandle.seek(8); 
    99119    assertEquals('e', fileHandle.readChar()); 
     
    104124  public void testReset() throws IOException { 
    105125    fileHandle.writeChar('a'); 
     126    if (checkGrowth) { 
     127      assertEquals(2, fileHandle.length()); 
     128    } 
    106129    fileHandle.writeChar('b'); 
     130    if (checkGrowth) { 
     131      assertEquals(4, fileHandle.length()); 
     132    } 
    107133    fileHandle.seek(0); 
    108134    assertEquals('a', fileHandle.readChar()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteCharsTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6162  private IRandomAccess fileHandle; 
    6263 
    63   @Parameters({"provider"}) 
     64  private boolean checkGrowth; 
     65 
     66  @Parameters({"provider", "checkGrowth"}) 
    6467  @BeforeMethod 
    65   public void setUp(String provider) throws IOException { 
     68  public void setUp(String provider, @Optional("false") String checkGrowth) 
     69    throws IOException { 
     70    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6671    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6772    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6974  } 
    7075 
    71   @Test 
     76  @Test(groups="initialLengthTest") 
    7277  public void testLength() throws IOException { 
    7378    assertEquals(16, fileHandle.length()); 
     
    7782  public void testWriteSequential() throws IOException { 
    7883    fileHandle.writeChars("ab"); 
     84    if (checkGrowth) { 
     85      assertEquals(4, fileHandle.length()); 
     86    } 
    7987    fileHandle.writeChars("cd"); 
     88    if (checkGrowth) { 
     89      assertEquals(8, fileHandle.length()); 
     90    } 
    8091    fileHandle.writeChars("ef"); 
     92    if (checkGrowth) { 
     93      assertEquals(12, fileHandle.length()); 
     94    } 
    8195    fileHandle.writeChars("gh"); 
     96    assertEquals(16, fileHandle.length()); 
    8297    fileHandle.seek(0); 
    8398    for (byte i = (byte) 0x61; i < 0x69; i++) { 
     
    91106    fileHandle.writeChars("ab"); 
    92107    assertEquals(4, fileHandle.getFilePointer()); 
     108    if (checkGrowth) { 
     109      assertEquals(4, fileHandle.length()); 
     110    } 
    93111    fileHandle.seek(0); 
    94112    assertEquals((byte) 0x00, fileHandle.readByte()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteDoubleTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    7172  private IRandomAccess fileHandle; 
    7273 
    73   @Parameters({"provider"}) 
     74  private boolean checkGrowth; 
     75 
     76  @Parameters({"provider", "checkGrowth"}) 
    7477  @BeforeMethod 
    75   public void setUp(String provider) throws IOException { 
     78  public void setUp(String provider, @Optional("false") String checkGrowth) 
     79    throws IOException { 
     80    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    7681    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7782    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7984  } 
    8085 
    81   @Test 
     86  @Test(groups="initialLengthTest") 
    8287  public void testLength() throws IOException { 
    8388    assertEquals(56, fileHandle.length()); 
     
    8792  public void testSequential() throws IOException { 
    8893    fileHandle.writeDouble(0.0d); 
     94    if (checkGrowth) { 
     95      assertEquals(8, fileHandle.length()); 
     96    } 
    8997    fileHandle.writeDouble(1.0d); 
     98    if (checkGrowth) { 
     99      assertEquals(16, fileHandle.length()); 
     100    } 
    90101    fileHandle.writeDouble(-1.0d); 
     102    if (checkGrowth) { 
     103      assertEquals(24, fileHandle.length()); 
     104    } 
    91105    fileHandle.writeDouble(3.1415926535897930d); 
     106    if (checkGrowth) { 
     107      assertEquals(32, fileHandle.length()); 
     108    } 
    92109    fileHandle.writeDouble(Double.MAX_VALUE); 
     110    if (checkGrowth) { 
     111      assertEquals(40, fileHandle.length()); 
     112    } 
    93113    fileHandle.writeDouble(Double.NEGATIVE_INFINITY); 
     114    if (checkGrowth) { 
     115      assertEquals(48, fileHandle.length()); 
     116    } 
    94117    fileHandle.writeDouble(Double.NaN); 
     118    if (checkGrowth) { 
     119      assertEquals(56, fileHandle.length()); 
     120    } 
    95121    fileHandle.seek(0); 
    96122    assertEquals(0.0d, fileHandle.readDouble()); 
    97123    assertEquals(1.0d, fileHandle.readDouble()); 
    98     fileHandle.writeDouble(-1.0d); 
    99     fileHandle.writeDouble(3.1415926535897930d); 
     124    assertEquals(-1.0d, fileHandle.readDouble()); 
     125    assertEquals(3.1415926535897930d, fileHandle.readDouble()); 
    100126    assertEquals(Double.MAX_VALUE, fileHandle.readDouble()); 
    101127    assertEquals(Double.NEGATIVE_INFINITY, fileHandle.readDouble()); 
     
    107133    fileHandle.seek(16); 
    108134    fileHandle.writeDouble(-1.0d); 
     135    if (checkGrowth) { 
     136      assertEquals(24, fileHandle.length()); 
     137    } 
    109138    fileHandle.writeDouble(3.1415926535897930d); 
     139    if (checkGrowth) { 
     140      assertEquals(32, fileHandle.length()); 
     141    } 
    110142    fileHandle.seek(16); 
    111143    assertEquals(-1.0d, fileHandle.readDouble()); 
     
    116148  public void testReset() throws IOException { 
    117149    fileHandle.writeDouble(0.0d); 
     150    if (checkGrowth) { 
     151      assertEquals(8, fileHandle.length()); 
     152    } 
    118153    fileHandle.writeDouble(1.0d); 
     154    if (checkGrowth) { 
     155      assertEquals(16, fileHandle.length()); 
     156    } 
    119157    fileHandle.seek(0); 
    120158    assertEquals(0.0d, fileHandle.readDouble()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteFloatTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6465  private IRandomAccess fileHandle; 
    6566 
    66   @Parameters({"provider"}) 
     67  private boolean checkGrowth; 
     68 
     69  @Parameters({"provider", "checkGrowth"}) 
    6770  @BeforeMethod 
    68   public void setUp(String provider) throws IOException { 
     71  public void setUp(String provider, @Optional("false") String checkGrowth) 
     72    throws IOException { 
     73    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6974    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7075    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7277  } 
    7378 
    74   @Test 
     79  @Test(groups="initialLengthTest") 
    7580  public void testLength() throws IOException { 
    7681    assertEquals(28, fileHandle.length()); 
     
    8085  public void testSequential() throws IOException { 
    8186    fileHandle.writeFloat(0.0f); 
     87    if (checkGrowth) { 
     88      assertEquals(4, fileHandle.length()); 
     89    } 
    8290    fileHandle.writeFloat(1.0f); 
     91    if (checkGrowth) { 
     92      assertEquals(8, fileHandle.length()); 
     93    } 
    8394    fileHandle.writeFloat(-1.0f); 
     95    if (checkGrowth) { 
     96      assertEquals(12, fileHandle.length()); 
     97    } 
    8498    fileHandle.writeFloat(3.1415927f); 
     99    if (checkGrowth) { 
     100      assertEquals(16, fileHandle.length()); 
     101    } 
    85102    fileHandle.writeFloat(Float.MAX_VALUE); 
     103    if (checkGrowth) { 
     104      assertEquals(20, fileHandle.length()); 
     105    } 
    86106    fileHandle.writeFloat(Float.NEGATIVE_INFINITY); 
     107    if (checkGrowth) { 
     108      assertEquals(24, fileHandle.length()); 
     109    } 
    87110    fileHandle.writeFloat(Float.NaN); 
     111    if (checkGrowth) { 
     112      assertEquals(28, fileHandle.length()); 
     113    } 
    88114    fileHandle.seek(0); 
    89115    assertEquals(0.0f, fileHandle.readFloat()); 
     
    100126    fileHandle.seek(8); 
    101127    fileHandle.writeFloat(-1.0f); 
     128    if (checkGrowth) { 
     129      assertEquals(12, fileHandle.length()); 
     130    } 
    102131    fileHandle.writeFloat(3.1415927f); 
     132    if (checkGrowth) { 
     133      assertEquals(16, fileHandle.length()); 
     134    } 
    103135    fileHandle.seek(8); 
    104136    assertEquals(-1.0f, fileHandle.readFloat()); 
     
    109141  public void testReset() throws IOException { 
    110142    fileHandle.writeFloat(0.0f); 
     143    if (checkGrowth) { 
     144      assertEquals(4, fileHandle.length()); 
     145    } 
    111146    fileHandle.writeFloat(1.0f); 
     147    if (checkGrowth) { 
     148      assertEquals(8, fileHandle.length()); 
     149    } 
    112150    fileHandle.seek(0); 
    113151    assertEquals(0.0f, fileHandle.readFloat()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteIntTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6566  private IRandomAccess fileHandle; 
    6667 
    67   @Parameters({"provider"}) 
     68  private boolean checkGrowth; 
     69 
     70  @Parameters({"provider", "checkGrowth"}) 
    6871  @BeforeMethod 
    69   public void setUp(String provider) throws IOException { 
     72  public void setUp(String provider, @Optional("false") String checkGrowth) 
     73    throws IOException { 
     74    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    7075    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7176    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7378  } 
    7479 
    75   @Test 
     80  @Test(groups="initialLengthTest") 
    7681  public void testLength() throws IOException { 
    7782    assertEquals(32, fileHandle.length()); 
     
    8186  public void testSequential() throws IOException { 
    8287    fileHandle.writeInt(1); 
     88    if (checkGrowth) { 
     89      assertEquals(4, fileHandle.length()); 
     90    } 
    8391    fileHandle.writeInt(268435202); 
     92    if (checkGrowth) { 
     93      assertEquals(8, fileHandle.length()); 
     94    } 
    8495    fileHandle.writeInt(3); 
     96    if (checkGrowth) { 
     97      assertEquals(12, fileHandle.length()); 
     98    } 
    8599    fileHandle.writeInt(268435204); 
     100    if (checkGrowth) { 
     101      assertEquals(16, fileHandle.length()); 
     102    } 
    86103    fileHandle.writeInt(5); 
     104    if (checkGrowth) { 
     105      assertEquals(20, fileHandle.length()); 
     106    } 
    87107    fileHandle.writeInt(-1); 
     108    if (checkGrowth) { 
     109      assertEquals(24, fileHandle.length()); 
     110    } 
    88111    fileHandle.writeInt(7); 
     112    if (checkGrowth) { 
     113      assertEquals(28, fileHandle.length()); 
     114    } 
    89115    fileHandle.writeInt(-2); 
     116    if (checkGrowth) { 
     117      assertEquals(32, fileHandle.length()); 
     118    } 
    90119    fileHandle.seek(0); 
    91120    assertEquals(1, fileHandle.readInt()); 
     
    103132    fileHandle.seek(8); 
    104133    fileHandle.writeInt(3); 
     134    if (checkGrowth) { 
     135      assertEquals(12, fileHandle.length()); 
     136    } 
    105137    fileHandle.writeInt(268435204); 
     138    if (checkGrowth) { 
     139      assertEquals(16, fileHandle.length()); 
     140    } 
    106141    fileHandle.seek(8); 
    107142    assertEquals(3, fileHandle.readInt()); 
     
    112147  public void testReset() throws IOException { 
    113148    fileHandle.writeInt(1); 
     149    if (checkGrowth) { 
     150      assertEquals(4, fileHandle.length()); 
     151    } 
    114152    fileHandle.writeInt(268435202); 
     153    if (checkGrowth) { 
     154      assertEquals(8, fileHandle.length()); 
     155    } 
    115156    fileHandle.seek(0); 
    116157    assertEquals(1, fileHandle.readInt()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteLongTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    7475  private IRandomAccess fileHandle; 
    7576 
    76   @Parameters({"provider"}) 
     77  private boolean checkGrowth; 
     78 
     79  @Parameters({"provider", "checkGrowth"}) 
    7780  @BeforeMethod 
    78   public void setUp(String provider) throws IOException { 
     81  public void setUp(String provider, @Optional("false") String checkGrowth) 
     82    throws IOException { 
     83    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    7984    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    8085    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    8287  } 
    8388 
    84   @Test 
     89  @Test(groups="initialLengthTest") 
    8590  public void testLength() throws IOException { 
    8691    assertEquals(64, fileHandle.length()); 
     
    9095  public void testSequential() throws IOException { 
    9196    fileHandle.writeLong(1L); 
     97    if (checkGrowth) { 
     98      assertEquals(8, fileHandle.length()); 
     99    } 
    92100    fileHandle.writeLong(1152921504606846722L); 
     101    if (checkGrowth) { 
     102      assertEquals(16, fileHandle.length()); 
     103    } 
    93104    fileHandle.writeLong(3L); 
     105    if (checkGrowth) { 
     106      assertEquals(24, fileHandle.length()); 
     107    } 
    94108    fileHandle.writeLong(1152921504606846724L); 
     109    if (checkGrowth) { 
     110      assertEquals(32, fileHandle.length()); 
     111    } 
    95112    fileHandle.writeLong(5L); 
     113    if (checkGrowth) { 
     114      assertEquals(40, fileHandle.length()); 
     115    } 
    96116    fileHandle.writeLong(-1L); 
     117    if (checkGrowth) { 
     118      assertEquals(48, fileHandle.length()); 
     119    } 
    97120    fileHandle.writeLong(7L); 
     121    if (checkGrowth) { 
     122      assertEquals(56, fileHandle.length()); 
     123    } 
    98124    fileHandle.writeLong(-2L); 
     125    if (checkGrowth) { 
     126      assertEquals(64, fileHandle.length()); 
     127    } 
    99128    fileHandle.seek(0); 
    100129    assertEquals(1L, fileHandle.readLong()); 
     
    112141    fileHandle.seek(8); 
    113142    fileHandle.writeLong(1152921504606846722L); 
     143    if (checkGrowth) { 
     144      assertEquals(16, fileHandle.length()); 
     145    } 
    114146    fileHandle.writeLong(3L); 
     147    if (checkGrowth) { 
     148      assertEquals(24, fileHandle.length()); 
     149    } 
    115150    fileHandle.seek(8); 
    116151    assertEquals(1152921504606846722L, fileHandle.readLong()); 
     
    121156  public void testReset() throws IOException { 
    122157    fileHandle.writeLong(1L); 
     158    if (checkGrowth) { 
     159      assertEquals(8, fileHandle.length()); 
     160    } 
    123161    fileHandle.writeLong(1152921504606846722L); 
     162    if (checkGrowth) { 
     163      assertEquals(16, fileHandle.length()); 
     164    } 
    124165    fileHandle.seek(0); 
    125166    assertEquals(1L, fileHandle.readLong()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteShortTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6667  private IRandomAccess fileHandle; 
    6768 
    68   @Parameters({"provider"}) 
     69  private boolean checkGrowth; 
     70 
     71  @Parameters({"provider", "checkGrowth"}) 
    6972  @BeforeMethod 
    70   public void setUp(String provider) throws IOException { 
     73  public void setUp(String provider, @Optional("false") String checkGrowth) 
     74    throws IOException { 
     75    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    7176    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7277    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7479  } 
    7580 
    76   @Test 
     81  @Test(groups="initialLengthTest") 
    7782  public void testLength() throws IOException { 
    7883    assertEquals(32, fileHandle.length()); 
     
    8287  public void testSequential() throws IOException { 
    8388    fileHandle.writeShort(1); 
     89    if (checkGrowth) { 
     90      assertEquals(2, fileHandle.length()); 
     91    } 
    8492    fileHandle.writeShort(3842); 
     93    if (checkGrowth) { 
     94      assertEquals(4, fileHandle.length()); 
     95    } 
    8596    fileHandle.writeShort(3); 
     97    if (checkGrowth) { 
     98      assertEquals(6, fileHandle.length()); 
     99    } 
    86100    fileHandle.writeShort(3844); 
     101    if (checkGrowth) { 
     102      assertEquals(8, fileHandle.length()); 
     103    } 
    87104    fileHandle.writeShort(5); 
     105    if (checkGrowth) { 
     106      assertEquals(10, fileHandle.length()); 
     107    } 
    88108    fileHandle.writeShort(3846); 
     109    if (checkGrowth) { 
     110      assertEquals(12, fileHandle.length()); 
     111    } 
    89112    fileHandle.writeShort(7); 
     113    if (checkGrowth) { 
     114      assertEquals(14, fileHandle.length()); 
     115    } 
    90116    fileHandle.writeShort(3848); 
     117    if (checkGrowth) { 
     118      assertEquals(16, fileHandle.length()); 
     119    } 
    91120    fileHandle.writeShort(9); 
     121    if (checkGrowth) { 
     122      assertEquals(18, fileHandle.length()); 
     123    } 
    92124    fileHandle.writeShort(3850); 
     125    if (checkGrowth) { 
     126      assertEquals(20, fileHandle.length()); 
     127    } 
    93128    fileHandle.writeShort(11); 
     129    if (checkGrowth) { 
     130      assertEquals(22, fileHandle.length()); 
     131    } 
    94132    fileHandle.writeShort(3852); 
     133    if (checkGrowth) { 
     134      assertEquals(24, fileHandle.length()); 
     135    } 
    95136    fileHandle.writeShort(13); 
     137    if (checkGrowth) { 
     138      assertEquals(26, fileHandle.length()); 
     139    } 
    96140    fileHandle.writeShort(-1); 
     141    if (checkGrowth) { 
     142      assertEquals(28, fileHandle.length()); 
     143    } 
    97144    fileHandle.writeShort(15); 
     145    if (checkGrowth) { 
     146      assertEquals(30, fileHandle.length()); 
     147    } 
    98148    fileHandle.writeShort(-2); 
     149    if (checkGrowth) { 
     150      assertEquals(32, fileHandle.length()); 
     151    } 
    99152    fileHandle.seek(0); 
    100153    assertEquals(1, fileHandle.readShort()); 
     
    120173    fileHandle.seek(8); 
    121174    fileHandle.writeShort(5); 
     175    if (checkGrowth) { 
     176      assertEquals(10, fileHandle.length()); 
     177    } 
    122178    fileHandle.writeShort(3846); 
     179    if (checkGrowth) { 
     180      assertEquals(12, fileHandle.length()); 
     181    } 
    123182    fileHandle.seek(8); 
    124183    assertEquals(5, fileHandle.readShort()); 
     
    129188  public void testReset() throws IOException { 
    130189    fileHandle.writeShort(1); 
     190    if (checkGrowth) { 
     191      assertEquals(2, fileHandle.length()); 
     192    } 
    131193    fileHandle.writeShort(3842); 
     194    if (checkGrowth) { 
     195      assertEquals(4, fileHandle.length()); 
     196    } 
    132197    fileHandle.seek(0); 
    133198    assertEquals(1, fileHandle.readShort()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteUTFTest.java

    r5859 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6061  private IRandomAccess fileHandle; 
    6162 
    62   @Parameters({"provider"}) 
     63  // Unused right now. 
     64  //private boolean checkGrowth; 
     65 
     66  @Parameters({"provider", "checkGrowth"}) 
    6367  @BeforeMethod 
    64   public void setUp(String provider) throws IOException { 
     68  public void setUp(String provider, @Optional("false") String checkGrowth) 
     69    throws IOException { 
     70    // Unused right now. 
     71    //this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6572    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6673    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6875  } 
    6976 
    70   @Test 
     77  @Test(groups="initialLengthTest") 
    7178  public void testLength() throws IOException { 
    7279    assertEquals(10, fileHandle.length()); 
  • branches/cleanup/components/common/test/loci/common/utests/WriteUnsignedByteTest.java

    r5836 r5876  
    3333 
    3434import org.testng.annotations.BeforeMethod; 
     35import org.testng.annotations.Optional; 
    3536import org.testng.annotations.Parameters; 
    3637import org.testng.annotations.Test; 
     
    6162  private IRandomAccess fileHandle; 
    6263 
    63   @Parameters({"provider"}) 
     64  private boolean checkGrowth; 
     65 
     66  @Parameters({"provider", "checkGrowth"}) 
    6467  @BeforeMethod 
    65   public void setUp(String provider) throws IOException { 
     68  public void setUp(String provider, @Optional("false") String checkGrowth) 
     69    throws IOException { 
     70    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6671    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    6772    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    6974  } 
    7075 
    71   @Test 
     76  @Test(groups="initialLengthTest") 
    7277  public void testLength() throws IOException { 
    7378    assertEquals(16, fileHandle.length()); 
     
    7580 
    7681  @Test 
    77   public void testSequentialReadUnsignedByte() throws IOException { 
     82  public void testSequential() throws IOException { 
    7883    fileHandle.writeByte(1); 
     84    if (checkGrowth) { 
     85      assertEquals(1, fileHandle.length()); 
     86    } 
    7987    fileHandle.writeByte(2); 
     88    if (checkGrowth) { 
     89      assertEquals(2, fileHandle.length()); 
     90    } 
    8091    fileHandle.writeByte(3); 
     92    if (checkGrowth) { 
     93      assertEquals(3, fileHandle.length()); 
     94    } 
    8195    fileHandle.writeByte(4); 
     96    if (checkGrowth) { 
     97      assertEquals(4, fileHandle.length()); 
     98    } 
    8299    fileHandle.writeByte(5); 
     100    if (checkGrowth) { 
     101      assertEquals(5, fileHandle.length()); 
     102    } 
    83103    fileHandle.writeByte(6); 
     104    if (checkGrowth) { 
     105      assertEquals(6, fileHandle.length()); 
     106    } 
    84107    fileHandle.writeByte(7); 
     108    if (checkGrowth) { 
     109      assertEquals(7, fileHandle.length()); 
     110    } 
    85111    fileHandle.writeByte(8); 
     112    if (checkGrowth) { 
     113      assertEquals(8, fileHandle.length()); 
     114    } 
    86115    fileHandle.writeByte(9); 
     116    if (checkGrowth) { 
     117      assertEquals(9, fileHandle.length()); 
     118    } 
    87119    fileHandle.writeByte(10); 
     120    if (checkGrowth) { 
     121      assertEquals(10, fileHandle.length()); 
     122    } 
    88123    fileHandle.writeByte(11); 
     124    if (checkGrowth) { 
     125      assertEquals(11, fileHandle.length()); 
     126    } 
    89127    fileHandle.writeByte(12); 
     128    if (checkGrowth) { 
     129      assertEquals(12, fileHandle.length()); 
     130    } 
    90131    fileHandle.writeByte(13); 
     132    if (checkGrowth) { 
     133      assertEquals(13, fileHandle.length()); 
     134    } 
    91135    fileHandle.writeByte(14); 
     136    if (checkGrowth) { 
     137      assertEquals(14, fileHandle.length()); 
     138    } 
    92139    fileHandle.writeByte((byte) 0xFF); 
     140    if (checkGrowth) { 
     141      assertEquals(15, fileHandle.length()); 
     142    } 
    93143    fileHandle.writeByte((byte) 0xFE); 
     144    if (checkGrowth) { 
     145      assertEquals(16, fileHandle.length()); 
     146    } 
    94147    fileHandle.seek(0); 
    95148    assertEquals(1, fileHandle.readUnsignedByte()); 
     
    112165 
    113166  @Test 
    114   public void testSeekForwardReadUnsignedByte() throws IOException { 
     167  public void testSeekForward() throws IOException { 
    115168    fileHandle.seek(7); 
    116169    fileHandle.writeByte(8); 
     170    if (checkGrowth) { 
     171      assertEquals(8, fileHandle.length()); 
     172    } 
    117173    fileHandle.writeByte(9); 
     174    if (checkGrowth) { 
     175      assertEquals(9, fileHandle.length()); 
     176    } 
    118177    fileHandle.seek(7); 
    119178    fileHandle.writeByte((byte) 0xFF); 
     
    125184 
    126185  @Test 
    127   public void testResetReadUnsignedByte() throws IOException { 
     186  public void testReset() throws IOException { 
     187    fileHandle.writeByte(1); 
     188    if (checkGrowth) { 
     189      assertEquals(1, fileHandle.length()); 
     190    } 
     191    fileHandle.writeByte(2); 
     192    if (checkGrowth) { 
     193      assertEquals(2, fileHandle.length()); 
     194    } 
     195    fileHandle.seek(0); 
    128196    fileHandle.writeByte(1); 
    129197    fileHandle.writeByte(2); 
     
    131199    assertEquals(1, fileHandle.readUnsignedByte()); 
    132200    assertEquals(2, fileHandle.readUnsignedByte()); 
    133     fileHandle.seek(0); 
    134     assertEquals(1, fileHandle.readUnsignedByte()); 
    135     assertEquals(2, fileHandle.readUnsignedByte()); 
    136201  } 
    137202 
  • branches/cleanup/components/common/test/loci/common/utests/WriteUnsignedShortTest.java

    r5836 r5876  
    3232 
    3333import org.testng.annotations.BeforeMethod; 
     34import org.testng.annotations.Optional; 
    3435import org.testng.annotations.Parameters; 
    3536import org.testng.annotations.Test; 
     
    6465  private IRandomAccess fileHandle; 
    6566 
    66   @Parameters({"provider"}) 
     67  private boolean checkGrowth; 
     68 
     69  @Parameters({"provider", "checkGrowth"}) 
    6770  @BeforeMethod 
    68   public void setUp(String provider) throws IOException { 
     71  public void setUp(String provider, @Optional("false") String checkGrowth) 
     72    throws IOException { 
     73    this.checkGrowth = Boolean.parseBoolean(checkGrowth); 
    6974    IRandomAccessProviderFactory factory = new IRandomAccessProviderFactory(); 
    7075    IRandomAccessProvider instance = factory.getInstance(provider); 
     
    7277  } 
    7378 
    74   @Test 
     79  @Test(groups="initialLengthTest") 
    7580  public void testLength() throws IOException { 
    7681    assertEquals(32, fileHandle.length()); 
     
    8085  public void testSequential() throws IOException { 
    8186    fileHandle.writeShort(1); 
     87    if (checkGrowth) { 
     88      assertEquals(2, fileHandle.length()); 
     89    } 
    8290    fileHandle.writeShort(3842); 
     91    if (checkGrowth) { 
     92      assertEquals(4, fileHandle.length()); 
     93    } 
    8394    fileHandle.writeShort(3); 
     95    if (checkGrowth) { 
     96      assertEquals(6, fileHandle.length()); 
     97    } 
    8498    fileHandle.writeShort(3844); 
     99    if (checkGrowth) { 
     100      assertEquals(8, fileHandle.length()); 
     101    } 
    85102    fileHandle.writeShort(5); 
     103    if (checkGrowth) { 
     104      assertEquals(10, fileHandle.length()); 
     105    } 
    86106    fileHandle.writeShort(3846); 
     107    if (checkGrowth) { 
     108      assertEquals(12, fileHandle.length()); 
     109    } 
    87110    fileHandle.writeShort(7); 
     111    if (checkGrowth) { 
     112      assertEquals(14, fileHandle.length()); 
     113    } 
    88114    fileHandle.writeShort(3848); 
     115    if (checkGrowth) { 
     116      assertEquals(16, fileHandle.length()); 
     117    } 
    89118    fileHandle.writeShort(9); 
     119    if (checkGrowth) { 
     120      assertEquals(18, fileHandle.length()); 
     121    } 
    90122    fileHandle.writeShort(3850); 
     123    if (checkGrowth) { 
     124      assertEquals(20, fileHandle.length()); 
     125    } 
    91126    fileHandle.writeShort(11); 
     127    if (checkGrowth) { 
     128      assertEquals(22, fileHandle.length()); 
     129    } 
    92130    fileHandle.writeShort(3852); 
     131    if (checkGrowth) { 
     132      assertEquals(24, fileHandle.length()); 
     133    } 
    93134    fileHandle.writeShort(13); 
     135    if (checkGrowth) { 
     136      assertEquals(26, fileHandle.length()); 
     137    } 
    94138    fileHandle.writeShort(65535); 
     139    if (checkGrowth) { 
     140      assertEquals(28, fileHandle.length()); 
     141    } 
    95142    fileHandle.writeShort(15); 
     143    if (checkGrowth) { 
     144      assertEquals(30, fileHandle.length()); 
     145    } 
    96146    fileHandle.writeShort(65534); 
     147    if (checkGrowth) { 
     148      assertEquals(32, fileHandle.length()); 
     149    } 
    97150    fileHandle.seek(0); 
    98151    assertEquals(1, fileHandle.readUnsignedShort()); 
     
    118171    fileHandle.seek(8); 
    119172    fileHandle.writeShort(5); 
     173    if (checkGrowth) { 
     174      assertEquals(10, fileHandle.length()); 
     175    } 
    120176    fileHandle.writeShort(3846); 
     177    if (checkGrowth) { 
     178      assertEquals(12, fileHandle.length()); 
     179    } 
    121180    fileHandle.seek(8); 
    122181    assertEquals(5, fileHandle.readUnsignedShort()); 
     
    127186  public void testReset() throws IOException { 
    128187    fileHandle.writeShort(1); 
     188    if (checkGrowth) { 
     189      assertEquals(2, fileHandle.length()); 
     190    } 
    129191    fileHandle.writeShort(3842); 
     192    if (checkGrowth) { 
     193      assertEquals(4, fileHandle.length()); 
     194    } 
    130195    fileHandle.seek(0); 
    131196    assertEquals(1, fileHandle.readUnsignedShort()); 
  • branches/cleanup/components/common/test/loci/common/utests/providers/IRandomAccessProviderFactory.java

    r5818 r5876  
    4242 
    4343  static { 
     44    providers.put("NewByteArrayHandle", new NewByteArrayHandleProvider()); 
    4445    providers.put("ByteArrayHandle", new ByteArrayHandleProvider()); 
    4546    providers.put("BZip2Handle", new BZip2HandleProvider()); 
  • branches/cleanup/components/common/test/loci/common/utests/testng-template.xml

    r5843 r5876  
    77                <include name="writeTests"/> 
    88                <exclude name="readLineTest"/> 
     9            </run> 
     10        </groups> 
     11        <packages> 
     12            <package name="loci.common.utests"/> 
     13        </packages> 
     14    </test> 
     15    <test name="NewByteArrayHandle"> 
     16        <parameter name="provider" value="NewByteArrayHandle"/> 
     17        <parameter name="checkGrowth" value="true"/> 
     18        <groups> 
     19            <run> 
     20                <include name="writeTests"/> 
     21                <exclude name="initialLengthTest"/> 
    922            </run> 
    1023        </groups> 
Note: See TracChangeset for help on using the changeset viewer.