@Before public void setUp() throws Exception { this.extensionsCoreService = getInjector().getInstance(ExtensionsCoreService.class); this.repository = getInjector().getInstance(IRepository.class); }
private void mockRequest(HttpServletRequest mockedRequest) { when(mockedRequest.getMethod()).thenReturn("GET"); when(mockedRequest.getRemoteUser()).thenReturn("tester"); when(mockedRequest.getHeaderNames()).thenReturn(Collections.enumeration(Arrays.asList("header1", "header2"))); when(mockedRequest.getServerName()).thenReturn("server1"); when(mockedRequest.getHeader("header1")).thenReturn("header1"); when(mockedRequest.isUserInRole("role1")).thenReturn(true); HttpSession mockedSession = Mockito.mock(HttpSession.class); when(mockedRequest.getSession()).thenReturn(mockedSession); when(mockedRequest.getSession(true)).thenReturn(mockedSession); mockSession(mockedSession); }
public void runSuite(IJavascriptEngineExecutor executor, IRepository repository) throws RepositoryWriteException, IOException, ScriptingException, ContextException, ExtensionsException { HttpServletRequest mockedRequest = Mockito.mock(HttpServletRequest.class); HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class); mockRequest(mockedRequest); mockResponse(mockedResponse); ThreadContextFacade.setUp(); try { ThreadContextFacade.set(HttpServletRequest.class.getCanonicalName(), mockedRequest); ThreadContextFacade.set(HttpServletResponse.class.getCanonicalName(), mockedResponse); extensionsCoreService.createExtensionPoint("/test_extpoint1", "test_extpoint1", "Test"); extensionsCoreService.createExtension("/test_ext1", "/test_ext_module1", "test_extpoint1", "Test"); try { for (String testModule : TEST_MODULES) { Object result = runTest(executor, repository, testModule); assertNotNull(result); assertTrue("API test failed: " + testModule, Boolean.parseBoolean(result.toString())); System.out.println(String.format("API test [%s] on engine [%s] passed successfully.", testModule, executor.getType())); } } finally { extensionsCoreService.removeExtension("/test_ext1"); extensionsCoreService.removeExtensionPoint("/test_extpoint1"); } } finally { ThreadContextFacade.tearDown(); } }
public void runSuite(IJavascriptEngineExecutor executor, IRepository repository) throws RepositoryWriteException, IOException, ScriptingException, ContextException, ExtensionsException { HttpServletRequest mockedRequest = Mockito.mock(HttpServletRequest.class); HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class); mockRequest(mockedRequest); mockResponse(mockedResponse); ThreadContextFacade.setUp(); try { ThreadContextFacade.set(HttpServletRequest.class.getCanonicalName(), mockedRequest); ThreadContextFacade.set(HttpServletResponse.class.getCanonicalName(), mockedResponse); extensionsCoreService.createExtensionPoint("/test_extpoint1", "test_extpoint1", "Test"); extensionsCoreService.createExtension("/test_ext1", "/test_ext_module1", "test_extpoint1", "Test"); try { for (String testModule : TEST_MODULES) { Object result = runTest(executor, repository, testModule); assertNotNull(result); assertTrue("API test failed: " + testModule, Boolean.parseBoolean(result.toString())); System.out.println(String.format("API test [%s] on engine [%s] passed successfully.", testModule, executor.getType())); } } finally { extensionsCoreService.removeExtension("/test_ext1"); extensionsCoreService.removeExtensionPoint("/test_extpoint1"); } } finally { ThreadContextFacade.tearDown(); } }
@Before public void setUp() throws Exception { this.extensionsCoreService = getInjector().getInstance(ExtensionsCoreService.class); this.repository = getInjector().getInstance(IRepository.class); }
private void mockRequest(HttpServletRequest mockedRequest) { when(mockedRequest.getMethod()).thenReturn("GET"); when(mockedRequest.getRemoteUser()).thenReturn("tester"); when(mockedRequest.getHeaderNames()).thenReturn(Collections.enumeration(Arrays.asList("header1", "header2"))); when(mockedRequest.getServerName()).thenReturn("server1"); when(mockedRequest.getHeader("header1")).thenReturn("header1"); when(mockedRequest.isUserInRole("role1")).thenReturn(true); HttpSession mockedSession = Mockito.mock(HttpSession.class); when(mockedRequest.getSession()).thenReturn(mockedSession); when(mockedRequest.getSession(true)).thenReturn(mockedSession); mockSession(mockedSession); }