suvallur / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Implement resource resolver in the XmlConfig to resolve resource problem when validating against complex schema file #317

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. "Main.xsd" contains import calls to external schema "CommonTypes.xsd", 
"CustomerTypes.xsd" (all files in same local folder)
2. Validate customer response again "Main.xsd" schema
3.
final InputStream xsd = getClass().getResourceAsStream("/main.xsd");
       expect().body(matchesXsd(xsd)).when().get("/customer");

What is the expected output?
  When a schema contains import and include external schema should import as needed and validation should be done.

What version of the product are you using? On what operating system?
rest-assured 2.2.0,
java 1.6
Windows 7

Please provide any additional information below.
sample.xml should be validate against main.xsd (which internally imports 
"CommonTypes.xsd", "CustomerTypes.xsd") , attached all the required files

Reference Forum Topic:
https://groups.google.com/forum/#!topic/rest-assured/Ue4m-bfrXFo

Original issue reported on code.google.com by rams.qa...@gmail.com on 5 Mar 2014 at 10:07

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 7 Mar 2014 at 11:17

GoogleCodeExporter commented 9 years ago
I've now committed this to master. Usage:

get("/x").then().body(matchesXsd(load("main.xsd")).using(new 
ClasspathResourceResolver()));

You can try it out by depending on version 2.3.1-SNAPSHOT after having added 
the following Maven repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

Original comment by johan.ha...@gmail.com on 10 Mar 2014 at 7:35

GoogleCodeExporter commented 9 years ago
Unlike matchesXsd(),

   matchesXsdInClasspath() 

does not return XmlXsdMatcher which makes it impossible to use 

  using(new ClasspathResourceResolver())

Are there any plans to update this part of the API?

Original comment by mgawine...@gmail.com on 1 Sep 2014 at 1:24

GoogleCodeExporter commented 9 years ago
matchesXsdInClasspath should of course also return a XmlXsdMatcher. That was 
probably just a miss. I've fixed it and deployed a new snapshot. Please try it 
out by depending on version 2.3.4-SNAPSHOT after having added the following 
repo:

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

Original comment by johan.ha...@gmail.com on 1 Sep 2014 at 1:52