mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Enforce serialization API for Java. (#2014)
This commit is contained in:
parent
117261caa4
commit
a036a6300c
@ -0,0 +1,37 @@
|
||||
package net.corda.core.flows;
|
||||
|
||||
import net.corda.core.serialization.SerializationDefaults;
|
||||
import net.corda.core.serialization.SerializationFactory;
|
||||
import net.corda.testing.SerializationEnvironmentRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static net.corda.core.serialization.SerializationAPIKt.serialize;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Enforce parts of the serialization API that aren't obvious from looking at the {@link net.corda.core.serialization.SerializationAPIKt} code.
|
||||
*/
|
||||
public class SerializationApiInJavaTest {
|
||||
@Rule
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
|
||||
@Test
|
||||
public void enforceSerializationFactoryApi() {
|
||||
assertNull(SerializationFactory.Companion.getCurrentFactory());
|
||||
SerializationFactory factory = SerializationFactory.Companion.getDefaultFactory();
|
||||
assertNull(factory.getCurrentContext());
|
||||
serialize("hello", factory, factory.getDefaultContext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enforceSerializationDefaultsApi() {
|
||||
SerializationDefaults defaults = SerializationDefaults.INSTANCE;
|
||||
SerializationFactory factory = defaults.getSERIALIZATION_FACTORY();
|
||||
serialize("hello", factory, defaults.getP2P_CONTEXT());
|
||||
serialize("hello", factory, defaults.getRPC_SERVER_CONTEXT());
|
||||
serialize("hello", factory, defaults.getRPC_CLIENT_CONTEXT());
|
||||
serialize("hello", factory, defaults.getSTORAGE_CONTEXT());
|
||||
serialize("hello", factory, defaults.getCHECKPOINT_CONTEXT());
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ import static org.assertj.core.api.ThrowableAssert.catchThrowable;
|
||||
|
||||
public final class ForbiddenLambdaSerializationTests {
|
||||
@Rule
|
||||
public SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
private SerializationFactory factory;
|
||||
|
||||
@Before
|
||||
|
@ -19,7 +19,7 @@ import static org.assertj.core.api.ThrowableAssert.catchThrowable;
|
||||
|
||||
public final class LambdaCheckpointSerializationTest {
|
||||
@Rule
|
||||
public SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
private SerializationFactory factory;
|
||||
private SerializationContext context;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
public class VaultQueryJavaTests {
|
||||
@Rule
|
||||
public SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
private MockServices services;
|
||||
private MockServices issuerServices;
|
||||
private VaultService vaultService;
|
||||
|
Loading…
Reference in New Issue
Block a user