public ContainerConfiguration clear(String property) { notNull(property, "Property name"); properties.remove(property); return this; }
public ContainerConfiguration webappClassPath(URL... locations) { notNull(locations, "Webapp classpath"); properties.put(WEBAPP_CLASSPATH, locations); return this; }
public ContainerConfiguration serverClassPath(URL... locations) { notNull(locations, "Server classpath"); properties.put(SERVER_CLASSPATH, locations); return this; }
public ContainerConfiguration webappRoot(File webappRoot) { notNull(webappRoot, "Webapp root"); properties.put(WEBAPP_ROOT, webappRoot); return this; }
public ContainerConfiguration set(String property, String value) { notNull(property, "Property name"); properties.setProperty(property, value); return this; }
public ContainerConfiguration context(String contextPath) { notNull(contextPath, "Webapp context path"); properties.put(CONTEXT, contextPath.startsWith("/") ? contextPath : "/" + contextPath); return this; }
public ContainerConfiguration webappRoot(String webappRoot) { notNull(webappRoot, "Webapp root"); return webappRoot(new File(webappRoot)); }
public ContainerConfiguration serverClassPath(File... paths) { notNull(paths, "Server classpath"); List<URL> urls = new ArrayList<URL>(paths.length); for (File path : paths) urls.add(pathAsURL(path.getAbsolutePath())); return serverClassPath(urls.toArray(new URL[urls.size()])); }
public ContainerConfiguration webappClassPath(File... paths) { notNull(paths, "Webapp classpath"); List<URL> urls = new ArrayList<URL>(paths.length); for (File path : paths) urls.add(pathAsURL(path.getAbsolutePath())); return webappClassPath(urls.toArray(new URL[urls.size()])); }
public ContainerConfiguration serverClassPath(String serverClassPath) { notNull(serverClassPath, "Server classpath"); return serverClassPath(toUrl(serverClassPath)); }
public ContainerConfiguration webappClassPath(String webappClassPath) { notNull(webappClassPath, "Webapp classpath"); return webappClassPath(toUrl(webappClassPath)); }
public Container buildContainer(String containerClass) { notNull(containerClass, "Container type " + Arrays.deepToString(TestatooContainer.values()) + " or container class"); Class<Container> clazz = null; for (TestatooContainer container : TestatooContainer.values()) { if (container.name().equalsIgnoreCase(containerClass)) { clazz = loadServerClass(container.serverClass()); break; } } if (clazz == null) clazz = loadServerClass(containerClass); try { return clazz.getConstructor(ContainerConfiguration.class).newInstance(ContainerConfiguration.from(this)); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof RuntimeException) throw (RuntimeException) e.getTargetException(); else throw new RuntimeException(e.getTargetException().getMessage(), e.getTargetException()); } catch (Exception e) { throw new IllegalArgumentException("Cannot instanciate class [" + clazz + "]. Ensure there is a public constructor having a parameter of type " + ContainerConfiguration.class.getName(), e); } }
public ContainerConfiguration set(TestatooProperties property, String value) { notNull(property, "Property name"); switch (property) { case CONTEXT: return context(value); case PORT: return port(Integer.parseInt(value)); case SERVER_CLASSPATH: return serverClassPath(value); case WEBAPP_CLASSPATH: return webappClassPath(value); case WEBAPP_ROOT: return webappRoot(value); } return this; }