<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : test_downgrade_sysdef.ant.xml 
Part of     : Helium AntLib

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
<project name="test-downgrade-sysdef" xmlns:au="antlib:org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
    <description>Helium antlib downgrade sysdef tests.</description>

    <taskdef resource="com/nokia/helium/sysdef/ant/antlib.xml" uri="http://www.nokia.com/helium" />
    <property name="epocroot" location="../../demo/data" />
    <property name="epocroot.temp" location="${epocroot}/temp" />


    <!-- is called prior to the test -->
    <target name="setUp">
        <delete dir="${epocroot.temp}/" failonerror="false" />
        <mkdir dir="${epocroot.temp}" />
        <hlm:joinSysdef epocroot="${epocroot}"
                        srcfile="${epocroot}/root/system_definition_layer1.xml"
                        destfile="${epocroot.temp}/layer1.sysdef.xml" />
        <hlm:joinSysdef epocroot="${epocroot}"
                        srcfile="${epocroot}/root/system_definition_layer2.xml"
                        destfile="${epocroot.temp}/layer2.sysdef.xml" />
        <hlm:mergeSysdef epocroot="${epocroot}"
                         srcfile="${epocroot.temp}/layer1.sysdef.xml"
                         downstreamfile="${epocroot.temp}/layer2.sysdef.xml"
                         destfile="${epocroot.temp}/full.sysdef.xml" />
    </target>

    <!-- is called after the test, even if that caused an error -->
    <target name="tearDown">
        <delete dir="${epocroot.temp}" failonerror="false" />
    </target>


    <target name="test-noargs">
        <au:expectfailure expectedMessage="'srcfile' attribute is not defined">
            <hlm:downgradeSysdef />
        </au:expectfailure>
        <au:assertFileDoesntExist file="${epocroot.temp}/output.sysdef.xml" />
    </target>

    <target name="test-srcfile">
        <au:expectfailure expectedMessage="'destfile' attribute is not defined">
            <hlm:downgradeSysdef epocroot="${epocroot}" srcfile="${epocroot.temp}/full.sysdef.xml" />
        </au:expectfailure>
        <au:assertFileDoesntExist file="${epocroot.temp}/output.sysdef.xml" />
    </target>
            
    <target name="test-srcfile-destfile">
        <hlm:downgradeSysdef epocroot="${epocroot}"
                             srcfile="${epocroot.temp}/full.sysdef.xml"
                             destfile="${epocroot.temp}/output.sysdef.xml" />
        <au:assertFileExists file="${epocroot.temp}/output.sysdef.xml" />
    </target>
        
</project>