[jboss-user] [JBoss Seam] - MockApplication in SeamTest not easily overridable

matt.drees do-not-reply at jboss.com
Thu Feb 15 16:53:05 EST 2007

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 {
  | 	@Override
  | 	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;
  | 	}
  | 	@Override
  | 	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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017244#4017244

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017244

More information about the jboss-user mailing list