### Question:
ViewEngineBase implements ViewEngine { protected String resolveView(ViewEngineContext context) { final String view = context.getView(); if (!PathUtils.hasStartingSlash(view)) { return PathUtils.ensureEndingSlash(getViewFolder(context)) + view; } return view; }    }### Answer:
@Test public void resolveView() { ViewEngineContext ctx = EasyMock.createMock(ViewEngineContext.class); Configuration config = EasyMock.createMock(Configuration.class); expect(config.getProperty(eq(ViewEngine.VIEW_FOLDER))).andReturn(null); expect(ctx.getConfiguration()).andReturn(config); expect(ctx.getView()).andReturn("index.jsp"); expect(ctx.getView()).andReturn("/somewhere/else/index.jsp"); replay(ctx, config); assertThat(viewEngineBase.resolveView(ctx), is("/WEB-INF/views/index.jsp")); assertThat(viewEngineBase.resolveView(ctx), is("/somewhere/else/index.jsp")); verify(ctx, config); }
@Test public void resolveViewCustomFolder() { ViewEngineContext ctx = EasyMock.createMock(ViewEngineContext.class); Configuration config = EasyMock.createMock(Configuration.class); expect(config.getProperty(eq(ViewEngine.VIEW_FOLDER))).andReturn("/somewhere/else"); expect(ctx.getConfiguration()).andReturn(config); expect(ctx.getView()).andReturn("index.jsp"); replay(ctx, config); assertThat(viewEngineBase.resolveView(ctx), is("/somewhere/else/index.jsp")); verify(ctx, config); }