Questo contenuto non è disponibile nella lingua selezionata.

35.3.4. Integration Testing Seam Mail


Warning

This feature is still under development.
It is very easy to integration test your Seam Mail:
public class MailTest extends SeamTest {
    
  @Test
  public void testSimpleMessage() throws Exception {
        
    new FacesRequest() {

      @Override
      protected void updateModelValues() throws Exception {
        setValue("#{person.firstname}", "Pete");
        setValue("#{person.lastname}", "Muir");
        setValue("#{person.address}", "test@example.com");
      }
            
      @Override
      protected void invokeApplication() throws Exception {
        MimeMessage renderedMessage = 
          getRenderedMailMessage("/simple.xhtml");
        assert renderedMessage.getAllRecipients().length == 1;
        InternetAddress to = 
          (InternetAddress) renderedMessage.getAllRecipients()[0];
        assert to.getAddress().equals("test@example.com");
      }
            
    }.run();       
  }
}
Copy to Clipboard Toggle word wrap
Create a new FacesRequest as normal. Inside the invokeApplication hook, we render the message using getRenderedMailMessage(viewId);, which passes the viewId of he message to be rendered. The method returns the rendered message on which you can perform tests. You can also use any standard JSF life cycle method.
There is no support for rendering standard JSF components, so you cannot easily test the contents of the mail message.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat