public virtual void TestDetectClose() { Directory dir = new RAMDirectory(); dir.Close(); try { dir.CreateOutput("test"); Assert.Fail("did not hit expected exception"); } catch (AlreadyClosedException ace) { } dir = FSDirectory.Open(new System.IO.FileInfo(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath()))); dir.Close(); try { dir.CreateOutput("test"); Assert.Fail("did not hit expected exception"); } catch (AlreadyClosedException ace) { } }
public virtual void TestDetectClose() { Directory dir = new RAMDirectory(); dir.Close(); Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"), "did not hit expected exception"); dir = FSDirectory.Open(new System.IO.DirectoryInfo(AppSettings.Get("tempDir", System.IO.Path.GetTempPath()))); dir.Close(); Assert.Throws<AlreadyClosedException>(() => dir.CreateOutput("test"), "did not hit expected exception"); }
public virtual void TestDetectClose() { Directory dir = new RAMDirectory(); dir.Close(); Assert.Throws <AlreadyClosedException>(() => dir.CreateOutput("test", null), "did not hit expected exception"); dir = FSDirectory.Open(new System.IO.DirectoryInfo(AppSettings.Get("tempDir", System.IO.Path.GetTempPath()))); dir.Close(); Assert.Throws <AlreadyClosedException>(() => dir.CreateOutput("test", null), "did not hit expected exception"); }
public override IndexOutput CreateOutput(string name, IOContext context) { if (VERBOSE) { Console.WriteLine("nrtdir.createOutput name=" + name); } if (DoCacheWrite(name, context)) { if (VERBOSE) { Console.WriteLine(" to cache"); } try { @delegate.DeleteFile(name); } catch (Exception ioe) when(ioe.IsIOException()) { // this is fine: file may not exist } return(cache.CreateOutput(name, context)); } else { try { cache.DeleteFile(name); } catch (Exception ioe) when(ioe.IsIOException()) { // this is fine: file may not exist } return(@delegate.CreateOutput(name, context)); } }
public override IndexOutput CreateOutput(string name, IOContext context) { if (VERBOSE) { Console.WriteLine("nrtdir.createOutput name=" + name); } if (DoCacheWrite(name, context)) { if (VERBOSE) { Console.WriteLine(" to cache"); } try { @delegate.DeleteFile(name); } catch (IOException) // LUCENENET: IDE0059: Remove unnecessary value assignment { // this is fine: file may not exist } return(cache.CreateOutput(name, context)); } else { try { cache.DeleteFile(name); } catch (IOException) // LUCENENET: IDE0059: Remove unnecessary value assignment { // this is fine: file may not exist } return(@delegate.CreateOutput(name, context)); } }
public virtual void TestIllegalEOF() { RAMDirectory dir = new RAMDirectory(); IndexOutput o = dir.CreateOutput("out"); byte[] b = new byte[1024]; o.WriteBytes(b, 0, 1024); o.Close(); IndexInput i = dir.OpenInput("out"); i.Seek(1024); i.Close(); dir.Close(); }
public virtual void TestIllegalEOF() { RAMDirectory dir = new RAMDirectory(); IndexOutput o = dir.CreateOutput("out", NewIOContext(Random)); var b = new byte[1024]; o.WriteBytes(b, 0, 1024); o.Dispose(); IndexInput i = dir.OpenInput("out", NewIOContext(Random)); i.Seek(1024); i.Dispose(); dir.Dispose(); }
public virtual void TestDetectClose() { Directory dir = new RAMDirectory(); dir.Close(); try { dir.CreateOutput("test"); Assert.Fail("did not hit expected exception"); } catch (AlreadyClosedException ace) { } dir = FSDirectory.Open(new System.IO.FileInfo(Support.AppSettings.Get("tempDir", System.IO.Path.GetTempPath()))); dir.Close(); try { dir.CreateOutput("test"); Assert.Fail("did not hit expected exception"); } catch (AlreadyClosedException ace) { } }
public virtual void TestSeekToEOFThenBack() { RAMDirectory dir = new RAMDirectory(); IndexOutput o = dir.CreateOutput("out", NewIOContext(Random)); var bytes = new byte[3 * RAMInputStream.BUFFER_SIZE]; o.WriteBytes(bytes, 0, bytes.Length); o.Dispose(); IndexInput i = dir.OpenInput("out", NewIOContext(Random)); i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1); i.Seek(3 * RAMInputStream.BUFFER_SIZE); i.Seek(RAMInputStream.BUFFER_SIZE); i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE); i.Dispose(); dir.Dispose(); }
public override IndexOutput CreateOutput(string name, IOContext context) { if (VERBOSE) { Console.WriteLine("nrtdir.createOutput name=" + name); } if (DoCacheWrite(name, context)) { if (VERBOSE) { Console.WriteLine(" to cache"); } try { @delegate.DeleteFile(name); } #pragma warning disable 168 catch (IOException ioe) #pragma warning restore 168 { // this is fine: file may not exist } return(cache.CreateOutput(name, context)); } else { try { cache.DeleteFile(name); } #pragma warning disable 168 catch (IOException ioe) #pragma warning restore 168 { // this is fine: file may not exist } return(@delegate.CreateOutput(name, context)); } }
public virtual void TestSeekToEOFThenBack() { RAMDirectory dir = new RAMDirectory(); IndexOutput o = dir.CreateOutput("out", NewIOContext(Random())); var bytes = new byte[3 * RAMInputStream.BUFFER_SIZE]; o.WriteBytes(bytes, 0, bytes.Length); o.Dispose(); IndexInput i = dir.OpenInput("out", NewIOContext(Random())); i.Seek(2 * RAMInputStream.BUFFER_SIZE - 1); i.Seek(3 * RAMInputStream.BUFFER_SIZE); i.Seek(RAMInputStream.BUFFER_SIZE); i.ReadBytes(bytes, 0, 2 * RAMInputStream.BUFFER_SIZE); i.Dispose(); dir.Dispose(); }
public virtual void TestIllegalEOF() { RAMDirectory dir = new RAMDirectory(); IndexOutput o = dir.CreateOutput("out", NewIOContext(Random())); var b = new byte[1024]; o.WriteBytes(b, 0, 1024); o.Dispose(); IndexInput i = dir.OpenInput("out", NewIOContext(Random())); i.Seek(1024); i.Dispose(); dir.Dispose(); }