Package com.apress.prospring.domain

Examples of com.apress.prospring.domain.Entry


  public void testTransaction2() {
    blogManager.setAuditService(new MockAuditService());
   
    int countBefore = blogManager.getAllEntries().size();

    Entry e = new Entry();
    e.setSubject("Tester");
    e.setBody("Body");
    e.setPostDate(new Date());

    try {
      blogManager.saveEntry(e, null);
      fail("Should have thrown RuntimeException");
    } catch (RuntimeException ex) {
View Full Code Here


        DefaultBlogManager bm = (DefaultBlogManager) ctx.getBean("blogManager");
        bm.setAuditService(new MockAuditService());

        int countBefore = bm.getAllEntries().size();

        Entry e = new Entry();
        e.setSubject("Tester");
        e.setBody("Body");
        e.setPostDate(new Date());

        try {
            bm.saveEntry(e, null);
            fail("Should have thrown RuntimeException");
        } catch (RuntimeException ex) {
View Full Code Here

    auditService = new MockAuditService();
    bm.setAuditService(auditService);
  }

  public void testSaveEntry() {
    bm.saveEntry(new Entry(), null);
    performAssert();
  }
View Full Code Here

    bm.setCommentDao(commentDao);
    bm.setEntryDao(entryDao);
  }

  public void testSaveEntry() {
    Entry entry = new Entry();
    auditService.writeAuditMessage("Entry " + entry + " saved", null);
    auditServiceControl.replay();
    bm.saveEntry(entry, null);
  }
View Full Code Here

   */
  public void testGetAll() {
    List entries = getDao().getAll();
    assertNotNull(entries);
    for (Iterator i = entries.iterator(); i.hasNext();) {
      Entry e = (Entry)i.next();
      assertNotNull(e);
    }
  }
View Full Code Here

   * Tests insert and delete
   *
   */
  public void testInsertDelete() {
    int all = count();
    Entry e = new Entry();
    e.setBody("body");
    e.setPostDate(new Date());
    e.setSubject("subject");
   
    getDao().save(e);
    assertEquals(all + 1, count());
    assertTrue(e.getEntryId() > 0);
   
    getDao().delete(e.getEntryId());
   
    assertEquals(all, count());
  }
View Full Code Here

  /**
   * Tests insert, update and delete
   *
   */
  public void testIUD() {
    Entry e = new Entry();
    e.setBody("body");
    e.setPostDate(new Date());
    e.setSubject("subject");
   
    getDao().save(e);
    assertTrue(e.getEntryId() > 0);
   
    Entry e2 = getDao().getById(e.getEntryId());
    assertEquals(e.getEntryId(), e2.getEntryId());
    assertEquals(e.getBody(), e2.getBody());
    assertEquals(e.getSubject(), e2.getSubject());
    assertEquals(e.getPostDate().getTime(), e2.getPostDate().getTime(), 1000);
   
    Date newDate = new Date(e.getPostDate().getTime() - 1000);
    e2.setSubject("foo");
    e2.setBody("bar");
    e2.setPostDate(newDate);
   
    getDao().save(e2);
   
    Entry e3 = getDao().getById(e2.getEntryId());
    assertEquals(e.getEntryId(), e3.getEntryId());
    assertEquals("bar", e3.getBody());
    assertEquals("foo", e3.getSubject());
    assertEquals(newDate.getTime(), e3.getPostDate().getTime(), 1000);

    getDao().delete(e3.getEntryId());
  }
View Full Code Here

    public List getAllEntries() {
        return entryDao.getAll();
    }

    public Entry getEntry(int entryId) {
        Entry entry = entryDao.getById(entryId);
        // entry.setAttachments(attachmentDao.getByEntry(entryId));
       
        return entry;
    }
View Full Code Here

  /* (non-Javadoc)
   * @see com.apress.prospring.data.EntryDao#save(com.apress.prospring.domain.Entry)
   */
  public void save(Entry entry) {
    Entry ex = new Entry();
    ex.setEntryId(entry.getEntryId());
    ex.setBody(entry.getBody());
    ex.setEntryId(entry.getEntryId());
    ex.setPostDate(entry.getPostDate());
    ex.setSubject(entry.getSubject());
    getHibernateTemplate().saveOrUpdate(ex);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.apress.prospring.data.EntryDao#delete(int)
   */
  public void delete(int entryId) {
    Entry entry = new Entry();
    entry.setEntryId(entryId);
    getHibernateTemplate().delete(entry);
  }
View Full Code Here

TOP

Related Classes of com.apress.prospring.domain.Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.