mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Move zip verification to tests.
This commit is contained in:
parent
1e958ef7dd
commit
92d281e423
3 changed files with 9 additions and 11 deletions
54
src/test/kotlin/com/beust/kobalt/VerifyKobaltZip.kt
Normal file
54
src/test/kotlin/com/beust/kobalt/VerifyKobaltZip.kt
Normal file
|
@ -0,0 +1,54 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
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.FileInputStream
|
||||
import java.util.jar.JarFile
|
||||
import java.util.jar.JarInputStream
|
||||
|
||||
class VerifyKobaltZipTest : KobaltTest() {
|
||||
@Test
|
||||
fun verifyZipFile() {
|
||||
var success = true
|
||||
var foundKobaltw = false
|
||||
var foundJar = false
|
||||
var foundWrapperJar = false
|
||||
|
||||
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))
|
||||
var entry = stream.nextEntry
|
||||
while (entry != null) {
|
||||
if (entry.name == "kobaltw") {
|
||||
foundKobaltw = true
|
||||
} else if (entry.name.endsWith(jarFilePath)) {
|
||||
val ins = zipFile.getInputStream(entry)
|
||||
if (ins.available() < 20000000) {
|
||||
throw KobaltException(jarFilePath + " is too small: " + jarFilePath)
|
||||
}
|
||||
foundJar = true
|
||||
} else if (entry.name.endsWith("kobalt-wrapper.jar")) {
|
||||
foundWrapperJar = true
|
||||
} else {
|
||||
success = false
|
||||
}
|
||||
entry = stream.nextEntry
|
||||
}
|
||||
if (! success) {
|
||||
throw KobaltException("Found unexpected file in $zipFilePath")
|
||||
}
|
||||
if (! foundKobaltw) {
|
||||
throw KobaltException("Couldn't find kobaltw in $zipFilePath")
|
||||
}
|
||||
if (! foundJar) {
|
||||
throw KobaltException("Couldn't find jar in $zipFilePath")
|
||||
}
|
||||
if (! foundWrapperJar) {
|
||||
throw KobaltException("Couldn't find wrapper jar in $zipFilePath")
|
||||
}
|
||||
log(1, "$zipFilePath looks correct")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue