KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > CatalogTest


1 /*
2  * Created on Jun 9, 2005
3  */

4 package com.openedit.store;
5
6 import com.openedit.WebPageRequest;
7 import com.openedit.modules.cart.CatalogModule;
8 import com.openedit.users.filesystem.FileSystemGroup;
9 import com.openedit.webui.tree.WebTree;
10
11
12 /**
13  * @author cburkey
14  *
15  */

16 public class CatalogTest extends StoreTestCase
17 {
18     /**
19      * @param inArg0
20      */

21     public CatalogTest(String JavaDoc inArg0)
22     {
23         super(inArg0);
24     }
25
26     public void testCatalogOptions() throws Exception JavaDoc
27     {
28         Category blank = getStore().getCatalogArchive().addCatalog( "GOODSTUFF","Some Good Stuff");
29         getStore().getCatalogArchive().saveCatalog( blank );
30
31         Category cat = getStore().getCatalog("GOODSTUFF");
32         cat.clearOptions();
33         
34         Option oneOption = new Option();
35         oneOption.setId("one");
36         oneOption.setName("Another");
37         cat.addOption(oneOption);
38         
39         getStore().getCatalogArchive().saveCatalogs();
40         
41         cat = getStore().getCatalog("GOODSTUFF");
42         Option one = cat.getOption("one");
43         assertNotNull(one);
44     }
45
46     public void testCatalogLimit() throws Exception JavaDoc
47     {
48         Category cat = getStore().getCatalog("LIMITGOODSTUFF");
49         if( cat == null)
50         {
51             cat = getStore().getCatalogArchive().addCatalog( "LIMITGOODSTUFF","Some Good Stuff");
52             getStore().getCatalogArchive().saveCatalog( cat );
53         }
54         CatalogModule mod = (CatalogModule)getFixture().getModuleManager().getModule("CatalogModule");
55         
56         WebPageRequest req = getFixture().createPageRequest("/store/categories/index.html");
57         
58         FileSystemGroup g = new FileSystemGroup();
59         g.setName("junk");
60         g.addPermission("limittocategory:LIMITGOODSTUFF");
61         req.getUser().addGroup(g);
62         
63         req.setRequestParameter("root", "index");
64         req.setRequestParameter("tree-name", "test");
65         
66         WebTree tree = mod.getCatalogTree(req);
67         Object JavaDoc top = tree.getModel().getRoot();
68         int count = tree.getModel().getChildCount(top);
69         assertEquals(1,count);
70
71         req.getUser().removeGroup(g);
72         req.setRequestParameter("tree-name", "testfresh");
73         tree = mod.getCatalogTree(req);
74         top = tree.getModel().getRoot();
75         count = tree.getModel().getChildCount(top);
76         assertTrue("Should be more than 1 was " + count, count > 1);
77         
78
79     }
80
81     
82     /*
83     public void testCategory() throws Exception
84     {
85         Category blank = getStore().getCatalogArchive().addCatalog( "GOODSTUFF","Some Good Stuff");
86         List children = blank.getCategories();
87         
88     }
89     */

90 }
91
Popular Tags