-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rest-api-model-server): fix Ktor compatibility
- Loading branch information
Showing
6 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
.idea/modules/rest-api-model-server/modelix-samples.rest-api-model-server.test.iml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
rest-api-model-server/src/test/kotlin/ReplicatedRepositoryInstantiationTest.kt
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,40 @@ | ||
package org.acme.getting.started.testing | ||
|
||
import io.quarkus.test.junit.QuarkusTest | ||
import io.quarkus.test.junit.QuarkusTestProfile | ||
import io.quarkus.test.junit.TestProfile | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertThrows | ||
import org.junit.jupiter.api.Test | ||
import org.modelix.model.client.ReplicatedRepository | ||
import javax.inject.Inject | ||
|
||
class UnreachableUrlProfile : QuarkusTestProfile { | ||
override fun getConfigOverrides(): Map<String, String> { | ||
// Override the server uri to be an unreachable URL. | ||
return mapOf("modelix.client.server-uri" to "http://non_existing_host:93939") | ||
} | ||
} | ||
|
||
@QuarkusTest | ||
@TestProfile(value = UnreachableUrlProfile::class) | ||
class ReplicatedRepositoryInstantiationTest { | ||
@Inject | ||
lateinit var replicatedRepository: ReplicatedRepository | ||
|
||
@Test | ||
fun testInjection() { | ||
// This tests, whether `replicatedRepository` can be correctly injected and instantiated by Quarkus. | ||
// The actual instantiation is happening when we call something on `replicatedRepository`. | ||
// Therefore, we call `.branch`. | ||
// The asserted exception message indicates that the `replicatedRepository` was injected correctly. | ||
// The exception message "java.lang.NoClassDefFoundError: kotlin/enums/EnumEntriesKt", for example, | ||
// would indicate that something is set up wrong and the instantiation is failing. | ||
// In the past, we had such issues with the wrong version of Kotlin and Ktor. | ||
val exception = assertThrows(RuntimeException::class.java) { replicatedRepository.branch } | ||
assertEquals( | ||
"Unable to connect to 'http://non_existing_host:93939/get/branch_courses_master' to get key branch_courses_master", | ||
exception.message | ||
) | ||
} | ||
} |