|
JUnit in Action Vincent Massol with Ted Husted 2003 | 384 pages ISBN: 1930110995 |
|||
![]() |
$20.00 | ThoutReader + PDF ebook | |
![]() |
$39.95 | Softbound print book | |
Index
 
Numerics
 
302 response code (redirect) 73
 
A
 
abstract classes, testing 311
AbstractHttpHandler method (Jetty) 128
AbstractHttpListener class (Jetty) 128
acceptance testing 6, 71, 7576
Account class 82, 141145
account transfer testing 141
AccountManager interface 141143
AccountService.transfer method 141, 143146
add method 78
addAccount method 144
addHandler method 42, 50, 60, 128
addTest method 23
addTestSuite method 24
Administration application 188189, 216, 240, 261
administrators 188
AdminServlet
Administration application and 216
DataAccessManager and 244247
refactoring 243244
testing with Cactus 189192
agile methodologies 68
Algol 68
alternate path of execution See failures
Ant
book 93
build process management with 92
build system choice with 315
build.properties file 94, 317
buildfiles 91, 9394, 98, 101102
cactification 266
cactifywar task 266271, 329
cactus task 333
cactus testing with 265274
Cactus/Ant integration module 265274, 329
configuration of 91
database integration testing and 261
ear task 317
fileset element 100
installing 9192, 98
Java application building tool 9192
javac task 9496
JDBC query invoking with 91
junit jar 98
junit task 9698, 100101, 272, 322, 333
junitreport task 98100
parallel task 321
project XML tag and 93
properties of 94
property elements 93
property task 94
retaining test results with 27
SQL task 266
targets 93, 101102
taskdef element 273
tasks 93
WAR task 266
web site 91
AOP (Aspect-Oriented Programming) 173
Apache test server 124
APIs (Application Programming Interface)
contract defined 6
methods 81
testing of public 72, 78
verifying behavior of 171
application.xml file 315, 317318, 331
architecture patterns 41
Aspect Oriented Programming (AOP) 173
AspectJ jar 177
aspectjrt.jar 270
assertEquals method 14, 31, 131, 134, 153, 219, 250
AssertionException 256
AssertionFailedError 159
assertSame 54
Avalon framework 149
 
B
 
BaseTestRunner class 21
BasicDynaClass class 219220
batchtest element 272
beanutils.RowSetDynaClass 247
Beck, Kent 5, 40, 70, 164, 166, 240
beginIsAuthenticatedNoSession method 181
best practices
business logics and mocks 144
Cactus tests, location of 176
code improvement with testing 60, 62
continuous regression testing 86
exception test readability 62
failure explanation in assert calls 51
packaging and directory locations of test classes 64
refactor long setups when using mock objects 254
refactor test setups and teardowns 299
refactoring and agile methodologies 68
test method naming 50
throw an exception for methods that arent implemented 204
unit test one object at a time 48
unit tests and testMethods 53
use TDD to implement The Simplest Thing That Could Possibly Work 197
verification of test failure 192
what to test 56, 145
black box testing 78, 81
body tag 228
BodyContent class 230
BodyTagSupport class 229
bottlenecks, finding with profilers 74
branches, conditional 78
Brunner, John 89
build cactus.xml buildfile 329
build.properties file 111, 317
buildfiles (Ant) 91, 9394, 9798, 101102
Bureau of Extreme Programming 45
business logic unit tests 144, 280
ByteArrayISO8859Writer class (Jetty) 128
 
C
 
C2 Wiki 163
cactification 192, 267, 270 271, 331
Cactus
Ant integration 266267, 328
DbUnit integration 271273
defined 173, 267
directory structure for tests 329
EJB unit tests 328
FileRedirector 212
front ends 179
in-container testing with 166, 173183
integration with Jetty 175178
jars 177
JSP testing 217218, 238, 331, 333
mock objects compared to 213, 216, 237, 278
running tests 174175
setInitParameter method 211
task 273
taskdef 270
test runners 174178
testing filters 208213
testing life cycles 179180, 230233
testing taglibs 224233, 237
testing under Jetty with Eclipse 177
testing under Maven 196
web sites 166, 267, 274
when to use 213214, 216, 237, 278
XML and 329331
cactus.jar 270
Cactus/Ant integration module 266267
cactus-ant integration jar 267
Calculator class 67
CalculatorTest program 810
callView method 189, 198, 200201, 242
Carroll, Lewis 282
Centipede 315
class factory refactoring 156
classloaders 10, 12
classpath 94, 9798, 177, 270, 272
classpath element 96
clean build 92
CLEAN INSERT strategy 264
clean target 101
clearCache method 307
close calls 258
close method 159
Clover 7980
coarse-grained testing 121
code issues 146
codesmell 62
collaboration tags, testing of 233
collecting parameters 2527
Common Public License 5
CommonMockStatement 251
CommonPetstoreTestCase 305306, 309
Commons-HttpClient jar 177
Commons-Logging jar 177
compile targets 9596, 268
compile.cactustest target 269
compile.test target 319
condition task 321
conditional branches 78
Connection object 248249, 258
ConnectionFactory class 156157
Container Managed Persistence (CMP) 282283
container-related code testing 167
continuous integration 179, 279280
controller component 4045
Controller interface 4142
controller object 50
Controller project 116
countTestCases method 30
Craig, Philip 140
create method 307
createCommandResult method 201
createdb target 267268
createOrder method 283, 286287, 290, 293, 297, 303, 314
createOrderHelper method 290, 293
cron job 99
Cunningham, Ward 75
custom taglibs 216
customer
always right 62
 
D
 
data access unit tests
types of 241
data.sql file 266
data.xml 263264, 270
DataAccessManager class 262
DataAccessManager interface 243, 247
database
access layer interface implementation 243
access unit tests 241, 278
connection pooling 241
connectivity 29, 258, 260, 263264
constraints 260
features 242, 260
in-memory 278
integration testing 260264, 279280
queries 261
referential integrity 260
schema 266267
triggers 260
unit-testing 240242, 260274
DatabaseTestSetup 275276
DataSource implementation 262
DbUnit
adding jar 273
Cactus integration 272
database data presetting with 263
database testing and 242, 260261
web site 260
dbunit.jar 270
DefaultAccountManager class 147149
DefaultController 43, 45, 48, 79, 91
DefaultJMSUtil class 294
DefaultOrderUtil class 294
definitions
acceptance tests 6
API contract 6
component 167
container 167
domain object 47
expectation 159
fixture 29
framework 5
integration tests 6
mock object 141
refactor 52
regression tests 90
stub 121
Test-Driven Development 81
unit of work 5
unit test 6
dependency in software development 120
deployment
automatic 319
descriptors 173, 238, 313, 318, 331
ears 333
targets 319
Design by Contract website 6
design patterns
collecting parameters 27
command pattern 25
composite pattern 25
Factory 134
Interfaces 164
Inversion of Control 42, 149, 155, 164
MVC Model 2 199
observer 28
development cycle 82
diagnostic tests 55
directory structure 63, 105, 111, 315, 329
dist target 101
doAfterBody method 229, 231
document root 125126
doEndTag method 226, 228
doGet method 201204, 206, 242, 246
domain object 4748
doStartTag method 226228
doubles 7
duplication eliminating 83
dyna beans 218220
DynaBean class 199
DynaBeans 219, 225226
dynamic proxies 167
Dynamic Proxy 204, 233, 238
DynaMock
EasyMock compared to 204
testing session beans with 284
writing mocks with 246
DynaPropertiesTag class 225
 
E
 
ear files 315317, 319321, 329, 331, 333
EasyMock 167170, 204
Eclipse
adding jars 177
Cactus testing under Jetty with 177
plug-ins 175, 234
projects 113, 115, 175177
Quick Fixes 191
test results retention with 27
TestDefaultController, running with 114
web site 112
EJB
defining sample applications 282
faηade strategies 283284
home caching issue 306
limitations of JUnit with 314
local interfaces 328, 334
Redirectors 328
remote interface testing 314
remote interfaces 314
unit test writing with Cactus 328
unit testing with Cactus 329
ejbCreate method 311312
EJBException class 293
ejb-jar.xml file 315
ejb-local-ref element 330
Electric XML 271
eliminating duplication 83
Emacs 112
embedded servers 124
endCallView method 221
entity beans 282, 310
EntityBean class 310
error conditions 56, 152
error handling 26, 56, 152
errorproperty attributes 322
ErrorResponse class 44, 79
Example TimedTest class 75
exceptions 42, 5556, 60
execute method 248250, 257258, 261
executeCommand method 189, 198, 201, 242
executeQuery method 251
exml.jar 271
expectAndReturn method 293
expectAndThrow method 307
expectations 159, 163, 256
Extreme Programming 5, 197
 
F
 
fail statements 61
failureproperty attributes 322
failures 51, 5657, 132133, 258
field getters/setters and absolute classes 311
fileset element 101
filesystem 126
FilterChain 209210, 212
FilterConfig 209, 212
filters 188, 208, 314
FilterTestCase 182
findAccountForUser method 142144, 147, 149
findAncestorWithClass method 233
fit framework
web site 75
Fixtures 50
controller object created by default 58
defined 29
de-initializing with tearDown 32
long and complex 254
test case sharing of 5354
TestSetup 129, 134, 145, 275276, 297298
fork attribute 97
formatter element 272
Fowler, Martin 4
framework 45
Freeman, Steve 140
functional testing 7172, 76, 171, 261, 279, 283
 
G
 Galileo 120
Gamma, Erich 112
Gang of Four 5
Generate Getters and Setters feature 311
getBalance method 82
getColumnCount method 254255
getCommand method 189191, 197198, 242243
getConnection method 249, 258
getContent method (WebClient) 122
getHandler method 44, 47, 60, 79
getInputStream method 136137, 153
getMetaData method 254255
getName method 55
getOrder method 287
getOrderHome method 287, 306
getOrderId method 292293
getParameter method 206
getParent method 233
getRequest method 50
getRequestDispatcher method 220
Giraudoux, Jean 140
green-bar tests 21
 
H
 
haltonerror attribute 97, 272
haltonfailure attribute 9697, 272
Handler class (Jetty) 127128
Hashtable 144
Heisenberg Uncertainty Principle 155
Hollywood Principle 42
hsqldb.jar 268
HTML DOM 222
HTTP
clients 40
connection mock objects 150
connections 122123, 150151, 181
cookies 181182
elements 40
headers 40, 181182, 222
parameters 40, 216, 225
protocols 157
HTTP requests
AdminServlet requirements 189
doGet method entry point for 242
functional unit tests using 73
HTTPContext processing of 126
HTTP-related parameters in 181
interception by the security filter 216
receipt by application 188
using Cactus to add SQL command to 210
web controller acceptance 40
HTTP response 128, 182, 210, 212, 222, 225, 230
HTTP sessions 40, 181, 225
httpclient.jar 270
HttpConnectionFactory class 157
HttpContext 126
HttpContext class 125126, 129, 132133
HttpRequest class 128129
HttpResponse class 127, 133
HttpServer class 125, 129130, 132
HttpServer class (Jetty) 125
HttpServlet class 166, 168, 242, 245
HttpServletRequest class 166, 168170, 181, 205
HttpServletResponse class 181, 220
HttpSession class 166, 168170, 181
HttpSocketListener class (Jetty) 129
HttpUnit class 167, 217, 221, 225
HttpURLConnection class 123, 133134, 136138, 153, 157
HttpURLConnection interface 123
Hypersonic SQL 260, 278, 315, 324
 
I
 
IDE (integrated development environments) 56, 112
IEEE 5
IllegalStateException 298
incomplete mock object test 251
in-container testing 166, 173, 178
InitialContext class 285, 297298, 314
inner classes 48
InputStream class 159
integrated development environments (IDE) 56, 112
integration testing 6, 7172, 133134, 283
integration unit testing
comparison with logic and functional unit testing 76, 172
database testing with 242, 260264, 279280
defined 76, 172173
EJBs and 313
errors in 323325
execution time 179
J2EE testing with 166
mock objects approach compared to 179180
with Cactus and JUnit 334
interactions between objects 81
introspect method 253
invalid URLs 132133
Inversion of Control (IOC) 148149
isAuthenticated method 166, 168169, 173
isolation testing 134, 140, 150, 164, 217
It Works! return 127128, 130
 
J
 
J2EE
component unit testing 166167
containers 260, 315
integration issues, costs of 279
jar proliferation 109
Java Complier (javac) 9496
Java IDEs 112
Java Messaging Service (JMS) 283284
Java Naming and Directory Interface (JNDI) 284285, 297307, 314
Java Server Pages (JSP) 188189, 216233
Java Virtual Machine (JVM) 96, 320
JAVA_HOME 92
JavaBean 56
javac (Java Compiler) 9496
Javadocs 14, 23, 30, 92, 102
JBoss
development 320
Hypersonic SQL and 260, 315, 324
installing 317
JNDI and 326
version 3.2.1 273
website 317
jboss.xml file 326
jboss3x element 273
jbossresult.txt file 273
JDBC 91, 120, 141, 145147, 284
JdbcDataAccessManager class 243244, 247, 249250, 261262
JEdit 112
Jeffries, Ron 148
Jester 80
Jetty
benefits of 124125, 138, 175
Cactus testing under, with Eclipse 177
embedded server used as 125
handler that returns 127
Handlers 127128
JettySample class 125
modularity 125
NotFoundHandler 132
opening a URL 125
pros 125
setting up stubs with 124125
starting and stopping 129
starting from code 125127
website 124
Jetty classes
AbstractHttpHandler 127129, 133
ByteArrayISO8859Writer 128
Handler 128129
HttpContext 125, 129
HttpServer 125
HttpServer class 129
JettySample 125
SocketListener 125, 129
Jetty methods
addHandler 128
handle 128
setContextPath 126
setResourceBase 126
setUpandtearDown 127
JMeter 73
JMS (Java Messaging Service 283284
JMSException class 293
JMSUtil class 287, 294295, 303
JMSUtil interface 295, 297
JNDI (Java Naming and Directory Interface) 284285, 297307, 314
JNDI API 188
jndi.properties file 297
JNDINames class 326
JNDITestSetup 298
Joyce, James 18
JspRedirector class 224
JSPs (JavaServer Pages) 216
JspTagLifecycle class 228, 230
JspTestCase class 182, 224225, 227, 230
JSTL 219, 226
JUnit
Assert interface 30
core classes 1920
core members 19
design goals 15, 24, 30
FAQ 56
features 13
IDEs and 112
JUnit (continued)
life cycle 3738
motto 20
overview 5
Test interface 23
JUnit classes
BaseTestRunner class 20, 22
TestCase class 13, 18, 25, 28, 31
TestFailure class 25
TestListener interface 27
TestResults class 25
TestRunner class 18, 20, 180
TestSuite class 18, 2123, 131
JUnit methods
assertEquals method 1314, 30, 126
JUnit TestClass constructors
version 3.8.1 and later 15
junit.jar file 98
JUnitEE website 314
JUnitPerf website 74
JUnitReport 99
JVM (Java Virtual Machine) 32, 96, 320
 
K
 
Kawasaki, Guy 66
 
L
 
Log interface 147
Log object 146
Log4j 109
LoggerFactory class 146
logging.jar 270
logic unit tests 76, 172, 241
lookup method 287
 
M
 
Mackinnon, Tim 140
Marick, Brian 216
matchAndReturn method 293, 307
Maven
artifacts 109
cactification 192
compared to Ant and Eclipse 90, 112
configuring 103105
dependency handling 108109
directory structure 193, 212
goal seeking 102, 109
handling dependent jars 109
HTML reports 196
ID element 105
IDEs and 112
installing 103
JUnit test with 109
JUnit testing with 109
maven-linkcheck-plugin 106
PATH 103
plugins 102103, 105106, 109, 192, 196
portability 103
project configuration files 222
project description 104
Project Object Module (POM) 104108
project.xml 108109, 196
reports element 108
repositories 109
running Cactus tests 192193, 212213
url element 105
version element 105
website 102
website generation with 105108
welcome page 106107
workflow 109
maven site 109
MAVEN_HOME 103
maven-changelog-report 106
MavenLJUnit test with 109
mergewebxml attribute 330
Message Driven Beans (MDB) 282283, 307310
metadata 173, 218, 238, 313
Method Factory refactoring 155
Mock DataAccessManager 246
mock objects
as probes 159
as Trojan horses 159
benefits of 140
best practices 254
Cactus compared to 213, 216, 237, 278
defined 141
entity beans, testing with 310312
finding methods to mock 250
HTTP connection and 150159
in-container testing with 166
indirect calls, discovery of 253
JNDI implementation stragegy 297, 303, 309
making generic 144
making mocks generic 144
message-driven bean testing 308
mocking at a different level 254
practical example 150
pros and cons 144, 170171
real objects compared to 163
servlet testing with 167170
session beans 284285
standard JDK APIs 163
stubs compared to 120, 141, 144
web site 163
when to use 121, 138, 163, 213214
white box tests and 78, 81
MockAccountManager class 143144
MockConfiguration class 149
MockConnectionFactory class 157, 160
MockHttpURLConnection class 153
MockInputStream class 159
MockLog class 149
MockMaker 234, 237238
MockMultiRowResultSet class 252
MockObject JDBC package 247
MockObjects
framework SQL package 280
jar 112
project web site 163
MockSingleRowResultSet class 252
MockURL class 150, 153
monumental methodologies 197
Murphys Law 56
MVC Model 2 199
 
N
 
name property 42
Newton 25
 
O
 
objective standards 77
openConnection method 134
optional.jar file 98
Oracle 278
OrderEJB class 310312
OrderFactory class 295
OrderProcessMDB 314
OrderProcessorMDB class 286
OrderUtil class 286, 303, 306307
OrderUtil interfaces 294
Orion 171, 273
 
P
 
PageContext class 224, 234, 238
Pascal 68
performance testing 74
Petstore application 314315
Petstore OrderEJB class 314
PetstoreEJB class 285, 289291, 295, 303, 314
play-testing 4
POJO (Plain Old Java Object) 212, 283
POM (project object model) 104108
pre-test state 50
printsummary attribute 97, 272
process method 42, 49
processRequest method 42, 44, 51, 57, 79
production environments, drawbacks in testing 124
profilers 73
project directory structure 265
project object model (POM) 104108
project.xml file 104
PropertyResourceBundle class 147
ProtocolException 136
proxy redirector 180
pushBody method 230
 
Q
 
QA teams 75
 
R
 
read-only data, factoring 275
red-bar tests 21, 58
redirect 302 response code 73
refactoring 244
best practice 60
class factory, used for 155159
courage for 68
defined 52
easy method technique for 152155
extract hierarchy 62
extract method 62
making code unit-testable with 69, 283
Method Factory 155
mock objects used as technique for 146149
natural solution 245
PetstoreEJB 294
renaming 294
sample 5859
setDataAccessManager 245
suite of unit tests, benefits for 140
TDD two-step 83
referential integrity 260
reflection and introspection 10
regression testing 86, 9091
report target 100
Request 209, 212
Request interface 41, 58
RequestDispatcher 208
RequestHandler class 42, 47, 4950
RequestHandler interface 41
Resin 273
Response 209, 212
response code (302) redirect 73
Response interface 41, 44
results.jsp 218
ResultSet interface 248, 251
RowSetDynaClass 247
run method 30
RuntimeException class 44, 58, 60, 314
 
S
 
Sample servlet 166
Sampling project buildfiles 93, 96
scriptlets 189
Security error page 211
security filter 216
SecurityFilter class 208
SecurityFilter Filter 208
SELECT queries 216
SELECT statement 206, 208, 250
sendToJMSQueue method 286, 303
sendToJMSQueueHelper method 290
sequence diagrams 33
Service Level Agreement (SLA) 188
Servlet class 180
ServletConfig 181
ServletRedirector 179, 181
ServletRedirector class 180
ServletRequest 208
ServletResponse 208
servlets
API 188
containers 125, 189, 223, 273
Pet Store sample 283
remote web resources as 122
sample method for unit testing 166
server side code that calls EJBs 314
testing a method 166
unit testing 188
writing tests for using Cactus 189
ServletTestCase class
Cactus and 180, 182, 217
extending with TestAdminServlet 190, 200
presetting database data with 261262
ServletUnit 167
SessionBean class 290, 295
setConnection method 250
setContextPath method 125
setDataAccessManager method 245246
setDoInput method 136
setExpectedCloseCalls method 256
setExpectedQueryString 256
setInitialContextFactoryBuilder method 297298
setJMSUtil method 293, 297
setOrderFactory method 297
setOrderUtil method 293
setPageContext method 224, 227
setParent method 227, 233
setResourceBase method 125
setUp methods 126128, 130
setURLStreamHandlerFactory method 134
simulations, using tests to create 57, 133, 150
SLA (Service Level Agreement) 188
SocketListener class 125, 133
software accidents 72
software, testing 71
sortHTMLTable tag 228
SortHtmlTableTag class 228
SQL
commands 210
queries 189, 208211
statements 208
standard output 8
start target 319
stateless session beans 283
Statement class 248
static modifier 294
stepwise refinement 68
stop target 319
stored procedures 242
strategies/techniques for testing
adjusting build failure criteria 79
Cactus in-container 167, 213214
choosing an appropriate 260264
creating a component class 249
creating a wrapper class 249
database access layer 244
exploring alternative 58
faηade 283284
factory class 285, 293, 303, 312
factory method 285, 289, 303, 309, 312
mock 297
mock JNDI 285, 297307, 309, 312
mock object 140141, 151, 213, 313
stubbing 120121, 124, 138
stress/load testing 7175, 261
Strong, William 188
Struts 40, 77, 199, 219
StubHttpURLConnection class 136
StubHttpURLStreamHandler class 134
stubs
choosing 124125
compared to mock objects 120, 138, 141, 144
creating sophisticated tests with 64
how to use 121
overview 120121
pros and cons 121
replacing real code with 122
sample use of 121124
stubbing connections 134138
stubbing web servers resources 126134
when to use 121, 138
white box testing and 81
StubStreamHandlerFactory class 134
subclasses, replacing with collaborators 156
suite method 34
Swing applications 283
 
T
 
tag life cycle testing method 227228, 230233
taglibs (tag libraries) 188, 216
Body tag container life cycle 230
EJB calling with 314
unit testing with Cactus 224233
unit testing with mock objects 233237
TagSupport class 225
TDD (Test Driven Development)
automatic documentation 69
avoiding interface overdesign with 44
best practice principle using 60
core tenets 83
defined 81
design process 82
effective adjustment to conventional development cycle 82
elimination of refactoring code in unit testing enabling with 164
initial step of 89
reference book about 164
Test First 189
writing tests before writing code 189
teams, working with 120, 140
tearDown method 126130
terrific trio 1819
Test class, writing the 131
Test Driven Development (TDD) See TDD (Test Driven Development)
test runners 1112, 21, 2627, 277
TestableJdbcDataAccessManager class 249
TestableOrderEJB 311
TestablePetstoreEJB class 291292
TestableWebClient class 154
TestAccount 82
TestAccount class 82
TestAccountService 144
TestAccountService class 144
testAddHandler method 52
TestAdminServlet 190, 200
TestAdminServlet class 192, 196, 199, 219
TestAdminServletDynaMock 246
TestAdminServletMO class 205
TestAll class 24
TestCalculator class 13, 34
TestCalculator program 18, 22, 25
TestCalculator walk-through 33
TestCallView 201
TestCase class 61
TestCases 131
collecting results from 25
defined 20
extending from JUnit 13
extracting from JUnit 13
fixtures and 29
for PetStoreEJB 295
grouping for performance 277
how to group 22
objects, adding to Test Suites 18, 25
requirements for 29
running several at once 18
test interface and 23
TestSampleServletIntegration 180
typical 29
working with 2832
writing the 299303
TestClass constructors version 3.8.1 16, 22
testCreateOrderOk method 299
testCreateOrderThrowsCreateException method 306
testCreateOrderThrowsException method 306
testCreateThrowsOrderException method 299
TestCustomerAll 277
TestCustomerAll class 277
TestDefaultController class 46, 4957, 101, 114
Test-Driven Development (TDD)
failures and 192
TestDynaPropertiesMO 234
TestDynaPropertiesTag class 227
TestExceptionHandler class 57
testExecuteCloseConnectionOnException 258
testExecuteOk method 256
TestFailure class 25
testGetBalanceOk method 82
testGetContentOk class 153
testGetContentOk method 154, 158, 161162
TestGetContentOkHandler class 127, 129
testGetOrderHomeFromCache method 306
test-infected programs 4, 45, 70
testing
as first customer 62
challenges 120
components 167
database access 241
database logic 241
effectiveness 102
fine-grained 164, 173
in isolation 129, 150, 164
inside the container 167
live database 260
outside the container 167
performance turning 275
prime objective 214
strategies 121
TestJdbcDataAccessManagerIC 261
TestJdbcDataAccessManagerIC2 276
TestJdbcDataAccess-ManagerMO1 class 250
TestJdbcDataAccess-ManagerMO3 255
TestOrderEJB 311, 328
TestOrderProcessorMDB 309
TestOrderUtil class 305
TestPetStoreEJB 299
TestPetstoreEJB class 292, 295, 325
TestPetstoreEJB.java file 315
testProcessRequest method 52, 54
TestRequest class 5758
constructor 59
TestRequestHandler 57
TestResponse class 49, 51, 54
TestResult 25, 27
TestRunner class 18, 20, 180
TestRunners
Cactus and 174, 180
combining with a TestSuite 24
defined 19
defining 21
failures and 2526
launching tests with 2021
read-only database data and 277
running graphical and text 11
selecting 20
tests
comparison of 172
composit and command patterns and 25
coverage 67, 7980
fine-grained 164
folders 64
simulation cases 293
targets 93, 96, 101, 273, 321
types of 7177, 172
TestSampleServlet 168
TestSampleServletIntegration class 173, 180
TestSetup 128131, 134, 145, 275276, 297299
TestSetup class 129
TestSortHtmlTableTag 230
testSubtract method 23
TestSuite class 18, 2123, 131
TestSuites
composing tests with 2125
customizing 2325
defined 1920
TestCustomerAll 277
TestJdbcDataAccessManager 276
TestSetup and 128
TestWebClient1 131
TestWebClient class 134, 137, 150, 158
TestWebClient test case 122
TestWebClient1 class 131
TestWebClientSetup1 class 129, 131
TestWebClientSkeleton class 126
TestWebSetup1 class 132
TextPad 112
Tomcat 171, 192, 273
too simple to break 7, 228
tools for analysis and reporting 79
transfer method 144
transparency 123
trap doors 148, 151
trial and error 250
triggers 242
try/catch block 10, 61
try/finally block 258
 
U
 
UML 33
unit of work 5, 7
unit testing
application life cycle 76
as first-class users 146
co-dependent tests, problems with 32
core tenet of 7
defined 6
description of a typical 6
drawbacks of 166
flavors 76
functional 7677
integration 76
interaction 76
logic 76
need for 6669
old school 146
running 20
UNIX 91, 103
updateAccount method 144
URL interface unavailability 153
URLConnection interface 123
URLStreamHandler class 134
URLStreamHandlerFactory class 134
 
V
 
verify method 256
version attribute 330
 
W
 
War plugin 222
war target 268
wars, creating 268
web application 222
web servers 124
WebClass methods
getContent 150
WebClient
refactored using ConnectionFactory 156
refactored using MockConnectionFactory 158
testing for failure conditions 132133
verification for failure conditions 126
WebClient methods
getContent 122, 150, 158
getHttpConnection 154
setHttpURLConnection 154
WebLogic 273
WebRequest class 224
WebResponse class 219, 224, 232
white box testing 76, 78, 81
Windows 91, 103
Wirth, Nikolas 68
writing a failing test 83
 
X
 
XDoclet 282, 318
XP2000 140
xPetstore application
web site 282
XSL stylesheet 99
xUnit 5
 
Y
 
YAGNI 68
DESCRIPTION
Developers in the know are switching to a new testing strategy - unit testing - which interleaves coding and testing in an integrated way. This has proven to be a powerful combination that results in better designed software with fewer defects and faster delivery cycles.
JUnit in Action shows you how to benefit from this strategy using the popular open source testing framework, JUnit. It's a no fluff discussion of unit testing techniques and best practices. It gives examples of tough situations such as how to unit test EJBs, database applications, JSPs and Taglibs. It discusses unit testing of J2EE applications, and shows how to test in automated builds.
What's Inside
- Testing in isolation with mock objects
- In-container testing with Cactus
- Automated builds with Ant and Maven
- Unit testing from within Eclipse
- Test Driven Development principles
- Unit testing
- Java apps
- Servlets
- JSP
- Taglibs
- Filters
- EJB
- DB apps
More Information
If you have questions about JUnit in Action, please use the following mailing lists or forums:- For questions related purely to the book itself or for any other questions, please use the Manning Author Online Forum.
- For questions related to the book's source code, please use the SourceForge forum.
- For questions related to JUnit, please use the JUnit mailing list on YahooGroups.
- For questions related to Cactus, please use the Cactus mailing list.
- For questions related to Maven, please use the Maven mailing list.
WHAT THE READERS SAY ABOUT THIS BOOK...
"There are a lot of poorly written books out there. Some are just plain wrong and others just barely manage to solve the problem, but don't go much further than that. With a number of the Manning books I can see myself start to think differently about the problems and so I end up being a better developer. The JUnit in Action book was like that for me. At first it bothered me that I was changing my code in order to test it, but then I started seeing that the changes made the code better overall. Now my code is littered with factory methods and similar structures.
You guys are doing good stuff."
-- Joshua Smith, a reader
"The book is liberally sprinkled with JUnit best practices that every reader should take to heart. The examples are clear and real world. The author addresses the complex issues of unit testing EJBs, and web apps head on. He does not shy away from the real issues that come with testing these kinds of applications."
-- Wade Matveyenko, A Reader
ABOUT THE AUTHORS...
Vincent Massol is Chief Technology Officer of Pivolis which specializes in agile offshore software development.. Vince is an active member of the Maven, Gump and MockObjects development teams and the creator of the Jakarta Cactus testing framework. He lives in the City of Light, Paris, France.
Ted Husted is the lead author of Struts in Action.

