diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-14 18:29:48 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-15 08:16:05 +0200 |
commit | 3fc8223f92ba140dbfa8e8371157b3bf782bda85 (patch) | |
tree | d45a9dd4c701f79cc8717b132e9fe0e2a2ddcd22 /runners/gradle-plugin/src/test/kotlin | |
parent | 2c9fe4c22e13f4d84f4085563715162fcdf2ec85 (diff) | |
download | dokka-3fc8223f92ba140dbfa8e8371157b3bf782bda85.tar.gz dokka-3fc8223f92ba140dbfa8e8371157b3bf782bda85.tar.bz2 dokka-3fc8223f92ba140dbfa8e8371157b3bf782bda85.zip |
Mark `DokkaBootstrap` with `Throws` annotation to avoid "UndeclaredThrowableException" when used with automagicProxy
Diffstat (limited to 'runners/gradle-plugin/src/test/kotlin')
-rw-r--r-- | runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt new file mode 100644 index 00000000..e981d6fe --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt @@ -0,0 +1,48 @@ +package org.jetbrains.dokka.gradle + +import org.jetbrains.dokka.DokkaBootstrap +import org.jetbrains.dokka.gradle.AutomagicProxyTest.TestInterface +import java.util.function.BiConsumer +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + + +class AutomagicProxyTest { + + private class TestException(message: String, cause: Throwable?) : Exception(message, cause) + + private fun interface TestInterface { + @Throws(Throwable::class) + operator fun invoke(): Int + } + + @Test + fun `simple method invocation`() { + val instance = TestInterface { 0 } + val proxy = automagicTypedProxy<TestInterface>(instance.javaClass.classLoader, instance) + assertEquals(0, proxy()) + } + + @Test + fun `exception throw in DokkaBootstrap is not wrapped inside UndeclaredThrowableException`() { + val instanceThrowingTestException = object : DokkaBootstrap { + override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) = Unit + override fun generate() { + throw TestException("Test Exception Message", Exception("Cause Exception Message")) + } + } + + val proxy = automagicTypedProxy<DokkaBootstrap>( + instanceThrowingTestException.javaClass.classLoader, + instanceThrowingTestException + ) + + val exception = assertFailsWith<TestException> { + proxy.generate() + } + + assertEquals("Test Exception Message", exception.message) + assertEquals("Cause Exception Message", exception.cause?.message) + } +} |