ENT-11270: fix structure tests (#7606)

* ENT-11270: Un-ignored new tests as newer JDK adds more details.

Newer JDK adds the line position as well along exception message string, this makes the actual as:
line too long (line 1)
instead of: line too long
So, error is still thrown but the message contains a little more detail in the newer JDK.

Hence, changing equals to contains.
This commit is contained in:
Suhas Krishna Srivastava 2023-12-14 16:39:16 +05:30 committed by GitHub
parent b375c7da21
commit dfbc5302a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,26 +1,25 @@
package net.corda.core.contracts
import net.corda.core.identity.Party
import org.junit.Test
import org.mockito.kotlin.doAnswer
import org.mockito.kotlin.spy
import org.mockito.kotlin.whenever
import net.corda.core.identity.Party
import org.junit.Ignore
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.util.*
import java.util.UUID
import java.util.jar.JarFile.MANIFEST_NAME
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
import kotlin.test.fail
class AttachmentTest {
@Test(timeout=300_000)
@Suppress("ThrowsCount")
@Ignore("TODO JDK17: Line too long no longer thrown?")
fun `openAsJAR does not leak file handle if attachment has corrupted manifest`() {
var closeCalls = 0
val inputStream = spy(ByteArrayOutputStream().apply {
@ -42,7 +41,7 @@ class AttachmentTest {
attachment.openAsJAR()
fail("Expected line too long.")
} catch (e: IOException) {
assertEquals("line too long", e.message)
assertTrue { e.message!!.contains("line too long") }
}
assertEquals(1, closeCalls)
}