1 15 package org.apache.tapestry.portlet; 16 17 import java.util.List ; 18 19 import javax.portlet.PortletSession; 20 21 import org.apache.tapestry.portlet.PortletWebSession; 22 import org.apache.tapestry.web.WebSession; 23 import org.easymock.MockControl; 24 25 31 public class TestPortletWebSession extends BasePortletWebTestCase 32 { 33 34 public void testGetAttributeNames() 35 { 36 MockControl control = newControl(PortletSession.class); 37 PortletSession session = (PortletSession) control.getMock(); 38 39 session.getAttributeNames(); 40 control.setReturnValue(newEnumeration()); 41 42 replayControls(); 43 44 WebSession ws = new PortletWebSession(session); 45 46 List l = ws.getAttributeNames(); 47 48 checkList(l); 49 50 verifyControls(); 51 } 52 53 public void testGetAttribute() 54 { 55 Object attribute = new Object (); 56 57 MockControl control = newControl(PortletSession.class); 58 PortletSession session = (PortletSession) control.getMock(); 59 60 session.getAttribute("attr"); 61 control.setReturnValue(attribute); 62 63 replayControls(); 64 65 WebSession ws = new PortletWebSession(session); 66 67 assertSame(attribute, ws.getAttribute("attr")); 68 69 verifyControls(); 70 } 71 72 public void testSetAttribute() 73 { 74 Object attribute = new Object (); 75 76 MockControl control = newControl(PortletSession.class); 77 PortletSession session = (PortletSession) control.getMock(); 78 79 session.setAttribute("name", attribute); 80 81 replayControls(); 82 83 WebSession ws = new PortletWebSession(session); 84 85 ws.setAttribute("name", attribute); 86 87 verifyControls(); 88 } 89 90 91 public void testGetId() 92 { 93 MockControl control = newControl(PortletSession.class); 94 PortletSession session = (PortletSession) control.getMock(); 95 96 session.getId(); 97 control.setReturnValue("abc"); 98 99 replayControls(); 100 101 WebSession ws = new PortletWebSession(session); 102 103 assertEquals("abc", ws.getId()); 104 105 verifyControls(); 106 } 107 } | Popular Tags |