Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_pt
CreateActions
CreateDAO
CreateDAO_sp
CreateDAOiBATIS
CreateDAOiBATIS_ko
CreateManager_es
JSFBeans
SpringControllers
...and 3 more




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateManager


Difference between version 10 and version 9:

At line 64 changed 1 line.
;;''...we create methods that begin with "test" (all lower case). As long as these methods are public, have a void return type and take no arguments, they will be called by our <junit> task in our Ant build.xml file. Here's some simple tests for testing CRUD. An important thing to remember is that each method (also known as a test), should be autonomous.''
;:''...we create methods that begin with "test" (all lower case). As long as these methods are public, have a void return type and take no arguments, they will be called by our <junit> task in our Ant build.xml file. Here's some simple tests for testing CRUD. An important thing to remember is that each method (also known as a test), should be autonomous.''
At line 66 changed 1 line.
Add the following methods to your PersonDaoTest.java file:
Add the following methods to your PersonManagerTest.java file:
{{{
public void testGetPerson() throws Exception {
personForm = (PersonForm) mgr.getPerson("1");
At line 71 added 48 lines.
if (log.isDebugEnabled()) {
log.debug(personForm);
}
assertTrue(personForm != null);
assertTrue(personForm.getRoles().size() == 1);
}
public void testSavePerson() throws Exception {
personForm = (PersonForm) mgr.getPerson("1");
personForm.setFirstName("Joe");
if (log.isDebugEnabled()) {
log.debug("saving person with updated firstName: " + personForm);
}
personForm = (PersonForm) mgr.savePerson(personForm);
assertTrue(personForm.getFirstName().equals("Joe"));
}
public void testAddAndRemovePerson() throws Exception {
personForm = new PersonForm();
// call populate method in super class to populate test data
// from a properties file matching this class name
personForm = (PersonForm) populate(personForm);
personForm = (PersonForm) mgr.savePerson(personForm);
assertTrue(personForm.getLastName().equals("Raible"));
if (log.isDebugEnabled()) {
log.debug("removing person...");
}
mgr.removePerson(personForm);
try {
personForm = (PersonForm) mgr.getPerson("1");
fail("Expected 'Exception' not thrown");
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(e);
}
assertTrue(e != null);
}
}
}}}

Back to CreateManager, or to the Page History.