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 65 and version 64:

At line 271 added 71 lines.
!EntryDaoTest
Now, create an ''EntryDaoTest.java'' class. Again, create this class in ''test/dao/**/dao'' and fill it with the following code.
[{Java2HtmlPlugin
package org.appfuse.dao;
import java.sql.Timestamp;
import org.appfuse.model.Entry;
import org.springframework.dao.DataAccessException;
public class EntryDaoTest extends BaseDaoTestCase {
private EntryDAO edao = null;
private Entry entry = null;
protected void setUp() throws Exception {
super.setUp();
edao = (EntryDAO) ctx.getBean("entryDAO");
}
protected void tearDown() throws Exception {
super.tearDown();
edao = null;
}
public void testGetEntry() throws Exception {
entry = edao.getEntry(new Long(1));
assertNotNull(entry);
assertEquals("Testing", entry.getText());
}
public void testUpdateEntry() throws Exception {
entry = edao.getEntry(new Long(2));
entry.setText("Testing update entry");
entry.setCategoryId(new Long(2));
edao.saveEntry(entry);
assertEquals("Testing update entry", entry.getText());
}
public void testAddAndRemoveEntry() throws Exception {
entry = new Entry();
entry.setText("Testing add a new entry");
entry.setTimeCreated(new Timestamp(2004-04-02));
entry.setCategoryId(new Long(3));
entry.setWeblogId(new Long(1));
edao.saveEntry(entry);
assertNotNull(entry.getText());
assertEquals("Testing add a new entry", entry.getText());
edao.removeEntry(entry.getEntryId());
try {
entry = edao.getEntry(entry.getEntryId());
fail("saveEntry didn't throw DataAccessException");
} catch (DataAccessException d) {
assertNotNull(d);
}
}
}
}]

Back to HibernateRelationships, or to the Page History.