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

fixes #12. adds support for version ranges

updates MavenId parsing to match gradle's parsing
This commit is contained in:
evanchooly 2015-12-15 21:04:04 -05:00
parent 6b1b141943
commit 6883db4bb2
10 changed files with 489 additions and 37 deletions

View file

@ -6,8 +6,10 @@ 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())
companion object {
@BeforeSuite
public fun bs() {
Kobalt.INJECTOR = com.google.inject.Guice.createInjector(TestModule())
}
}
}

View file

@ -16,6 +16,8 @@ public class DependencyTest @Inject constructor(val depFactory: DepFactory,
@DataProvider
fun dpVersions(): Array<Array<out Any>> {
return arrayOf(
arrayOf("0.1", "0.1.1"),
arrayOf("0.1", "1.4"),
arrayOf("6.9.4", "6.9.5"),
arrayOf("1.7", "1.38"),
arrayOf("1.70", "1.380"),

View file

@ -26,7 +26,7 @@ public class DownloadTest @Inject constructor(
executor = executors.newExecutor("DependentTest", 5)
}
private fun deleteDir() : Boolean {
private fun deleteDir(): Boolean {
val dir = File(localRepo.toFullPath("$groupId"))
val result = dir.deleteRecursively()
return result
@ -52,7 +52,7 @@ public class DownloadTest @Inject constructor(
val version = "2.9.1"
val previousVersion = "2.9"
val groupId = "joda-time"
val artifactId = "joda-time"
val artifactId = "joda-time"
val jarFile = "$artifactId-$version.jar"
val idNoVersion = "$groupId:$artifactId:"
@ -72,12 +72,27 @@ public class DownloadTest @Inject constructor(
}
}
@Test
public fun shouldDownloadRangedVersion() {
File(localRepo.toFullPath("javax/servlet/servlet-api")).deleteRecursively()
testRange("[2.5,)", "3.0-alpha-1")
}
private fun testRange(range: String, expected: String) {
val dep = depFactory.create("javax.servlet:servlet-api:${range}", executor)
val future = dep.jarFile
val file = future.get()
Assert.assertFalse(future is CompletedFuture)
Assert.assertEquals(file.getName(), "servlet-api-${expected}.jar")
Assert.assertTrue(file.exists())
}
@Test
public fun shouldFindLocalJar() {
MavenDependency.create("$idNoVersion$version")
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())
}

View file

@ -15,7 +15,7 @@ class MavenIdTest {
null, null),
arrayOf("com.google.inject:guice:4.0:no_aop",
"com.google.inject", "guice", "4.0", null, "no_aop"),
arrayOf("com.android.support:appcompat-v7:aar:22.2.1",
arrayOf("com.android.support:appcompat-v7:22.2.1@aar",
"com.android.support", "appcompat-v7", "22.2.1", "aar", null)
)
}
@ -30,4 +30,4 @@ class MavenIdTest {
Assert.assertEquals(mi.packaging, packaging)
// Assert.assertEquals(mi.qualifier, qualifier)
}
}
}

View file

@ -0,0 +1,32 @@
package com.beust.kobalt.misc
import com.beust.kobalt.KobaltTest
import org.testng.Assert
import org.testng.annotations.Test
class VersionTest : KobaltTest() {
@Test
fun snapshot() {
val version = Version.of("1.2.0-SNAPSHOT")
Assert.assertTrue(version.isSnapshot())
}
@Test
fun rangedVersions() {
val ranged = Version.of("[2.5,)")
Assert.assertTrue(ranged.isRangedVersion())
}
@Test
fun selectVersion() {
var versions = listOf("2.4.public_draft", "2.2", "2.3", "2.4", "2.4-20040521", "2.5", "3.0-alpha-1").map { Version.of(it) }
Assert.assertEquals(Version.of("[2.5,)").select(versions), Version.of("3.0-alpha-1"))
Assert.assertEquals(Version.of("[2.5,3.0)").select(versions), Version.of("3.0-alpha-1"))
Assert.assertEquals(Version.of("[2.6-SNAPSHOT,)").select(versions), Version.of("3.0-alpha-1"))
versions = listOf("1.0", "1.1", "1.2", "1.2.3", "1.3", "1.4.2", "1.5-SNAPSHOT").map { Version.of(it) }
Assert.assertEquals(Version.of("[1.2,1.2.3)").select(versions), Version.of("1.2"))
Assert.assertEquals(Version.of("[1.2,1.2.3]").select(versions), Version.of("1.2.3"))
}
}