summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/thrift/lib/xml/test/build.xml
blob: f0e95cf02122c9e1c677d163239e325398d0b839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!--
 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.
-->
<project name="XML Schema Test" default="test" basedir=".">

  <description>XML Schema Validation Test</description>

  <property name="xml.dir" location="${basedir}/.." />
  <property name="gen.xml.dir" location="${basedir}/../gen-xml" />
  <property name="idl.xml.schema" location="${xml.dir}/thrift-idl.xsd" />

  <property name="thrift.dir" location="../../../" />
  <property name="thrift.test.dir" location="${thrift.dir}/test" />
  <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />

  <property file="${basedir}/build.properties" />

  <target name="compiler.check">
    <fail>
      <condition>
        <not>
          <resourcecount count="1">
            <fileset id="fs" file="${thrift.compiler}"/>
          </resourcecount>
        </not>
      </condition>
      Thrift compiler is missing !
    </fail>
  </target>

  <target name="init" depends="compiler.check, mkdirs">
    <tstamp />
  </target>

  <target name="mkdirs">
    <mkdir dir="${gen.xml.dir}"/>
  </target>

  <target name="generate" depends="init">
    <generate-xml file="${thrift.test.dir}/ThriftTest.thrift"/>
    <generate-xml file="${thrift.test.dir}/Include.thrift"/>
    <generate-xml file="${thrift.test.dir}/Recursive.thrift"/>
    <generate-xml file="${thrift.test.dir}/ManyOptionals.thrift"/>
    <generate-xml file="${thrift.test.dir}/OptionalRequiredTest.thrift"/>
    <generate-xml file="${thrift.test.dir}/ConstantsDemo.thrift"/>
    <generate-xml file="${thrift.test.dir}/TypedefTest.thrift" />
    <generate-xml file="${thrift.test.dir}/AnnotationTest.thrift" />
    <generate-xml file="${thrift.test.dir}/DocTest.thrift" />
    <generate-xml file="${thrift.test.dir}/EnumTest.thrift" />
    <generate-xml file="${thrift.test.dir}/ManyTypedefs.thrift" />
  </target>

  <target name="test" description="run schema validation"
          depends="validate-generated-xml"/>
    
  <target name="validate-generated-xml" depends="init, generate">
    <validate-xml file="${gen.xml.dir}/ThriftTest.xml"/>
    <validate-xml file="${gen.xml.dir}/Include.xml"/>
    <validate-xml file="${gen.xml.dir}/Recursive.xml"/>
    <validate-xml file="${gen.xml.dir}/ManyOptionals.xml"/>
    <validate-xml file="${gen.xml.dir}/OptionalRequiredTest.xml"/>
    <validate-xml file="${gen.xml.dir}/ConstantsDemo.xml"/>
    <validate-xml file="${gen.xml.dir}/TypedefTest.xml"/>
    <validate-xml file="${gen.xml.dir}/AnnotationTest.xml"/>
    <validate-xml file="${gen.xml.dir}/DocTest.xml"/>
    <validate-xml file="${gen.xml.dir}/EnumTest.xml"/>
    <validate-xml file="${gen.xml.dir}/ManyTypedefs.xml"/>
  </target>

  <target name="clean">
    <delete dir="${build.dir}" />
    <delete dir="${gen.xml.dir}" />
  </target>

  <macrodef name="generate-xml">
    <attribute name="file" />
    <sequential>
      <exec executable="${thrift.compiler}" failonerror="true">
        <arg line="-gen xml:merge"/>
        <arg line="-out ${gen.xml.dir}"/>
        <arg line="@{file}"/>
      </exec>
    </sequential>
  </macrodef>

  <macrodef name="validate-xml">
    <attribute name="file" />
    <sequential>
      <echo message="validating generated XML: @{file}" />
      <schemavalidate file="@{file}">
        <schema namespace="http://thrift.apache.org/xml/idl" 
                file="${idl.xml.schema}" />
      </schemavalidate>
    </sequential>
  </macrodef>

</project>