/** * method to close the datagram socket */ @Override public void close() { super.close(); if (datagramSocket != null) { datagramSocket.close(); } }
/** * method to close the datagram socket */ @Override public void close() { super.close(); if (datagramSocket != null) { datagramSocket.close(); } }
/** * method to close the datagram socket */ @Override public void close() { super.close(); if (datagramSocket != null) { datagramSocket.close(); } }
/** * method to close the datagram socket */ @Override public void close() { super.close(); if (datagramSocket != null) { datagramSocket.close(); } }
@Test public void testCloseShouldCloseTheSocketWhichIsCreatedByInit() throws Exception { AbstractMetricsContext context=new GangliaContext(); context.init("gangliaContext", ContextFactory.getFactory()); GangliaContext gangliaContext =(GangliaContext) context; assertFalse("Socket already closed",gangliaContext.datagramSocket.isClosed()); context.close(); assertTrue("Socket not closed",gangliaContext.datagramSocket.isClosed()); } }
@Test public void testCloseShouldCloseTheSocketWhichIsCreatedByInit() throws Exception { AbstractMetricsContext context=new GangliaContext(); context.init("gangliaContext", ContextFactory.getFactory()); GangliaContext gangliaContext =(GangliaContext) context; assertFalse("Socket already closed",gangliaContext.datagramSocket.isClosed()); context.close(); assertTrue("Socket not closed",gangliaContext.datagramSocket.isClosed()); } }
@Test public void testCloseShouldCloseTheSocketWhichIsCreatedByInit() throws Exception { AbstractMetricsContext context=new GangliaContext(); context.init("gangliaContext", ContextFactory.getFactory()); GangliaContext gangliaContext =(GangliaContext) context; assertFalse("Socket already closed",gangliaContext.datagramSocket.isClosed()); context.close(); assertTrue("Socket not closed",gangliaContext.datagramSocket.isClosed()); } }