KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > manager > TestPersistenceManagerConfig


1 //
2
// Informa -- RSS Library for Java
3
// Copyright (c) 2002 by Niko Schmuck
4
//
5
// Niko Schmuck
6
// http://sourceforge.net/projects/informa
7
// mailto:niko_schmuck@users.sourceforge.net
8
//
9
// This library is free software.
10
//
11
// You may redistribute it and/or modify it under the terms of the GNU
12
// Lesser General Public License as published by the Free Software Foundation.
13
//
14
// Version 2.1 of the license should be included with this distribution in
15
// the file LICENSE. If the license is not included with this distribution,
16
// you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17
// or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18
// MA 02139 USA.
19
//
20
// This library is distributed in the hope that it will be useful,
21
// but WITHOUT ANY WARRANTY; without even the implied waranty of
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
// Lesser General Public License for more details.
24
//
25
// $Id: TestPersistenceManagerConfig.java,v 1.2 2004/09/02 09:19:16 spyromus Exp $
26
//
27

28 package de.nava.informa.utils.manager;
29
30 import de.nava.informa.core.ChannelGroupIF;
31 import de.nava.informa.core.ChannelIF;
32 import de.nava.informa.core.ItemIF;
33 import junit.framework.TestCase;
34
35 import java.net.URL JavaDoc;
36
37 /**
38  * @author Aleksey Gureev (spyromus@noizeramp.com)
39  * @see PersistenceManagerConfig
40  */

41 public class TestPersistenceManagerConfig extends TestCase {
42   /**
43    * @see PersistenceManagerConfig#getPersistenceManager
44    * @see PersistenceManagerConfig#setPersistenceManagerClassName
45    */

46   public void testGetPersistenceManager() {
47     // JVM property isn't set - so the manager shouldn't be initialized by default.
48
assertNull(PersistenceManagerConfig.getPersistenceManager());
49
50     // Set the name of non-existing class and catch the exception.
51
try {
52       PersistenceManagerConfig.setPersistenceManagerClassName("badname");
53       fail("ClassNotFountException should be thrown.");
54     } catch (ClassNotFoundException JavaDoc e) {
55       // expected behavior
56
} catch (Exception JavaDoc e) {
57       fail("ClassNotFountException should be thrown.");
58     }
59
60     // Set the name of existing implementation class.
61
final String JavaDoc className = DummyPersistenceManager.class.getName();
62     try {
63       PersistenceManagerConfig.setPersistenceManagerClassName(className);
64       assertTrue(PersistenceManagerConfig.getPersistenceManager()
65         instanceof DummyPersistenceManager);
66
67     } catch (Exception JavaDoc e) {
68       e.printStackTrace();
69       fail("Unexpected exception.");
70     }
71   }
72
73   /**
74    * Empty implementation for test purpose only.
75    */

76   public static class DummyPersistenceManager implements PersistenceManagerIF {
77     /**
78      * Creates new group of channels in persistent storage.
79      *
80      * @param title title of the group.
81      * @return initialized and persisted group object.
82      */

83     public ChannelGroupIF createGroup(String JavaDoc title) {
84       return null;
85     }
86
87     /**
88      * Updates data in storage with data from the group object.
89      *
90      * @param group group object
91      */

92     public void updateGroup(ChannelGroupIF group) {
93     }
94
95     /**
96      * Deletes group from persistent storage.
97      *
98      * @param group group to delete.
99      */

100     public void deleteGroup(ChannelGroupIF group) {
101     }
102
103     /**
104      * Takes channels from the <code>second</code> group and put them all in <code>first</code>
105      * group. Then <code>second</code> group is deleted.
106      *
107      * @param first first group of channels.
108      * @param second second group of channels.
109      */

110     public void mergeGroups(ChannelGroupIF first, ChannelGroupIF second) {
111     }
112
113     /**
114      * Returns the list of groups available in database.
115      *
116      * @return list of groups.
117      */

118     public ChannelGroupIF[] getGroups() {
119       return new ChannelGroupIF[0];
120     }
121
122     /**
123      * Creates new channel object and persists it into storage.
124      *
125      * @param title title of the channel.
126      * @param location location of channel data resource.
127      * @return newly created object.
128      */

129     public ChannelIF createChannel(String JavaDoc title, URL JavaDoc location) {
130       return null;
131     }
132
133     /**
134      * Updates data in database with data from channel object.
135      *
136      * @param channel channel object.
137      */

138     public void updateChannel(ChannelIF channel) {
139     }
140
141     /**
142      * Adds <code>channel</code> to the <code>group</code>.
143      *
144      * @param channel channel to add.
145      * @param group group to use.
146      */

147     public void addChannelToGroup(ChannelIF channel, ChannelGroupIF group) {
148     }
149
150     /**
151      * Deletes <code>channel</code> from the <code>group</code>.
152      * This method doesn't delete channel from persistent storage. It only
153      * breaks the association between channel and group.
154      *
155      * @param channel channel to delete.
156      * @param group group to use.
157      */

158     public void removeChannelFromGroup(ChannelIF channel, ChannelGroupIF group) {
159     }
160
161     /**
162      * Deletes channel from persistent storage.
163      *
164      * @param channel channel to delete.
165      */

166     public void deleteChannel(ChannelIF channel) {
167     }
168
169     /**
170      * Creates new item in the channel.
171      *
172      * @param channel channel to put new item into.
173      * @param title title of new item.
174      * @return new item object.
175      */

176     public ItemIF createItem(ChannelIF channel, String JavaDoc title) {
177       return null;
178     }
179
180     /**
181      * Creates new item using specified object as ethalon.
182      *
183      * @param channel channel to put new item into.
184      * @param ethalon object to copy properties values from.
185      * @return new item object.
186      */

187     public ItemIF createItem(ChannelIF channel, ItemIF ethalon) {
188       return null;
189     }
190
191     /**
192      * Updates data in database with data from item object.
193      *
194      * @param item item object.
195      */

196     public void updateItem(ItemIF item) {
197     }
198
199     /**
200      * Deletes the item from the persistent storage.
201      *
202      * @param item item to delete.
203      */

204     public void deleteItem(ItemIF item) {
205     }
206   }
207 }
208
Popular Tags