1 7 package org.exoplatform.services.wsrp.test; 8 9 10 import java.rmi.RemoteException ; 11 import org.exoplatform.services.wsrp.type.*; 12 13 17 public class TestWSRPSession extends BaseTest{ 18 19 public TestWSRPSession(String s) { 20 super(s); 21 } 22 23 public void testSession() throws Exception { 24 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 25 getServiceDescription.setDesiredLocales(new String []{"en"}); 26 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 27 RegistrationContext rc = null; 28 if(sd.isRequiresRegistration()) 29 rc = new RegistrationContext(); 30 String portletHandle = "hello/PortletToTestSession"; 31 PortletContext portletContext = new PortletContext(); 32 portletContext.setPortletHandle(portletHandle); 33 portletContext.setPortletState(null); 34 markupParams.setMimeTypes(mimeTypes); 35 markupParams.setMode("wsrp:view"); 36 markupParams.setWindowState("wsrp:normal"); 37 MarkupRequest getMarkup = getMarkup(rc, portletContext); 38 MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup); 39 String sessionID = response.getSessionContext().getSessionID(); 40 runtimeContext.setSessionID(sessionID); 41 manageTemplatesOptimization(sd, portletHandle); 42 manageUserContextOptimization(sd, portletHandle, getMarkup); 43 response = markupOperationsInterface.getMarkup(getMarkup); 44 assertEquals("attribute set in first call", response.getMarkupContext().getMarkupString()); 45 } 46 47 public void testReleaseSession() throws RemoteException { 48 ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest(); 49 getServiceDescription.setDesiredLocales(new String []{"en"}); 50 ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ; 51 RegistrationContext rc = null; 52 if(sd.isRequiresRegistration()) 53 rc = new RegistrationContext(); 54 PortletContext portletContext = new PortletContext(); 55 String portletHandle = "hello/PortletToTestSession"; 56 portletContext.setPortletHandle(portletHandle); 57 markupParams.setMimeTypes(mimeTypes); 58 markupParams.setMode("wsrp:view"); 59 markupParams.setWindowState("wsrp:normal"); 60 MarkupRequest getMarkup = getMarkup(rc,portletContext); 61 MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup); 62 String sessionID = response.getSessionContext().getSessionID(); 63 ReleaseSessionsRequest releaseSessions = new ReleaseSessionsRequest(); 64 releaseSessions.setRegistrationContext(rc); 65 releaseSessions.setSessionIDs(new String []{sessionID}); 66 markupOperationsInterface.releaseSessions(releaseSessions); 67 runtimeContext.setSessionID(sessionID); 68 manageTemplatesOptimization(sd, portletHandle); 69 manageUserContextOptimization(sd, portletHandle, getMarkup); 70 try { 71 markupOperationsInterface.getMarkup(getMarkup); 72 fail("Session should not exist anymore"); 73 } catch (RemoteException e) { 74 } 75 76 } 77 } 78 | Popular Tags |