script | mock xml server setup |
add response file | http://files/xmlTestExamples/valid_shiporder.xml |
add response file | http://files/xmlTestExamples/invalid_shiporder.xml |
$url<-[http://127.0.0.1:8000/FitNesseMock] | get mock server url |
XSD String definition
script | file fixture | |
$xsdSchema<-[<?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema>] |
content of | http://files/xmlTestExamples/shiporder_schema.xsd |
script | xml http test |
get from | $url->[http://127.0.0.1:8000/FitNesseMock] |
validate response against xsd file | http://files/xmlTestExamples/shiporder_schema.xsd |
validate response against xsd | $xsdSchema->[<?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema>] |
An XML that is not schema valid gives a descriptive exception
script | |||
get from | $url->[http://127.0.0.1:8000/FitNesseMock] | ||
check | validate response against xsd file | http://files/xmlTestExamples/shiporder_schema.xsd | /.*Attribute 'orderid' must appear on element 'shiporder'.*/ found in: __EXCEPTION__:nl.hsac.fitnesse.fixture.slim.SlimFixtureException: message:<<XML Validation failed: cvc-complex-type.4: Attribute 'orderid' must appear on element 'shiporder'.>> at nl.hsac.fitnesse.fixture.util.XMLValidator.validateAgainst(XMLValidator.java:88) [file:/home/travis/build/fhoeben/hsac-fitnesse-fixtures/wiki/fixtures/] at nl.hsac.fitnesse.fixture.slim.XmlHttpTest.validateResponseAgainstXsdFile(XmlHttpTest.java:125) [file:/home/travis/build/fhoeben/hsac-fitnesse-fixtures/wiki/fixtures/] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_242] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_242] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_242] at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_242] at fitnesse.slim.fixtureInteraction.SimpleInteraction.methodInvoke(SimpleInteraction.java:322) [fitnesse-20200308.jar:20200308] at nl.hsac.fitnesse.fixture.slim.SlimFixture.invoke(SlimFixture.java:61) [file:/home/travis/build/fhoeben/hsac-fitnesse-fixtures/wiki/fixtures/] at nl.hsac.fitnesse.fixture.slim.SlimFixture.aroundSlimInvoke(SlimFixture.java:41) [file:/home/travis/build/fhoeben/hsac-fitnesse-fixtures/wiki/fixtures/] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) [n/a] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_242] at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_242] at fitnesse.slim.fixtureInteraction.SimpleInteraction.methodInvoke(SimpleInteraction.java:322) [fitnesse-20200308.jar:20200308] at fitnesse.slim.fixtureInteraction.SimpleInteraction.callMethod(SimpleInteraction.java:305) [fitnesse-20200308.jar:20200308] at fitnesse.slim.fixtureInteraction.SimpleInteraction.invokeMethod(SimpleInteraction.java:290) [fitnesse-20200308.jar:20200308] at fitnesse.slim.fixtureInteraction.SimpleInteraction.findAndInvoke(SimpleInteraction.java:217) [fitnesse-20200308.jar:20200308] at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:18) [fitnesse-20200308.jar:20200308] at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:18) [fitnesse-20200308.jar:20200308] at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:139) [fitnesse-20200308.jar:20200308] at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:112) [fitnesse-20200308.jar:20200308] at fitnesse.slim.instructions.CallAndOptionalAssignInstruction.executeInternal(CallAndOptionalAssignInstruction.java:30) [fitnesse-20200308.jar:20200308] at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29) [fitnesse-20200308.jar:20200308] at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49) [fitnesse-20200308.jar:20200308] at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43) [fitnesse-20200308.jar:20200308] at fitnesse.slim.ListExecutor.execute(ListExecutor.java:85) [fitnesse-20200308.jar:20200308] at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:82) [fitnesse-20200308.jar:20200308] at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:75) [fitnesse-20200308.jar:20200308] at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:62) [fitnesse-20200308.jar:20200308] at fitnesse.slim.SlimServer.serve(SlimServer.java:47) [fitnesse-20200308.jar:20200308] at fitnesse.testsystems.slim.InProcessSlimClient$1.run(InProcessSlimClient.java:55) [fitnesse-20200308.jar:20200308] at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_242] |