KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > wsrp > test > TestWSRPSession


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  *
5  * Created on 11 janv. 2004
6  */

7 package org.exoplatform.services.wsrp.test;
8
9
10 import java.rmi.RemoteException JavaDoc;
11 import org.exoplatform.services.wsrp.type.*;
12
13 /**
14  * @author Mestrallet Benjamin
15  * benjmestrallet@users.sourceforge.net
16  */

17 public class TestWSRPSession extends BaseTest{
18
19   public TestWSRPSession(String JavaDoc s) {
20     super(s);
21   }
22
23   public void testSession() throws Exception JavaDoc {
24     ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest();
25     getServiceDescription.setDesiredLocales(new String JavaDoc[]{"en"});
26     ServiceDescription sd = serviceDescriptionInterface.getServiceDescription(getServiceDescription) ;
27     RegistrationContext rc = null;
28     if(sd.isRequiresRegistration())
29       rc = new RegistrationContext();
30     String JavaDoc 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 JavaDoc 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 JavaDoc {
48     ServiceDescriptionRequest getServiceDescription = new ServiceDescriptionRequest();
49     getServiceDescription.setDesiredLocales(new String JavaDoc[]{"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 JavaDoc 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 JavaDoc sessionID = response.getSessionContext().getSessionID();
63     ReleaseSessionsRequest releaseSessions = new ReleaseSessionsRequest();
64     releaseSessions.setRegistrationContext(rc);
65     releaseSessions.setSessionIDs(new String JavaDoc[]{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 JavaDoc e) {
74     }
75
76   }
77 }
78
Popular Tags