mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
parent
a9c391d045
commit
ef9bbe580b
3 changed files with 22 additions and 49 deletions
|
@ -4,42 +4,19 @@ import com.beust.kobalt.api.Kobalt
|
|||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.log
|
||||
import org.testng.annotations.Test
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
import java.util.jar.JarFile
|
||||
import java.util.jar.JarInputStream
|
||||
|
||||
@Test
|
||||
class VerifyKobaltZipTest : KobaltTest() {
|
||||
private fun assertExistsInJar(jarName: String, fileName: String) {
|
||||
val sourceJarPath = KFiles.joinDir("kobaltBuild", "libs", jarName)
|
||||
assertExistsInJar(JarInputStream(FileInputStream(File(sourceJarPath))), fileName)
|
||||
}
|
||||
|
||||
fun assertExistsInJar(stream: JarInputStream, fileName: String) {
|
||||
var entry = stream.nextEntry
|
||||
var found = false
|
||||
while (entry != null) {
|
||||
if (entry.name == fileName) found = true
|
||||
entry = stream.nextEntry
|
||||
}
|
||||
if (! found) {
|
||||
throw AssertionError("Couldn't find Main.kt in $fileName")
|
||||
}
|
||||
}
|
||||
|
||||
fun verifySourceFile() {
|
||||
assertExistsInJar("kobalt-" + Kobalt.version + "-sources.jar", "com/beust/kobalt/Main.kt")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyZipFile() {
|
||||
var success = true
|
||||
var foundKobaltw = false
|
||||
var foundJar = false
|
||||
var foundWrapperJar = false
|
||||
|
||||
val mainJarFilePath = "kobalt-" + Kobalt.version + ".jar"
|
||||
val jarFilePath = "kobalt-" + Kobalt.version + ".jar"
|
||||
val zipFilePath = KFiles.joinDir("kobaltBuild", "libs", "kobalt-" + Kobalt.version + ".zip")
|
||||
val zipFile = JarFile(zipFilePath)
|
||||
val stream = JarInputStream(FileInputStream(zipFilePath))
|
||||
|
@ -47,12 +24,11 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
while (entry != null) {
|
||||
if (entry.name == "kobaltw") {
|
||||
foundKobaltw = true
|
||||
} else if (entry.name.endsWith(mainJarFilePath)) {
|
||||
} else if (entry.name.endsWith(jarFilePath)) {
|
||||
val ins = zipFile.getInputStream(entry)
|
||||
if (ins.available() < 20000000) {
|
||||
throw AssertionError(mainJarFilePath + " is too small: " + mainJarFilePath)
|
||||
throw KobaltException(jarFilePath + " is too small: " + jarFilePath)
|
||||
}
|
||||
verifyMainJarFile(ins)
|
||||
foundJar = true
|
||||
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
|
||||
foundWrapperJar = true
|
||||
|
@ -62,21 +38,17 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
entry = stream.nextEntry
|
||||
}
|
||||
if (! success) {
|
||||
throw AssertionError("Found unexpected file in $zipFilePath")
|
||||
throw KobaltException("Found unexpected file in $zipFilePath")
|
||||
}
|
||||
if (! foundKobaltw) {
|
||||
throw AssertionError("Couldn't find kobaltw in $zipFilePath")
|
||||
throw KobaltException("Couldn't find kobaltw in $zipFilePath")
|
||||
}
|
||||
if (! foundJar) {
|
||||
throw AssertionError("Couldn't find jar in $zipFilePath")
|
||||
throw KobaltException("Couldn't find jar in $zipFilePath")
|
||||
}
|
||||
if (! foundWrapperJar) {
|
||||
throw AssertionError("Couldn't find wrapper jar in $zipFilePath")
|
||||
throw KobaltException("Couldn't find wrapper jar in $zipFilePath")
|
||||
}
|
||||
log(1, "$zipFilePath looks correct")
|
||||
}
|
||||
|
||||
private fun verifyMainJarFile(ins: InputStream) {
|
||||
assertExistsInJar(JarInputStream(ins), "com/beust/kobalt/MainKt.class")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue