<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<!--
    ==================================================
    ========== The Simple Methods Section ==========
    ==================================================
    (see further down for the Simple Map Processor Section)
-->

  <!-- Reusable artifacts (abstract elements, groups, attributeGroups -->
    <xs:element name="TestCaseTypes" abstract="true"/>
    <xs:group name="AllTestCaseTypes">
        <xs:choice>
            <xs:element ref="TestCaseTypes"/>
        </xs:choice>
    </xs:group>

    <!-- ELEMENTS start here -->
    <xs:element name="test-suite">
        <xs:complexType>
            <xs:choice minOccurs="1" maxOccurs="unbounded">
                <xs:element ref="test-case"/>
                <xs:element ref="test-group"/>
        </xs:choice>
            <xs:attributeGroup ref="attlist.test-suite"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.test-suite">
        <xs:attribute type="xs:string" name="suite-name" use="required"/>
        <xs:attribute type="xs:string" name="delegator-name" default="test"/>
        <xs:attribute type="xs:string" name="dispatcher-name" default="test-dispatcher"/>
    </xs:attributeGroup>
    <xs:element name="test-case">
        <xs:annotation><xs:documentation></xs:documentation></xs:annotation>
        <xs:complexType>
            <xs:group minOccurs="1" maxOccurs="1" ref="AllTestCaseTypes"/>
            <xs:attributeGroup ref="attlist.test-case"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.test-case">
        <xs:attribute type="xs:string" name="case-name" use="required"/>
    </xs:attributeGroup>
    <xs:element name="test-group">
        <xs:annotation><xs:documentation></xs:documentation></xs:annotation>
        <xs:complexType>
            <xs:group minOccurs="1" maxOccurs="unbounded" ref="AllTestCaseTypes"/>
            <xs:attributeGroup ref="attlist.test-group"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.test-group">
        <xs:attribute type="xs:string" name="case-name" use="required"/>
    </xs:attributeGroup>

    <xs:element name="junit-test-suite" substitutionGroup="TestCaseTypes">
        <xs:annotation><xs:documentation>Used for JUnit test suites written as a Java class.</xs:documentation></xs:annotation>
        <xs:complexType>
            <xs:attributeGroup ref="attlist.junit-test-suite"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.junit-test-suite">
        <xs:attribute type="xs:string" name="class-name" use="required">
            <xs:annotation>
                <xs:documentation>
                    At minimum should extend the junit.framework.TestCase class. If you want to use a GenericDelegator or 
                    LocalDispatcher you should extend the OFBizTestCase class and use the ones provided by it.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:element name="groovy-test-suite" substitutionGroup="TestCaseTypes">
        <xs:annotation>
            <xs:documentation>
                Used for JUnit test suites written as a Groovy class. See http://groovy-lang.org/testing.html
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attributeGroup ref="attlist.groovy-test-suite"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.groovy-test-suite">
        <xs:attribute type="xs:string" name="name"/>
        <xs:attribute type="xs:string" name="location" use="required">
            <xs:annotation>
                <xs:documentation>
                    Give the location where is groovy file that contaions the test suite.
                    You can use a flexible url location like component://mycomponent/groovyScripts/test/MySuiteTest.groovy
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:element name="service-test" substitutionGroup="TestCaseTypes">
        <xs:complexType>
            <xs:attributeGroup ref="attlist.service-test"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.service-test">
        <xs:attribute type="xs:string" name="service-name" use="required"/>
    </xs:attributeGroup>

    <xs:element name="webdriver-test" substitutionGroup="TestCaseTypes">
        <xs:complexType>
            <xs:attributeGroup ref="attlist.webdriver-test"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.webdriver-test">
        <xs:attribute type="xs:string" name="location" use="required"/>
    </xs:attributeGroup>

    <xs:element name="simple-method-test" substitutionGroup="TestCaseTypes">
        <xs:complexType>
            <xs:attributeGroup ref="attlist.simple-method-test"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.simple-method-test">
        <xs:attribute type="xs:string" name="location" use="required"/>
        <xs:attribute type="xs:string" name="name">
            <xs:annotation>
                <xs:documentation>
                    The method-name of the simple-method to execute.  If no name is supplied then all simple-methods from
                    location with a method-name beginning with "test" will be added as individual tests.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:element name="entity-xml" substitutionGroup="TestCaseTypes">
        <xs:complexType>
            <xs:attributeGroup ref="attlist.entity-xml"/>
        </xs:complexType>
    </xs:element>
    <xs:attributeGroup name="attlist.entity-xml">
        <xs:attribute type="xs:string" name="entity-xml-url" use="required"/>
        <xs:attribute name="action" use="optional" default="assert">
            <xs:simpleType>
                <xs:restriction base="xs:token">
                    <xs:enumeration value="assert"/>
                    <xs:enumeration value="load"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:attributeGroup>

</xs:schema>
