private void testSetDatagramSocketImpl(HttpServletResponse response) throws IOException, AssertionFailedException { DatagramSocketImplFactory mockFactory = new DatagramSocketImplFactory() { @Override public DatagramSocketImpl createDatagramSocketImpl() { return null; } }; SocketException caught = null; try { DatagramSocket.setDatagramSocketImplFactory(mockFactory); } catch (SocketException e) { caught = e; } assertNotNull("caught", caught, response); }
/** * Set up socket factories to use JikesRVMSocketImpl */ public static void boot() { try { Socket.setSocketImplFactory(new SocketImplFactory() { public SocketImpl createSocketImpl() { return new JikesRVMSocketImpl(); } }); ServerSocket.setSocketFactory(new SocketImplFactory() { public SocketImpl createSocketImpl() { return new JikesRVMSocketImpl(); } }); DatagramSocket.setDatagramSocketImplFactory(new DatagramSocketImplFactory() { public DatagramSocketImpl createDatagramSocketImpl() { throw new VM_UnimplementedError("Need to implement JikesRVMDatagramSocketImpl"); } }); } catch (java.io.IOException e) { VM.sysFail("trouble setting socket impl factories"); } }