@Test public void testSerialization() throws Exception { TestWelder testWelder = new TestWelder(); testWelder.registrationReference = new MockRegistrationReference(null); TestWelder newTestWelder = WelderTestUtil.transform(testWelder); Assert.assertNull(newTestWelder.registrationReference); Assert.assertFalse(newTestWelder.server); Assert.assertEquals(BaseWelder.State.CREATED, newTestWelder.state); }
@Test public void testWeld() throws Exception { TestWelder testWelder = new TestWelder(); testWelder.state = BaseWelder.State.DESTROYED; try { testWelder.weld(null); Assert.fail(); } catch (IllegalStateException ise) { Assert.assertEquals("Unable to weld a welder with state DESTROYED", ise.getMessage()); } testWelder.state = BaseWelder.State.CREATED; RegistrationReference registrationReference = testWelder.weld(null); Assert.assertNull(testWelder._clientRegistrationReference); Assert.assertEquals(testWelder._serverRegistrationReference, registrationReference); Assert.assertEquals(BaseWelder.State.WELDED, testWelder.state); TestWelder newTestWelder = WelderTestUtil.transform(testWelder); registrationReference = newTestWelder.weld(null); Assert.assertEquals(newTestWelder._clientRegistrationReference, registrationReference); Assert.assertNull(newTestWelder._serverRegistrationReference); Assert.assertEquals(BaseWelder.State.WELDED, newTestWelder.state); }
@Test public void testDestroty() throws IOException { TestWelder testWelder = new TestWelder(); try { testWelder.destroy(); Assert.fail(); } catch (IllegalStateException ise) { Assert.assertEquals("Unable to destroy a welder with state CREATED", ise.getMessage()); } RegistrationReference registrationReference = new MockRegistrationReference(null); testWelder.registrationReference = registrationReference; testWelder.state = BaseWelder.State.WELDED; testWelder.destroy(); Assert.assertFalse(registrationReference.isValid()); Assert.assertTrue(testWelder._destroyed); Assert.assertEquals(BaseWelder.State.DESTROYED, testWelder.state); }