小编Isr*_*ael的帖子

具有多条路由和路由器出口的角度路由

除了应用程序根目录的导航之外,我还尝试向组件添加导航,但它没有导航到组件路由。

我正在使用两个路由器插座:

  • 应用程序根的路由器出口(app.component.html)
  • 用户组件的路由器插座(users.component.html)

有两条路线:

  • 应用程序的路由(app.routing.module.ts)
  • 用户路由(users.routing.module.ts)

当导航到“用户”我可以看到users.component.html有两个链接,但链接“当按下列表”,它没有导航到:UsersListComponent定义users.routing.module.ts

我不确定这是否是正确的方法。

下面是项目和源代码的文件夹结构:

-- app.routing.module.ts
-- app.component.html
-- components
   -- dashboard
   -- users
      -- users.component.html
      -- users.module.ts
      -- users.routing.module.ts
Run Code Online (Sandbox Code Playgroud)

app.routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { UsersModule } from './panels/users/users.module';

const AppRouting: Routes = [
    { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
    { path: 'dashboard', component: DashboardComponent },
    { path: 'users', loadChildren: () => …
Run Code Online (Sandbox Code Playgroud)

routes angular-routing router-outlet angular

7
推荐指数
1
解决办法
1万
查看次数

Mockito 太多实际调用

我正在使用 Junit 和 Mockito 进行测试。这是PortalServletTest课程的一部分:

@SuppressWarnings("serial")
@BeforeClass
public static void setUpTests() {
    when(request.getRequestDispatcher(Mockito.anyString())).thenReturn(rd);
    when(request.getSession()).thenReturn(httpSession);
    when(httpSession.getServletContext()).thenReturn(servletContext);
    when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
    when(configurationManager.getConfiguration()).thenReturn(configuration);
    List<List<String>> mandatoryHeaders = new ArrayList<List<String>>();
    mandatoryHeaders.add(new ArrayList<String>() {
        {
            add("HTTP_XXXX");
            add("http-xxxx");
        }
    });

    List<List<String>> optionalHeaders = new ArrayList<List<String>>();
    optionalHeaders.add(new ArrayList<String>() {
        {
            add("HTTP_YYYY");
            add("http-yyyy");
        }
    });

    when(configuration.getIdentificationHeaderFields()).thenReturn(mandatoryHeaders);
    when(configuration.getOptionalHeaderFields()).thenReturn(optionalHeaders);

}

@Test
public void testMissingHeadersRequest() throws IOException {
    when(request.getHeader(Mockito.anyString())).thenReturn(null);
    target().path("/portal").request().get();
    Mockito.verify(response, times(1)).sendError(HttpServletResponse.SC_USE_PROXY, PortalServlet.MISSING_HEADERS_MSG);
}

@Test
public void testSuccesfulRequest() throws IOException, ServletException {
    Mockito.doAnswer(new Answer<Object>() {
        public Object answer(InvocationOnMock invocation) {
            Object[] args = …
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing mockito

6
推荐指数
2
解决办法
1万
查看次数