From 7088e781be5a6fbc3277370469badca9bd18ab71 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 16 Nov 2015 03:11:24 -0800 Subject: [PATCH] Test fixes. --- .../kotlin/com/beust/kobalt/KobaltTest.kt | 13 +++++++++++ .../com/beust/kobalt/maven/DownloadTest.kt | 22 +++---------------- .../com/beust/kobalt/maven/MavenIdTest.kt | 2 +- .../kotlin/com/beust/kobalt/maven/PomTest.kt | 3 ++- 4 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 src/test/kotlin/com/beust/kobalt/KobaltTest.kt diff --git a/src/test/kotlin/com/beust/kobalt/KobaltTest.kt b/src/test/kotlin/com/beust/kobalt/KobaltTest.kt new file mode 100644 index 00000000..73ae4758 --- /dev/null +++ b/src/test/kotlin/com/beust/kobalt/KobaltTest.kt @@ -0,0 +1,13 @@ +package com.beust.kobalt + +import com.beust.kobalt.api.Kobalt +import org.testng.annotations.BeforeSuite +import org.testng.annotations.Guice + +@Guice(modules = arrayOf(TestModule::class)) +open class KobaltTest { + @BeforeSuite + public fun bs() { + Kobalt.INJECTOR = com.google.inject.Guice.createInjector(TestModule()) + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt b/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt index 81f3d583..ac3a291a 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/DownloadTest.kt @@ -1,20 +1,9 @@ package com.beust.kobalt.maven -import com.beust.kobalt.maven.CompletedFuture -import com.beust.kobalt.maven.DepFactory -import com.beust.kobalt.maven.LocalRepo +import com.beust.kobalt.KobaltTest import com.beust.kobalt.misc.KobaltExecutors -import com.beust.kobalt.misc.MainModule -import com.beust.kobalt.TestModule -import com.beust.kobalt.api.Kobalt -import com.google.inject.Module -import com.google.inject.util.Modules import org.testng.Assert -import org.testng.IModuleFactory -import org.testng.ITestContext import org.testng.annotations.BeforeClass -import org.testng.annotations.BeforeSuite -import org.testng.annotations.Guice import org.testng.annotations.Test import java.io.File import java.util.concurrent.ExecutorService @@ -24,18 +13,12 @@ import kotlin.properties.Delegates /** * TODO: test snapshots https://repository.jboss.org/nexus/content/repositories/root_repository//commons-lang/commons-lang/2.7-SNAPSHOT/commons-lang-2.7-SNAPSHOT.jar */ -@Guice(modules = arrayOf(TestModule::class)) public class DownloadTest @Inject constructor( val depFactory: DepFactory, val localRepo: LocalRepo, - val executors: KobaltExecutors) { + val executors: KobaltExecutors) : KobaltTest() { var executor: ExecutorService by Delegates.notNull() - @BeforeSuite - public fun bs() { - Kobalt.INJECTOR = com.google.inject.Guice.createInjector(TestModule()) - } - @BeforeClass public fun bc() { executor = executors.newExecutor("DependentTest", 5) @@ -87,3 +70,4 @@ public class DownloadTest @Inject constructor( Assert.assertTrue(file.exists()) } } + diff --git a/src/test/kotlin/com/beust/kobalt/maven/MavenIdTest.kt b/src/test/kotlin/com/beust/kobalt/maven/MavenIdTest.kt index ab8d7e2c..fcc4999e 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/MavenIdTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/MavenIdTest.kt @@ -22,7 +22,7 @@ class MavenIdTest { @Test(dataProvider = "dp") fun parseVersions(id: String, groupId: String, artifactId: String, version: String?, - packaging: String? /* , qualifier: String? */) { + packaging: String?, qualifier: String?) { val mi = MavenId(id) Assert.assertEquals(mi.groupId, groupId) Assert.assertEquals(mi.artifactId, artifactId) diff --git a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt index fb3b6eca..4c54de83 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt @@ -1,6 +1,7 @@ package com.beust.kobalt.maven import com.beust.kobalt.Args +import com.beust.kobalt.KobaltTest import com.beust.kobalt.ProjectGenerator import com.beust.kobalt.internal.PluginInfo import com.google.inject.Inject @@ -8,7 +9,7 @@ import org.testng.Assert import org.testng.annotations.Test import java.io.File -class PomTest @Inject constructor(val pluginInfo: PluginInfo){ +class PomTest @Inject constructor(val pluginInfo: PluginInfo) : KobaltTest() { @Test fun importPom() { val pomSrc = File("src/test/resources/pom.xml")