aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'runners/gradle-plugin/src/test')
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt (renamed from runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt)5
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt68
2 files changed, 70 insertions, 3 deletions
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt
index b6cf2119..d80f43e4 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt
@@ -1,6 +1,5 @@
package org.jetbrains.dokka.gradle
-import org.gradle.api.artifacts.FileCollectionDependency
import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
@@ -8,7 +7,7 @@ import java.net.URL
import kotlin.test.Test
import kotlin.test.assertEquals
-class GradleDokkaConfigurationJsonTest {
+class DokkaConfigurationJsonTest {
@Test
fun `DokkaTask configuration toJsonString then parseJson`() {
@@ -35,7 +34,7 @@ class GradleDokkaConfigurationJsonTest {
link.url = URL("http://some.other.url")
}
sourceSet.collectKotlinTasks = {
- println(this@GradleDokkaConfigurationJsonTest)
+ println(this@DokkaConfigurationJsonTest)
println("This lambda is capturing the entire test")
emptyList()
}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt
new file mode 100644
index 00000000..70ecfcf0
--- /dev/null
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt
@@ -0,0 +1,68 @@
+package org.jetbrains.dokka.gradle
+
+import org.gradle.kotlin.dsl.withType
+import org.gradle.testfixtures.ProjectBuilder
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.toJsonString
+import org.junit.Rule
+import org.junit.rules.TemporaryFolder
+import java.io.ObjectInputStream
+import java.io.ObjectOutputStream
+import java.net.URL
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class DokkaConfigurationSerializableTest {
+
+ @get:Rule
+ val temporaryFolder = TemporaryFolder()
+
+ @Test
+ fun `DokkaTask configuration write to file then parse`() {
+ val project = ProjectBuilder.builder().build()
+ project.plugins.apply("org.jetbrains.dokka")
+ val dokkaTask = project.tasks.withType<DokkaTask>().first()
+ dokkaTask.plugins.withDependencies { dependencies ->
+ dependencies.clear()
+ }
+ dokkaTask.apply {
+ this.failOnWarning = true
+ this.offlineMode = true
+ this.outputDirectory = "customOutputDir"
+ this.cacheRoot = "customCacheRoot"
+ this.pluginsConfiguration["0"] = "a"
+ this.pluginsConfiguration["1"] = "b"
+ this.dokkaSourceSets.create("main") { sourceSet ->
+ sourceSet.moduleDisplayName = "moduleDisplayName"
+ sourceSet.displayName = "customSourceSetDisplayName"
+ sourceSet.reportUndocumented = true
+
+ sourceSet.externalDocumentationLink { link ->
+ link.packageListUrl = URL("http://some.url")
+ link.url = URL("http://some.other.url")
+ }
+ sourceSet.collectKotlinTasks = {
+ emptyList()
+ }
+
+ sourceSet.perPackageOption { packageOption ->
+ packageOption.includeNonPublic = true
+ packageOption.reportUndocumented = true
+ packageOption.skipDeprecated = true
+ }
+ }
+ }
+
+ val sourceConfiguration = dokkaTask.getConfigurationOrThrow()
+ val configurationFile = temporaryFolder.root.resolve("config.bin")
+ ObjectOutputStream(configurationFile.outputStream()).use { stream ->
+ stream.writeObject(sourceConfiguration)
+ }
+ val parsedConfiguration = ObjectInputStream(configurationFile.inputStream()).use { stream ->
+ stream.readObject() as DokkaConfiguration
+ }
+
+ /* Abusing toJsonString, since there is no proper .equals on the gradle implementations yet */
+ assertEquals(sourceConfiguration.toJsonString(), parsedConfiguration.toJsonString())
+ }
+}