Created
November 4, 2015 22:10
-
-
Save jasondlee/219465267279c88dd1e3 to your computer and use it in GitHub Desktop.
This is a rough example of a Kotlin-based Arquillian test. DatabaseService is, for what it's worth, a CDI-exposed Kotlin-based class as well.
This file contains hidden or 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
package com.steeplesoft.kotlinee | |
import com.steeplesoft.kotlinee.service.DatabaseService | |
import org.jboss.arquillian.container.test.api.Deployment | |
import org.jboss.arquillian.junit.Arquillian | |
import org.jboss.shrinkwrap.api.ShrinkWrap | |
import org.jboss.shrinkwrap.api.spec.JavaArchive | |
import org.jboss.shrinkwrap.api.spec.WebArchive | |
import org.jboss.shrinkwrap.resolver.api.maven.Maven | |
import org.junit.Assert | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
import java.io.File | |
import javax.inject.Inject | |
/** | |
* @author jdlee | |
* @since 2015-11-04 | |
*/ | |
@RunWith(Arquillian::class) | |
class DatabaseServiceTest { | |
@Inject | |
var service : DatabaseService? = null | |
companion object { | |
@JvmStatic | |
@Deployment | |
fun createBaseDeployment(): WebArchive { | |
val kotlinRuntime = Maven.configureResolver() | |
.workOffline() | |
.withMavenCentralRepo(true) | |
.withClassPathResolution(true) | |
.loadPomFromFile("pom.xml") | |
.resolve("org.jetbrains.kotlin:kotlin-stdlib") | |
.withTransitivity().`as`(JavaArchive::class.java) | |
return ShrinkWrap.create(WebArchive::class.java, "test.war") | |
.addPackages(true, "com.steeplesoft.kotlinee") | |
.addAsWebInfResource(File("src/main/webapp/WEB-INF/web.xml")) | |
.addAsManifestResource(File("src/main/webapp/WEB-INF/beans.xml")) | |
.addAsLibraries(kotlinRuntime) | |
} | |
} | |
@Test | |
fun testService(): Unit { | |
Assert.assertNotNull(service) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello...
I tried to apply this example, but I got
addAsLibraries
as Unresolved reference....couldn't move ahead...
any solution?