KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > setup > PortalCmsSetupTestCase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.setup;
10
11 import junit.framework.TestCase;
12 import junit.framework.Assert;
13 import org.jboss.portal.cms.CMS;
14 import org.jboss.portal.setup.config.CmsAccessConfig;
15 import org.jboss.portal.setup.impl.config.CmsAccessConfigImpl;
16 import org.jboss.portal.setup.impl.dl.cmsloader.CmsDataLoaderConfig;
17 import org.jboss.portal.setup.impl.dl.cmsloader.CmsDataLoader;
18 import org.jboss.portal.setup.impl.CMSSetupImpl;
19 import org.jboss.portal.setup.dl.DataLoaderConfig;
20 import org.w3c.dom.Document JavaDoc;
21 import org.w3c.dom.Element JavaDoc;
22
23 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
24 import java.io.InputStream JavaDoc;
25
26 /**
27  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
28  * Date: May 3, 2005; Time: 12:22:23 AM
29  * @since JBoss portal 2.0
30  * Class org.jboss.portal.test.setup.PortalCmsSetupTestCase
31  */

32 public class PortalCmsSetupTestCase extends TestCase
33 {
34    public PortalCmsSetupTestCase(String JavaDoc name)
35    {
36       super(name);
37    }
38
39    private CMS m_cms;
40
41    private CmsAccessConfig m_accessConfig = new CmsAccessConfigImpl();
42    private DataLoaderConfig m_dlConfig = new CmsDataLoaderConfig();
43    private CmsSetupWrapper m_cmsSetup = null;
44
45    protected void setUp() throws Exception JavaDoc
46    {
47       setUpCms();
48       m_dlConfig.setDataLoaderClass(CmsDataLoader.class.getName());
49       m_dlConfig.setDataQueryString("/files/default");
50       m_cmsSetup = new CmsSetupWrapper();
51       m_cmsSetup.setCmsAccessConfig(this.m_accessConfig);
52       m_cmsSetup.setDataLoaderConfig(this.m_dlConfig);
53       m_cmsSetup.setDataFileLocation(null);
54
55    }
56
57    public void testCmsSetup()
58    {
59       try
60       {
61          m_cmsSetup.startService();
62       }
63       catch (Exception JavaDoc ex)
64       {
65          System.out.println("Got exception");
66          ex.printStackTrace();
67          Assert.assertTrue(false);
68       }
69    }
70
71    protected void tearDown() throws Exception JavaDoc
72    {
73       if (m_cmsSetup != null)
74       {
75          m_cmsSetup.stopService();
76          m_cmsSetup = null;
77       }
78       m_cms.destroyService();
79    }
80
81    private void setUpCms() throws Exception JavaDoc
82    {
83       ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
84       InputStream JavaDoc in = loader.getResourceAsStream("test/setup/domain.xml");
85       Document JavaDoc doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
86       Element JavaDoc elt = doc.getDocumentElement();
87       m_cms = new CMS();
88       m_cms.setConfig(elt);
89       m_cms.createService();
90       m_cms.startService();
91
92
93    }
94
95    class CmsSetupWrapper extends CMSSetupImpl
96    {
97       CmsSetupWrapper()
98       {
99          super();
100       }
101
102       protected void startService() throws Exception JavaDoc
103       {
104          super.startService();
105       }
106
107       protected void stopService() throws Exception JavaDoc
108       {
109          super.stopService();
110       }
111    }
112
113 }
114
Popular Tags