KickJava   Java API By Example, From Geeks To Geeks.

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


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

5
6 package org.exoplatform.services.wsrp.test;
7
8 import java.rmi.RemoteException JavaDoc;
9 import org.exoplatform.services.wsrp.WSRPConstants;
10 import org.exoplatform.services.wsrp.type.CacheControl;
11 import org.exoplatform.services.wsrp.type.MarkupResponse;
12 import org.exoplatform.services.wsrp.type.PortletContext;
13 import org.exoplatform.services.wsrp.type.RegistrationContext;
14 import org.exoplatform.services.wsrp.type.ServiceDescription;
15
16
17 /*
18  * @author Mestrallet Benjamin
19  * benjmestrallet@users.sourceforge.net
20  * Date: 25 janv. 2004
21  * Time: 19:29:55
22  */

23
24 public class TestCachingMechanism extends BaseTest{
25
26   public TestCachingMechanism(String JavaDoc s) {
27     super(s);
28   }
29
30   public void testExistenceOfValidateTag() throws RemoteException JavaDoc {
31     ServiceDescription sd = getServiceDescription(new String JavaDoc[]{"en"});
32     RegistrationContext rc = null;
33     if(sd.isRequiresRegistration()) rc = new RegistrationContext();
34     PortletContext portletContext = new PortletContext();
35     portletContext.setPortletHandle("hello/HelloWorld2");
36     MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup(rc, portletContext));
37     CacheControl cacheControl = response.getMarkupContext().getCacheControl();
38     assertEquals(4, cacheControl.getExpires());
39     assertEquals(WSRPConstants.WSRP_USER_SCOPE_CACHE, cacheControl.getUserScope());
40     assertNotNull(cacheControl.getValidateTag());
41   }
42   /*
43   public void testUseCacheReturn() throws RemoteException, UnsupportedWindowStateFault, InvalidHandleFault, UnsupportedModeFault {
44     ServiceDescription sd = getServiceDescription(new String[]{"en"});
45     RegistrationContext rc = null;
46     if(sd.isRequiresRegistration())
47       rc = new RegistrationContext();
48
49     String portletHandle = "hello/HelloWorld2";
50     PortletContext portletContext = new PortletContext();
51     portletContext.setPortletHandle(portletHandle);
52
53     MarkupRequest getMarkup = getMarkup(rc, portletContext);
54     MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup);
55     CacheControl cacheControl = response.getMarkupContext().getCacheControl();
56     System.out.println("[test] validate tag key : " + cacheControl.getValidateTag());
57     markupParams.setValidateTag(cacheControl.getValidateTag());
58     runtimeContext.setSessionID(response.getSessionContext().getSessionID());
59     manageTemplatesOptimization(sd, portletHandle);
60     manageUserContextOptimization(sd, portletHandle, getMarkup);
61     response = markupOperationsInterface.getMarkup(getMarkup);
62     assertTrue(response.getMarkupContext().getUseCachedMarkup().booleanValue());
63   }
64
65   public void testExistenceOfGlobal() throws RemoteException {
66     ServiceDescription sd = getServiceDescription(new String[]{"en"});
67     RegistrationContext rc = null;
68     if(sd.isRequiresRegistration())
69       rc = new RegistrationContext();
70
71     PortletContext portletContext = new PortletContext();
72     portletContext.setPortletHandle("hello/EmptyPortletWithGlobalCache");
73
74     MarkupResponse response = markupOperationsInterface.getMarkup(getMarkup(rc, portletContext));
75     CacheControl cacheControl = response.getMarkupContext().getCacheControl();
76     assertEquals(-1, cacheControl.getExpires());
77     assertEquals(WSRPConstants.WSRP_GLOBAL_SCOPE_CACHE, cacheControl.getUserScope());
78     assertNotNull(cacheControl.getValidateTag());
79   }
80   */

81 }
82
Popular Tags