1 Reply Latest reply on Feb 16, 2007 4:06 AM by Denis Karpov

    MockApplication in SeamTest not easily overridable

    Matt Drees Master

      The app I'm working on has to do some dynamic UIComponent creation. Something like

      questionPanel = (HtmlPanelGrid) facesContext.getApplication().createComponent(HtmlPanelGrid.COMPONENT_TYPE);

      where facesContext is injected.

      For my unit tests, I'm using a simple mock Application:
      public class MockApplicationExtension extends MockApplication {
       public UIComponent createComponent(String name) throws FacesException {
       if (name.equals(HtmlOutputLabel.COMPONENT_TYPE))
       return new HtmlOutputLabel();
       if (name.equals(HtmlOutputText.COMPONENT_TYPE))
       return new HtmlOutputText();
       if (name.equals(HtmlInputText.COMPONENT_TYPE))
       return new HtmlInputText();
       if (name.equals(HtmlPanelGrid.COMPONENT_TYPE))
       return new HtmlPanelGrid();
       return null;
       public ValueBinding createValueBinding(String valueExpression) throws ReferenceSyntaxException {
       return null;

      I can't use this in integration tests, however. SeamTest doesn't provide a nice way to override the built-in MockApplication (that I can see).

      Could SeamTest be altered to let me hook into the instantiation of the application field?

      Or could MockApplication be extended to do some basic component creation, as I've done above? (maybe this wouldn't work well; I haven't thought about it much)

      Also, if anyone has any pointers on how to work with dynamic UIComponent creation/binding in Seam, I'd love to hear them. I'm mostly going off this article:
      I'm not sure if Seam provides a better way to do it.