@Test public void testUninstall() throws Exception { Sniffy.initialize(); SnifferSocketImplFactory.uninstall(); try (Spy<?> s = Sniffy.spy()) { performSocketOperation(); assertTrue(s.getSocketOperations(CURRENT, null, true).isEmpty()); } SnifferSocketImplFactory.install(); }
public static void uninstall() throws IOException { try { Field factoryField = Socket.class.getDeclaredField("factory"); factoryField.setAccessible(true); factoryField.set(null, previousSocketImplFactory); } catch (IllegalAccessException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } catch (NoSuchFieldException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } }
SnifferSocketImplFactory implements SocketImplFactory { public static void uninstall() throws IOException { try { Field factoryField = Socket.class.getDeclaredField("factory"); factoryField.setAccessible(true); factoryField.set(null, previousSocketImplFactory); } catch (IllegalAccessException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } catch (NoSuchFieldException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } } }
SnifferSocketImplFactory implements SocketImplFactory { public static void uninstall() throws IOException { try { Field factoryField = Socket.class.getDeclaredField("factory"); factoryField.setAccessible(true); factoryField.set(null, previousSocketImplFactory); } catch (IllegalAccessException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } catch (NoSuchFieldException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } }  }
SnifferSocketImplFactory implements SocketImplFactory { public static void uninstall() throws IOException { try { Field factoryField = Socket.class.getDeclaredField("factory"); factoryField.setAccessible(true); factoryField.set(null, previousSocketImplFactory); } catch (IllegalAccessException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } catch (NoSuchFieldException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } }  static void install(); static void uninstall(); @Override SocketImpl createSocketImpl(); }
SnifferSocketImplFactory implements SocketImplFactory { public static void uninstall() throws IOException { try { Field factoryField = Socket.class.getDeclaredField("factory"); factoryField.setAccessible(true); factoryField.set(null, previousSocketImplFactory); } catch (IllegalAccessException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } catch (NoSuchFieldException e) { throw new IOException("Failed to initialize SnifferSocketImplFactory", e); } }  static void install(); static void uninstall(); @Override SocketImpl createSocketImpl();  }