示例#1
0
  @Test
  public void resolve_otherSchemas_withShortName() throws SAXException, IOException {
    InputSource source =
        resolver.resolveEntity(
            null, "http://any.domain.com/any/prefix/www.alibaba.com/schema/tests.xsd");

    String str = getContent(source);

    assertEquals("dummy", str);
  }
示例#2
0
  @Test
  public void resolve_configurationPoint_hybridSlash() throws SAXException, IOException {
    InputSource source = resolver.resolveEntity(null, "c:\\schema\\\\services/services.xsd");

    String str = getContent(source);

    assertThat(
        str,
        containsAll(
            "xmlns=\"http://www.alibaba.com/schema/services\"",
            "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
            "targetNamespace=\"http://www.alibaba.com/schema/services\"",
            "schemaLocation=\"services/container.xsd\""));
  }
示例#3
0
  @Test
  public void resolveDefault_springSchemas() throws SAXException, IOException {
    InputSource source =
        resolver.resolveEntity(
            null, "http://www.springframework.org/schema/beans/spring-beans-2.5.xsd");

    String str = getContent(source);

    assertThat(
        str,
        containsAll(
            "xmlns=\"http://www.springframework.org/schema/beans\"",
            "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
            "targetNamespace=\"http://www.springframework.org/schema/beans\""));
  }
示例#4
0
  @Test
  public void resolve_configurationPoint_withDefaultElement() throws SAXException, IOException {
    InputSource source =
        resolver.resolveEntity(null, "http://localhost/schema/services/services-tools.xsd");

    String str = getContent(source);

    assertThat(
        str,
        containsAll(
            "xmlns=\"http://www.alibaba.com/schema/services/tools\"",
            "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
            "targetNamespace=\"http://www.alibaba.com/schema/services/tools\"",
            "schemaLocation=\"services/tools/dateformat.xsd\"",
            "xsd:element name=\"tool\" type=\"springext:referenceableBeanType\""));
  }
示例#5
0
  @Test
  public void resolve_configurationPoint_noDefaultElement() throws SAXException, IOException {
    InputSource source =
        resolver.resolveEntity(null, "http://localhost/schema/services/services.xsd");

    String str = getContent(source);

    assertThat(
        str,
        containsAll(
            "xmlns=\"http://www.alibaba.com/schema/services\"",
            "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
            "targetNamespace=\"http://www.alibaba.com/schema/services\"",
            "schemaLocation=\"services/container.xsd\""));

    assertThat(str, not(containsString("xsd:element")));
  }
示例#6
0
  @Test
  public void resolveDefault_resourceLoader() throws SAXException, IOException {
    InputSource source = resolver.resolveEntity(null, "classpath:dummy.txt");

    assertEquals("dummy", getContent(source));
  }
示例#7
0
  @Test
  public void resolve_notFound() throws SAXException, IOException {
    InputSource source = resolver.resolveEntity(null, "http://localhost/not-found.xsd");

    assertThat(source, nullValue());
  }