Skip to content

Instantly share code, notes, and snippets.

@ffbit
Created November 16, 2012 20:58
Show Gist options
  • Select an option

  • Save ffbit/4090864 to your computer and use it in GitHub Desktop.

Select an option

Save ffbit/4090864 to your computer and use it in GitHub Desktop.
Jetty Connector Port unit test
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class JettyConnectorTest {
private static Server server = new Server();
private static Connector connector = new SelectChannelConnector();
@BeforeClass
public static void setUp() throws Exception {
connector.setPort(0);
server.addConnector(connector);
server.start();
}
@Test
public void connectorsShouldHaveTheSameLocalPort() throws Exception {
assertThat(connector.getLocalPort(),
is(server.getConnectors()[0].getLocalPort()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment