HibernateCollectionAdapter extends BasicAdapter { @Override public Entry createEntry(Entry entry) throws Exception { Session session = getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); Serializable entryId = null; try { Object mapping = collectMappingObject(entry, null); entryId = session.save(mapping); tx.commit(); } catch (Exception ex) { tx.rollback(); logger.error("error creating a new entry", ex); } finally { session.close(); } return getEntry(entryId); } HibernateCollectionAdapter(Abdera abdera, FeedConfiguration config); @Override Entry createEntry(Entry entry); @Override boolean deleteEntry(Object entryId); @Override Entry getEntry(Object entryId); @Override Feed getFeed(); @Override Entry updateEntry(Object entryId, Entry entry); static final String HIBERNATE_ANNOTATION_CONFIG; static final String HIBERNATE_CFG_PATH; static final String ENTRY_MAPPING_CLASS_NAME; }
@Test public void testCreateEntry() { Entry entry = abdera.newEntry(); entry.setId("foo"); entry.setTitle("test entry"); entry.setContent("Test Content"); entry.addLink("http: entry.setUpdated(new Date()); entry.addAuthor("david"); ClientResponse resp = client.post("http: assertNotNull(resp); assertEquals(ResponseType.SUCCESS, resp.getType()); assertEquals(201, resp.getStatus()); assertEquals("http: resp = client.get("http: Document<Feed> feed_doc = resp.getDocument(); Feed feed = feed_doc.getRoot(); assertEquals(feed.getEntries().size(), 1); resp.release(); }