kotlin.test: Rename jvm module to junit
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kotlin.test</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>kotlin.test.junit</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>(4,5)</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin.test.shared</artifactId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/assembly/sources.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<forceCreation>true</forceCreation>
|
||||
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
|
||||
<archive>
|
||||
<forced />
|
||||
<manifestEntries>
|
||||
<Built-By>${user.name}</Built-By>
|
||||
|
||||
<Implementation-Vendor>JetBrains s.r.o.</Implementation-Vendor>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
||||
<dir>${project.basedir}/src/main/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
||||
<dir>${project.basedir}/src/test/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
|
||||
<id>sources</id>
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
|
||||
<baseDirectory>/</baseDirectory>
|
||||
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<filtered>true</filtered>
|
||||
<lineEnding>unix</lineEnding>
|
||||
|
||||
<directory>../shared/src/main/kotlin</directory>
|
||||
|
||||
<outputDirectory/>
|
||||
|
||||
<includes>
|
||||
<include>**/*.kt</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<filtered>true</filtered>
|
||||
<lineEnding>unix</lineEnding>
|
||||
|
||||
<directory>../shared/src/main/kotlin.jvm</directory>
|
||||
<outputDirectory/>
|
||||
|
||||
<includes>
|
||||
<include>**/*.kt</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<filtered>true</filtered>
|
||||
<lineEnding>unix</lineEnding>
|
||||
|
||||
<directory>src/main/kotlin</directory>
|
||||
<outputDirectory/>
|
||||
|
||||
<includes>
|
||||
<include>**/*.kt</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,41 @@
|
||||
package kotlin.test.junit
|
||||
|
||||
import org.junit.*
|
||||
import kotlin.test.*
|
||||
|
||||
class JUnitContributor : AsserterContributor {
|
||||
override fun contribute(): Asserter? {
|
||||
for (stackFrame in currentStackTrace()) {
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
val className = stackFrame.className as java.lang.String
|
||||
|
||||
if (className.startsWith("org.junit.") || className.startsWith("junit.")) {
|
||||
return JUnitAsserter
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
object JUnitAsserter : Asserter {
|
||||
override fun assertEquals(message : String?, expected : Any?, actual : Any?) {
|
||||
Assert.assertEquals(message, expected, actual)
|
||||
}
|
||||
|
||||
override fun assertNotEquals(message : String?, illegal : Any?, actual : Any?) {
|
||||
Assert.assertNotEquals(message, illegal, actual)
|
||||
}
|
||||
|
||||
override fun assertNotNull(message : String?, actual : Any?) {
|
||||
Assert.assertNotNull(message ?: "actual value is null", actual)
|
||||
}
|
||||
|
||||
override fun assertNull(message : String?, actual : Any?) {
|
||||
Assert.assertNull(message ?: "actual value is not null", actual)
|
||||
}
|
||||
|
||||
override fun fail(message : String?) {
|
||||
Assert.fail(message)
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.test.junit.JUnitContributor
|
||||
@@ -0,0 +1,27 @@
|
||||
package kotlinx.testing.tests
|
||||
|
||||
import org.junit.*
|
||||
import java.util.concurrent.*
|
||||
|
||||
class JUnitContributorTest {
|
||||
@Test
|
||||
fun smokeTest() {
|
||||
Assert.assertEquals("JUnitAsserter", asserter.`class`.simpleName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should fail to contribute if it was run outside of junit`() {
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
val q = ArrayBlockingQueue<java.lang.Object>(1)
|
||||
|
||||
Thread {
|
||||
q.put(asserter)
|
||||
}.start()
|
||||
|
||||
Assert.assertEquals("DefaultAsserter", q.take().`class`.simpleName)
|
||||
}
|
||||
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
private val asserter: java.lang.Object
|
||||
get() = Class.forName("kotlin.test.TestAssertionsKt").getMethod("getAsserter").invoke(null) as java.lang.Object
|
||||
}
|
||||
Reference in New Issue
Block a user