//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCloseOnActiveFileDuringRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCloseOnActiveFileDuringRotation() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(5, true), typeof(StoreChannel).GetMethod("close")), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain close() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "close"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertThat(restoredState.TheState, greaterThanOrEqualTo(lastValue)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCrashOnFileForceDuringWrite() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCrashOnFileForceDuringWrite() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); /* * Magic number warning. For a rotation threshold of 14, 990 operations on file A falls on a force() of the * current active file. This has been discovered via experimentation. The end result is that there is a * flush (but not write) a value. This should be recoverable. Interestingly, the failure semantics are a bit * unclear on what should happen to that value. We assume that exception during persistence requires recovery * to discover if the last argument made it to disk or not. Since we use an EFSA, force is not necessary and * the value that caused the failure is actually "persisted" and recovered. */ AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(40, true), typeof(StoreChannel).GetMethod("force", typeof(bool))), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain force() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "force"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertThat(restoredState.TheState, greaterThanOrEqualTo(lastValue)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCrashOnFileCreationDuringRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCrashOnFileCreationDuringRotation() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); /* * Magic number warning. For a rotation threshold of 14, 998 operations on file A falls on truncation of the * file during rotation. This has been discovered via experimentation. The end result is that there is a * failure to create the file to rotate to. This should be recoverable. */ AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(20, true), typeof(FileSystemAbstraction).GetMethod("truncate", typeof(File), typeof(long))), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain FSA.truncate() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "truncate"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertEquals(lastValue, restoredState.TheState); } }