OptimizedMarshaller extends AbstractNodeNameAwareMarshaller { public OptimizedMarshaller setRequireSerializable(boolean requireSer) { this.requireSer = requireSer; return this; } OptimizedMarshaller();  OptimizedMarshaller(boolean requireSer); OptimizedMarshaller setRequireSerializable(boolean requireSer); OptimizedMarshaller setIdMapper(OptimizedMarshallerIdMapper mapper); OptimizedMarshaller setPoolSize(int poolSize); @SuppressWarnings({"TypeParameterExtendsFinalClass", "ErrorNotRethrown"}) static boolean available(); @Override void onUndeploy(ClassLoader ldr); @Override String toString(); static final boolean USE_DFLT_SUID; }
@Test public void testNonSerializable() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(false); NonSerializable outObj = marsh.unmarshal(marsh.marshal(new NonSerializable(null)), null); outObj.checkAfterUnmarshalled(); }
@Test public void testNonSerializable1() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(false); byte[] bytes = marsh.marshal(new TcpDiscoveryVmIpFinder()); TcpDiscoveryIpFinder ipFinder = marsh.unmarshal(bytes, null); assertFalse(ipFinder.isShared()); ipFinder = marsh.unmarshal(marsh.marshal(new TcpDiscoveryVmIpFinder(true)), null); assertTrue(ipFinder.isShared()); }
@Test public void testNonSerializable2() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(false); TcpDiscoveryIpFinderAdapter ipFinder = new TcpDiscoveryIpFinderAdapter() { @Override public Collection<InetSocketAddress> getRegisteredAddresses() { return null; } @Override public void registerAddresses(Collection<InetSocketAddress> addrs) { } @Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) { } }; ipFinder.setShared(false); byte[] bytes = marsh.marshal(ipFinder); ipFinder = marsh.unmarshal(bytes, null); assertFalse(ipFinder.isShared()); }
@Test public void testNonSerializable3() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(false); byte[] bytes = marsh.marshal(new TestTcpDiscoveryIpFinderAdapter()); TcpDiscoveryIpFinder ipFinder = marsh.unmarshal(bytes, null); assertFalse(ipFinder.isShared()); }
@Test public void testRequireSerializable() { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(true); try { marsh.marshal(new NonSerializable(null)); fail(); } catch (IgniteCheckedException ignore) { } }
@Test public void testProxy() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); marsh.setRequireSerializable(false); SomeItf inItf = (SomeItf)Proxy.newProxyInstance( OptimizedMarshallerTest.class.getClassLoader(), new Class[] {SomeItf.class}, new InvocationHandler() { private NonSerializable obj = new NonSerializable(null); @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable { obj.checkAfterUnmarshalled(); return 17; } } ); SomeItf outItf = marsh.unmarshal(marsh.marshal(inItf), null); assertEquals(outItf.checkAfterUnmarshalled(), 17); }