//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void mustCloseFilesIfTakingFileLockThrows(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustCloseFilesIfTakingFileLockThrows(int noChannelStriping) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger openFilesCounter = new java.util.concurrent.atomic.AtomicInteger(); AtomicInteger openFilesCounter = new AtomicInteger(); PageSwapperFactory factory = CreateSwapperFactory(); factory.open(new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _fileSystem, openFilesCounter) , Configuration.EMPTY); File file = TestDir.file("file"); try { using (StoreChannel ch = _fileSystem.create(file), FileLock ignore = ch.TryLock()) { CreateSwapper(factory, file, 4, NoCallback, false, Bool(noChannelStriping)).close(); fail("Creating a page swapper for a locked channel should have thrown"); } } catch (FileLockException) { // As expected. } assertThat(openFilesCounter.get(), @is(0)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void fileMustRemainLockedEvenIfChannelIsClosedByStrayInterrupt(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void FileMustRemainLockedEvenIfChannelIsClosedByStrayInterrupt(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); _fileSystem.create(file).close(); PageSwapper pageSwapper = CreateSwapper(factory, file, 4, NoCallback, false, Bool(noChannelStriping)); try { StoreChannel channel = _fileSystem.open(file, OpenMode.READ_WRITE); Thread.CurrentThread.Interrupt(); pageSwapper.Force(); assertThrows(typeof(OverlappingFileLockException), channel.tryLock); } finally { pageSwapper.Close(); } }
public IntegrationTests() { TestDir.EnsureCreated(REF); _person = new Person() { Address = new Address() { Street = "Unknown", City = "Newermind" }, Salary = 100, DateOfBirth = default(DateTime), FullName = "Name1" }; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void creatingSwapperForInternallyLockedFileMustThrow(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void CreatingSwapperForInternallyLockedFileMustThrow(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); StoreFileChannel channel = _fileSystem.create(file); using (FileLock fileLock = channel.TryLock()) { assertThat(fileLock, @is(not(nullValue()))); assertThrows(typeof(FileLockException), () => CreateSwapper(factory, file, 4, NoCallback, true, Bool(noChannelStriping))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void mustUnlockFileWhenThePageSwapperIsClosed(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void MustUnlockFileWhenThePageSwapperIsClosed(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); _fileSystem.create(file).close(); CreateSwapper(factory, file, 4, NoCallback, false, false).close(); using (StoreFileChannel channel = _fileSystem.open(file, OpenMode.READ_WRITE), FileLock fileLock = channel.TryLock()) { assertThat(fileLock, @is(not(nullValue()))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void creatingSwapperForExternallyLockedFileMustThrow(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void CreatingSwapperForExternallyLockedFileMustThrow(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); _fileSystem.create(file).close(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: ProcessBuilder pb = new ProcessBuilder(JavaExecutable.ToString(), "-cp", ClassPath, typeof(LockThisFileProgram).FullName, file.AbsolutePath); File wd = (new File("target/test-classes")).AbsoluteFile; pb.directory(wd); Process process = pb.start(); StreamReader stdout = new StreamReader(process.InputStream); Stream stderr = process.ErrorStream; try { assumeThat(stdout.ReadLine(), @is(LockThisFileProgram.LOCKED_OUTPUT)); } catch (Exception e) { int b = stderr.Read(); while (b != -1) { System.err.write(b); b = stderr.Read(); } System.err.flush(); int exitCode = process.waitFor(); Console.WriteLine("exitCode = " + exitCode); throw e; } try { assertThrows(typeof(FileLockException), () => CreateSwapper(factory, file, 4, NoCallback, true, Bool(noChannelStriping))); } finally { process.OutputStream.write(0); process.OutputStream.flush(); process.waitFor(); } }
/// <exception cref="System.Exception"/> public override void Evaluate() { FilePath testDir = null; TestDir testDirAnnotation = frameworkMethod.GetAnnotation <TestDir>(); if (testDirAnnotation != null) { testDir = TestDirHelper.ResetTestCaseDir(frameworkMethod.GetName()); } try { TestDirHelper.TestDirTl.Set(testDir); statement.Evaluate(); } finally { TestDirHelper.TestDirTl.Remove(); } }
/// <summary> /// The OverlappingFileLockException is thrown when tryLock is called on the same file *in the same JVM*. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void creatingSwapperForFileMustTakeLockOnFile(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void CreatingSwapperForFileMustTakeLockOnFile(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); _fileSystem.create(file).close(); PageSwapper pageSwapper = CreateSwapper(factory, file, 4, NoCallback, false, Bool(noChannelStriping)); try { StoreChannel channel = _fileSystem.open(file, OpenMode.READ_WRITE); assertThrows(typeof(OverlappingFileLockException), channel.tryLock); } finally { pageSwapper.Close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMultipleThreads() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestMultipleThreads() { LockWorker t1 = new LockWorker("T1", Locks); LockWorker t2 = new LockWorker("T2", Locks); LockWorker t3 = new LockWorker("T3", Locks); LockWorker t4 = new LockWorker("T4", Locks); long r1 = 1L; try { t1.GetReadLock(r1, true); t2.GetReadLock(r1, true); t3.GetReadLock(r1, true); Future <Void> t4Wait = t4.GetWriteLock(r1, false); t3.ReleaseReadLock(r1); t2.ReleaseReadLock(r1); assertTrue(!t4Wait.Done); t1.ReleaseReadLock(r1); // now we can wait for write lock since it can be acquired // get write lock t4.AwaitFuture(t4Wait); t4.GetReadLock(r1, true); t4.GetReadLock(r1, true); // put readlock in queue Future <Void> t1Wait = t1.GetReadLock(r1, false); t4.GetReadLock(r1, true); t4.ReleaseReadLock(r1); t4.GetWriteLock(r1, true); t4.ReleaseWriteLock(r1); assertTrue(!t1Wait.Done); t4.ReleaseWriteLock(r1); // get read lock t1.AwaitFuture(t1Wait); t4.ReleaseReadLock(r1); // t4 now has 1 readlock and t1 one readlock // let t1 drop readlock and t4 get write lock t4Wait = t4.GetWriteLock(r1, false); t1.ReleaseReadLock(r1); t4.AwaitFuture(t4Wait); t4.ReleaseReadLock(r1); t4.ReleaseWriteLock(r1); t4.GetWriteLock(r1, true); t1Wait = t1.GetReadLock(r1, false); Future <Void> t2Wait = t2.GetReadLock(r1, false); Future <Void> t3Wait = t3.GetReadLock(r1, false); t4.GetReadLock(r1, true); t4.ReleaseWriteLock(r1); t1.AwaitFuture(t1Wait); t2.AwaitFuture(t2Wait); t3.AwaitFuture(t3Wait); t1Wait = t1.GetWriteLock(r1, false); t2.ReleaseReadLock(r1); t4.ReleaseReadLock(r1); t3.ReleaseReadLock(r1); t1.AwaitFuture(t1Wait); t1.ReleaseWriteLock(r1); t2.GetReadLock(r1, true); t1.ReleaseReadLock(r1); t2.GetWriteLock(r1, true); t2.ReleaseWriteLock(r1); t2.ReleaseReadLock(r1); } catch (Exception e) { LockWorkFailureDump dumper = new LockWorkFailureDump(TestDir.file(this.GetType().Name)); File file = dumper.DumpState(Locks, t1, t2, t3, t4); throw new Exception("Failed, forensics information dumped to " + file.AbsolutePath, e); } finally { t1.Dispose(); t2.Dispose(); t3.Dispose(); t4.Dispose(); } }
protected internal override GraphDatabaseService CreateGraphDatabase() { return((new TestEnterpriseGraphDatabaseFactory()).setFileSystem(FileSystemRule.get()).newEmbeddedDatabaseBuilder(TestDir.storeDir()).newGraphDatabase()); }
public EmbeddedStorageTests() { TestDir.EnsureCreated(REF); }
public IntegrationTests() { TestDir.EnsureCreated(REF); }