@Test
  public void testCustomSchemaWithImportJaxbContextPrefixes() throws Exception {
    WadlGenerator wg = new WadlGenerator();
    wg.setSchemaLocations(Collections.singletonList("classpath:/books.xsd"));

    ClassResourceInfo cri =
        ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
    Message m = mockMessage("http://localhost:8080/baz", "/bar", WadlGenerator.WADL_QUERY, cri);
    Response r = handleRequest(wg, m);
    checkResponse(r);
    Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
    List<Element> grammarEls =
        DOMUtils.getChildrenWithName(doc.getDocumentElement(), WadlGenerator.WADL_NS, "grammars");
    assertEquals(1, grammarEls.size());
    List<Element> schemasEls =
        DOMUtils.getChildrenWithName(grammarEls.get(0), Constants.URI_2001_SCHEMA_XSD, "schema");
    assertEquals(1, schemasEls.size());
    assertEquals("http://books", schemasEls.get(0).getAttribute("targetNamespace"));
    List<Element> elementEls =
        DOMUtils.getChildrenWithName(schemasEls.get(0), Constants.URI_2001_SCHEMA_XSD, "element");
    assertEquals(1, elementEls.size());
    assertTrue(checkElement(elementEls, "books", "books"));

    List<Element> complexTypesEls =
        DOMUtils.getChildrenWithName(
            schemasEls.get(0), Constants.URI_2001_SCHEMA_XSD, "complexType");
    assertEquals(1, complexTypesEls.size());
    assertTrue(checkComplexType(complexTypesEls, "books"));

    List<Element> importEls =
        DOMUtils.getChildrenWithName(schemasEls.get(0), Constants.URI_2001_SCHEMA_XSD, "import");
    assertEquals(1, importEls.size());
    assertEquals(
        "http://localhost:8080/baz/book1.xsd", importEls.get(0).getAttribute("schemaLocation"));
  }
  @Test
  public void testCustomSchemaJaxbContextPrefixes() throws Exception {
    WadlGenerator wg = new WadlGenerator();
    wg.setSchemaLocations(Collections.singletonList("classpath:/book1.xsd"));

    ClassResourceInfo cri =
        ResourceUtils.createClassResourceInfo(BookStore.class, BookStore.class, true, true);
    Message m =
        mockMessage("http://localhost:8080/baz", "/bookstore/1", WadlGenerator.WADL_QUERY, cri);
    Response r = handleRequest(wg, m);
    checkResponse(r);
    Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
    checkGrammars(doc.getDocumentElement(), "thebook", "thebook2", "thechapter");
    List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 1);
    checkBookStoreInfo(els.get(0), "prefix1:thebook", "prefix1:thebook2", "prefix1:thechapter");
  }