@Test public void oneToOneRelationBetweenBrowserAndUI() throws MalformedURLException { openWindow(INSTRUMENTED_UI_URI); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); int clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(1)); assertThat(InstrumentedUI.getNumberOfInstances(), is(1)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(2)); assertThat(InstrumentedUI.getNumberOfInstances(), is(1)); firstWindow.restartBrowser(); openWindow(INSTRUMENTED_UI_URI); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(1)); assertThat(InstrumentedUI.getNumberOfInstances(), is(2)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(2)); assertThat(InstrumentedUI.getNumberOfInstances(), is(2)); assertDefaultRootNotInstantiated(); }
@Test public void interceptedScopedEventListener() throws MalformedURLException { assertThat(InterceptedUI.getNumberOfInstances(), is(0)); assertThat(InstrumentedInterceptor.getCounter(), is(0)); String uri = deriveMappingForUI(InterceptedUI.class); openWindow(uri); waitModel.until(elementPresent.locator(LABEL)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(InstrumentedInterceptor.getCounter(), is(1)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(InstrumentedInterceptor.getCounter(), is(2)); }
@Test public void cdiEventsArrivesInTheSameUIScopedInstance() throws MalformedURLException { assertThat(UIWithCDISelfListener.getNumberOfInstances(), is(0)); assertThat(UIWithCDISelfListener.getNumberOfDeliveredEvents(), is(0)); String uri = deriveMappingForUI(UIWithCDISelfListener.class); openWindow(uri); waitModel.until(elementPresent.locator(LABEL)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(UIWithCDISelfListener.getNumberOfInstances(), is(1)); assertThat(UIWithCDISelfListener.getNumberOfDeliveredEvents(), is(1)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(UIWithCDISelfListener.getNumberOfInstances(), is(1)); assertThat(UIWithCDISelfListener.getNumberOfDeliveredEvents(), is(2)); }
@Test public void dependentScopedViewIsInstantiatedOnce() throws MalformedURLException { String uri = deriveMappingForUI(NoViewProviderNavigationUI.class); openWindow(uri); assertThat(InstrumentedView.getNumberOfInstances(), is(1)); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(InstrumentedView.getNumberOfInstances(), is(1)); assertThat(NoViewProviderNavigationUI.getNumberOfInstances(), is(1)); assertThat(NoViewProviderNavigationUI.getNumberOfNavigations(), is(1)); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(InstrumentedView.getNumberOfInstances(), is(1)); assertThat(NoViewProviderNavigationUI.getNumberOfInstances(), is(1)); assertThat(NoViewProviderNavigationUI.getNumberOfNavigations(), is(2)); }
@Test public void dependentScopedViewIsInstantiatedTwiceWithViewProvider() throws MalformedURLException { openWindow(firstWindow, INSTRUMENTED_VIEW_URI); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(InstrumentedView.getNumberOfInstances(), is(2)); }
@Test public void danglingViewCauses404() throws MalformedURLException { openWindow(DANGLING_VIEW_URI); waitModel.until(elementPresent.locator(LABEL)); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(SecondUI.getNumberOfInstances(), is(1)); assertThat(DanglingView.getNumberOfInstances(), is(0)); }
@Test public void recognitionOfViewWithoutAnnotation() throws MalformedURLException { ParameterizedNavigationUI.NAVIGATE_TO = "viewWithoutAnnotation"; openWindow(deriveMappingForUI(ParameterizedNavigationUI.class)); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(ViewWithoutAnnotation.getNumberOfInstances(), is(1)); assertDefaultRootNotInstantiated(); }
@Test public void ejbInvocation() throws MalformedURLException { openWindow(deriveMappingForUI(EnterpriseUI.class)); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(EnterpriseUI.getNumberOfInstances(), is(1)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); final String labelText = retrieveText.locator(LABEL).retrieve(); assertThat(labelText, startsWith("Echo:")); assertThat(EnterpriseUI.getNumberOfInstances(), is(1)); assertDefaultRootNotInstantiated(); }
@Test public void navigationToRestrictedViewFails() throws MalformedURLException { assertThat(ParameterizedNavigationUI.getNumberOfInstances(), is(0)); assertThat(RestrictedView.getNumberOfInstances(), is(0)); ParameterizedNavigationUI.NAVIGATE_TO = deriveMappingForView(RestrictedView.class); openWindow(deriveMappingForUI(ParameterizedNavigationUI.class)); firstWindow.click(NAVIGATE_BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); assertThat(ParameterizedNavigationUI.getNumberOfInstances(), is(1)); assertThat(RestrictedView.getNumberOfInstances(), is(0)); assertDefaultRootNotInstantiated(); }