### Question:
Jetty implements WebsterService { public int getPort() { if (server == null) { return port; } return ((ServerConnector)server.getConnectors()[0]).getLocalPort(); } Jetty();  Jetty(File jettyConfig);  Jetty(Configuration config); Jetty setRoots(String... roots); Jetty setPort(int port); Jetty setMinThreads(int minThreads); Jetty setMaxThreads(int maxThreads); Jetty setPutDir(String putDir); @Override void start(); @Override void startSecure(); @Override void terminate(); @Override URI getURI(); int getPort(); String getAddress(); void join(); static void main(String[] args);  }### Answer:
@Test public void testStartWithConfig() throws Exception { DynamicConfiguration config = new DynamicConfiguration(); config.setEntry(Jetty.COMPONENT,"port", int.class,9020); config.setEntry(Jetty.COMPONENT,"roots", String[].class, new String[]{ System.getProperty("user.dir") + "/build/classes", System.getProperty("user.dir") + "/build/libs" }); Jetty jetty = new Jetty(config); assertEquals(9020, jetty.getPort()); }
@Test public void testStartWithGroovyConfig() throws Exception { String projectDir = System.getProperty("projectDir"); String resources = new File(projectDir+"/src/test/resources").getPath(); File config = new File(resources +"/jetty.groovy"); Jetty jetty = new Jetty(config); assertEquals(9029, jetty.getPort()); }