jamesnetherton commented on code in PR #3685:
URL: https://github.com/apache/camel-quarkus/pull/3685#discussion_r843955711


##########
integration-tests/mail/src/main/java/org/apache/camel/quarkus/component/mail/CamelRoute.java:
##########
@@ -16,38 +16,215 @@
  */
 package org.apache.camel.quarkus.component.mail;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.CopyOnWriteArrayList;
 
+import javax.activation.DataHandler;
+import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.Produces;
-import javax.mail.Session;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
+import javax.mail.Folder;
+import javax.mail.MessagingException;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePropertyKey;
+import org.apache.camel.attachment.AttachmentMessage;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mail.MailComponent;
+import org.apache.camel.component.mail.MailConverters;
+import org.apache.camel.component.mail.MailMessage;
+import org.apache.camel.support.jsse.KeyManagersParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
 
+@ApplicationScoped
 public class CamelRoute extends RouteBuilder {
+
+    enum Routes {
+        convertersRoute, batchReceiveRoute, imapReceiveRoute, 
imapsReceiveRoute, pop3ReceiveRoute, pop3sReceiveRoute;
+    }
+
+    @Inject
+    @Named("mailReceivedMessages")
+    List<Map<String, Object>> mailReceivedMessages;
+
+    @Inject
+    CamelContext camelContext;
+
+    static final String EMAIL_ADDRESS = "test@localhost";
+    static final String USERNAME = "test";
+    static final String PASSWORD = "s3cr3t";
+
+    @ConfigProperty(name = "mail.smtp.port")
+    int smtpPort;
+
+    @ConfigProperty(name = "mail.smtps.port")
+    int smtpsPort;
+
+    @ConfigProperty(name = "mail.pop3.port")
+    int pop3Port;
+
+    @ConfigProperty(name = "mail.pop3s.port")
+    int pop3sPort;
+
+    @ConfigProperty(name = "mail.imap.port")
+    int imapPort;
+
+    @ConfigProperty(name = "mail.imaps.port")
+    int imapsPort;
+
     @Override
     public void configure() {
-        bindToRegistry("smtp", smtp());
 
-        from("direct:mailtext")
-                .setHeader("Subject", constant("Hello World"))
-                .setHeader("To", constant("james@localhost"))
-                .setHeader("From", constant("claus@localhost"))
-                .to("smtp://localhost?initialDelay=100&delay=100");
+        from("direct:sendMail")
+                .toF("smtp://localhost:%d?username=%s&password=%s", smtpPort, 
USERNAME, PASSWORD);
+
+        from("direct:sendMailSecured").toF(

Review Comment:
   Should we not test the other protocols with the producer?



##########
integration-tests/mail/src/test/java/org/apache/camel/quarkus/component/mail/MailTest.java:
##########
@@ -45,27 +70,89 @@
             + "Hello attachment!"
             + "${delimiter}--\r\n";
 
-    @Test
-    public void testSendAsMail() {
+    @BeforeEach
+    public void beforeEach() {
+        // Configure users
+        Config config = ConfigProvider.getConfig();
+        String userJson = String.format("{ \"email\": \"%s\", \"login\": 
\"%s\", \"password\": \"%s\"}", EMAIL_ADDRESS,
+                USERNAME, PASSWORD);
         RestAssured.given()
-                .contentType(ContentType.TEXT)
-                .body("Hi how are you")
-                .post("/mail/route/mailtext")
+                .contentType(ContentType.JSON)
+                .body(userJson)
+                .post("http://localhost:"; + config.getValue("mail.api.port", 
Integer.class) + "/api/user")
                 .then()
                 .statusCode(200);
 
-        RestAssured.given()
-                .get("/mock/{username}/size", "james@localhost")
+        try {
+            Thread.sleep(3_000);

Review Comment:
   Is the `Thread.sleep` necessary?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to