public virtual void TestReadBytes() { MyBufferedIndexInput input = new MyBufferedIndexInput(); int pos = 0; // gradually increasing size: for (int size = 1; size < BufferedIndexInput.BUFFER_SIZE * 10; size = size + size / 200 + 1) { CheckReadBytes(input, size, pos); pos += size; } // wildly fluctuating size: for (long i = 0; i < 1000; i++) { // The following function generates a fluctuating (but repeatable) // size, sometimes small (<100) but sometimes large (>10000) int size1 = (int) (i % 7 + 7 * (i % 5) + 7 * 5 * (i % 3) + 5 * 5 * 3 * (i % 2)); int size2 = (int) (i % 11 + 11 * (i % 7) + 11 * 7 * (i % 5) + 11 * 7 * 5 * (i % 3) + 11 * 7 * 5 * 3 * (i % 2)); int size = (i % 3 == 0)?size2 * 10:size1; CheckReadBytes(input, size, pos); pos += size; } // constant small size (7 bytes): for (int i = 0; i < BufferedIndexInput.BUFFER_SIZE; i++) { CheckReadBytes(input, 7, pos); pos += 7; } }
public virtual void TestReadByte() { MyBufferedIndexInput input = new MyBufferedIndexInput(); for (int i = 0; i < BufferedIndexInput.BUFFER_SIZE * 10; i++) { Assert.AreEqual(input.ReadByte(), Byten(i)); } }
public virtual void TestEOF() { MyBufferedIndexInput input = new MyBufferedIndexInput(1024); // see that we can read all the bytes at one go: CheckReadBytes(input, (int)input.Length, 0); // go back and see that we can't read more than that, for small and // large overflows: int pos = (int)input.Length - 10; input.Seek(pos); CheckReadBytes(input, 10, pos); input.Seek(pos); try { CheckReadBytes(input, 11, pos); Assert.Fail("Block read past end of file"); } #pragma warning disable 168 catch (IOException e) #pragma warning restore 168 { /* success */ } input.Seek(pos); try { CheckReadBytes(input, 50, pos); Assert.Fail("Block read past end of file"); } #pragma warning disable 168 catch (IOException e) #pragma warning restore 168 { /* success */ } input.Seek(pos); try { CheckReadBytes(input, 100000, pos); Assert.Fail("Block read past end of file"); } #pragma warning disable 168 catch (IOException e) #pragma warning restore 168 { /* success */ } }
public virtual void TestEOF() { MyBufferedIndexInput input = new MyBufferedIndexInput(1024); // see that we can read all the bytes at one go: CheckReadBytes(input, (int)input.Length(), 0); // go back and see that we can't read more than that, for small and // large overflows: int pos = (int)input.Length() - 10; input.Seek(pos); CheckReadBytes(input, 10, pos); input.Seek(pos); Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 11, pos), "Block read past end of file"); input.Seek(pos); Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 50, pos), "Block read past end of file"); input.Seek(pos); Assert.Throws <System.IO.IOException>(() => CheckReadBytes(input, 100000, pos), "Block read past end of file"); }
public virtual void TestEOF() { MyBufferedIndexInput input = new MyBufferedIndexInput(1024); // see that we can read all the bytes at one go: CheckReadBytes(input, (int) input.Length(), 0); // go back and see that we can't read more than that, for small and // large overflows: int pos = (int) input.Length() - 10; input.Seek(pos); CheckReadBytes(input, 10, pos); input.Seek(pos); try { CheckReadBytes(input, 11, pos); Assert.Fail("Block read past end of file"); } catch (System.IO.IOException) { /* success */ } input.Seek(pos); try { CheckReadBytes(input, 50, pos); Assert.Fail("Block read past end of file"); } catch (System.IO.IOException) { /* success */ } input.Seek(pos); try { CheckReadBytes(input, 100000, pos); Assert.Fail("Block read past end of file"); } catch (System.IO.IOException) { /* success */ } }
public virtual void TestReadBytes() { MyBufferedIndexInput input = new MyBufferedIndexInput(); RunReadBytes(input, BufferedIndexInput.BUFFER_SIZE, Random()); }
public virtual void TestReadBytes() { System.Random r = NewRandom(); MyBufferedIndexInput input = new MyBufferedIndexInput(); RunReadBytes(input, BufferedIndexInput.BUFFER_SIZE, r); // This tests the workaround code for LUCENE-1566 where readBytesInternal // provides a workaround for a JVM Bug that incorrectly raises a OOM Error // when a large byte buffer is passed to a file read. // NOTE: this does only test the chunked reads and NOT if the Bug is triggered. //final int tmpFileSize = 1024 * 1024 * 5; int inputBufferSize = 128; System.String tempDirectory = System.IO.Path.GetTempPath(); System.IO.FileInfo tmpInputFile = new System.IO.FileInfo(System.IO.Path.Combine(tempDirectory, "IndexInput.tmpFile")); System.IO.File.Delete(tmpInputFile.FullName); WriteBytes(tmpInputFile, TEST_FILE_LENGTH); // run test with chunk size of 10 bytes RunReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile, inputBufferSize, 10), inputBufferSize, r); // run test with chunk size of 100 MB - default RunReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile, inputBufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE), inputBufferSize, r); Assert.Pass("Supressing Sub-Tests on NIOFSIndexInput classes"); // run test with chunk size of 10 bytes //RunReadBytesAndClose(new NIOFSIndexInput(tmpInputFile, inputBufferSize, 10), inputBufferSize, r); // {{Aroush-2.9}} suppressing this test since NIOFSIndexInput isn't ported System.Console.Out.WriteLine("Suppressing sub-test: 'RunReadBytesAndClose(new NIOFSIndexInput(tmpInputFile, inputBufferSize, 10), inputBufferSize, r);' since NIOFSIndexInput isn't ported"); // run test with chunk size of 100 MB - default //RunReadBytesAndClose(new NIOFSIndexInput(tmpInputFile, inputBufferSize), inputBufferSize, r); // {{Aroush-2.9}} suppressing this test since NIOFSIndexInput isn't ported System.Console.Out.WriteLine("Suppressing sub-test: 'RunReadBytesAndClose(new NIOFSIndexInput(tmpInputFile, inputBufferSize), inputBufferSize, r);' since NIOFSIndexInput isn't ported"); }