KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portletcontainer > imp > TestHibernatePersistenceManager


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 package org.exoplatform.services.portletcontainer.imp;
6
7
8 import javax.portlet.PortletPreferences;
9 import javax.portlet.PreferencesValidator;
10 import javax.portlet.ValidatorException;
11 import org.exoplatform.container.PortalContainer;
12 import org.exoplatform.services.portletcontainer.helper.PortletWindowInternal;
13 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.PortletPreferencesImp;
14 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.persistenceImp.DefaultPersistenceManager;
15 import org.exoplatform.services.portletcontainer.pci.ExoWindowID;
16 import org.exoplatform.services.portletcontainer.pci.Input;
17 import org.exoplatform.services.portletcontainer.pci.model.ExoPortletPreferences;
18 import org.exoplatform.services.portletcontainer.pci.model.Portlet;
19
20 /**
21  * Created by The eXo Platform SARL .
22  * Author : Tuan Nguyen
23  * tuan08@users.sourceforge.net
24  * Date: Aug 1st, 2003
25  **/

26 public class TestHibernatePersistenceManager extends BaseTest {
27   public TestHibernatePersistenceManager(String JavaDoc s) {
28     super(s);
29   }
30
31   public void setUp() throws Exception JavaDoc {
32     super.setUp();
33   }
34
35   public void testStorePortletPreferences() throws Exception JavaDoc {
36     ExoWindowID windowID = new ExoWindowID("exotest:/hello/HelloWorld/banner");
37     ExoPortletPreferences prefs =
38         ((Portlet) portletApp_.getPortlet().get(0)).getPortletPreferences();
39     //PreferencesValidator validator =
40
// proxy.getValidator(prefs.getPreferencesValidator());
41
PreferencesValidator validator = new PreferencesValidator() {
42       public void validate(PortletPreferences portletPreferences) throws ValidatorException {
43       }
44     };
45     PortletPreferencesImp preferences =
46         new PortletPreferencesImp(validator, prefs, windowID, persister);
47     //preferences.setValue("param-1", "value-1") ; //null pointer exception ??
48
//preferences.setValue("param-2", "value-2") ;
49
preferences.setMethodCalledIsAction(true);
50     preferences.store();
51     DefaultPersistenceManager manager =
52         (DefaultPersistenceManager) PortalContainer.getInstance().
53         getComponentInstanceOfType(DefaultPersistenceManager.class);
54     //get the window for an anonymous user
55
Input input = new Input();
56     input.setWindowID(windowID);
57     PortletWindowInternal pwi = manager.getWindow(input, null);
58     //get the window for a identified user
59
pwi = manager.getWindow(input, null);
60   }
61 }
Popular Tags