@Test public void testInstallAfterOtherServletMapping() throws Exception { Project project = getProject(); assertFalse(project.hasFacet(RestFacet.class)); queueInputLines(""); getShell().execute("setup servlet"); ServletFacet web = project.getFacet(ServletFacet.class); WebAppDescriptor config = web.getConfig(); config.facesServlet(); web.saveConfig(config); org.jboss.forge.parser.xml.Node webXml = XMLParser.parse(web.getConfig().exportAsString()); assertEquals(1, webXml.get("servlet-mapping").size()); assertTrue(config.exportAsString().contains("servlet-mapping")); setupRest(); assertTrue(project.hasFacet(RestFacet.class)); assertTrue( project .getFacet(DependencyFacet.class) .hasEffectiveDependency( DependencyBuilder.create("org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_1.1_spec"))); RestFacet restFacet = project.getFacet(RestFacet.class); assertEquals("/rest", restFacet.getApplicationPath()); assertTrue(project.hasFacet(RestWebXmlFacet.class)); RestWebXmlFacet restWebXmlFacet = project.getFacet(RestWebXmlFacet.class); assertEquals("/rest/*", restWebXmlFacet.getServletPath()); webXml = XMLParser.parse(web.getConfig().exportAsString()); assertEquals(2, webXml.get("servlet-mapping").size()); }
@Test public void testInstallWebIntoXML() throws Exception { Project project = getProject(); assertFalse(project.hasFacet(RestFacet.class)); setupRest(); assertTrue(project.hasFacet(RestFacet.class)); assertTrue(project.getFacet(DependencyFacet.class).hasEffectiveDependency(JAX_RS_DEPENDENCY)); ServletFacet web = project.getFacet(ServletFacet.class); Node servletName = ((WebAppDescriptorImpl) web.getConfig()) .getRootNode() .getSingle("servlet-mapping/servlet-name=" + RestWebXmlFacetImpl.JAXRS_SERVLET); assertNotNull(servletName); assertEquals("/rest/*", servletName.getParent().getSingle("url-pattern").getText()); }
@Override public List<String> getEffectiveFacesServletMappings() { List<String> results = new ArrayList<String>(); ServletFacet facet = project.getFacet(ServletFacet.class); WebAppDescriptor webXml = facet.getConfig(); // TODO should probably take into account facelets view mappings // facelets.VIEW_MAPPINGS if (webXml.hasFacesServlet()) { results.addAll(getExplicitFacesServletMappings(webXml)); } else { if (webXml.getVersion().startsWith("3")) { results.add("*.jsf"); results.add("/faces/*"); } else ShellMessages.info( out, "FacesServlet not found in web.xml and Servlet " + "Version not >= 3.0, could not discover FacesServlet mappings"); } return results; }
@Override public List<String> getFaceletsViewMapping() { ServletFacet facet = project.getFacet(ServletFacet.class); WebAppDescriptor webXml = facet.getConfig(); return webXml.getFaceletsViewMappings(); }
@Override public List<String> getFaceletsDefaultSuffixes() { ServletFacet facet = project.getFacet(ServletFacet.class); WebAppDescriptor webXml = facet.getConfig(); return webXml.getFaceletsDefaultSuffixes(); }
@Override public List<String> getFacesServletMappings() { ServletFacet facet = project.getFacet(ServletFacet.class); WebAppDescriptor webXml = facet.getConfig(); return getExplicitFacesServletMappings(webXml); }
@Override public FacesProjectStage getProjectStage() { ServletFacet facet = project.getFacet(ServletFacet.class); WebAppDescriptor config = facet.getConfig(); return config.getFacesProjectStage(); }