CORDA-2345: Simplified TestCordapp to make it inline with the recent CorDapp versioning changes (#4434)

TestCordapp has now two implementations to clearly separate the two use cases it has in the Corda repo:

* TestCordappImpl which implements the revised public API of TestCordapp; namely that a TestCordapp instance references a real CorDapp jar on the classpath. This is either an external dependency jar in which case it’s taken as is and given to the node, or it’s a local gradle project in which case it’s compiled using the gradle “jar” task to generate the CorDapp jar. This approach means the jar has all the original CorDapp versioning information, which is important that it’s correct when testing. To this end, TestCordapp only needs to expose the ability to specify the app’s config. All the remaining properties have moved to CustomCordapp.

* CustomCordapp for creating arbitrary custom CorDapps, including specifying the jar’s MANIFEST values. This is internal API and only used for testing the platform. Technically this shouldn’t implement TestCordapp but does so to reduce the complexity of the driver and mock network.
This commit is contained in:
Shams Asari
2018-12-20 09:49:58 +00:00
committed by GitHub
parent 4aaefb4fe9
commit 830959c9f7
37 changed files with 748 additions and 633 deletions

View File

@ -0,0 +1,39 @@
package net.corda.serialization.internal.amqp.custom
import net.corda.serialization.internal.amqp.SerializerFactory
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.nullValue
import org.junit.Assert.assertThat
import org.junit.Test
import org.mockito.Mockito
import java.util.*
class OptionalSerializerTest {
@Test
fun `should convert optional with item to proxy`() {
val opt = Optional.of("GenericTestString")
val proxy = OptionalSerializer(Mockito.mock(SerializerFactory::class.java)).toProxy(opt)
assertThat(proxy.item, `is`<Any>("GenericTestString"))
}
@Test
fun `should convert optional without item to empty proxy`() {
val opt = Optional.ofNullable<String>(null)
val proxy = OptionalSerializer(Mockito.mock(SerializerFactory::class.java)).toProxy(opt)
assertThat(proxy.item, `is`(nullValue()))
}
@Test
fun `should convert proxy without item to empty optional `() {
val proxy = OptionalSerializer.OptionalProxy(null)
val opt = OptionalSerializer(Mockito.mock(SerializerFactory::class.java)).fromProxy(proxy)
assertThat(opt.isPresent, `is`(false))
}
@Test
fun `should convert proxy with item to empty optional `() {
val proxy = OptionalSerializer.OptionalProxy("GenericTestString")
val opt = OptionalSerializer(Mockito.mock(SerializerFactory::class.java)).fromProxy(proxy)
assertThat(opt.get(), `is`<Any>("GenericTestString"))
}
}