RtpPortManager implements PortManager { @Override public int next() { return this.maximum - (this.current.getAndAdd(1) % step) * 2; } RtpPortManager(int minimum, int maximum);  RtpPortManager(); @Override int getLowest(); @Override int getHighest(); @Override int next(); int peek(); int current(); static final int MIN_PORT; static final int MAX_PORT; }
@Test public void testNext() { final int minimum = 2; final int maximum = 10; final PortManager portManager = new RtpPortManager(minimum, maximum); assertEquals(10, portManager.next()); assertEquals(8, portManager.next()); assertEquals(6, portManager.next()); assertEquals(4, portManager.next()); assertEquals(10, portManager.next()); }