コード例 #1
0
 /** Test of getMainSessionController method, of class SilverpeasWebUtil. */
 @Test
 public void checkDefaultOrganizationController() {
   OrganizationControllerProvider.getFactory().clearFactory();
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   assertEquals(
       DefaultOrganizationController.class.getName(),
       util.getOrganisationController().getClass().getName());
 }
コード例 #2
0
 @Test
 public void getComponentIdWithNullPathInfo() {
   MockHttpServletRequest request =
       new MockHttpServletRequest(
           "GET", "http://localhost:8000/silverpeas/Rtoolbox/toolbox8/Main");
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   String[] result = util.getComponentId(request);
   String[] expResult = new String[] {"-1", "-1", "Error"};
   assertArrayEquals(expResult, result);
 }
コード例 #3
0
 @Test
 public void getComponentIdWithJspPathInfo() {
   MockHttpServletRequest request =
       new MockHttpServletRequest(
           "GET", "http://localhost:8000/silverpeas/jsp/javaScript/forums.js");
   request.setPathInfo("/jsp/javaScript/forums.js");
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   String[] result = util.getComponentId(request);
   String[] expResult = new String[] {null, null, "javaScript/forums.js"};
   assertArrayEquals(expResult, result);
 }
コード例 #4
0
 /** Test of getComponentId method, of class SilverpeasWebUtil. */
 @Test
 public void getComponentIdForURLWithFunction() {
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   MockHttpServletRequest request =
       new MockHttpServletRequest(
           "GET", "http://localhost:8000/silverpeas/Rtoolbox/toolbox8/ViewAttachments");
   request.setPathInfo("/toolbox8/ViewAttachments");
   String[] expResult = new String[] {null, "toolbox8", "ViewAttachments"};
   String[] result = util.getComponentId(request);
   assertArrayEquals(expResult, result);
 }
コード例 #5
0
 /** Test of getMainSessionController method, of class SilverpeasWebUtil. */
 @Test
 public void testGetMainSessionController() {
   HttpServletRequest request = mock(HttpServletRequest.class);
   HttpSession session = mock(HttpSession.class);
   MainSessionController controller = mock(MainSessionController.class);
   when(session.getAttribute(MainSessionController.MAIN_SESSION_CONTROLLER_ATT))
       .thenReturn(controller);
   when(request.getSession()).thenReturn(session);
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   MainSessionController result = util.getMainSessionController(request);
   assertEquals(controller, result);
 }
コード例 #6
0
  /** Test of getRoles method, of class SilverpeasWebUtil. */
  @Test
  public void testGetRoles() {
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpSession session = mock(HttpSession.class);
    MainSessionController controller = mock(MainSessionController.class);
    when(controller.getUserId()).thenReturn("18");
    when(session.getAttribute(MainSessionController.MAIN_SESSION_CONTROLLER_ATT))
        .thenReturn(controller);
    when(request.getSession()).thenReturn(session);
    when(request.getPathInfo()).thenReturn("/toolbox8/ViewAttachments");

    SilverpeasWebUtil util = new SilverpeasWebUtil();
    util.getRoles(request);
    verify(getOrganisationController()).getUserProfiles("18", "toolbox8");
  }
コード例 #7
0
 @Test
 public void getComponentIdForMainURL() {
   MockHttpServletRequest request =
       new MockHttpServletRequest(
           "GET", "http://localhost:8000/silverpeas/Rtoolbox/toolbox8/Main");
   request.setPathInfo("/toolbox8/Main");
   OrganizationController controller = getOrganisationController();
   ComponentInstLight component = mock(ComponentInstLight.class);
   String spaceId = "12";
   when(component.getDomainFatherId()).thenReturn(spaceId);
   when(controller.getComponentInstLight("toolbox8")).thenReturn(component);
   SilverpeasWebUtil util = new SilverpeasWebUtil();
   String[] result = util.getComponentId(request);
   String[] expResult = new String[] {"12", "toolbox8", "Main"};
   assertArrayEquals(expResult, result);
 }