Tests for free
Fully Automatic Generator-Driven Tests of XSL Transformations
Adam Duracz Walid Taha Halmstad University
July 16, 2012
Tests for free Fully Automatic Generator-Driven Tests of XSL - - PowerPoint PPT Presentation
Tests for free Fully Automatic Generator-Driven Tests of XSL Transformations Adam Duracz Walid Taha Halmstad University July 16, 2012 Motivation XML Popular to specify XML formats using XML Schema XSL Transformations (XSLT)
Fully Automatic Generator-Driven Tests of XSL Transformations
Adam Duracz Walid Taha Halmstad University
July 16, 2012
Transformations (XSLT)
XSLT is not possible *
* Alon et al 2001
Sin XML Document XML Document XSLT Sout
Sin Generator Validator T Sout d T(d)
<people> <person id="P001"> <name>Anna</name> <age>66</age> </person> <person id="P002"> <name>Jan</name> <age>35</age> </person> </people> <xsd:element name="people" type="PeopleType"/> <xsd:complexType name="PeopleType"> <xsd:sequence> <xsd:element name="person" type="PersonType" minOccurs="2"/> </xsd:sequence> </xsd:complexType>
<people> <person id="P001"> <name>Anna</name> <age>66</age> </person> <person id="P002"> <name>Jan</name> <age>35</age> </person> </people> <xsd:element name="people" type="PeopleType"/> <xsd:complexType name="PeopleType"> <xsd:sequence> <xsd:element name="person" type="PersonType" minOccurs="2"/> </xsd:sequence> </xsd:complexType>
<people> <person id="P001"> <name>Anna</name> <age>66</age> </person> <person id="P002"> <name>Jan</name> <age>35</age> </person> </people> <xsd:element name="people" type="PeopleType"/> <xsd:complexType name="PeopleType"> <xsd:sequence> <xsd:element name="person" type="PersonType" minOccurs="2"/> </xsd:sequence> </xsd:complexType>
<people> <person id="P001"> <name>Anna</name> <age>66</age> </person> <person id="P002"> <name>Jan</name> <age>35</age> </person> </people> <xsd:element name="people" type="PeopleType"/> <xsd:complexType name="PeopleType"> <xsd:sequence> <xsd:element name="person" type="PersonType" minOccurs="2"/> </xsd:sequence> </xsd:complexType>
<people> <person id="P001"> <name>Anna</name> <age>66</age> </person> <person id="P002"> <name>Jan</name> <age>35</age> </person> </people> <xsd:element name="people" type="PeopleType"/> <xsd:complexType name="PeopleType"> <xsd:sequence> <xsd:element name="person" type="PersonType" minOccurs="2"/> </xsd:sequence> </xsd:complexType>
Sin Generator Validator T Sout d T(d)
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
Element
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
Element ComplexType
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
Element ComplexType Sequence
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
Element ComplexType Sequence Element Element
Element ComplexType Sequence Element Element
genElement genComplexType genSequence genElement genElement
Element ComplexType Sequence Element Element
genElement genComplexType genSequence genElement genElement
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ...
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... genElement genComplexType genSequence genElement genElement
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... <family> </family> genElement genComplexType genSequence genElement genElement
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... <family> </family> genElement genComplexType genSequence genElement genElement
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... <family> </family> genElement genComplexType genSequence genElement genElement
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... genElement genComplexType genSequence genElement genElement <family> </family>
<xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... genElement genComplexType genSequence genElement genElement <family> </family> <person name="Anna"/> <person name="Jan"/>
<family> <person name="Anna"/> <person name="Jan"/> </family> <xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... genElement genComplexType genSequence genElement genElement
<family> <person name="Anna"/> <person name="Jan"/> </family> <xsd:element name="family" <xsd:complexType> <xsd:sequence> <xsd:element name="person" type="..." minOccurs="2" <xsd:element name="pet" ... genElement genComplexType genSequence genElement genElement <pet name="Moxy" species="rabbit"/>
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genBranch
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genBranch genPiece genPiece genPiece genPiece genPiece
genPiece genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom
genPiece genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom genMatch
genAtom genPiece genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom genMatch genAtom
genAtom genPiece genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom genMatch genAtom
genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch
genPiece
genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom
genPiece
genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom
genPiece genCharClassEsc
genPiece genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch genAtom
genPiece genCharClassEsc
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genBranch
genPiece genPiece genPiece genPiece genPiece
genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch
genPiece genPiece
genAtom
genPiece genPiece
<xsd:simpleType name="SsnType"> <xsd:restriction base="xsd:string"> <xsd:pattern value=" (19|20)?\d\d (0[1-9]|1[012]) (0[1-9]|[12]\d|3[01]) \d{4} "/> </xsd:restriction> </xsd:simpleType>
genMatch genPiece genBranch
genPiece genPiece
genAtom genCharClassEsc
sizedListOf :: Occurs -> Occurs -> Gen a -> Gen [a] elements :: [a] -> Gen a listOf :: Gen a -> Gen [a] listOf . elements :: [a] -> Gen [a]
<xsd:element name="person" type="i:PersonType" minOccurs="2" maxOccurs="unbounded"/> sizedListOf :: Occurs -> Occurs -> Gen e -> Gen [e]
<?xml version="1.0" encoding="UTF-8" ?> <i:people xmlns:i="input"> <person> <location>stockholm</location> <ssn>195510319244</ssn> </person> <person> <location>gothenburg</location> <ssn>199410182576</ssn> </person> </i:people>
Sin QuickCheck Generators Validator T Sout d T(d)
Testing
create input data
prop_RevRev (xs::[Int]) = reverse (reverse xs) == xs
Sin Generator Validator T Sout d T(d)
Sin
* Tozawa 2001 / Møller, Kuula 2006
<people> <person id="P001"> <name>Anna</name> <age>-1</age> </person> <person id="P002"> <name>Andrzej</name> <age>67</age> </person> <person id="P003"> <name>Jan</name> <age>35</age> </person> </people> <people> <person id="P001"> <name>Anna</name> <age>-1</age> </person> <person id="P002"> <name>Andrzej</name> <age>67</age> </person> </people>
⇒
<people> <person id="P001"> <name>Anna</name> <age>-1</age> </person> <person id="P002"> <name>Andrzej</name> <age>67</age> </person> <person id="P003"> <name>Jan</name> <age>35</age> </person> </people>
ElementWithComplexTypeDecl "people" ... ComplexTypeSequence "PersonType" .. ElementWithSimpleTypeDecl "name" ... ElementWithSimpleTypeDecl "age" ... ...