Esempio n. 1
0
 public InputStream addFacesServletMapping(
     final InputStream webXmlStream, final String mapping) {
   Node root = XMLParser.parse(webXmlStream);
   Node facesServlet = getOrCreateFacesServlet(root);
   boolean mappingCreated = createMappingIfNotExists(root, facesServlet, mapping);
   if (mappingCreated) {
     return XMLParser.toXMLInputStream(root);
   } else {
     return XMLParser.toXMLInputStream(root);
   }
 }
 private static void initializeAllTypes() {
   ALL_TYPES = new HashMap<String, ConnectionProfileType>();
   ClassLoader cl = Thread.currentThread().getContextClassLoader();
   Node main = XMLParser.parse(cl.getResourceAsStream("connection.profile.types"));
   if (!main.getName().equals("types")) return; // Ill formatted datasource resource
   for (Node node : main.getChildren()) {
     if (node.getName().equals("type")) {
       ConnectionProfileType type = createConnectionProfileType(node);
       ALL_TYPES.put(type.name, type);
     }
   }
 }
 @Test
 public void testFacesConfig() throws Exception {
   Project project = initializeJavaProject();
   queueInputLines("Y", "Y", "Y");
   getShell().execute("faces setup");
   getShell().execute("i18n setup");
   FileResource<?> configFile = project.getFacet(FacesFacet.class).getConfigFile();
   assertTrue(configFile.exists());
   Node facesConfig = XMLParser.parse(configFile.getResourceInputStream());
   assertEquals(
       "messages",
       facesConfig.getTextValueForPatternName("application/resource-bundle/base-name"));
   assertEquals("msg", facesConfig.getTextValueForPatternName("application/resource-bundle/var"));
 }
  @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());
  }