1 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 53 public class TestWorkplace extends OpenCmsTestCase { 54 55 60 public TestWorkplace(String arg0) { 61 62 super(arg0); 63 } 64 65 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 100 public void testGalleryClassCreation() throws Exception { 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 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 e) { 138 error = false; 139 } 140 if (error) { 141 fail("Null gallery instance class could be created"); 142 } 143 } 144 }
| Popular Tags
|