View Javadoc
1 /*
2 * Created on Feb 21, 2003
3 *
4 * To change this generated comment go to
5 * Window>Preferences>Java>Code Generation>Code Template
6 */
7 package test.net.sf.fastxmldb;
8
9 import org.xmldb.api.base.Collection;
10 import org.xmldb.api.base.XMLDBException;
11
12 import net.sf.fastxmldb.impl.CollectionBroker;
13 import net.sf.fastxmldb.impl.LocalCollection;
14 import junit.framework.TestCase;
15
16 /***
17 * @author jbirchfield
18 */
19 public class CollectionBrokerTest extends TestCase {
20
21 private CollectionBroker instance = null;
22
23 /***
24 * Constructor for CollectionBrokerTest.
25 * @param arg0
26 */
27 public CollectionBrokerTest(String arg0) {
28 super(arg0);
29 }
30
31 /***
32 * @see TestCase#setUp()
33 */
34 protected void setUp() throws Exception {
35 super.setUp();
36 instance = CollectionBroker.getInstance();
37 //since this is a singleton, clear it out first
38 instance.clearCollections();
39 }
40
41 /***
42 * @see TestCase#tearDown()
43 */
44 protected void tearDown() throws Exception {
45 super.tearDown();
46 }
47
48 public void testGetCollection() {
49 String testName = "test";
50 Collection testCollection = new LocalCollection(testName);
51 try {
52 instance.addCollection(testCollection);
53 Collection retreivedCollection = instance.getCollection(testName);
54 assertEquals(testCollection, retreivedCollection);
55 } catch (XMLDBException e) {
56 fail(e.getMessage());
57 }
58 }
59
60 public void testAddCollection() {
61 instance.clearCollections();
62 String testName = "test";
63 Collection testCollection = new LocalCollection(testName);
64 try {
65 instance.addCollection(testCollection);
66 int collectionBrokerSize = instance.getCollectionCount();
67 //we expect 2 because there is always a default collection
68 assertEquals(collectionBrokerSize, 2);
69 } catch (XMLDBException e) {
70 fail(e.getMessage());
71 }
72 }
73
74 }
This page was automatically generated by Maven