1 package net.sf.flock.hibernate;
2
3 import java.net.URL;
4 import java.util.Date;
5 import java.util.Properties;
6
7 import net.sf.flock.FeedI;
8 import net.sf.flock.MetaData;
9 import net.sf.flock.SubscriptionI;
10
11 import junit.framework.TestCase;
12
13 public class HibernateSubscriptionManagerTest extends TestCase {
14
15 private final static Properties PROPERTIES = new Properties();
16 static {
17 PROPERTIES.put("hibernate.dialect", "cirrus.hibernate.sql.HSQLDialect");
18 PROPERTIES.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
19 PROPERTIES.put("hibernate.connection.username", "sa");
20 PROPERTIES.put("hibernate.connection.password", "");
21 PROPERTIES.put("hibernate.connection.url", "jdbc:hsqldb:flocktest");
22
23 //PROPERTIES.put("hibernate.use_outer_join", "true");
24 PROPERTIES.put("hibernate.show_sql", "true");
25 }
26
27 public HibernateSubscriptionManagerTest(String name) {
28 super(name);
29 }
30
31 public void testPersistence() throws Exception {
32 Subscription sub = new Subscription();
33 sub.setLocation(new URL("http://foo.net/feed.rss"));
34 MetaData md = new MetaData();
35 md.set("foo", "bar");
36 md.set("blah", "blah");
37 sub.setMetaData(md);
38
39 Feed f = new Feed();
40 f.setSite(new URL("http://foo.net"));
41 f.setTitle("Test title");
42 f.newItem(new Date(), "test item", "Test description blah", new URL("http://foo.net/blah1"));
43 f.newItem(new Date(), "second test item", "Test description blah", new URL("http://foo.net/blah2"));
44
45 sub.setFeed(f);
46
47 HibernateSubscriptionManager mgr = new HibernateSubscriptionManager( PROPERTIES );
48 mgr.storeSubscription(sub);
49
50 SubscriptionI loadedSub = mgr.loadSubscription(new URL("http://foo.net/feed.rss"));
51
52 assertEquals(sub.getLocation(), loadedSub.getLocation());
53 assertEquals("bar", loadedSub.getMetaData().get("foo"));
54 assertEquals("blah", loadedSub.getMetaData().get("blah"));
55
56 FeedI loadedFeed = loadedSub.getFeed();
57 assertEquals(f.getTitle(), loadedFeed.getTitle());
58 assertEquals(f.getSite(), loadedFeed.getSite());
59 }
60
61 }
This page was automatically generated by Maven