Java Reference
In-Depth Information
Duplicate managed bean declarations
■
Various
JSF
tag problems
■
Wrong-navigation problems
■
JSFU
nit static analysis can solve all of these problems, as demonstrated in listing 15.8.
Listing 15.8
Static analysis for your faces-config.xml
[...]
public class
FacesConfigTestCase
extends
AbstractFacesConfigTestCase {
B
C
private static
Set<String> paths =
new
HashSet<String>()
{
{
add( "src/main/webapp/WEB-INF/faces-config.xml" );
}
};
public
FacesConfigTestCase()
{
super
( paths );
}
}
First, we extend the
JSFU
nit class
AbstractFacesConfigTestCase
B
, and then we cre-
ate a
Set
of
String
s to hold the paths to our faces-config.xml files
C
and call the
constructor of the base class with the
Set
D
.
JSFU
nit will parse the config files we've
specified, and it will check the following:
D
That all of our session and application scope beans are serializable
■
That all of our managed beans are in a valid scope
■
Whether we have missing managed beans
■
Whether we're using the right
faces.config
class inheritance
■
For missing setter methods and for duplicate managed beans
■
Next, we create tests.
15.4
Strategies for testing JSF applications
The problems that might occur when developing
JSF
applications have different
approaches for solving them. Let's try to categorize the various ways to test a
JSF
application.
15.4.1
Black box approach
This is probably the most straightforward approach.
2
With
JSF
applications, a form of
black box testing would be to open a web browser and start clicking pages to verify
that everything works as expected. One way to automate black box testing would be to
2
We highly recommend you read chapter 5 before continuing with this section.