@Test public void testDeserialize() throws Exception { Exception ex = new Exception("test exception"); SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl(); try { pb.deSerialize(); Assert.fail("deSerialze should throw YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass()); } pb.init(ex); Assert.assertEquals(ex.toString(), pb.deSerialize().toString()); }
@Test public void testDeserialize() throws Exception { Exception ex = new Exception("test exception"); SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl(); try { pb.deSerialize(); Assert.fail("deSerialze should throw YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass()); } pb.init(ex); Assert.assertEquals(ex.toString(), pb.deSerialize().toString()); }
@Test public void testDeserialize() throws Exception { Exception ex = new Exception("test exception"); SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl(); try { pb.deSerialize(); Assert.fail("deSerialze should throw YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass()); } pb.init(ex); Assert.assertEquals(ex.toString(), pb.deSerialize().toString()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }