1 package org.exoplatform.services.portletcontainer.imp; 2 3 4 import javax.portlet.WindowState; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 import org.exoplatform.services.portletcontainer.PortletContainerException; 8 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.pool.EmptyResponse; 9 import org.exoplatform.services.portletcontainer.pci.ExoWindowID; 10 import org.exoplatform.services.portletcontainer.pci.RenderOutput; 11 import org.exoplatform.test.mocks.servlet.MockHttpSession; 12 import org.exoplatform.test.mocks.servlet.MockServletRequest; 13 import org.exoplatform.test.mocks.servlet.MockServletResponse; 14 import java.util.Collection ; 15 import java.util.Iterator ; 16 import java.util.Locale ; 17 18 22 23 30 public class TestWindowState extends BaseTest{ 31 public TestWindowState(String s) { 32 super(s); 33 } 34 35 public void testWindowStateSupport(){ 36 Collection states = portletContainer.getWindowStates("hello"); 37 38 assertTrue(contains(states,WindowState.NORMAL)); 39 assertTrue(contains(states,WindowState.MINIMIZED)); 40 assertTrue(contains(states,WindowState.MAXIMIZED)); 41 assertTrue(contains(states,new WindowState("half-page"))); 42 assertFalse(contains(states,new WindowState("max-per-column"))); 43 assertFalse(contains(states, new WindowState("not_exist"))); 44 } 45 46 52 public void testPortletNotCalledWithAnUnsupportedMode() throws PortletContainerException { 53 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 54 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 55 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestNonUsageOfUndefinedState"); 56 input.setWindowState(new WindowState("max-per-column")); 57 RenderOutput o = portletContainer.render(request, response, input); 58 assertNull(o.getTitle()); 59 assertTrue(new String (o.getContent()).startsWith("Everything is ok")); 60 } 61 62 private boolean contains(Collection modes, WindowState state){ 63 for (Iterator iterator = modes.iterator(); iterator.hasNext();) { 64 WindowState windowState = (WindowState) iterator.next(); 65 if(windowState.toString().equals(state.toString())) 66 return true; 67 } 68 return false; 69 } 70 71 } 72 | Popular Tags |