dir="${web.dir}"> <include name="**/*.*"/> </fileset> </war> <copy todir="${deploy.path}" preservelastmodified="true"> <fileset dir="."> <include name="*.war"/> </fileset> </copy> </target> <target name="buildtests" description="Compile test tree javafiles"> <mkdir dir="${build.dir}"/> <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="${test.dir}"/> <classpath refid="master-classpath"/> </javac> </target> <target name="tests" depends="build, buildtests" description="Run tests"> <junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed" showoutput="true"> <classpath refid="master-classpath"/> <formatter type="brief" usefile="false"/> <batchtest> <fileset dir="${build.dir}"> <include name="**/*Tests.*"/> </fileset> </batchtest> </junit> <fail if="tests.failed"> tests.failed=${tests.failed} *********************************************************** *********************************************************** **** One or more tests failed! Check the output ... **** *********************************************************** *********************************************************** </fail> </target> <!--============================================================== --><!-- Tomcat tasks - remove theseif you don't have Tomcat installed --><!--============================================================== --> <path id="catalina-ant-classpath"> <!-- We need the Catalina jars for Tomcat --> <!-- * for otherapp servers - check the docs --> <fileset dir="${appserver.lib}"> <include name="catalina-ant.jar"/> </fileset> </path> <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="start" classname="org.apache.catalina.ant.StartTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <target name="install" description="Install application inTomcat"> <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}"/> </target> <target name="reload" description="Reload application in Tomcat"> <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="start" description="Start Tomcat application"> <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="stop" description="Stop Tomcat application"> <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="list" description="List Tomcat applications"> <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/> </target><!-- End Tomcat tasks --></project>Agora execute a tarefa 'tests' Ant e o teste deve passar.$ ant testsBuildfile: build.xmlbuild:buildtests: [javac] Compiling 1 source file to /Users/Shared/Projects/springapp/war/WEB-INF/classestests: [junit] Running springapp.web.HelloWorldControllerTests [junit] Oct 30, 2007 11:31:43 PM springapp.web.HelloController handleRequest [junit] INFO: Returning hello view [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.03 sec [junit] Testsuite: springapp.web.HelloWorldControllerTests [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.03 sec [junit] ------------- Standard Error ----------------- [junit] Oct 30, 2007 11:31:43 PM springapp.web.HelloController handleRequest [junit] INFO: Returning hello view [junit] ------------- ---------------- ---------------BUILD SUCCESSFULTotal time: 2 secondsUma das melhores praticas de desenvolvimento agil e aIntegracao Continua. E uma boa ideia para garantir queseus testes sao executados em cada compilacao de modo que vocesabe que a logica do aplicativo esta se comportando comoesperado com a evolucao do codigo.1.10. Criandoa ViewAgora e a hora de criar sua primeira view. Now it is time to create our first view. Como foi mencionado anteriormente,estamos encaminhando para uma pagina JSP chamada 'hello.jsp'. Para comecar vamoscoloca-lo na pasta 'war'.'springapp/war/hello.jsp':<html><head><title>Hello :: Spring Application</title></head><body> <h1>Hello - Spring Application</h1> <p>Greetings.</p></body></html> 1.11. Compilando edistribuindo a aplicacaoExecute a target 'deploy' do Ant (que invoca a target build), e, em seguida,execute reload que estao configurados no arquivo 'build.xml'.Isto ira forcar uma compilacao e recarregar a aplicacao no Tomcat. Temos queverificar a saida do Ant e os logs do Tomcat para possiveis erros naimplantacao, tais como erros de digitacao nos arquivos criados ou classesausentes nos arquivos JAR.Aqui esta um exemplo de saida do build Ant:$ ant deploy reload Buildfile: build.xml build: [mkdir] Created dir: /Users/trisberg/Projects/springapp/war/WEB-INF/classes [javac] Compiling 1 source file to /Users/trisberg/Projects/springapp/war/WEB-INF/classes deploy: [copy] Copying 7 files to /Users/trisberg/apache-tomcat-5.5.17/webapps/springapp BUILD SUCCESSFUL Total time: 3 seconds $ ant reload Buildfile: build.xml reload: [reload] OK - Reloaded application at context path /springapp BUILD SUCCESSFUL Total time: 2 secondsE aqui esta um trecho