Skip to content

Commit

Permalink
[ANCHOR-571] Add @LockStatic to NetUtilTests function to avoid concur…
Browse files Browse the repository at this point in the history
…rent test fai… (#1230)

### Description

Add @LockStatic to NetUtilTests function to avoid concurrent test
failures

### Testing

- `./gradlew test`
  • Loading branch information
lijamie98 authored Dec 13, 2023
1 parent 93b43ff commit c023147
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/test/kotlin/org/stellar/anchor/util/NetUtilTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.junit.jupiter.params.provider.NullSource
import org.junit.jupiter.params.provider.ValueSource
import org.stellar.anchor.LockAndMockStatic
import org.stellar.anchor.LockAndMockTest
import org.stellar.anchor.LockStatic
import org.stellar.anchor.util.NetUtil.*

@Order(100)
Expand Down Expand Up @@ -100,6 +101,7 @@ internal class NetUtilTest {
"file:///home/johndoe/a.toml"
]
)
@LockStatic([NetUtil::class])
fun `test valid urls with isUrlValid()`(testValue: String?) {
assertTrue(isUrlValid(testValue))
}
Expand All @@ -121,6 +123,7 @@ internal class NetUtilTest {
""
]
)
@LockStatic([NetUtil::class])
fun `test bad urls with isUrlValid()`(testValue: String?) {
assertFalse(isUrlValid(testValue))
}
Expand All @@ -139,6 +142,7 @@ internal class NetUtilTest {
"127.0.0.1:8080"
]
)
@LockStatic([NetUtil::class])
fun `test valid server port with isServerPortValid`(testValue: String) {
assertTrue(isServerPortValid(testValue, false))
}
Expand All @@ -157,6 +161,7 @@ internal class NetUtilTest {
""
]
)
@LockStatic([NetUtil::class])
fun `test bad server port with isServerPortValid`(testValue: String?) {
assertFalse(isServerPortValid(testValue, true))
}
Expand All @@ -171,13 +176,15 @@ internal class NetUtilTest {
"http://test.stellar.org:9800,test.stellar.org:9800",
]
)
@LockStatic([NetUtil::class])
fun `test good URLs for getDomainFromURL`(testUri: String, compareDomain: String) {
val domain = getDomainFromURL(testUri)
assertEquals(domain, compareDomain)
}

@ParameterizedTest
@ValueSource(strings = ["bad url", "http :///test.stellar.org:9800/"])
@LockStatic([NetUtil::class])
fun `test bad URLs for getDomainFromURL`(testUrl: String) {
org.junit.jupiter.api.assertThrows<MalformedURLException> { getDomainFromURL(testUrl) }
}
Expand Down

0 comments on commit c023147

Please sign in to comment.