Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 31 32 33 34 35 36 < 37 > 38 39 40 41 42 43 .. 166 >> Next

013 <property name="builddir" value="build"/>
014 <property name="driver" value="org.gjt.mm.mysql.Driver" />
015 <property name="url" value="jdbc:mysql://localhost/States" />
016 <property name="userid" value="" />
017 <property name="password" value="" />
018 <property name="destdir" value="bugrat" />
019 <property name="zip.bugrat" value="bugrat.zip" />
020 <property name="destdir.bugrat" value="${destdir}/test" />
021 <property name="catalina.home" value="c:\apache\tomcat403"/>
022 <property name="cvs.repository" 2
value=":pserver:<username>@<hostname>:c:\cvsrep"/>
023 <property name="cvs.package" value="tests"/>
024
025 </target>
026
027 <!--
028 *******************************************************
029 ** Java compilation
030 ****************************************************-- >
031 <target name="compile" depends="init">
032 <javac srcdir="." destdir="." classpath="junit.jar" />
033 </target>
034
Listing 11.1 lifecycle_build.xml (continued)
90 Item 11
Lines 39 to 57 illustrate how Ant can be used to run JUnit tests on your Java applications. JUnit is an open-source testing framework that allows developers to build test suites so that unit testing can be performed on Java components. Personally, we like to use them to create unit tests on JavaBean applications to ensure that developers on our team do not corrupt these files during development activities. If a developer is experiencing a problem with some code, we run some tests that were crafted during development to verify that no bugs have been introduced into an application.
035
036 *******************************************************
037 ** JUnit tests
038 ****************************************************-- >
039 <target name="test" depends="compile">
040
041 <echo message="Running JUnit tests." />
042 <junit printsummary="true">
043 <! <formatter type="plain" usefile="false" /> -->
044 <formatter type="xml" />
045 <test name="AllTests2" />
046 <classpath>
047 <pathelement location="." />
048 </classpath>
049 </junit>
050 <junitreport todir=".">
051 <fileset dir=".">
052 <include name="TEST-*.xml" />
053 </fileset>
054 <report format="frames" todir="." />
055 </junitreport>
056
057 </target>
058
Listing 11.1 (continued)
Obviously, the setting of appropriate classpath properties is paramount when running Ant and compiling individual Java code. This is accomplished by setting the paths and their components on lines 63 to 69.
059 <!--
060 *******************************************************
061 ** Classpath properties.
062 ****************************************************-- >
063 <path id="classpath.path">
064 <pathelement location="${builddir}"/>
065 <fileset dir="cache/lib">
066 <include name="*.jar"/>
067 </fileset>
068 <pathelement location="cache/lib/servlet.jar"/>
069 </path>
070
Listing 11.1 (continued)
Apache Ant and Lifecycle Management 91
Additionally, directory creation scripts on lines 75 to 104 are needed to move source code to proper deployment areas so that they are accessible to other Ant targets.
071 <!--
072 *******************************************************
073 ** Create the output directory structure.
074 ****************************************************-->.
075 <target name="prepare">
076
077 <mkdir dir="${builddir}"/>
078 <mkdir dir="${builddir}/tests"/>
079 <mkdir dir="${builddir}/WEB-INF/lib"/>
080 <mkdir dir="${builddir}/WEB-INF/classes/cache"/>
081
082 <copy todir="${builddir}/WEB-INF/classes/cache">
083 <fileset dir="cache/beans"/>
084 </copy>
085 <copy todir="${builddir}">
086 <fileset dir="cache/src"/>
087 </copy>
<!- - some copy elements deleted for brevity ... -->
104 </target>
105
Listing 11.1 (continued)
All Ant scripts should provide Help targets to assist end users in their build operations as verified on lines 110 to 115. Cleanup targets should be created to remove unwanted files and directories, and to ensure that legacy code that is no longer pertinent does not get added to production builds, which is demonstrated on lines 121 to 125.
106: <!
107: ********************************************************
108: ** Help
109: *****************************************************__>
110: <target name="help" description="Lifecycle Help">.
111:
112: <echo message="Lifecycle Help"/>
113: <echo message="Type 'ant -projecthelp' for more 2
assistance..."/>
114:
115: </target>
116:
117: <!
118: ********************************************************
119: ** Remove the (build/release) directories
120: *****************************************************__>
121: <target name="clean">.
122:
123: <delete dir="${builddir}"/>
124:
125: </target>
126:
Listing 11.1 (continued)
92 Item 11
On many development efforts, code repositories and versioning systems are deployed to share code among programmers and to save modifications for redistribution. Often, an open-source application called Concurrent Versioning System (CVS) is used to perform these tracking and coordination activities. With CVS, check-in and checkout procedures allow users to access source code repositories to ensure that proper builds are deployed and archived. Source code control is an absolute necessity during multiple developer projects because it prevents inconsistencies in program updates and automates coordination among developers. A very simple glimpse of a CVS update operation embedded in Ant is shown on lines 131 to 139.
Previous << 1 .. 31 32 33 34 35 36 < 37 > 38 39 40 41 42 43 .. 166 >> Next