This content has been marked as final.
Show 3 replies
-
1. Re: Inject a mocked component for integration testing
lowecg2004 May 17, 2007 8:32 AM (in response to denis.diggin)Add your mock class to your test package and annotate it with the following:
@Install(precedence=MOCK)
More info in Seam reference section 26.2.1. "Using mocks in integration tests". -
2. Re: Inject a mocked component for integration testing
denis.diggin May 17, 2007 9:43 AM (in response to denis.diggin)Works. Many thanks.
-
3. Re: Inject a mocked component for integration testing
lowecg2004 Jun 2, 2007 8:24 AM (in response to denis.diggin)You're welcome. As a general solution to invoking e-mails from test code, I use this:
import java.io.IOException; import javax.faces.context.FacesContext; import org.jboss.seam.InterceptionType; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Install; import org.jboss.seam.annotations.Intercept; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.ui.facelet.FaceletsRenderer; import com.sun.facelets.Facelet; @Scope(ScopeType.STATELESS) @Intercept(InterceptionType.NEVER) @Name("org.jboss.seam.core.renderer") @Install(precedence = Install.MOCK, classDependencies = { "com.sun.facelets.Facelet" }) public class FaceletsRendererMock extends FaceletsRenderer { @Override protected void renderFacelet(final FacesContext facesContext, final Facelet facelet) throws IOException { // This mock will be used when sending e-mails. // JSF cannot render in testng environment so this mock version does nothing. // Despite this, allowing the rest of the Renderer to run will still catch // blatently malformed documents (unterminated XML tags for example). } }
Place this somewhere in your test source folder.
Hope this is useful.
Ps. Sorry it took me so long to reply - I'd not checked the "notify me" option on this thread.