mirror of
https://github.com/corda/corda.git
synced 2024-12-20 21:43:14 +00:00
Minor: ClassLoaderTests reformatting
This commit is contained in:
parent
13f334ceba
commit
7e9cbaa36e
@ -66,7 +66,6 @@ class ClassLoaderTests {
|
||||
|
||||
@Test
|
||||
fun `test overlapping file exception`() {
|
||||
|
||||
val storage = MockAttachmentStorage()
|
||||
|
||||
val att0 = importJar(storage)
|
||||
@ -74,15 +73,12 @@ class ClassLoaderTests {
|
||||
val att2 = storage.importAttachment(ByteArrayInputStream(fakeAttachment("file.txt", "some other data")))
|
||||
|
||||
assertFailsWith(OverlappingAttachments::class) {
|
||||
|
||||
AttachmentsClassLoader.create(arrayOf(att0, att1, att2).map { storage.openAttachment(it)!! })
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `basic`() {
|
||||
|
||||
val storage = MockAttachmentStorage()
|
||||
|
||||
val att0 = importJar(storage)
|
||||
@ -104,10 +100,8 @@ class ClassLoaderTests {
|
||||
val att2 = storage.importAttachment(ByteArrayInputStream(fakeAttachment("file2.txt", "some other data")))
|
||||
|
||||
AttachmentsClassLoader.create(arrayOf(att0, att1, att2).map { storage.openAttachment(it)!! }).use {
|
||||
|
||||
val contractClass = Class.forName("contracts.isolated.AnotherDummyContract", true, it)
|
||||
val contract = contractClass.newInstance() as Contract
|
||||
|
||||
assertEquals(SecureHash.sha256("https://anotherdummy.org"), contract.legalContractReference)
|
||||
}
|
||||
}
|
||||
@ -192,29 +186,21 @@ class ClassLoaderTests {
|
||||
@Test
|
||||
fun `test serialization of WireTransaction with statically loaded contract`() {
|
||||
val tx = DUMMY_PROGRAM_ID.generateInitial(MEGA_CORP.ref(0), 42)
|
||||
|
||||
val wireTransaction = tx.toWireTransaction()
|
||||
|
||||
val bytes = wireTransaction.serialize()
|
||||
|
||||
val copiedWireTransaction = bytes.deserialize()
|
||||
|
||||
assertEquals(1, copiedWireTransaction.outputs.size)
|
||||
|
||||
assertEquals(42, (copiedWireTransaction.outputs[0] as DummyContract.State).magicNumber)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test serialization of WireTransaction with dynamically loaded contract`() {
|
||||
val child = URLClassLoader(arrayOf(ISOLATED_CONTRACTS_JAR_PATH))
|
||||
|
||||
val contractClass = Class.forName("contracts.isolated.AnotherDummyContract", true, child)
|
||||
val contract = contractClass.newInstance() as DummyContractBackdoor
|
||||
|
||||
val tx = contract.generateInitial(MEGA_CORP.ref(0), 42)
|
||||
|
||||
val storage = MockAttachmentStorage()
|
||||
|
||||
val kryo = createKryo()
|
||||
|
||||
// todo - think about better way to push attachmentStorage down to serializer
|
||||
@ -244,14 +230,10 @@ class ClassLoaderTests {
|
||||
@Test
|
||||
fun `test deserialize of WireTransaction where contract cannot be found`() {
|
||||
val child = URLClassLoader(arrayOf(ISOLATED_CONTRACTS_JAR_PATH))
|
||||
|
||||
val contractClass = Class.forName("contracts.isolated.AnotherDummyContract", true, child)
|
||||
val contract = contractClass.newInstance() as DummyContractBackdoor
|
||||
|
||||
val tx = contract.generateInitial(MEGA_CORP.ref(0), 42)
|
||||
|
||||
val storage = MockAttachmentStorage()
|
||||
|
||||
val kryo = createKryo()
|
||||
|
||||
// todo - think about better way to push attachmentStorage down to serializer
|
||||
|
Loading…
Reference in New Issue
Block a user