/** * <p class="changed_added_4_0"> * </p> * * @param path * @param resource * @see org.jboss.test.faces.staging.StagingServer#addResource(java.lang.String, java.lang.String) */ public FacesEnvironment withContent(String path, String pageContent) { this.facesServer.addContent(path, pageContent); return this; }
/** * This template method called from the {@link #setupFacesListener()} if Sun JSF reference implementation presents. * The default implementation sets the "com.sun.faces.validateXml" "com.sun.faces.verifyObjects" init parameters to * the "true" */ protected void setupSunFaces() { facesServer.addInitParameter("com.sun.faces.validateXml", "true"); facesServer.addInitParameter("com.sun.faces.verifyObjects", "true"); }
/** * <p class="changed_added_4_0"> * </p> * * @param path * @param resource * @see org.jboss.test.faces.staging.StagingServer#addResource(java.lang.String, java.lang.String) */ public FacesEnvironment withResource(String path, String resource) { this.facesServer.addResource(path, resource); return this; }
contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); facesServer.addResource(WEB_XML, webXmlDefault); if (null != webRoot) { facesServer.addResourcesFromDirectory("/", webRoot); facesServer.addServlet(facesServletContainer); facesServer.addFilter(filterContainer); facesServer.init(); ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder .getFactory(FactoryFinder.APPLICATION_FACTORY);
/** * Internal reccursive method process directory content and all subdirectories. * * @param baseDirectory * @param file * @throws MalformedURLException */ protected void addFiles(String resourcePath, File file) throws MalformedURLException { File[] files = file.listFiles(); for (File subfile : files) { if (!subfile.isDirectory()) { addResource(resourcePath + "/" + subfile.getName(), subfile.toURI().toURL()); } else { String directoryPath = resourcePath + "/" + subfile.getName(); addDirectory(directoryPath); addFiles(directoryPath, subfile); } } }
/** * Add all resources from the directory to the virtual web application content. * * @param path * name of the target directory in the virtual web application. If no such directory exists, it will be * created, as well as all parent directories as needed. * @param resource * {@code URL} to the source directory or any file in the source directory. Only 'file' or 'jar' * protocols are supported. If this parameter points to a file, it will be converted to a enclosing * directory. */ public void addResourcesFromDirectory(String path, URL resource) { String protocol = resource.getProtocol(); if ("jar".equals(protocol)) { addResourcesFromJar(path, resource); } else if ("file".equals(protocol)) { addResourcesFromFile(path, resource); } else { throw new TestException("Unsupported protocol " + protocol); } }
public FacesEnvironment withResourcesFromDirectory(String path, URL resource){ this.facesServer.addResourcesFromDirectory(path, resource); return this; } /**
/** * Internal method used by the {@link #addResourcesFromDirectory(String, URL)} to process 'file' protocol. * * @param resource * source directory. * @param baseDirectory * target virtual directory. */ protected void addResourcesFromFile(String resourcePath, URL resource) { File file = new File(resource.getPath()); if (!file.isDirectory()) { file = file.getParentFile(); } try { addFiles(resourcePath, file); } catch (MalformedURLException e) { throw new TestException(e); } }
contextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); facesServer.addResource(WEB_XML, webXmlDefault); if (null != webRoot) { facesServer.addResourcesFromDirectory("/", webRoot); facesServer.addServlet(facesServletContainer); facesServer.addFilter(filterContainer); facesServer.init(); ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder .getFactory(FactoryFinder.APPLICATION_FACTORY);
/** * Internal reccursive method process directory content and all subdirectories. * * @param baseDirectory * @param file * @throws MalformedURLException */ protected void addFiles(String resourcePath, File file) throws MalformedURLException { File[] files = file.listFiles(); for (File subfile : files) { if (!subfile.isDirectory()) { addResource(resourcePath + "/" + subfile.getName(), subfile.toURI().toURL()); } else { String directoryPath = resourcePath + "/" + subfile.getName(); addDirectory(directoryPath); addFiles(directoryPath, subfile); } } }
/** * Add all resources from the directory to the virtual web application content. * * @param path * name of the target directory in the virtual web application. If no such directory exists, it will be * created, as well as all parent directories as needed. * @param resource * {@code URL} to the source directory or any file in the source directory. Only 'file' or 'jar' * protocols are supported. If this parameter points to a file, it will be converted to a enclosing * directory. */ public void addResourcesFromDirectory(String path, URL resource) { String protocol = resource.getProtocol(); if ("jar".equals(protocol)) { addResourcesFromJar(path, resource); } else if ("file".equals(protocol)) { addResourcesFromFile(path, resource); } else { throw new TestException("Unsupported protocol " + protocol); } }
public FacesEnvironment withResourcesFromDirectory(String path, URL resource){ this.facesServer.addResourcesFromDirectory(path, resource); return this; } /**
/** * Internal method used by the {@link #addResourcesFromDirectory(String, URL)} to process 'file' protocol. * * @param resource * source directory. * @param baseDirectory * target virtual directory. */ protected void addResourcesFromFile(String resourcePath, URL resource) { File file = new File(resource.getPath()); if (!file.isDirectory()) { file = file.getParentFile(); } try { addFiles(resourcePath, file); } catch (MalformedURLException e) { throw new TestException(e); } }
/** * This template method called from the {@link #setupFacesListener()} if Sun JSF reference implementation presents. * The default implementation sets the "com.sun.faces.validateXml" "com.sun.faces.verifyObjects" init parameters to * the "true" */ protected void setupSunFaces() { facesServer.addInitParameter("com.sun.faces.validateXml", "true"); facesServer.addInitParameter("com.sun.faces.verifyObjects", "true"); }
public FacesEnvironment withResource(String path, URL resource) { this.facesServer.addResource(path, resource); return this; }
/** * <p class="changed_added_4_0"> * </p> * * @param path * @param resource * @see org.jboss.test.faces.staging.StagingServer#addResource(java.lang.String, java.net.URL) */ public FacesEnvironment withWebRoot(URL root) { checkNotInitialized(); this.facesServer.addResourcesFromDirectory("/", root); webRoot = null; return this; }
/** * Add all files from the directory to the virtual web application content. * * @param path * name of the target directory in the virtual web application. If no such directory exists, it will be * created, as well as all parent directories as needed. * @param resource * {@code File} of the source directory or any file in the source directory. If this parameter points to * a file, it will be converted to a enclosing directory. */ public void addResourcesFromDirectory(String path, File directory) { if (!directory.exists()) { throw new TestException("directory does not exist:" + directory.getAbsolutePath()); } try { addFiles(path, directory); } catch (MalformedURLException e) { throw new TestException(e); } }
/** * <p class="changed_added_4_0"> * </p> * * @param path * @param resource * @see org.jboss.test.faces.staging.StagingServer#addResource(java.lang.String, java.lang.String) */ public FacesEnvironment withContent(String path, String pageContent) { this.facesServer.addContent(path, pageContent); return this; }
/** * This template method called from {@link #setUp()} to append appropriate init parameters to the test server. The * default implementation sets state saving method to the "server", default jsf page suffix to the ".xhtml" and * project stage to UnitTest */ protected void setupJsfInitParameters() { facesServer.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_SERVER); facesServer.addInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME, ".xhtml"); // Do not use Jsf 2.0 classes directly because this environment should // be applicable for any JSF version. facesServer.addInitParameter("javax.faces.PROJECT_STAGE", "UnitTest"); }
/** * <p class="changed_added_4_0"> * </p> * * @param path * @param resource * @see org.jboss.test.faces.staging.StagingServer#addResource(java.lang.String, java.lang.String) */ public FacesEnvironment withResource(String path, String resource) { this.facesServer.addResource(path, resource); return this; }