KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > TestWorkplace


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/workplace/TestWorkplace.java,v $
3  * Date : $Date: 2005/06/23 14:27:27 $
4  * Version: $Revision: 1.9 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace;
33
34 import org.opencms.test.OpenCmsTestCase;
35 import org.opencms.test.OpenCmsTestProperties;
36 import org.opencms.workplace.galleries.A_CmsGallery;
37 import org.opencms.workplace.galleries.CmsDownloadGallery;
38 import org.opencms.workplace.galleries.CmsHtmlGallery;
39 import org.opencms.workplace.galleries.CmsImageGallery;
40 import org.opencms.workplace.galleries.CmsLinkGallery;
41
42 import junit.extensions.TestSetup;
43 import junit.framework.Test;
44 import junit.framework.TestSuite;
45
46 /**
47  * @author Alexander Kandzior
48  *
49  * @version $Revision: 1.9 $
50  *
51  * @since 6.0.0
52  */

53 public class TestWorkplace extends OpenCmsTestCase {
54
55     /**
56      * Default JUnit constructor.<p>
57      *
58      * @param arg0 JUnit parameters
59      */

60     public TestWorkplace(String JavaDoc arg0) {
61
62         super(arg0);
63     }
64
65     /**
66      * Test suite for this test class.<p>
67      *
68      * @return the test suite
69      */

70     public static Test suite() {
71
72         OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);
73
74         TestSuite suite = new TestSuite();
75         suite.setName(TestWorkplace.class.getName());
76
77         suite.addTest(new TestWorkplace("testGalleryClassCreation"));
78
79         TestSetup wrapper = new TestSetup(suite) {
80
81             protected void setUp() {
82
83                 setupOpenCms("simpletest", "/sites/default/");
84             }
85
86             protected void tearDown() {
87
88                 removeOpenCms();
89             }
90         };
91
92         return wrapper;
93     }
94
95     /**
96      * Tests dynamic creation of gallery classes.<p>
97      *
98      * @throws Exception in case the test fails
99      */

100     public void testGalleryClassCreation() throws Exception JavaDoc {
101
102         A_CmsGallery gallery;
103
104         gallery = A_CmsGallery.createInstance("imagegallery", null);
105         assertEquals(gallery.getClass().getName(), CmsImageGallery.class.getName());
106         assertEquals("imagegallery", gallery.getGalleryTypeName());
107         assertEquals(8, gallery.getGalleryTypeId());
108         
109         gallery = A_CmsGallery.createInstance("downloadgallery", null);
110         assertEquals(gallery.getClass().getName(), CmsDownloadGallery.class.getName());
111         assertEquals("downloadgallery", gallery.getGalleryTypeName());
112         assertEquals(9, gallery.getGalleryTypeId());
113         
114         gallery = A_CmsGallery.createInstance("linkgallery", null);
115         assertEquals(gallery.getClass().getName(), CmsLinkGallery.class.getName());
116         assertEquals("linkgallery", gallery.getGalleryTypeName());
117         assertEquals(10, gallery.getGalleryTypeId());
118         
119         gallery = A_CmsGallery.createInstance("htmlgallery", null);
120         assertEquals(gallery.getClass().getName(), CmsHtmlGallery.class.getName());
121         assertEquals("htmlgallery", gallery.getGalleryTypeName());
122         assertEquals(11, gallery.getGalleryTypeId());
123         
124         boolean error = true;
125         try {
126             A_CmsGallery.createInstance("unknowngallery", null);
127         } catch (RuntimeException JavaDoc e) {
128             error = false;
129         }
130         if (error) {
131             fail("Unknown gallery instance class could be created");
132         }
133
134         error = true;
135         try {
136             A_CmsGallery.createInstance(null, null);
137         } catch (RuntimeException JavaDoc e) {
138             error = false;
139         }
140         if (error) {
141             fail("Null gallery instance class could be created");
142         }
143     }
144 }
Popular Tags