Java Extreme Programming Cookbook

Book description

Extreme Programming does not mean programming naked while rollerblading down the side of the Grand Canyon. It does mean a new approach to software development that is both radical and common-sense. Unlike many software development methodologies, XP has been accepted quickly because its core practices--particularly code sharing, test-first development, and continuous integration--resonated immediately with software developers everywhere. Instead of impressing developers with a body of theory, XP got programmers to say, "Yeah, that's how I'd like to work." Oddly enough, although most developers turn to Extreme Programming methods in order to code real, hands-on, and extensible projects quickly ("Code comes first"), most books on Extreme Programming insist on focusing on the theory and not the practice. Not the Java Extreme Programming Cookbook. Brimming with over 100 "recipes" for getting down to business and actually doing XP, the Java Extreme Programming Cookbook doesn't try to "sell" you on XP; it succinctly documents the most important features of popular open source tools for XP in Java--including Ant, Junit, HttpUnit, Cactus, Tomcat, XDoclet--and then digs right in, providing recipes for implementing the tools in real-world environments. Each recipe offers solutions that help you put an extreme programming environment together: then provides code for automating the build process and testing. Although the time saved using any one of these solutions will more than pay for the book, Java Extreme Programming Cookbook offers more than just a collection of cut-and-paste code. Each recipe also includes explanations of how and why the approach works, so you can adapt the techniques to similar situations. One of the biggest challenges facing developers today is sorting through the wide variety of tools available form various source and figuring out how to them effectively. The recipes in Java Extreme Programming Cookbook showcase how to use the most important features of these XP tools. Many of these tools are geared towards unit testing, while others are invaluable for continuous integration; with these practical examples, you'll be able to choose the most effective tools to accomplish your goals, then implement them in a cohesive development environment quickly. If you want to set up a test-driven development environment that allows you to focus on writing testable code--now--this book will prove invaluable.

Table of contents

  1. Java Extreme Programming Cookbook
    1. Preface
      1. Audience
      2. About the Recipes
      3. Organization
      4. Conventions Used in This Book
      5. Comments and Questions
      6. Acknowledgments
    2. 1. XP Tools
      1. Java and XP
      2. Tools and Philosophies
        1. The IDE Philosophy
        2. Minimum Tool Requirements
          1. Automation
          2. Regression testing
          3. Consistency among developers
      3. Open Source Toolkit
        1. Version Control
        2. Ant
        3. JUnit
        4. HttpUnit and Cactus
        5. JUnitPerf
        6. Application Servers
        7. Setting Up a Build Server
    3. 2. XP Overview
      1. What Is XP?
        1. Simplicity
        2. Communication
        3. Feedback
        4. Courage
      2. Coding
        1. Simplicity
        2. Comments
        3. Pair Programming
        4. Collective Code Ownership
        5. Coding Standards
        6. Code Inspections
      3. Unit Testing
        1. Why Test?
        2. Who Writes Unit Tests?
        3. What Tests Are Written?
        4. Testing New Features
        5. Testing Bugs
        6. How Do You Write Tests?
        7. Unit Tests Always Pass
        8. Testing Improves Design
        9. Acceptance Testing
      4. Refactoring
        1. Goals
        2. When to Refactor
        3. How to Refactor
        4. Refactoring Tools
      5. Design
        1. Design Today’s Features
        2. Simple Design
        3. UML
          1. UML tools
          2. Whiteboards and scratch paper
      6. Builds
        1. Continuous Integration
        2. Small Tasks
    4. 3. Ant
      1. Introduction
      2. Writing a Basic Buildfile
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Running Ant
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Providing Help
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Using Environment Variables
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Passing Arguments to a Buildfile
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Checking for the Existence of Properties
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Defining a Classpath
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Defining Platform-Independent Paths
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Including and Excluding Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Implementing Conditional Logic
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Defining a Consistent Environment
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Preventing Build Breaks
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. Building JAR Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. Installing JUnit
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      16. Running Unit Tests
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      17. Running Specific Tests
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. Generating a Test Report
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      19. Checking Out Code from CVS
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      20. Bootstrapping a Build
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    5. 4. JUnit
      1. Introduction
      2. Getting Started
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Running JUnit
        1. Problem
        2. Solution
        3. Discussion
          1. Text testing
          2. Graphical testing
          3. Reload classes every run
        4. See Also
      4. assertXXX( ) Methods
        1. Problem
        2. Solution
        3. Discussion
          1. Optional first argument
          2. Equality comparison
          3. Additional examples
        4. See Also
      5. Unit Test Granularity
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Set Up and Tear Down
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. One-Time Set Up and Tear Down
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Organizing Tests into Test Suites
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Running a Test Class Directly
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Repeating Tests
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Test Naming Conventions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Unit Test Organization
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Exception Handling
        1. Problem
        2. Solution
        3. Discussion
      14. Running Tests Concurrently
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. Testing Asynchronous Methods
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      16. Writing a Base Class for Your Tests
        1. Problem
        2. Solution
        3. Discussion
      17. Testing Swing Code
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      18. Avoiding Swing Threading Problems
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      19. Testing with the Robot
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      20. Testing Database Logic
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      21. Repeatedly Testing the Same Method
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    6. 5. HttpUnit
      1. Introduction
      2. Installing HttpUnit
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Preparing for Test-First Development
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Checking a Static Web Page
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Following Hyperlinks
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Writing Testable HTML
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Testing HTML Tables
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Testing a Form Tag and Refactoring Your Tests
        1. Problem
        2. Solution
        3. Discussion
      9. Testing for Elements on HTML Forms
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Submitting Form Data
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Testing Through a Firewall
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Testing Cookies
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Testing Secure Pages
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    7. 6. Mock Objects
      1. Introduction
      2. Event Listener Testing
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Mock Object Self-Validation
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Writing Testable JDBC Code
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Testing JDBC Code
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Generating Mock Objects with MockMaker
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Breaking Up Methods to Avoid Mock Objects
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Testing Server-Side Business Logic
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    8. 7. Cactus
      1. Introduction
        1. Implicit Objects
        2. How Does It Work?
      2. Configuring Cactus
        1. Problem
        2. Solution
        3. Discussion
          1. Client-side classpath
          2. Server-side classpath
        4. See Also
      3. Setting Up a Stable Build Environment
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Creating the cactus.properties File
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Generating the cactus.properties File Automatically
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Writing a Cactus Test
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Submitting Form Data
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Testing Cookies
        1. Problem
        2. Solution
        3. Discussion
          1. testGetInitialCookie( )
          2. testGetUpdatedCookie( )
        4. See Also
      9. Testing Session Tracking Using HttpSession
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Testing Servlet Initialization Parameters
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Testing Servlet Filters
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      12. Securing Cactus Tests
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Using HttpUnit to Perform Complex Assertions
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. Testing the Output of a JSP
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      15. When Not to Use Cactus
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      16. Designing Testable JSPs
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    9. 8. JUnitPerf
      1. Introduction
      2. When to Use JUnitPerf
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Creating a Timed Test
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Creating a LoadTest
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Creating a Timed Test for Varying Loads
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Testing Individual Response Times Under Load
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Running a TestSuite with Ant
        1. Problem
        2. Solution
        3. Discussion
      8. Generating JUnitPerf Tests
        1. Problem
        2. Solution
        3. Discussion
          1. Creating a timed test
          2. Creating a load test
          3. Generating the code
        4. See Also
    10. 9. XDoclet
      1. Introduction
      2. Setting Up a Development Environment for Generated Files
        1. Problem
        2. Solution
        3. Discussion
          1. Why not place generated files in the source directory?
          2. Why not place generated files in the build directory?
          3. Why not place the compiled generated code in the build directory?
        4. See Also
      3. Setting Up Ant to Run XDoclet
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Regenerating Files That Have Changed
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Generating the EJB Deployment Descriptor
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Specifying Different EJB Specifications
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Generating EJB Home and Remote Interfaces
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      8. Creating and Executing a Custom Template
        1. Problem
        2. Solution
        3. Discussion
          1. Block
          2. Content
        4. See Also
      9. Extending XDoclet to Generate Custom Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Creating an Ant XDoclet Task
        1. Problem
        2. Solution
        3. Discussion
          1. Creating an Ant XDoclet task
          2. Creating the Ant Doclet subtask
        4. See Also
      11. Creating an XDoclet Tag Handler
        1. Problem
        2. Solution
        3. Discussion
          1. Block
          2. Content
        4. See Also
      12. Creating a Template File
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      13. Creating an XDoclet xdoclet.xml File
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      14. Creating an XDoclet Module
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    11. 10. Tomcat and JBoss
      1. Introduction
      2. Managing Web Applications Deployed to Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Hot-Deploying to Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      4. Removing a Web Application from Tomcat
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Checking If a Web Application Is Deployed
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      6. Starting Tomcat with Ant
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      7. Stopping Tomcat with Ant
        1. Problem
        2. Solution
        3. Discussion
      8. Setting Up Ant to Use Tomcat’s Manager Web Application
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      9. Hot-Deploying to JBoss
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      10. Hot-Deploying a Web Application to JBoss
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      11. Testing Against Multiple Servers
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    12. 11. Additional Topics
      1. Introduction
      2. Testing XML Files
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      3. Enterprise JavaBeans Testing Tools
        1. Problem
        2. Solution
        3. Discussion
          1. ServletTestCase
          2. J2EEUnit
        4. See Also
      4. Avoiding EJB Testing
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
      5. Testing Swing GUIs
        1. Problem
        2. Solution
        3. Discussion
          1. Abbot
          2. Pounder
          3. Jemmy
          4. JFCUnit
        4. See Also
      6. Testing Private Methods
        1. Problem
        2. Solution
        3. Discussion
        4. See Also
    13. Index
    14. Colophon

Product information

  • Title: Java Extreme Programming Cookbook
  • Author(s): Eric M. Burke, Brian M. Coyner
  • Release date: March 2003
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596003876