Java Code Examples for javax.faces.component.UIViewRoot#setViewId()
The following examples show how to use
javax.faces.component.UIViewRoot#setViewId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 7 votes |
@Test public void validateSubscriptionId_ShowExternalConfiguratorIsFalse() throws Exception { // given model.setShowExternalConfigurator(false); UIViewRoot viewRoot = mock(UIViewRoot.class); viewRoot.setViewId(SUBSCRIPTIONADD_VIEWID); FacesContext context = mock(FacesContext.class); context.setViewRoot(viewRoot); // when UIComponent toValidate = mock(UIComponent.class); doReturn("").when(toValidate).getClientId(); bean.validateSubscriptionId(context, toValidate, new String()); // then assertEquals(Boolean.FALSE, Boolean.valueOf(model.isShowExternalConfigurator())); }
Example 2
Source File: MockedJsf2TestContainer.java From deltaspike with Apache License 2.0 | 5 votes |
protected void initDefaultView() { UIViewRoot root = new UIViewRoot(); root.setViewId("/viewId"); root.setLocale(getLocale()); root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); this.facesContext.setViewRoot(root); }
Example 3
Source File: MockedJsfContainerTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void firstTest() { Assert.assertEquals(0, requestScopedBean.getCount()); requestScopedBean.increaseCount(); Assert.assertEquals(1, requestScopedBean.getCount()); Assert.assertEquals(0, sessionScopedBean.getCount()); sessionScopedBean.increaseCount(); Assert.assertEquals(1, sessionScopedBean.getCount()); Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot()); Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId()); UIViewRoot uiViewRoot = new UIViewRoot(); uiViewRoot.setViewId("/test1.xhtml"); uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication()); Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler()); Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "1"); Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); }
Example 4
Source File: MockedJsfContainerTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void secondTest() { Assert.assertEquals(0, requestScopedBean.getCount()); requestScopedBean.increaseCount(); Assert.assertEquals(1, requestScopedBean.getCount()); Assert.assertEquals(0, sessionScopedBean.getCount()); sessionScopedBean.increaseCount(); Assert.assertEquals(1, sessionScopedBean.getCount()); Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot()); Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId()); UIViewRoot uiViewRoot = new UIViewRoot(); uiViewRoot.setViewId("/test2.xhtml"); uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication()); Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler()); Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "2"); Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); }
Example 5
Source File: JsfContainerTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void firstTest() { Assert.assertEquals(0, requestScopedBean.getCount()); requestScopedBean.increaseCount(); Assert.assertEquals(1, requestScopedBean.getCount()); Assert.assertEquals(0, sessionScopedBean.getCount()); sessionScopedBean.increaseCount(); Assert.assertEquals(1, sessionScopedBean.getCount()); UIViewRoot uiViewRoot = new UIViewRoot(); uiViewRoot.setViewId("/viewId"); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot()); Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId()); uiViewRoot.setViewId("/test1.xhtml"); uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication()); Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler()); Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "1"); Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap(); if (identityHashCode == null) { identityHashCode = System.identityHashCode(applicationMap); } else { Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap)); } }
Example 6
Source File: JsfContainerTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void secondTest() { Assert.assertEquals(0, requestScopedBean.getCount()); requestScopedBean.increaseCount(); Assert.assertEquals(1, requestScopedBean.getCount()); Assert.assertEquals(0, sessionScopedBean.getCount()); sessionScopedBean.increaseCount(); Assert.assertEquals(1, sessionScopedBean.getCount()); UIViewRoot uiViewRoot = new UIViewRoot(); uiViewRoot.setViewId("/viewId"); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot()); Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId()); uiViewRoot.setViewId("/test2.xhtml"); uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); FacesContext.getCurrentInstance().setViewRoot(uiViewRoot); Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication()); Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext()); Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit()); Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler()); Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test", "2"); Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test")); Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap(); if (identityHashCode == null) { identityHashCode = System.identityHashCode(applicationMap); } else { Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap)); } }