예제 #1
0
  @Test
  public void testInstall() throws Exception {
    Project project = getProject();

    assertFalse(project.hasFacet(RestFacet.class));
    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());
  }
예제 #2
0
  @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());
  }