@Override public ContainerBuilder set(String property, String value) { containerConfiguration.set(property, value); return this; }
@Override public ContainerBuilder set(TestatooProperties property, String value) { containerConfiguration.set(property, value); return this; }
public ContainerConfiguration add(Properties settings) { // emulate JDK 6's stringPropertyNames() for (Map.Entry<Object, Object> entry : settings.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) set((String) entry.getKey(), (String) entry.getValue()); } // override by more important properties for (Map.Entry<Object, Object> entry : settings.entrySet()) if (entry.getKey() instanceof TestatooProperties) properties.put(entry.getKey(), entry.getValue()); return this; }
public static void main(String... args) throws Exception { CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); if (line.hasOption("help") || !line.hasOption(CONTAINER.getName())) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(ContainerRunner.class.getSimpleName(), options); return; } // Set default values // And override by system properties. This way, we can start ContainerRunner with specific options such as -DjettyConf=.. -DjettyEnv=... ContainerConfiguration settings = ContainerConfiguration.from(System.getProperties()); // Then parse command line for (Option option : line.getOptions()) { settings.set(TestatooProperties.from(option.getOpt()), line.getOptionValue(option.getOpt())); } Container container = settings.buildContainer(line.getOptionValue(CONTAINER.getName())); container.start(); } }
@Test public void test_port() throws Exception { Container container = ContainerConfiguration.create() .port(9999) .webappRoot("../core/src/test/webapp") .context("superApp") .set("jetty.conf", "src/test/data/jetty-conf.xml") .set("jetty.trace", "true") .buildContainer(TestatooContainer.JETTY); assertEquals(container.port(), 6837); assertFalse(container.isRunning()); container.start(); assertTrue(container.isRunning()); WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse("http://127.0.0.1:6837/superApp/index.jsp"); assertEquals(resp.getTitle(), "JSP Test"); assertThat(resp.getText(), containsString("Languages")); container.stop(); assertFalse(container.isRunning()); }