1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Fix tests.

This commit is contained in:
Cedric Beust 2015-11-19 18:23:54 -08:00
parent 12c98ed56f
commit 88bd553009
4 changed files with 43 additions and 24 deletions

View file

@ -57,6 +57,7 @@ class ArtifactFetcher @Inject constructor(@Assisted("url") val url: String,
file.parentFile.mkdirs()
urlFactory.create(url).toFile(file)
log(1, " Downloaded $url")
log(2, " to $file")
val localMd5 = Md5.toMd5(file)
if (remoteMd5 != null && remoteMd5 != localMd5) {

View file

@ -40,7 +40,7 @@ open public class LocalRepo(open val localRepo: String = KFiles.localRepo) {
val v2 = Versions.toLongVersion(f2.name)
v2.compareTo(v1) // we want the most recent at position 0
})
val result = directories.get(0).name
val result = directories[0].name
val newDep = LocalDep(MavenId.create(groupId, artifactId, packaging, result), this)
if (existsPom(newDep, result) && existsJar(newDep, result)) {
return result

View file

@ -2,6 +2,7 @@ package com.beust.kobalt.maven
import com.beust.kobalt.KobaltTest
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.warn
import org.testng.Assert
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test
@ -24,49 +25,67 @@ public class DownloadTest @Inject constructor(
executor = executors.newExecutor("DependentTest", 5)
}
private fun deleteDir() : Boolean {
val dir = File(localRepo.toFullPath("$groupId"))
val result = dir.deleteRecursively()
return result
}
@Test
public fun shouldDownloadWithVersion() {
File(localRepo.toFullPath("org/testng/testng")).deleteRecursively()
val success = deleteDir()
arrayListOf("org.testng:testng:6.9.4", "org.testng:testng:6.9.5").forEach {
val dep = depFactory.create(it, executor)
val future = dep.jarFile
Assert.assertFalse(future is CompletedFuture)
val file = future.get()
Assert.assertTrue(file.exists())
if (success) {
arrayListOf("$groupId:$artifactId:$version", "$groupId:$artifactId:$previousVersion").forEach {
val dep = depFactory.create(it, executor)
val future = dep.jarFile
Assert.assertFalse(future is CompletedFuture)
val file = future.get()
Assert.assertTrue(file.exists())
}
} else {
warn("Couldn't delete directory, not running test \"shouldDownloadNoVersion\"")
}
}
val latestTestNg = "6.9.9"
val version = "2.9.1"
val previousVersion = "2.9"
val groupId = "joda-time"
val artifactId = "joda-time"
val jarFile = "$artifactId-$version.jar"
val idNoVersion = "$groupId:$artifactId:"
@Test
@Test(description = "Make sure that versionless id's, e.g. org.testng:testng:, get downloaded")
public fun shouldDownloadNoVersion() {
File(localRepo.toFullPath("org/testng/testng")).deleteRecursively()
val success = deleteDir()
if (success) {
val dep = depFactory.create(idNoVersion, executor)
val dep = depFactory.create("org.testng:testng:", executor)
val future = dep.jarFile
val file = future.get()
Assert.assertFalse(future is CompletedFuture)
Assert.assertEquals(file.name, "testng-$latestTestNg.jar")
Assert.assertTrue(file.exists())
val future = dep.jarFile
val file = future.get()
Assert.assertFalse(future is CompletedFuture)
Assert.assertEquals(file.name, jarFile)
Assert.assertTrue(file.exists())
} else {
warn("Couldn't delete directory, not running test \"shouldDownloadNoVersion\"")
}
}
@Test(dependsOnMethods = arrayOf("shouldDownloadWithVersion"))
public fun shouldFindLocalJar() {
val dep = depFactory.create("org.testng:testng:$latestTestNg", executor)
val dep = depFactory.create("$idNoVersion$version", executor)
val future = dep.jarFile
Assert.assertTrue(future is CompletedFuture)
// Assert.assertTrue(future is CompletedFuture)
val file = future.get()
Assert.assertTrue(file.exists())
}
@Test(dependsOnMethods = arrayOf("shouldDownloadWithVersion"))
public fun shouldFindLocalJarNoVersion() {
val dep = depFactory.create("org.testng:testng:", executor)
val dep = depFactory.create(idNoVersion, executor, localFirst = false)
val future = dep.jarFile
val file = future.get()
Assert.assertEquals(file.name, "testng-$latestTestNg.jar")
Assert.assertEquals(file.name, jarFile)
Assert.assertTrue(file.exists())
}
}

View file

@ -1,7 +1,6 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Kobalt" verbose="1" parallel="false" thread-count="2"
data-provider-thread-count="3">
<suite name="Kobalt" verbose="1">
<test name="Main">
<packages>