//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotUpdateOutputStreamWhenClosedDuringRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotUpdateOutputStreamWhenClosedDuringRotation() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch allowRotationComplete = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent allowRotationComplete = new System.Threading.CountdownEvent(1); RotationListener rotationListener = spy(new RotationListenerAnonymousInnerClass2(this, allowRotationComplete)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<java.io.OutputStream> mockStreams = new java.util.ArrayList<>(); IList <Stream> mockStreams = new List <Stream>(); FileSystemAbstraction fs = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _fileSystem, mockStreams); ExecutorService rotationExecutor = Executors.newSingleThreadExecutor(); try { RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(fs, _logFile, 10, 0, 10, rotationExecutor, rotationListener); Stream outputStream = supplier.Get(); Write(supplier, "A string longer than 10 bytes"); assertThat(supplier.Get(), @is(outputStream)); allowRotationComplete.Signal(); supplier.Dispose(); } finally { ShutDownExecutor(rotationExecutor); } AssertStreamClosed(mockStreams[0]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotifyListenerWhenNewLogIsCreated() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotifyListenerWhenNewLogIsCreated() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch allowRotationComplete = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent allowRotationComplete = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch rotationComplete = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent rotationComplete = new System.Threading.CountdownEvent(1); string outputFileCreatedMessage = "Output file created"; string rotationCompleteMessage = "Rotation complete"; RotationListener rotationListener = spy(new RotationListenerAnonymousInnerClass(this, allowRotationComplete, rotationComplete, outputFileCreatedMessage, rotationCompleteMessage)); ExecutorService rotationExecutor = Executors.newSingleThreadExecutor(); try { RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(_fileSystem, _logFile, 10, 0, 10, rotationExecutor, rotationListener); Write(supplier, "A string longer than 10 bytes"); Write(supplier, "A string longer than 10 bytes"); allowRotationComplete.Signal(); rotationComplete.await(1L, TimeUnit.SECONDS); verify(rotationListener).outputFileCreated(any(typeof(Stream))); verify(rotationListener).rotationCompleted(any(typeof(Stream))); } finally { ShutDownExecutor(rotationExecutor); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: RotatingFileOutputStreamSupplier(System.Func<long> currentTimeSupplier, org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File outputFile, long rotationThresholdBytes, long rotationDelay, int maxArchives, java.util.concurrent.Executor rotationExecutor, RotationListener rotationListener) throws java.io.IOException internal RotatingFileOutputStreamSupplier(System.Func <long> currentTimeSupplier, FileSystemAbstraction fileSystem, File outputFile, long rotationThresholdBytes, long rotationDelay, int maxArchives, Executor rotationExecutor, RotationListener rotationListener) { this._currentTimeSupplier = currentTimeSupplier; this._fileSystem = fileSystem; this._outputFile = outputFile; this._rotationThresholdBytes = rotationThresholdBytes; this._rotationDelay = rotationDelay; this._maxArchives = maxArchives; this._rotationListener = rotationListener; this._rotationExecutor = rotationExecutor; this._outRef = OpenOutputFile(); // Wrap the actual reference to prevent race conditions during log rotation this._streamWrapper = new OutputStreamAnonymousInnerClass(this); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotifyListenerOnRotationErrorDuringRotationIO() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotifyListenerOnRotationErrorDuringRotationIO() { RotationListener rotationListener = mock(typeof(RotationListener)); FileSystemAbstraction fs = spy(_fileSystem); RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(fs, _logFile, 10, 0, 10, _directExecutor, rotationListener); Stream outputStream = supplier.Get(); IOException exception = new IOException("text exception"); doThrow(exception).when(fs).renameFile(any(typeof(File)), any(typeof(File))); Write(supplier, "A string longer than 10 bytes"); assertThat(supplier.Get(), @is(outputStream)); verify(rotationListener).rotationError(eq(exception), any(typeof(Stream))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotifyListenerOnRotationErrorDuringJobExecution() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotifyListenerOnRotationErrorDuringJobExecution() { RotationListener rotationListener = mock(typeof(RotationListener)); Executor executor = mock(typeof(Executor)); RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(_fileSystem, _logFile, 10, 0, 10, executor, rotationListener); Stream outputStream = supplier.Get(); RejectedExecutionException exception = new RejectedExecutionException("text exception"); doThrow(exception).when(executor).execute(any(typeof(ThreadStart))); Write(supplier, "A string longer than 10 bytes"); assertThat(supplier.Get(), @is(outputStream)); verify(rotationListener).rotationError(exception, outputStream); }
/// <param name="fileSystem"> The filesystem to use </param> /// <param name="outputFile"> The file that the latest <seealso cref="System.IO.Stream_Output"/> should output to </param> /// <param name="rotationThresholdBytes"> The size above which the file should be rotated </param> /// <param name="rotationDelay"> The minimum time (ms) after last rotation before the file may be rotated again </param> /// <param name="maxArchives"> The maximum number of archived output files to keep </param> /// <param name="rotationExecutor"> An <seealso cref="Executor"/> for performing the rotation </param> /// <param name="rotationListener"> A <seealso cref="org.neo4j.logging.RotatingFileOutputStreamSupplier.RotationListener"/> that can /// observe the rotation process and be notified of errors </param> /// <exception cref="IOException"> If the output file cannot be created </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public RotatingFileOutputStreamSupplier(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File outputFile, long rotationThresholdBytes, long rotationDelay, int maxArchives, java.util.concurrent.Executor rotationExecutor, RotationListener rotationListener) throws java.io.IOException public RotatingFileOutputStreamSupplier(FileSystemAbstraction fileSystem, File outputFile, long rotationThresholdBytes, long rotationDelay, int maxArchives, Executor rotationExecutor, RotationListener rotationListener) : this(_defaultCurrentTimeSupplier, fileSystem, outputFile, rotationThresholdBytes, rotationDelay, maxArchives, rotationExecutor, rotationListener) { }