Skip to content

Commit

Permalink
Experimental support for Kotlin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theigl committed Apr 4, 2023
1 parent e7c37a9 commit 8373653
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
63 changes: 62 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
<javac.target>1.8</javac.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.2</junit.version>
<kotlin.version>1.8.20</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>

<modules>
Expand Down Expand Up @@ -109,7 +111,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.5.1</version>
<configuration>
<source>${javac.target}</source>
<target>${javac.target}</target>
Expand Down Expand Up @@ -339,6 +341,63 @@
</plugins>
</build>
</profile>
<!-- Include any tests that require kotlin -->
<profile>
<id>kotlin</id>
<activation>
<property>
<name>!skipKotlin</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>test-kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<!-- Include any tests that require JDK11+ -->
<profile>
<id>jdk11ge</id>
Expand All @@ -360,6 +419,7 @@
</goals>
<configuration>
<sources>
<source>test-kotlin</source>
<source>test-jdk11</source>
</sources>
</configuration>
Expand Down Expand Up @@ -406,6 +466,7 @@
</goals>
<configuration>
<sources>
<source>test-kotlin</source>
<source>test-jdk11</source>
<source>test-jdk14</source>
</sources>
Expand Down
33 changes: 33 additions & 0 deletions test-kotlin/com.esotericsoftware.kryo/LambdaTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.esotericsoftware.kryo

import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

class LambdaTest {
private class Example(private val p: (Long) -> String) {
constructor() : this({ it.toString() })
}

@Test
@Disabled("Expected to fail")
fun testLambda() {
val kryo = Kryo().apply {
isRegistrationRequired = false
}

val example = Example()

val bytes = Output(1024).use { output ->
kryo.writeClassAndObject(output, example)
output.toBytes()
}

val deserialized = Input(bytes).use { input ->
kryo.readClassAndObject(input)
}

println(deserialized)
}
}

0 comments on commit 8373653

Please sign in to comment.