Appendix C. The source code for the book

This appendix covers

  • Installing the book’s source code
  • Software versions required
  • Directory structure conventions

This appendix gives an overview of the book’s source code, where to find it, how to install it, and how to run it. When we were writing this book, we decided to donate all of the book’s source code to the Apache Software Foundation, because we used many Apache frameworks in the making of this book. Therefore, we’ve made our source code available as open source on SourceForge at http://junitbook.sourceforge.net/junit2/.

We’re also committed to maintaining this source code and fixing it if bugs are found, as a standard open source project. In addition, a Manning author forum has been set up for discussing the code at http://www.manning-sandbox.com/forum.jspa?forumID=502.

C.1. Getting the source code

There are two possibilities for getting the source code on your local machine:

C.2. Source code overview

Once you put the source code in the junitbook2/ directory, you should have the directory structure shown in figure C.1. Each directory represents the source code for a chapter of the book (except the repository/ directory, which contains external JARs required by the chapter projects). The mapping between chapter names and directory names is listed in table C.1.

Figure C.1. Directory structure for the source code, shown here in Windows Explorer. (Note that the directory and file icons are decorated by the TortoiseSVN client.)

Table C.1. Mappings between chapter names and source directory names

Chapter name

Directory name

Chapter 1: JUnit jump-start junitbook2/ch01-jumpstart/
Chapter 2: Exploring core JUnit junitbook2/ch02-internals/
Chapter 3: Mastering JUnit  
Chapter 4: Software testing principles  
Chapter 5: Test coverage and development junitbook2/ch05-coberturra/
Chapter 6: Coarse-grained testing with stubs junitbook2/ch06-stubs/
Chapter 7: Testing with mock objects junitbook2/ch07-mocks/
Chapter 8: In-container testing junitbook2/ch08-incontainer/
Chapter 9: Running JUnit tests from Ant junitbook2/ch09-ant/
Chapter 10: Running JUnit tests from Maven2 junitbook2/ch10-maven/
Chapter 11: Continuous integration tools  
Chapter 12: Presentation-layer testing junitbook2/ch12-gui/
Chapter 13: Ajax testing junitbook2/ch13-ajax/
Chapter 14: Server-side Java testing with Cactus junitbook2/ch14-cactus/
Chapter 15: Testing JSF applications junitbook2/ch15-jsfunit/
Chapter 16: Testing OSGi components junitbook2/ch16-osgi/
Chapter 17: Testing database access junitbook2/ch17-dbunit/
Chapter 18: Testing JPA-based applications junitbook2/ch18-jpa/
Chapter 19: JUnit on steroids junitbook2/ch19-steroids/

Each directory maps directly to a project. A project is a way to regroup Java sources, test sources, configuration files, and so on under a single location. A project also has a build, which lets you perform various actions such as compiling the code, running the tests, and generating the Javadoc. We use various build tools (Ant and Maven) for the different projects, as explained in the chapter matching each project.

C.3. External libraries

You may have noticed a directory named repository/ in figure C.1. It contains the different external libraries (JARs) that all the other projects need in order to compile and run. As a convenience, we make them readily available to prevent you from having to fish for them all over the Net.

C.4. JAR versions

Table C.2 lists the versions of all external JARs and applications used in the projects. We recommend using these versions when you try the book examples.

Table C.2. External JAR/application versions (sorted in alphabetical order)

External project name

Version

Project URL

Ant 1.7.1 http://ant.apache.org/
Cactus 1.8.1 http://jakarta.apache.org/cactus
Commons BeanUtils   http://commons.apache.org/
Commons Collections   http://commons.apache.org/
Commons HttpClient   http://commons.apache.org/
Commons Logging   http://commons.apache.org/
DBUnit 1.5.5 http://dbunit.sourceforge.net/
EasyMock 1.0 http://easymock.org/
Eclipse 3.5.2 http://eclipse.org/
HttpUnit 1.5.3 http://httpunit.sourceforge.net/
Jakarta Taglibs/JSTL 1.0.2 http://jakarta.apache.org/taglibs/
JBoss 4.2.1 http://jboss.org/
Jetty 7.0.0.pre5 http://jetty.mortbay.org/
JUnit 4.6 http://junit.org/
Maven 2.0.10 http://maven.apache.org/
MockObjects 0.09 http://mockobjects.com/
ServletAPI 2.5 http://repo1.maven.org/maven2/javax/servlet/
Tomcat 6.0.14 http://tomcat.apache.org/

C.5. Directory structure conventions

For each project, we followed the directory conventions listed in table C.3.

Table C.3. Directory structure conventions

Directory name

Explanation

<project name>/src/main/java Java runtime sources.
<project name>/src/test/java Java test sources.
<project name>/src/main/webapp Web app resources (JSPs, web.xml, taglibs, and so on).
<project name>/src/main/conf Configuration files (if any).
<project name>/target Directory created by the build process (Ant or Maven) to store generated files and temporary files. It can be safely deleted, because it’s re-created by the build.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.83.151