From f0d7e7d0ee96c6f2fe4f25f5eb6006bc5f8c6d49 Mon Sep 17 00:00:00 2001 From: Dimitris Kafetzis Date: Thu, 23 May 2024 13:25:07 +0300 Subject: [PATCH] [WFLY-18768] OpenShift support for the mail quickstart --- mail/README-source.adoc | 24 +- mail/README.adoc | 321 +++++++++++++++++- mail/charts/greenmail-openshift.yaml | 46 +++ mail/charts/helm.yaml | 9 + mail/configure-mail-session.cli | 10 +- mail/docker-compose.yaml | 27 +- mail/helm-install-prerequisites.adoc | 22 ++ mail/mail-server-conf/imapserver.xml | 17 - mail/mail-server-conf/pop3server.xml | 19 -- mail/mail-server-conf/smtpserver.xml | 28 -- mail/pom.xml | 42 ++- .../org/jboss/as/quickstarts/mail/Email.java | 12 +- mail/src/main/webapp/home.xhtml | 2 +- .../as/quickstarts/mail/MailTestCaseIT.java | 26 +- 14 files changed, 475 insertions(+), 130 deletions(-) create mode 100644 mail/charts/greenmail-openshift.yaml create mode 100644 mail/charts/helm.yaml create mode 100644 mail/helm-install-prerequisites.adoc delete mode 100644 mail/mail-server-conf/imapserver.xml delete mode 100644 mail/mail-server-conf/pop3server.xml delete mode 100644 mail/mail-server-conf/smtpserver.xml diff --git a/mail/README-source.adoc b/mail/README-source.adoc index 15d2a3a308..6394d1ad0d 100644 --- a/mail/README-source.adoc +++ b/mail/README-source.adoc @@ -41,12 +41,12 @@ To run the Mail Quickstart, you need a Mail Server configured with the following In addition, the Mail Subsystem configuration and the test cases expect you have the following Mail accounts configured on your Mail Server: -- user01@james.local -- user02@james.local +- user01@mail.local +- user02@mail.local -You can use any Mail Server you consider, although to facilitate this task, you will find under the Mail Quickstart root directory a docker compose file prepared to launch an Apache James Mail server with all the required configuration. You will need to have installed a Container Engine capable of work with Docker compose files and Linux images. The following command assumes you have https://podman.io/[Podman] and https://docs.podman.io/en/latest/markdown/podman-compose.1.html[Podman Compose] installed in your local environment. +You can use any Mail Server you consider, although to facilitate this task, you will find under the Mail Quickstart root directory a docker compose file prepared to launch an Greenmail mail server with all the required configuration. You will need to have installed a Container Engine capable of work with Docker compose files and Linux images. The following command assumes you have https://podman.io/[Podman] and https://docs.podman.io/en/latest/markdown/podman-compose.1.html[Podman Compose] installed in your local environment. -To launch the Apache James Mail server, open the terminal and navigate to the Mail Quickstart root directory and execute the following: +To launch the Greenmail server, open the terminal and navigate to the Mail Quickstart root directory and execute the following: ``` $ podman compose up --wait @@ -56,10 +56,7 @@ $ podman compose up --wait ✔ Container apache-james Healthy ``` -NOTE: The Apache James server is configured without allowing the relay of the emails to external addresses that are not configured in the server. When you are sending / receiving emails with this server, you have to use the accounts shipped with the apache James demo image. These are the accounts available out of the box: user01@james.local, user02@james.local and user03@james.local. -All accounts use the same password: `1234` - -Once you have finished with the Mail Quickstart, you can shutdown and remove the Apache James Mail server with the following command: +Once you have finished with the Mail Quickstart, you can shutdown and remove the Greenmail server with the following command: ``` $ podman compose down --volumes @@ -138,9 +135,9 @@ The `MyOtherMail` mail session is added to the `mail` subsystem and configured t - + - + ---- @@ -153,9 +150,6 @@ include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+1] The application will be running at the following URL: http://localhost:8080/{artifactId}/[http://localhost:8080/{artifactId}/^]. NOTE: If you see `Error processing request` in the browser when you access the application and attempt to send email, followed by `jakarta.servlet.ServletException: MailConnectException: Couldn't connect to host, port: localhost, 1025; timeout -1; nested exception is: java.net.ConnectException: Connection refused`, make sure you followed the instructions above to xref:configure_an_smtp_server_on_your_local_machine[Configure an SMTP Server on Your Local Machine]. - -NOTE: If you are using the Mail server shipped with this Quickstart and see `Error sending the Email. Invalid Addresses` in the browser when you attempt to send email, make sure you are sending your email to an existing account configured in the Mail Server since by default Apache James demo image is shipped with relay disabled. By default, Apache James demo image has the following accounts configured: user01@james.local, user02@james.local and user03@james.local. - // Server Distribution Testing include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2] @@ -198,7 +192,7 @@ endif::[] //************************************************* ifdef::ProductRelease[] -// Quickstart not compatible with OpenShift -include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1] +// OpenShift +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] endif::[] diff --git a/mail/README.adoc b/mail/README.adoc index b02add4ef5..24cdd4f5ef 100644 --- a/mail/README.adoc +++ b/mail/README.adoc @@ -295,8 +295,8 @@ To run the Mail Quickstart, you need a Mail Server configured with the following In addition, the Mail Subsystem configuration and the test cases expect you have the following Mail accounts configured on your Mail Server: -- user01@james.local -- user02@james.local +- user01@mail.local +- user02@mail.local You can use any Mail Server you consider, although to facilitate this task, you will find under the Mail Quickstart root directory a docker compose file prepared to launch an Apache James Mail server with all the required configuration. You will need to have installed a Container Engine capable of work with Docker compose files and Linux images. The following command assumes you have https://podman.io/[Podman] and https://docs.podman.io/en/latest/markdown/podman-compose.1.html[Podman Compose] installed in your local environment. @@ -310,7 +310,7 @@ $ podman compose up --wait ✔ Container apache-james Healthy ``` -NOTE: The Apache James server is configured without allowing the relay of the emails to external addresses that are not configured in the server. When you are sending / receiving emails with this server, you have to use the accounts shipped with the apache James demo image. These are the accounts available out of the box: user01@james.local, user02@james.local and user03@james.local. +NOTE: The Apache James server is configured without allowing the relay of the emails to external addresses that are not configured in the server. When you are sending / receiving emails with this server, you have to use the accounts shipped with the apache James demo image. These are the accounts available out of the box: user01@mail.local, user02@mail.local and user03@mail.local. All accounts use the same password: `1234` Once you have finished with the Mail Quickstart, you can shutdown and remove the Apache James Mail server with the following command: @@ -1199,7 +1199,316 @@ $ mvn -f {deploymentDir}/pom.xml wildfly:shutdown ---- endif::[] -:leveloffset: 1 +[[build_and_run_the_quickstart_on_openshift]] += Building and running the quickstart application with OpenShift +// The openshift profile +:leveloffset: +1 + +[[build-the-quickstart-for-openshift]] +== Build the {productName} Source-to-Image (S2I) Quickstart to OpenShift with Helm Charts + +On OpenShift, the S2I build with Apache Maven uses an `openshift` Maven profile to provision a {productName} server, deploy and run the quickstart in OpenShift environment. + +ifndef::ProductRelease,EAPXPRelease[] +The server provisioning functionality is provided by the WildFly Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: +endif::[] +ifdef::ProductRelease,EAPXPRelease[] +The server provisioning functionality is provided by the EAP Maven Plugin, and you may find its configuration in the quickstart `pom.xml`: +endif::[] + +ifndef::ProductRelease,EAPXPRelease[] + +[source,xml,subs="attributes+"] +---- + + openshift + + + + org.wildfly.plugins + wildfly-maven-plugin + + + ${version.server} + cloud + + + ROOT.war + ... + + + + + package + + + + + ... + + + +---- +You may note that unlike the `provisioned-server` profile it uses the cloud context which enables a configuration tuned for OpenShift environment. + +The plugin uses https://github.com/wildfly/wildfly-glow[WildFly Glow] to discover the feature packs and layers required to run the application, and provisions a server containing those layers. + +If you get an error or the server is missing some functionality which cannot be auto-discovered, you can download the https://github.com/wildfly/wildfly-glow/releases[WildFly Glow CLI] and run the following command to see more information about what add-ons are available: +[source,shell] +---- +wildfly-glow show-add-ons +---- +endif::ProductRelease,EAPXPRelease[] + +ifdef::ProductRelease,EAPXPRelease[] +[source,xml,subs="attributes+"] +---- + + openshift + + + + org.jboss.eap.plugins + eap-maven-plugin + + ... + + + org.jboss.eap:wildfly-ee-galleon-pack + + + org.jboss.eap.cloud:eap-cloud-galleon-pack + + + ... + ROOT.war + + + + + package + + + + + ... + + + +---- +You may note that it uses the cloud feature pack which enables a configuration tuned for OpenShift environment. +endif::[] + +:leveloffset!: +// Getting Started with Helm +:leveloffset: +1 + +[[getting_started_with_helm]] += Getting Started with {xpaasproduct-shortname} and Helm Charts + +This section contains the basic instructions to build and deploy this quickstart to {xpaasproduct-shortname} or {xpaasproductOpenShiftOnline-shortname} using Helm Charts. + +[[prerequisites_helm_openshift]] +== Prerequisites + +* You must be logged in OpenShift and have an `oc` client to connect to OpenShift +* https://helm.sh[Helm] must be installed to deploy the backend on OpenShift. + +Once you have installed Helm, you need to add the repository that provides Helm Charts for {productName}. + +ifndef::ProductRelease,EAPXPRelease[] +[source,options="nowrap"] +---- +$ helm repo add wildfly https://docs.wildfly.org/wildfly-charts/ +"wildfly" has been added to your repositories +$ helm search repo wildfly +NAME CHART VERSION APP VERSION DESCRIPTION +wildfly/wildfly ... ... Build and Deploy WildFly applications on OpenShift +wildfly/wildfly-common ... ... A library chart for WildFly-based applications +---- +endif::[] +ifdef::ProductRelease[] +[source,options="nowrap",subs="+attributes"] +---- +$ helm repo add jboss-eap https://jbossas.github.io/eap-charts/ +"jboss-eap" has been added to your repositories +$ helm search repo jboss-eap +NAME CHART VERSION APP VERSION DESCRIPTION +{helmChartName} ... ... A Helm chart to build and deploy EAP {productVersion} applications +---- +endif::[] +ifdef::EAPXPRelease[] +[source,options="nowrap",subs="+attributes"] +---- +$ helm repo add jboss-eap https://jbossas.github.io/eap-charts/ +"jboss-eap" has been added to your repositories +$ helm search repo jboss-eap +NAME CHART VERSION APP VERSION DESCRIPTION +{helmChartName} ... ... A Helm chart to build and deploy EAP XP {productVersion} applications +---- +endif::[] + +:leveloffset!: + +ifdef::helm-install-prerequisites[] +// Additional steps needed before deploying in Helm +[[deploy_helm_prerequisites]] +include::{helm-install-prerequisites}[leveloffset=+1] +endif::helm-install-prerequisites[] + +//Prepare Helm for Quickstart Deployment +:leveloffset: +1 + + +ifeval::[{useHelmChartDir} == true] +:helm_chart_values: charts +endif::[] +ifndef::useHelmChartDir[] +:helm_chart_values: -f charts/helm.yaml {helmChartName} +endif::[] +[[deploy_helm]] +== Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift with Helm Charts + +Log in to your OpenShift instance using the `oc login` command. +The backend will be built and deployed on OpenShift with a Helm Chart for {productName}. + +Navigate to the root directory of this quickstart and run the following command: +[source,options="nowrap",subs="+attributes"] +---- +$ helm install {helm-app-name} {helm_chart_values} --wait --timeout=10m0s +NAME: {helm-app-name} +... +STATUS: deployed +REVISION: 1 +---- + +This command will return once the application has successfully deployed. In case of a timeout, you can check the status of the application with the following command in another terminal: + +[source,options="nowrap",subs="+attributes"] +---- +oc get deployment {helm-app-name} +---- + +The Helm Chart for this quickstart contains all the information to build an image from the source code using S2I on Java 17: + + +ifndef::requires-http-route[] +ifdef::useHelmChartDir[] +[source,yaml] +---- +include::{docdir}/charts/Chart.yaml[] +---- +endif::useHelmChartDir[] +ifndef::useHelmChartDir[] +[source,yaml] +---- +build: + uri: https://github.com/wildfly/quickstart.git + ref: main + contextDir: mail +deploy: + replicas: 1 + env: + - name: MAIL_SERVER_ADDRESS + value: "greenmail" +---- +endif::useHelmChartDir[] +endif::requires-http-route[] + +ifdef::requires-http-route[] +[source,options="nowrap",subs="+attributes"] +---- +build: + uri: {githubRepoCodeUrl} + ref: {WildFlyQuickStartRepoTag} + contextDir: {artifactId} +deploy: + replicas: 1 + route: + tls: + enabled: false +---- +endif::requires-http-route[] + +This will create a new deployment on OpenShift and deploy the application. + +If you want to see all the configuration elements to customize your deployment you can use the following command: +[source,options="nowrap",subs="+attributes"] +---- +$ helm show readme {helmChartName} +---- + + +Get the URL of the route to the deployment. + +[source,options="nowrap",subs="+attributes"] +---- +$ oc get route {helm-app-name} -o jsonpath="{.spec.host}" +---- +Access the application in your web browser using the displayed URL. + +[NOTE] +==== +The Maven profile named `openshift` is used by the Helm chart to provision the server with the quickstart deployed on the root web context, and thus the application should be accessed with the URL without the `/{artifactId}` path segment after `HOST:PORT`. +==== + +ifdef::post-helm-install-actions[] +include::{post-helm-install-actions}[leveloffset=+1] +endif::post-helm-install-actions[] + +:leveloffset!: + +// Testing on Openshift +:leveloffset: +1 + +[[run_the_integration_tests_with_openshift]] += Run the Integration Tests with OpenShift +The integration tests included with this quickstart, which verify that the quickstart runs correctly, may also be run with the quickstart running on OpenShift. +[NOTE] +==== +The integration tests expect a deployed application, so make sure you have deployed the quickstart on OpenShift before you begin. +==== + +ifdef::extra-openshift-testing-actions[] +include::{extra-openshift-testing-actions}[leveloffset=+1] +endif::extra-openshift-testing-actions[] + +ifndef::extra-openshift-test-arguments[:extra-openshift-test-arguments:] + +Run the integration tests using the following command to run the `verify` goal with the `integration-testing` profile activated and the proper URL: +ifndef::requires-http-route[] +[source,options="nowrap",subs="+attributes"] +---- +$ mvn verify -Pintegration-testing -Dserver.host=https://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-openshift-test-arguments} +---- +endif::requires-http-route[] +ifdef::requires-http-route[] +[source,options="nowrap",subs="+attributes"] +---- +$ mvn verify -Pintegration-testing -Dserver.host=http://$(oc get route {helm-app-name} --template='{{ .spec.host }}') {extra-openshift-test-arguments} +---- +endif::requires-http-route[] + +[NOTE] +==== +The tests are using SSL to connect to the quickstart running on OpenShift. So you need the certificates to be trusted by the machine the tests are run from. +==== + +:leveloffset!: + +//Prepare Helm for Quickstart Deployment +:leveloffset: +1 + +[[undeploy_helm]] +== Undeploy the {ProductShortName} Source-to-Image (S2I) Quickstart from OpenShift with Helm Charts + +[source,options="nowrap",subs="+attributes"] +---- +$ helm uninstall {helm-app-name} +---- :leveloffset!: endif::[] @@ -1209,7 +1518,7 @@ endif::[] //************************************************* ifdef::ProductRelease[] -// Quickstart not compatible with OpenShift -include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1] +// OpenShift +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] endif::[] diff --git a/mail/charts/greenmail-openshift.yaml b/mail/charts/greenmail-openshift.yaml new file mode 100644 index 0000000000..b316d04fa3 --- /dev/null +++ b/mail/charts/greenmail-openshift.yaml @@ -0,0 +1,46 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: greenmail +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: greenmail + template: + metadata: + labels: + app.kubernetes.io/name: greenmail + spec: + containers: + - name: greenmailserver + image: greenmail/standalone:2.0.1 +--- +apiVersion: v1 +kind: Service +metadata: + name: greenmail +spec: + ports: + - name: "1465" + port: 1465 + targetPort: 3465 + - name: "1993" + port: 1993 + targetPort: 3993 + - name: "1025" + port: 1025 + targetPort: 3025 + - name: "1110" + port: 1110 + targetPort: 3110 + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "1143" + port: 1143 + targetPort: 3143 + selector: + app.kubernetes.io/name: greenmail + type: ClusterIP \ No newline at end of file diff --git a/mail/charts/helm.yaml b/mail/charts/helm.yaml new file mode 100644 index 0000000000..2d2ad9ad18 --- /dev/null +++ b/mail/charts/helm.yaml @@ -0,0 +1,9 @@ +build: + uri: https://github.com/wildfly/quickstart.git + ref: main + contextDir: mail +deploy: + replicas: 1 + env: + - name: MAIL_SERVER_ADDRESS + value: "greenmail" diff --git a/mail/configure-mail-session.cli b/mail/configure-mail-session.cli index e0ed2f5208..e89115db8f 100644 --- a/mail/configure-mail-session.cli +++ b/mail/configure-mail-session.cli @@ -7,14 +7,14 @@ batch /subsystem=mail/mail-session=MyOtherMail:add(jndi-name=java:jboss/mail/MyOtherMail,debug=true) # Configure the custom SMTP, POP3, and IMAP socket binding groups -/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-smtp-binding:add(host=localhost,port=1025) -/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-pop3-binding:add(host=localhost,port=1110) -/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-imap-binding:add(host=localhost,port=1143) +/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-smtp-binding:add(host=${MAIL_SERVER_ADDRESS:localhost},port=1025) +/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-pop3-binding:add(host=${MAIL_SERVER_ADDRESS:localhost},port=1110) +/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=my-imap-binding:add(host=${MAIL_SERVER_ADDRESS:localhost},port=1143) # Add the custom socket binding groups to the custom MyOtherMail mail session -/subsystem=mail/mail-session=MyOtherMail/server=smtp:add(outbound-socket-binding-ref=my-smtp-binding,username="user01@james.local",password=1234) +/subsystem=mail/mail-session=MyOtherMail/server=smtp:add(outbound-socket-binding-ref=my-smtp-binding,username="user01@mail.local",password=1234) /subsystem=mail/mail-session=MyOtherMail/server=pop3:add(outbound-socket-binding-ref=my-pop3-binding) -/subsystem=mail/mail-session=MyOtherMail/server=imap:add(outbound-socket-binding-ref=my-imap-binding, username="user02@james.local",password=1234) +/subsystem=mail/mail-session=MyOtherMail/server=imap:add(outbound-socket-binding-ref=my-imap-binding, username="user02@mail.local",password=1234) # Run the batch commands run-batch diff --git a/mail/docker-compose.yaml b/mail/docker-compose.yaml index f20af5c8a5..9d2db77f49 100644 --- a/mail/docker-compose.yaml +++ b/mail/docker-compose.yaml @@ -1,22 +1,11 @@ services: quickstart-mail-server: - image: "apache/james:demo-3.8.0" - container_name: "apache-james" - hostname: "james.local" + image: "greenmail/standalone:2.0.1" + container_name: "greenmail" ports: - - "1465:465" - - "1993:993" - - "1025:25" - - "1110:110" - - "1587:587" - - "1143:143" - volumes: - - ./mail-server-conf/imapserver.xml:/root/conf/imapserver.xml - - ./mail-server-conf/pop3server.xml:/root/conf/pop3server.xml - - ./mail-server-conf/smtpserver.xml:/root/conf/smtpserver.xml - healthcheck: - test: [ "CMD-SHELL", "/bin/james-cli -h 127.0.0.1 -p 9999 ListUsers | grep -q 'user03@james.local'" ] - interval: 5s - timeout: 1m - retries: 5 - start_period: 20s + - "1465:3465" + - "1993:3993" + - "1025:3025" + - "1110:3110" + - "8081:8080" + - "1143:3143" \ No newline at end of file diff --git a/mail/helm-install-prerequisites.adoc b/mail/helm-install-prerequisites.adoc new file mode 100644 index 0000000000..d5cf2caf48 --- /dev/null +++ b/mail/helm-install-prerequisites.adoc @@ -0,0 +1,22 @@ +=== Install OpenTelemetry Collector on OpenShift + +The functionality of this quickstart depends on a running instance of the https://greenmail-mail-test.github.io/greenmail/[Greenmail Standalone server]. + +To deploy and configure the mail server, you will need to apply a set of configurations to your OpenShift cluster: + +[source,options="nowrap",subs="+attributes"] +---- +include::charts/greenmail-openshift.yaml[] +---- + +To make things simpler, you can find these commands in `charts/greenmail-openshift.yaml`, and to apply them run the following command in your terminal: + +[source] +---- +$ oc apply -f charts/greenmail-openshift.yaml +---- + +[NOTE] +==== +When done with the quickstart, the `oc delete -f charts/greenmail-openshift.yaml` command may be used to revert the applied changes. +==== \ No newline at end of file diff --git a/mail/mail-server-conf/imapserver.xml b/mail/mail-server-conf/imapserver.xml deleted file mode 100644 index c7e3d1afe2..0000000000 --- a/mail/mail-server-conf/imapserver.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - imapserver - 0.0.0.0:143 - 200 - - file://conf/private.key - file://conf/private.csr - - 0 - 0 - false - false - - diff --git a/mail/mail-server-conf/pop3server.xml b/mail/mail-server-conf/pop3server.xml deleted file mode 100644 index e43e368be9..0000000000 --- a/mail/mail-server-conf/pop3server.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - pop3server - 0.0.0.0:110 - 200 - - file://conf/private.key - file://conf/private.csr - - 1200 - 0 - 0 - - - - - diff --git a/mail/mail-server-conf/smtpserver.xml b/mail/mail-server-conf/smtpserver.xml deleted file mode 100644 index c2a5b4d2ef..0000000000 --- a/mail/mail-server-conf/smtpserver.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - smtpserver-global - 0.0.0.0:25 - 200 - - file://conf/private.key - file://conf/private.csr - - 360 - 0 - 0 - - never - false - - false - 0 - true - Apache JAMES awesome SMTP Server - - - - - - diff --git a/mail/pom.xml b/mail/pom.xml index 79128bd61b..1260c816c7 100644 --- a/mail/pom.xml +++ b/mail/pom.xml @@ -50,8 +50,8 @@ ${version.server} 5.0.0.Final - 4.15.0 - 5.7.0 + 4.21.0 + 5.8.0 @@ -231,6 +231,44 @@ + + openshift + + + + org.wildfly.plugins + wildfly-maven-plugin + + + ${version.server} + cloud + + + + + + + false + + + + ROOT.war + + + + + package + + + + + + + + integration-testing diff --git a/mail/src/main/java/org/jboss/as/quickstarts/mail/Email.java b/mail/src/main/java/org/jboss/as/quickstarts/mail/Email.java index 0e76b078da..22bb7d8176 100644 --- a/mail/src/main/java/org/jboss/as/quickstarts/mail/Email.java +++ b/mail/src/main/java/org/jboss/as/quickstarts/mail/Email.java @@ -64,15 +64,15 @@ public class Email implements Serializable { @Resource(mappedName = "java:jboss/mail/MyOtherMail") private Session mySession; - private String to = "user02@james.local"; + private String to = "user02@mail.local"; - private String from = "user01@james.local"; + private String from = "user01@mail.local"; private String subject; private String body; - private String pop3User = "user02@james.local"; + private String pop3User = "user02@mail.local"; private String pop3Password = "1234"; @@ -105,8 +105,8 @@ public void send() { } public void resetSmtp() { - from = "user01@james.local"; - to = "user02@james.local"; + from = "user01@mail.local"; + to = "user02@mail.local"; subject = null; body = null; } @@ -127,7 +127,7 @@ public void retrievePop3() throws Exception { } public void resetPop3() { - pop3User = "user02@james.local"; + pop3User = "user02@mail.local"; pop3Password = "1234"; pop3Emails = null; } diff --git a/mail/src/main/webapp/home.xhtml b/mail/src/main/webapp/home.xhtml index 7461ff12fb..35b8111141 100644 --- a/mail/src/main/webapp/home.xhtml +++ b/mail/src/main/webapp/home.xhtml @@ -109,7 +109,7 @@

- Retrieve emails for the user01@james.local account using IMAP: + Retrieve emails for the user01@mail.local account using IMAP:

diff --git a/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java b/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java index fde3fd784e..98af0d929c 100644 --- a/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java +++ b/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java @@ -46,7 +46,7 @@ public void testSetup() { } driver.get(serverHost); - driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500)); + driver.manage().timeouts().implicitlyWait(Duration.ofMillis(800)); } @After @@ -58,7 +58,7 @@ public void cleanUp() { @Test public void a_testSMTP() { - Wait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); + Wait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); WebElement from = driver.findElement(By.id("smtp_from")); WebElement to = driver.findElement(By.id("smtp_to")); @@ -66,10 +66,10 @@ public void a_testSMTP() { WebElement body = driver.findElement(By.id("smtp_body")); from.clear(); - from.sendKeys("user01@james.local"); + from.sendKeys("user01@mail.local"); to.clear(); - to.sendKeys("user02@james.local"); + to.sendKeys("user02@mail.local"); subject.clear(); subject.sendKeys("This is a test"); @@ -80,21 +80,23 @@ public void a_testSMTP() { WebElement submitButton = driver.findElement(By.id("smtp_send_btn")); submitButton.click(); - WebElement message = driver.findElement(By.xpath("//ul[@id='smtp_messages']/li")); - wait.until(d -> message.isDisplayed()); + wait.until(d -> driver.findElement(By.xpath("//ul[@id='smtp_messages']/li")).isDisplayed()); - Assert.assertEquals("Unexpected result messages after sending an email via SMTP.", "Email sent to user02@james.local", message.getText()); + Assert.assertEquals( + "Unexpected result messages after sending an email via SMTP.", + "Email sent to user02@mail.local", + driver.findElement(By.xpath("//ul[@id='smtp_messages']/li")).getText()); } @Test public void b_retrievePOP3() { - Wait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); + Wait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); WebElement user = driver.findElement(By.id("pop3_user")); WebElement password = driver.findElement(By.id("pop3_password")); user.clear(); - user.sendKeys("user02@james.local"); + user.sendKeys("user02@mail.local"); password.clear(); password.sendKeys("1234"); @@ -112,7 +114,7 @@ public void b_retrievePOP3() { }); WebElement emails = driver.findElement(By.id("pop3_emails")); - Assert.assertTrue("Expected From not found: " + emails.getText(), emails.getText().contains("From : user01@james.local")); + Assert.assertTrue("Expected From not found: " + emails.getText(), emails.getText().contains("From : user01@mail.local")); Assert.assertTrue("Expected Subject not found: " + emails.getText(), emails.getText().contains("Subject : This is a test")); Assert.assertTrue("Expected Body not found : " + emails.getText(), emails.getText().contains("Body : Hello user02, I've sent an email.")); } @@ -120,7 +122,7 @@ public void b_retrievePOP3() { @Test public void c_retrieveIMAP() { - Wait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); + Wait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); WebElement submitButton = driver.findElement(By.id("imap_get_emails_btn")); submitButton.click(); @@ -136,7 +138,7 @@ public void c_retrieveIMAP() { WebElement emails = driver.findElement(By.id("imap_emails")); Assert.assertNotNull("IMAP No messages found.", emails.getText()); - Assert.assertTrue("Expected email not found.", emails.getText().contains("From : user01@james.local")); + Assert.assertTrue("Expected email not found.", emails.getText().contains("From : user01@mail.local")); Assert.assertTrue("Expected email not found.", emails.getText().contains("Subject : This is a test")); Assert.assertTrue("Expected email not found.", emails.getText().contains("Body : Hello user02, I've sent an email.")); }