コード例 #1
0
  @Test
  public void testSetLocalizedPreferencesValues() throws Exception {
    MockPortletRequest request = new MockPortletRequest();

    request.setParameter("greeting_" + _ENGLISH_LANGUAGE_ID, _ENGLISH_HELLO);
    request.setParameter("greeting_" + _GERMAN_LANGUAGE_ID, _GERMAN_HELLO);

    PortletPreferences preferences = new PortletPreferencesImpl();

    LocalizationUtil.setLocalizedPreferencesValues(request, preferences, "greeting");

    Assert.assertEquals(
        _ENGLISH_HELLO,
        LocalizationUtil.getPreferencesValue(preferences, "greeting", _ENGLISH_LANGUAGE_ID));
    Assert.assertEquals(
        _GERMAN_HELLO,
        LocalizationUtil.getPreferencesValue(preferences, "greeting", _GERMAN_LANGUAGE_ID));
  }
コード例 #2
0
 public void testGetAttributeNames() {
   request.setParameter("Some param", "Some value");
   // perform test
   Iterator<String> names = tested.getAttributeNames();
   assertNotNull("Null result unexpected", names);
   assertTrue("More elements", names.hasNext());
   String name = names.next();
   assertEquals("Some param", name);
 }
コード例 #3
0
 public void testRemoveAttribute() {
   request.setParameter("Some param", "Some value");
   // perform test
   try {
     tested.removeAttribute("Some param");
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
     // expected
   }
 }
  /**
   * Test method for {@link
   * se.vgregion.portal.auditlog.AuditLogInfoContainerFactoryImpl#getAuditLogInfoContainer(java.lang.String,
   * java.lang.String, javax.portlet.PortletRequest)} .
   */
  @Test
  public final void testGetAuditLogInfoContainerUserFromLdap() {
    MockPortletRequest portletRequest = new MockPortletRequest();

    Map<String, String> uInfoMap = new HashMap<String, String>();
    uInfoMap.put(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString(), "remoteUid");
    portletRequest.setAttribute(PortletRequest.USER_INFO, uInfoMap);

    MockHttpServletRequest httpRequest = new MockHttpServletRequest();

    given(converter.getHttpServletRequest(portletRequest)).willReturn(httpRequest);

    LdapUser ldapUser = new SimpleLdapUser("dn");
    ldapUser.setAttributeValue("cn", "searcherId");
    given(ldapService.getLdapUserByUid("remoteUid")).willReturn(ldapUser);

    AuditLogInfoContainer container = factory.getAuditLogInfoContainer("patientId", portletRequest);

    assertEquals("searcherId", container.getSearcherId());
  }
  /**
   * Test method for {@link
   * se.vgregion.portal.auditlog.AuditLogInfoContainerFactoryImpl#getAuditLogInfoContainer(java.lang.String,
   * java.lang.String, javax.portlet.PortletRequest)} .
   */
  @Test
  public final void testGetAuditLogInfoContainer() {
    MockPortletRequest portletRequest = new MockPortletRequest();

    Map<String, String> uInfoMap = new HashMap<String, String>();
    uInfoMap.put(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString(), "remoteUid");
    portletRequest.setAttribute(PortletRequest.USER_INFO, uInfoMap);

    MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    httpRequest.setRemoteAddr("127.0.0.1");
    httpRequest.setRemoteHost("remoteHost");
    httpRequest.setRemotePort(123);

    given(converter.getHttpServletRequest(portletRequest)).willReturn(httpRequest);

    AuditLogInfoContainer container = factory.getAuditLogInfoContainer("patientId", portletRequest);

    assertEquals("patientId", container.getPatientId());
    assertEquals("[LiferayUser:]remoteUid", container.getSearcherId());
    assertEquals("remoteUid", container.getRemoteUser());
    assertEquals("127.0.0.1 [Default]", container.getRemoteIpAddress());
    assertEquals("remoteHost", container.getRemoteHost());
    assertEquals(123, container.getRemotePort());
  }
コード例 #6
0
 public void testGetAttribute() {
   request.setParameter("Some param", "Some value");
   // perform test
   Object result = tested.getAttribute("Some param");
   assertEquals("Some value", result);
 }