<project name="DependencyCheckingTaskTest" default="testEmbeddedDefinitions" 
         basedir="temporaryTestDirectory">
  <taskdef name="classycleDependencyCheck" 
           classname="classycle.ant.DependencyCheckingTask"/>

  <property name="package" value="example"/>

  <target name="testEmbeddedDefinitions" >
    <classycleDependencyCheck resultRenderer="classycle.dependency.XMLResultRenderer">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
#      show allResults
      [A] = *A*
      [non-A] = example.* excluding [A]
      check [A] independentOf [non-A]
      check [non-A] independentOf [A]
    </classycleDependencyCheck>
  </target>

  <target name="testEmbeddedDefinitionsFailureOn">
    <classycleDependencyCheck failOnUnwantedDependencies="true">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      show allResults
      [A] = *A*
      [non-A] = ${package}.* excluding [A]
      check [A] independentOf [non-A]
      check [non-A] independentOf [A]
    </classycleDependencyCheck>
  </target>

  <target name="testExcluding">
    <classycleDependencyCheck excludingClasses="example.p.*">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      check *A independentOf java.*.Ob*
    </classycleDependencyCheck>
  </target>

  <target name="testCheckCyclesFailureOn">
    <classycleDependencyCheck failOnUnwantedDependencies="true">
      <fileset dir="../classes">
        <include name="**/*.class"/>
      </fileset>
      check ${package}.A* independentOf ${package}.B*
      check absenceOfClassCycles > 1 in ${package}.*
    </classycleDependencyCheck>
  </target>

  <target name="testCheckCyclesMergedInnerClassesFailureOn">
    <classycleDependencyCheck mergeInnerClasses="true" 
                  resultRenderer="classycle.dependency.XMLResultRenderer"
    	            reportFile="dependency-checking-result.xml"
  							  failOnUnwantedDependencies="true">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      {pckg} = example
      show allResults
      check absenceOfClassCycles &gt; 1 in ${pckg}.*
    </classycleDependencyCheck>
  </target>

  <target name="testResetGraphAfterCheck">
    <classycleDependencyCheck>
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      [A-not-p] = *A excluding example.p.*
      check [A-not-p] independentOf *h* *S*
    </classycleDependencyCheck>
  </target>

  <target name="testDependentOnlyOn">
    <classycleDependencyCheck>
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      check example.B* example.p.* dependentOnlyOn java.lang.* example.A*
    	[set] = example.B* example.p.*
      check [set] dependentOnlyOn java.lang.*
    	check example.B* dependentOnlyOn *A
    </classycleDependencyCheck>
  </target>

  <target name="testReflection">
    <classycleDependencyCheck reflectionPattern="">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      [A-not-p] = *A excluding example.p.*
      check [A-not-p] independentOf *h*
    </classycleDependencyCheck>
  </target>

  <target name="testReflectionWithRestriction">
    <classycleDependencyCheck reflectionPattern="java.*">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      [A-not-p] = *A excluding example.p.*
      check [A-not-p] independentOf *h*
    </classycleDependencyCheck>
  </target>

  <target name="testFile">
    <classycleDependencyCheck definitionFile="test.ddf">
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
      bla bla
    </classycleDependencyCheck>
  </target>

  <target name="testNoClasses">
    <classycleDependencyCheck>
      show allResults
    </classycleDependencyCheck>
  </target>

  <target name="testEmpty">
    <classycleDependencyCheck>
      <fileset dir="../classes/example">
        <include name="**/*.class"/>
      </fileset>
    </classycleDependencyCheck>
  </target>
</project>
