Skip to content

Instantly share code, notes, and snippets.

@lfryc
Created November 21, 2012 07:11
Show Gist options
  • Select an option

  • Save lfryc/4123535 to your computer and use it in GitHub Desktop.

Select an option

Save lfryc/4123535 to your computer and use it in GitHub Desktop.
@RunAsClient
@WarpTest
@RunWith(Arquillian.class)
public class TestFocusValidationAware {
...
@Test
public void testGlobalMessageIsIgnored() {
Warp
.given(new Activity() {
public void do() {
guardHttp(submitButton).click();
}
})
.when(JsfViewFilter.class)
.then(new Inspect() {
@BeforePhase(Phase.RENDER_RESPONSE)
public void addGlobalMessage() {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("global message"));
}
@AfterPhase(Phase.RENDER_RESPONSE)
public void verifyGlobalMessageIsIgnored() {
FacesContext context = FacesContext.getCurrentInstance();
AbstractFocus component = bean.getComponent();
FocusRendererBase renderer = bean.getRenderer();
String candidates = renderer.getFocusCandidatesAsString(context, component);
assertEquals("form", candidates);
}
});
assertEquals(input3, getFocusedElement());
}
@Test
public void testGlobalMessageIsIgnored_alternativeSyntax() {
Warp.given(submitButton).click();
Warp.when(JsfViewFilter.class);
Warp.then(new Inspect() {
@BeforePhase(Phase.RENDER_RESPONSE)
public void addGlobalMessage() {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("global message"));
}
@AfterPhase(Phase.RENDER_RESPONSE)
public void verifyGlobalMessageIsIgnored() {
FacesContext context = FacesContext.getCurrentInstance();
AbstractFocus component = bean.getComponent();
FocusRendererBase renderer = bean.getRenderer();
String candidates = renderer.getFocusCandidatesAsString(context, component);
assertEquals("form", candidates);
}
});
assertEquals(input3, getFocusedElement());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment