@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); }
@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); }
/** 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); }
@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); }