forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mailer: register default mailer beans correctly
- even if only mail template record is used - get rid of unnecessary programmatic lookup in MailTemplateProducer - fixes quarkusio#43518
- Loading branch information
Showing
3 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../mailer/deployment/src/test/java/io/quarkus/mailer/MailTemplateRecordNoInjectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.quarkus.mailer; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.mailer.MailTemplate.MailTemplateInstance; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.ext.mail.MailMessage; | ||
|
||
public class MailTemplateRecordNoInjectionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(confirmation.class) | ||
.addAsResource("mock-config.properties", "application.properties") | ||
.addAsResource(new StringAsset("" | ||
+ "<html>{name}</html>"), "templates/MailTemplateRecordNoInjectionTest/confirmation.html")); | ||
|
||
@Test | ||
public void testMailTemplateRecord() { | ||
// Intentionally use programmatic lookup to obtain the MockMailbox | ||
MockMailbox mockMailbox = Arc.container().instance(MockMailbox.class).get(); | ||
new confirmation("Ondrej").to("[email protected]").from("[email protected]").subject("test mailer") | ||
.send().await().indefinitely(); | ||
assertEquals(1, mockMailbox.getMailMessagesSentTo("[email protected]").size()); | ||
MailMessage message = mockMailbox.getMailMessagesSentTo("[email protected]").get(0); | ||
assertEquals("[email protected]", message.getFrom()); | ||
assertEquals("<html>Ondrej</html>", message.getHtml()); | ||
} | ||
|
||
record confirmation(String name) implements MailTemplateInstance { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters