@AfterClass public static void afterClass() { InternalInstantiator.unregister(CustId.class, (short) 1); }
InternalInstantiator.unregister(c, id); InternalInstantiator.unregister(c, id);
@Test public void testInstantiator2() throws Exception { final boolean[] wasInvoked = new boolean[] {false}; Instantiator.register(new Instantiator(DataSerializableImpl.class, 20000) { @Override public DataSerializable newInstance() { wasInvoked[0] = true; return new DataSerializableImpl(); } }); try { byte id = (byte) 57; Class_testInstantiator.supClass = DataSerializableImpl.class; DataSerializer.register(Class_testInstantiator.class); try { Object o = new DataSerializableImpl(new Random()); DataSerializer.writeObject(o, getDataOutput()); Object o2 = DataSerializer.readObject(getDataInput()); assertTrue(wasInvoked[0]); assertEquals(o, o2); } finally { InternalDataSerializer.unregister(id); } } finally { InternalInstantiator.unregister(DataSerializableImpl.class, 20000); } }
@Test public void testInstantiator4() throws Exception { final boolean[] wasInvoked = new boolean[] {false}; Instantiator.register(new Instantiator(DataSerializableImpl.class, 123456789) { @Override public DataSerializable newInstance() { wasInvoked[0] = true; return new DataSerializableImpl(); } }); try { byte id = (byte) 57; Class_testInstantiator.supClass = DataSerializableImpl.class; DataSerializer.register(Class_testInstantiator.class); try { Object o = new DataSerializableImpl(new Random()); DataSerializer.writeObject(o, getDataOutput()); Object o2 = DataSerializer.readObject(getDataInput()); assertTrue(wasInvoked[0]); assertEquals(o, o2); } finally { InternalDataSerializer.unregister(id); } } finally { InternalInstantiator.unregister(DataSerializableImpl.class, 123456789); } }
/** * Tests that an <code>Instantiator</code> is invoked at the appropriate times. */ @Test public void testInstantiator() throws Exception { final boolean[] wasInvoked = new boolean[] {false}; Instantiator.register(new Instantiator(DataSerializableImpl.class, (byte) 45) { @Override public DataSerializable newInstance() { wasInvoked[0] = true; return new DataSerializableImpl(); } }); try { byte id = (byte) 57; Class_testInstantiator.supClass = DataSerializableImpl.class; DataSerializer.register(Class_testInstantiator.class); try { Object o = new DataSerializableImpl(new Random()); DataSerializer.writeObject(o, getDataOutput()); Object o2 = DataSerializer.readObject(getDataInput()); assertTrue(wasInvoked[0]); assertEquals(o, o2); } finally { InternalDataSerializer.unregister(id); } } finally { InternalInstantiator.unregister(DataSerializableImpl.class, (byte) 45); } }
InternalInstantiator.unregister(DataSerializableImpl.class, (byte) 42);
InternalInstantiator.unregister(CanonicalDataSerializableImpl.class, (byte) 45);
InternalInstantiator.unregister(c, id); InternalDataSerializer.removeRegistrationListener(l3); InternalDataSerializer.removeRegistrationListener(l4);