use of org.apereo.portal.utils.MultivaluedMapPopulator in project uPortal by Jasig.
the class HttpRequestPropertiesManagerTest method testGetRequestProperties.
public void testGetRequestProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("1.2.3.4");
request.setMethod("POST");
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
final IPortalRequestUtils portalRequestUtils = EasyMock.createMock(IPortalRequestUtils.class);
EasyMock.expect(portalRequestUtils.getOriginalPortalRequest(request)).andReturn(request);
EasyMock.replay(portletWindow, portalRequestUtils);
this.httpRequestPropertiesManager.setPortalRequestUtils(portalRequestUtils);
final MultivaluedMapPopulator<String, String> populator = new MultivaluedMapPopulator<String, String>();
this.httpRequestPropertiesManager.populateRequestProperties(request, portletWindow, populator);
final Map<String, List<String>> properties = populator.getMap();
assertNotNull("properties Map should not be null", properties);
final Map<String, List<String>> expected = ImmutableMap.of("REMOTE_ADDR", Collections.singletonList("1.2.3.4"), "REQUEST_METHOD", Collections.singletonList("POST"), "REMOTE_HOST", Collections.singletonList("localhost"));
assertEquals(expected, properties);
EasyMock.verify(portletWindow, portalRequestUtils);
}
use of org.apereo.portal.utils.MultivaluedMapPopulator in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testGetProperties.
public void testGetProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
EasyMock.replay(portletWindow);
final MockRequestPropertiesManager delegateManager1 = new MockRequestPropertiesManager();
delegateManager1.setOrder(Ordered.HIGHEST_PRECEDENCE);
final MockRequestPropertiesManager delegateManager2 = new MockRequestPropertiesManager();
delegateManager2.setOrder(Ordered.LOWEST_PRECEDENCE);
this.requestPropertiesManagerBroker.setPropertiesManagers(ImmutableList.of(delegateManager1, delegateManager2));
delegateManager1.setResponseProperty(request, portletWindow, "prop.A", "prop.A.1");
delegateManager1.setResponseProperty(request, portletWindow, "prop.B", "prop.B.1");
delegateManager2.setResponseProperty(request, portletWindow, "prop.C", "prop.C.1");
MultivaluedMapPopulator<String, String> multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
final Map<String, List<String>> expected1 = ImmutableMap.<String, List<String>>of("prop.A", ImmutableList.of("prop.A.1"), "prop.B", ImmutableList.of("prop.B.1"), "prop.C", ImmutableList.of("prop.C.1"));
assertEquals(expected1, multivaluedMapPopulator.getMap());
delegateManager2.setResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
final Map<String, List<String>> expected2 = ImmutableMap.<String, List<String>>of("prop.A", ImmutableList.of("prop.A.1", "prop.A.2"), "prop.B", ImmutableList.of("prop.B.1"), "prop.C", ImmutableList.of("prop.C.1"));
assertEquals(expected2, multivaluedMapPopulator.getMap());
}
use of org.apereo.portal.utils.MultivaluedMapPopulator in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testSetProperties.
public void testSetProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
EasyMock.replay(portletWindow);
final MockRequestPropertiesManager delegateManager1 = new MockRequestPropertiesManager();
delegateManager1.setOrder(Ordered.HIGHEST_PRECEDENCE);
final MockRequestPropertiesManager delegateManager2 = new MockRequestPropertiesManager();
delegateManager2.setOrder(Ordered.LOWEST_PRECEDENCE);
this.requestPropertiesManagerBroker.setPropertiesManagers(ImmutableList.of(delegateManager1, delegateManager2));
this.requestPropertiesManagerBroker.setResponseProperty(request, portletWindow, "prop.A", "prop.A.1");
final Map<String, List<String>> expected1 = Collections.singletonMap("prop.A", Collections.singletonList("prop.A.1"));
MultivaluedMapPopulator<String, String> multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
this.requestPropertiesManagerBroker.setResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
final Map<String, List<String>> expected2 = Collections.<String, List<String>>singletonMap("prop.A", ImmutableList.of("prop.A.2"));
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
}
use of org.apereo.portal.utils.MultivaluedMapPopulator in project uPortal by Jasig.
the class RequestPropertiesManagerBrokerTest method testAddProperties.
public void testAddProperties() {
final MockHttpServletRequest request = new MockHttpServletRequest();
final IPortletWindow portletWindow = EasyMock.createMock(IPortletWindow.class);
EasyMock.replay(portletWindow);
final MockRequestPropertiesManager delegateManager1 = new MockRequestPropertiesManager();
delegateManager1.setOrder(Ordered.HIGHEST_PRECEDENCE);
final MockRequestPropertiesManager delegateManager2 = new MockRequestPropertiesManager();
delegateManager2.setOrder(Ordered.LOWEST_PRECEDENCE);
this.requestPropertiesManagerBroker.setPropertiesManagers(ImmutableList.of(delegateManager1, delegateManager2));
this.requestPropertiesManagerBroker.addResponseProperty(request, portletWindow, "prop.A", "prop.A.1");
final Map<String, List<String>> expected1 = Collections.singletonMap("prop.A", Collections.singletonList("prop.A.1"));
MultivaluedMapPopulator<String, String> multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected1, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
this.requestPropertiesManagerBroker.addResponseProperty(request, portletWindow, "prop.A", "prop.A.2");
final Map<String, List<String>> expected2 = Collections.<String, List<String>>singletonMap("prop.A", ImmutableList.of("prop.A.1", "prop.A.2"));
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
this.requestPropertiesManagerBroker.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager1.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(expected2, multivaluedMapPopulator.getMap());
multivaluedMapPopulator = new MultivaluedMapPopulator<String, String>();
delegateManager2.populateRequestProperties(request, portletWindow, multivaluedMapPopulator);
assertEquals(Collections.EMPTY_MAP, multivaluedMapPopulator.getMap());
}
Aggregations