Java Extreme Programming CookbookExtreme 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. |
Contents
XP Tools | xi |
Tools and Philosophies | xii |
Open Source Toolkit | 2 |
XP Overview | 9 |
Coding | 12 |
Unit Testing | 15 |
Refactoring | 20 |
Design | 22 |
Mock Objects | 122 |
61 Event Listener Testing | 123 |
62 Mock Object SelfValidation | 128 |
63 Writing Testable JDBC Code | 131 |
64 Testing JDBC Code | 133 |
65 Generating Mock Objects with MockMaker | 136 |
66 Breaking Up Methods to Avoid Mock Objects | 138 |
67 Testing ServerSide Business Logic | 140 |
Builds | 24 |
Ant | 26 |
31 Writing a Basic Buildfile | 27 |
32 Running Ant | 29 |
33 Providing Help | 30 |
34 Using Environment Variables | 32 |
35 Passing Arguments to a Buildfile | 34 |
36 Checking for the Existence of Properties | 37 |
37 Defining a Classpath | 38 |
38 Defining PlatformIndependent Paths | 40 |
39 Including and Excluding Files | 41 |
310 Implementing Conditional Logic | 42 |
311 Defining a Consistent Environment | 43 |
312 Preventing Build Breaks | 44 |
313 Building JAR Files | 45 |
314 Installing JUnit | 46 |
315 Running Unit Tests | 48 |
316 Running Specific Tests | 51 |
317 Generating a Test Report | 52 |
318 Checking Out Code from CVS | 53 |
319 Bootstrapping a Build | 54 |
JUnit | 57 |
41 Getting Started | 58 |
42 Running JUnit | 60 |
43 assertXXX Methods Problem | 63 |
44 Unit Test Granularity | 66 |
45 Set Up and Tear Down | 67 |
46 OneTime Set Up and Tear Down | 69 |
47 Organizing Tests into Test Suites | 71 |
48 Running a Test Class Directly | 72 |
49 Repeating Tests | 73 |
410 Test Naming Conventions | 74 |
411 Unit Test Organization | 75 |
412 Exception Handling | 77 |
413 Running Tests Concurrently | 78 |
414 Testing Asynchronous Methods | 79 |
415 Writing a Base Class for Your Tests | 82 |
416 Testing Swing Code | 83 |
417 Testing with the Robot | 90 |
418 Testing Database Logic | 91 |
419 Repeatedly Testing the Same Method | 92 |
HttpUnit | 97 |
51 Installing HttpUnit Problem | 98 |
53 Checking a Static Web Page | 102 |
54 Following Hyperlinks | 104 |
55 Writing Testable HTML | 105 |
56 Testing HTML Tables | 106 |
57 Testing a Form Tag and Refactoring Your Tests | 109 |
58 Testing for Elements on HTML Forms | 111 |
59 Submitting Form Data | 114 |
510 Testing Through a Firewall | 118 |
512 Testing Secure Pages | 120 |
Cactus | 143 |
71 Configuring Cactus | 146 |
72 Setting Up a Stable Build Environment | 147 |
73 Creating the cactusproperties File | 153 |
74 Generating the cactusproperties File Automatically | 155 |
75 Writing a Cactus Test | 157 |
76 Submitting Form Data | 160 |
77 Testing Cookies | 165 |
78 Testing Session Tracking Using HttpSession | 168 |
79 Testing Servlet Initialization Parameters | 174 |
710 Testing Servlet Filters | 175 |
711 Securing Cactus Tests | 178 |
712 Using HttpUnit to Perform Complex Assertions | 181 |
714 When Not to Use Cactus | 183 |
JUnitPerf | 185 |
81 When to Use JUnitPerf | 186 |
82 Creating a Timed Test | 187 |
83 Creating a LoadTest | 190 |
84 Creating a Timed Test for Varying Loads | 192 |
85 Testing Individual Response Times Under Load | 193 |
86 Running a TestSuite with Ant | 195 |
87 Generating JUnitPerf Tests | 196 |
XDoclet | 199 |
91 Setting Up a Development Environment for Generated Files | 200 |
92 Setting Up Ant to Run XDoclet | 202 |
93 Regenerating Files That Have Changed | 205 |
94 Generating the EJB Deployment Descriptor | 206 |
95 Specifying Different EJB Specifications | 210 |
97 Creating and Executing a Custom Template | 215 |
98 Extending XDoclet to Generate Custom Files | 218 |
99 Creating an Ant XDoclet Task | 220 |
910 Creating an XDoclet Tag Handler | 224 |
911 Creating a Template File | 230 |
912 Creating an XDoclet xdodetxml File | 232 |
913 Creating an XDoclet Module | 235 |
Tomcat and JBoss | 237 |
102 HotDeploying to Tomcat | 238 |
103 Removing a Web Application from Tomcat | 240 |
104 Checking If a Web Application Is Deployed | 242 |
105 Starting Tomcat with Ant | 243 |
106 Stopping Tomcat with Ant | 250 |
107 Setting Up Ant to Use Tomcats Manager Web Application | 251 |
108 HotDeploying to JBoss | 252 |
109 HotDeploying a Web Application to JBoss | 253 |
1010 Testing Against Multiple Servers | 254 |
Additional Topics | 256 |
1 1 2 Enterprise JavaBeans Testing Tools | 257 |
113 Avoiding EJB Testing | 258 |
114 Testing Swing GUIs | 260 |
115 Testing Private Methods | 261 |
Index | 263 |