1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.pluto.descriptors.services.impl;
17
18 import java.io.InputStream;
19 import java.io.IOException;
20 import java.io.OutputStream;
21 import java.io.ByteArrayInputStream;
22 import java.io.ByteArrayOutputStream;
23
24 import junit.framework.TestCase;
25 import org.apache.pluto.descriptors.portlet.PortletAppDD;
26 import org.apache.pluto.descriptors.portlet.PortletDD;
27
28 /***
29 *
30 * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
31 * @version 1.0
32 * @since Mar 23, 2005
33 */
34 public class AbstractPortletAppDescriptorServiceTest extends TestCase {
35
36 private AbstractPortletAppDescriptorService service;
37
38 public AbstractPortletAppDescriptorServiceTest() {
39
40 }
41
42 public void setUp() {
43 service = new ServiceImpl();
44 }
45
46 public void tearDown() {
47 service = null;
48 }
49
50 public void testPortletCount() throws IOException {
51 PortletAppDD dd = service.read();
52 assertEquals(dd.getPortlets().size(), 2);
53 }
54
55 public void testPortletNames() throws IOException {
56 PortletAppDD dd = service.read();
57 assertNotNull(dd.getPortlet("TestPortlet1"));
58 assertNotNull(dd.getPortlet("TestPortlet2"));
59 }
60
61 public void testPortletClassNames() throws IOException {
62 PortletAppDD app = service.read();
63 PortletDD dd = app.getPortlet("TestPortlet1");
64 assertEquals(dd.getPortletClass(),
65 "org.apache.pluto.portalImpl.portlet.TestPortlet");
66 }
67
68 public class ServiceImpl extends AbstractPortletAppDescriptorService {
69
70 public ServiceImpl() {
71 super("test-context");
72 }
73
74 protected InputStream getInputStream() throws IOException {
75 return new ByteArrayInputStream(XML.getBytes());
76 }
77
78 protected OutputStream getOutputStream() throws IOException {
79 return new ByteArrayOutputStream();
80 }
81 }
82
83 public static final String XML =
84 "<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\" "+
85 "version=\"1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
86 "xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd "+
87 "http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\">"+
88 "<portlet>"+
89 "<description>Test #1</description>"+
90 "<portlet-name>TestPortlet1</portlet-name>"+
91 "<display-name>Test Portlet #1</display-name>"+
92 "<portlet-class>org.apache.pluto.portalImpl.portlet.TestPortlet</portlet-class>"+
93 "<init-param>"+
94 " <name>config</name>"+
95 " <value>/WEB-INF/testsuite-config.xml</value>"+
96 "</init-param>"+
97 "</portlet>"+
98 "<portlet>"+
99 "<description>TestSuiteDescription</description>"+
100 "<portlet-name>TestPortlet2</portlet-name>"+
101 "<display-name>Test Portlet #1</display-name>"+
102 "<portlet-class>org.apache.pluto.portalImpl.portlet.TestPortlet</portlet-class>"+
103 "<init-param>"+
104 " <name>config</name>"+
105 " <value>/WEB-INF/testsuite-config.xml</value>"+
106 "</init-param>"+
107 "</portlet>"+
108 "</portlet-app>";
109 }
110