-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a test for KeyAwareAutoCloseableLockTest
- Loading branch information
1 parent
9d0ba52
commit cc23c7b
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
testng-core/src/test/java/org/testng/internal/KeyAwareAutoCloseableLockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.testng.internal; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class KeyAwareAutoCloseableLockTest { | ||
|
||
@Test | ||
public void ensureLockIsReEntrant() { | ||
String key = "TestNG"; | ||
KeyAwareAutoCloseableLock lock = new KeyAwareAutoCloseableLock(); | ||
KeyAwareAutoCloseableLock.AutoReleasable outer, inner1, inner2; | ||
try (KeyAwareAutoCloseableLock.AutoReleasable ignore = lock.lockForObject(key)) { | ||
outer = ignore; | ||
try (KeyAwareAutoCloseableLock.AutoReleasable ignore1 = lock.lockForObject(key)) { | ||
inner1 = ignore1; | ||
} | ||
try (KeyAwareAutoCloseableLock.AutoReleasable ignore2 = lock.lockForObject(key)) { | ||
inner2 = ignore2; | ||
} | ||
} | ||
assertThat(outer).isEqualTo(inner1); | ||
assertThat(inner1).isEqualTo(inner2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters