Source:
public void ContentFallbackTrue_PageFallbackFalse_PageEnglish_ViewEnglishContent1And2_ViewSpanish404(final Container container, final Template template) throws Exception{ Config.setProperty(contentFallbackProperty,true); Config.setProperty(pageFallbackProperty,false); final String pageName = "test7Page-"+System.currentTimeMillis(); final HTMLPageAsset pageEnglishVersion = createHtmlPageAsset(template, pageName, 1); createMultiTree(pageEnglishVersion.getIdentifier(), container.getIdentifier()); HttpServletRequest mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); Mockito.when(mockRequest.getParameter("host_id")).thenReturn(site.getIdentifier()); mockRequest.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, "1"); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue("ENG = "+html , html.contains("content2content1")); mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); mockRequest .setAttribute(WebKeys.HTMLPAGE_LANGUAGE, String.valueOf(spanishLanguage.getId())); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); }

Target:
public void ContentFallbackTrue_PageFallbackFalse_PageEnglish_ViewEnglishContent1And2_ViewSpanish404(final Container container, final Template template) throws Exception{ Config.setProperty(contentFallbackProperty,true); Config.setProperty(pageFallbackProperty,false); final String pageName = "test7Page-"+System.currentTimeMillis(); final HTMLPageAsset pageEnglishVersion = createHtmlPageAsset(template, pageName, 1); createMultiTree(pageEnglishVersion.getIdentifier(), container.getIdentifier()); HttpServletRequest mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); Mockito.when(mockRequest.getParameter("host_id")).thenReturn(site.getIdentifier()); mockRequest.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, "1"); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); final HttpServletResponse mockResponse = mock(HttpServletResponse.class); String html = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); Assert.assertTrue("ENG = "+html , html.contains("content2content1")); mockRequest = new MockSessionRequest( new MockAttributeRequest(new MockHttpRequest("localhost", "/").request()).request()) .request(); mockRequest .setAttribute(WebKeys.HTMLPAGE_LANGUAGE, String.valueOf(spanishLanguage.getId())); HttpServletRequestThreadLocal.INSTANCE.setRequest(mockRequest); try{ APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setUser(systemUser) .setPageUri(pageEnglishVersion.getURI()) .setPageMode(PageMode.LIVE) .build(), mockRequest, mockResponse); throw new AssertionError("HTMLPageAssetNotFoundException expected"); }catch(HTMLPageAssetNotFoundException e) { } }