/** * Convert WatchedEvent to type that can be sent over network */ public WatcherEvent getWrapper() { return new WatcherEvent(eventType.getIntValue(), keeperState.getIntValue(), path); } }
/** * Convert WatchedEvent to type that can be sent over network */ public WatcherEvent getWrapper() { return new WatcherEvent(eventType.getIntValue(), keeperState.getIntValue(), path); } }
@Test public void testCreatingWatchedEventFromInvalidWrapper() { // Make sure we can't convert from an invalid wrapper try { WatcherEvent wep = new WatcherEvent(-2342, -252352, "foo"); new WatchedEvent(wep); Assert.fail("Was able to create WatchedEvent from bad wrapper"); } catch (RuntimeException re) { // we're good } }
+ Long.toHexString(sessionId)); WatcherEvent event = new WatcherEvent(); event.deserialize(bbia, "response");
@Test public void testCreatingWatchedEventFromWrapper() { // Make sure we can handle any type of correct wrapper EnumSet<EventType> allTypes = EnumSet.allOf(EventType.class); EnumSet<KeeperState> allStates = EnumSet.allOf(KeeperState.class); WatchedEvent we; WatcherEvent wep; for(EventType et : allTypes) { for(KeeperState ks : allStates) { wep = new WatcherEvent(et.getIntValue(), ks.getIntValue(), "blah"); we = new WatchedEvent(wep); Assert.assertEquals(et, we.getType()); Assert.assertEquals(ks, we.getState()); Assert.assertEquals("blah", we.getPath()); } } }
+ Long.toHexString(sessionId)); WatcherEvent event = new WatcherEvent(); event.deserialize(bbia, "response");
/** * Convert WatchedEvent to type that can be sent over network */ public WatcherEvent getWrapper() { return new WatcherEvent(eventType.getIntValue(), keeperState.getIntValue(), path); } }
+ Long.toHexString(sessionId)); WatcherEvent event = new WatcherEvent(); event.deserialize(bbia, "response");