001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.wsrp;
023:
024: import javax.naming.InitialContext;
025: import javax.naming.NamingException;
026: import javax.xml.rpc.Service;
027:
028: import junit.framework.Test;
029:
030: import org.jboss.test.webservice.WebserviceTestBase;
031: import org.jboss.test.wsrp.core.ClonePortlet;
032: import org.jboss.test.wsrp.core.DestroyPortlets;
033: import org.jboss.test.wsrp.core.DestroyPortletsResponse;
034: import org.jboss.test.wsrp.core.Extension;
035: import org.jboss.test.wsrp.core.GetPortletDescription;
036: import org.jboss.test.wsrp.core.GetPortletProperties;
037: import org.jboss.test.wsrp.core.GetPortletPropertyDescription;
038: import org.jboss.test.wsrp.core.PortletContext;
039: import org.jboss.test.wsrp.core.PortletDescriptionResponse;
040: import org.jboss.test.wsrp.core.PortletPropertyDescriptionResponse;
041: import org.jboss.test.wsrp.core.PropertyList;
042: import org.jboss.test.wsrp.core.RegistrationContext;
043: import org.jboss.test.wsrp.core.SetPortletProperties;
044: import org.jboss.test.wsrp.core.UserContext;
045: import org.jboss.test.wsrp.core.UserProfile;
046:
047: //$Id: PortletManagementTestCase.java 57211 2006-09-26 12:39:46Z dimitris@jboss.org $
048:
049: /**
050: * Test Case that tests WSRP Portlet Management
051: * @author <a href="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
052: * @since Mar 27, 2006
053: * @version $Revision: 57211 $
054: */
055: public class PortletManagementTestCase extends WebserviceTestBase {
056: public PortletManagementTestCase(String name) {
057: super (name);
058: }
059:
060: /**
061: * deploy the test archives
062: */
063: public static Test suite() throws Exception {
064: return getDeploySetup(PortletManagementTestCase.class,
065: "wsrp.war, wsrp-client.jar");
066: }
067:
068: public void testGetPortletDescription() throws Exception {
069: Service service = getService();
070: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
071: .getPort(WSRP_v1_PortletManagement_PortType.class);
072: GetPortletDescription ic = new GetPortletDescription(
073: new RegistrationContext(), new PortletContext(
074: "portletHandle", "portletState".getBytes(),
075: new Extension[] {}), new UserContext(
076: "userContextKey", new String[] {},
077: new UserProfile(), new Extension[] {}),
078: new String[] {});
079: //Invoke the Web Service
080: PortletDescriptionResponse ra = endpoint
081: .getPortletDescription(ic);
082: assertNotNull("PortletDescriptionResponse != null", ra);
083: }
084:
085: public void testGetPortletDescriptionDynamicEndpoint()
086: throws Exception {
087: Service service = getService();
088: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
089: .getPort(WSRP_v1_PortletManagement_PortType.class);
090: ((javax.xml.rpc.Stub) endpoint)._setProperty(
091: "javax.xml.rpc.service.endpoint.address", "http://"
092: + getServerHost()
093: + ":8080/wsrp/PortletManagementService");
094:
095: GetPortletDescription ic = new GetPortletDescription(
096: new RegistrationContext(), new PortletContext(
097: "portletHandle", "portletState".getBytes(),
098: new Extension[] {}), new UserContext(
099: "userContextKey", new String[] {},
100: new UserProfile(), new Extension[] {}),
101: new String[] {});
102: //Invoke the Web Service
103: PortletDescriptionResponse ra = endpoint
104: .getPortletDescription(ic);
105: assertNotNull("PortletDescriptionResponse != null", ra);
106: }
107:
108: public void testClonePortlet() throws Exception {
109: Service service = getService();
110: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
111: .getPort(WSRP_v1_PortletManagement_PortType.class);
112: ClonePortlet cp = new ClonePortlet(new RegistrationContext(),
113: new PortletContext(), new UserContext());
114: //Invoke the Web Service
115: PortletContext ra = endpoint.clonePortlet(cp);
116: assertNotNull("PortletContext != null", ra);
117: }
118:
119: public void testDestroyPortlets() throws Exception {
120: Service service = getService();
121: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
122: .getPort(WSRP_v1_PortletManagement_PortType.class);
123: DestroyPortlets cp = new DestroyPortlets(
124: new RegistrationContext(), new String[] {});
125: //Invoke the Web Service
126: DestroyPortletsResponse ra = endpoint.destroyPortlets(cp);
127: assertNotNull("DestroyPortletsResponse != null", ra);
128: }
129:
130: public void testSetPortletProperties() throws Exception {
131: Service service = getService();
132: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
133: .getPort(WSRP_v1_PortletManagement_PortType.class);
134: SetPortletProperties cp = new SetPortletProperties(
135: new RegistrationContext(), new PortletContext(),
136: new UserContext(), new PropertyList());
137: //Invoke the Web Service
138: PortletContext ra = endpoint.setPortletProperties(cp);
139: assertNotNull("PortletContext != null", ra);
140: }
141:
142: public void testGetPortletProperties() throws Exception {
143: Service service = getService();
144: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
145: .getPort(WSRP_v1_PortletManagement_PortType.class);
146: GetPortletProperties cp = new GetPortletProperties(
147: new RegistrationContext(), new PortletContext(),
148: new UserContext(), new String[] {});
149: //Invoke the Web Service
150: PropertyList ra = endpoint.getPortletProperties(cp);
151: assertNotNull("PropertyList != null", ra);
152: }
153:
154: public void testGetPortletPropertyDescription() throws Exception {
155: Service service = getService();
156: WSRP_v1_PortletManagement_PortType endpoint = (WSRP_v1_PortletManagement_PortType) service
157: .getPort(WSRP_v1_PortletManagement_PortType.class);
158: GetPortletPropertyDescription cp = new GetPortletPropertyDescription(
159: new RegistrationContext(), new PortletContext(),
160: new UserContext(), new String[] {});
161: //Invoke the Web Service
162: PortletPropertyDescriptionResponse ra = endpoint
163: .getPortletPropertyDescription(cp);
164: assertNotNull("PortletPropertyDescriptionResponse != null", ra);
165: }
166:
167: private Service getService() throws NamingException {
168: InitialContext iniCtx = getClientContext("wsrp-client");
169: Service service = (Service) iniCtx
170: .lookup("java:comp/env/service/PortletManagementService");
171: return service;
172: }
173: }
|