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_cn
Articles_de
Articles_pt
Articles_zh
HibernateRelationshi...




JSPWiki v2.2.33

[RSS]


Hide Menu

HibernateRelationships


Difference between version 66 and version 65:

At line 321 added 1 line.
At line 343 added 66 lines.
!CategoryDaoTest
Next, create an ''CategoryDaoTest.java'' class in ''test/dao/**/dao''.
[{Java2HtmlPlugin
package org.appfuse.dao;
import org.appfuse.model.Category;
import org.springframework.dao.DataAccessException;
public class CategoryDaoTest extends BaseDaoTestCase {
private CategoryDAO catdao = null;
private Category category = null;
protected void setUp() throws Exception {
super.setUp();
catdao = (CategoryDAO) ctx.getBean("categoryDAO");
}
protected void tearDown() throws Exception {
super.tearDown();
catdao = null;
}
public void testGetCategory() throws Exception {
category = catdao.getCategory(new Long(1));
assertNotNull(category);
assertEquals("Struts v. Spring MVC", category.getCategoryName());
}
public void testUpdateCategory() throws Exception {
category = catdao.getCategory(new Long(2));
category.setCategoryName("Testing update category");
catdao.saveCategory(category);
assertEquals("Testing update category", category.getCategoryName());
}
public void testAddAndRemoveCategory() throws Exception {
category = new Category();
category.setCategoryName("Spaceman Biff");
category.setCategoryDescription("Paying homage to Calvin's alter ego!");
catdao.saveCategory(category);
assertNotNull(category.getCategoryDescription());
assertEquals("Spaceman Biff", category.getCategoryName());
catdao.removeCategory(category.getCategoryId());
try {
category = catdao.getCategory(category.getCategoryId());
fail("saveCategory didn't throw DataAccessException");
} catch (DataAccessException d) {
assertNotNull(d);
}
}
}
}]

Back to HibernateRelationships, or to the Page History.