From 151df2b224c1fa2805392eb43882738ade390ad6 Mon Sep 17 00:00:00 2001 From: Yeray Borges Date: Tue, 11 Oct 2022 19:17:52 +0100 Subject: [PATCH] [JBEE-257] Add an script to run the Standalone Jakarta Mail TCK Jira issue: https://issues.redhat.com/browse/JBEE-257 --- standalone-tck/run-jakarta-mail-tck.sh | 252 +++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100755 standalone-tck/run-jakarta-mail-tck.sh diff --git a/standalone-tck/run-jakarta-mail-tck.sh b/standalone-tck/run-jakarta-mail-tck.sh new file mode 100755 index 00000000..0898a55b --- /dev/null +++ b/standalone-tck/run-jakarta-mail-tck.sh @@ -0,0 +1,252 @@ +#!/bin/bash +# +# Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + + +# This script will run the Jakarta Mail standalone TCK against a local build of Jakarta Mail API +# To run it: +# $ cd standalone-tck +# $ ./run-jakarta-mail-tck.sh +# +# To test with a different version of Jakarta Activation use the following +# export JAF_BUNDLE_URL=https://repository.jboss.org/nexus/content/groups/public/jakarta/activation/jakarta.activation-api/2.1.1.jbossorg-1/jakarta.activation-api-2.1.1.jbossorg-1.jar +# $ ./run-jakarta-mail-tck.sh + + +# Requirements: +# - You need docker installed and running +# - You have build a local build of Jakarta Mail API +# + + +WGET='wget -q --no-check-certificate --tries=100' +WORKSPACE=/tmp/standalone-tck +CURRENT_DIR=$(pwd) + +if [ -d "${WORKSPACE}" ]; then + rm -rf ${WORKSPACE} 2>/dev/null +fi + +mkdir ${WORKSPACE} +mkdir ${WORKSPACE}/libs + +if [ -z "${JAVA_HOME}" ]; then + echo "JAVA_HOME is not configured" + exit 1 +fi + +export JDK_HOME=$JAVA_HOME +export PATH=$JDK_HOME/bin:$PATH + +java -version + +if [ -z "$JAF_BUNDLE_URL" ];then + export JAF_BUNDLE_URL=https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.jar +fi +if [ -z "$ANGUS_JAF_BUNDLE_URL" ];then + export ANGUS_JAF_BUNDLE_URL=https://repo1.maven.org/maven2/org/eclipse/angus/angus-activation/1.0.0/angus-activation-1.0.0.jar +fi +if [ -z "$ANGUS_MAIL_BUNDLE_URL" ];then + export ANGUS_MAIL_BUNDLE_URL=https://repo1.maven.org/maven2/org/eclipse/angus/angus-mail/1.0.0/angus-mail-1.0.0.jar +fi +if [ -z "$MAIL_API_UNDER_TEST" ];then + export MAIL_API_UNDER_TEST="${CURRENT_DIR}/../api/target/jakarta.mail-api-2.1.2-SNAPSHOT-jbossorg-1.jar" + if [ ! -f "${MAIL_API_UNDER_TEST}" ]; then + echo "Jakarta Mail API jar file not found in ${MAIL_API_UNDER_TEST}" + exit 1 + fi +fi + +# TCK +if [ -z "$MAIL_TCK_BUNDLE_URL" ];then + export MAIL_TCK_BUNDLE_URL=https://download.eclipse.org/jakartaee/mail/2.1/jakarta-mail-tck-2.1.0.zip +fi + +cd ${WORKSPACE} +$WGET -O libs/jakarta.activation-api.jar $JAF_BUNDLE_URL +$WGET -O libs/angus-activation.jar $ANGUS_JAF_BUNDLE_URL +$WGET -O libs/angus-mail.jar $ANGUS_MAIL_BUNDLE_URL +cp ${MAIL_API_UNDER_TEST} ${WORKSPACE}/libs/jakarta.mail-api.jar + +$WGET -O jakarta-mail-tck-2.1.0.zip ${MAIL_TCK_BUNDLE_URL} +unzip -d . jakarta-mail-tck-2.1.0.zip + +$WGET -O apache-ant-1.10.12-bin.zip https://dlcdn.apache.org/ant/binaries/apache-ant-1.10.12-bin.zip +unzip -d . apache-ant-1.10.12-bin.zip + +export TS_HOME=${WORKSPACE}/mail-tck +export ANT_HOME=${WORKSPACE}/apache-ant-1.10.12 + +$WGET https://repo1.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar +mv ant-contrib-1.0b3.jar "$ANT_HOME/lib" + + +export PATH=$TS_HOME/bin:$ANT_HOME/bin:$PATH +echo "*********************************************************" +echo JAVA_HOME = $JAVA_HOME +echo ANT_HOME = $ANT_HOME +echo PATH = $PATH +echo TS_HOME = $TS_HOME +echo WORKSPACE = $WORKSPACE +echo "*********************************************************" + +JAVA_OPTS="-Xms512m -Xmx800m -XX:MaxPermSize=512m -Xss1m -XX:+HeapDumpOnOutOfMemoryError -XX:-UseGCOverheadLimit -Dtest.ejb.stateful.timeout.wait.seconds=70 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000" +JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true" + +# update ts.jte + +cd $TS_HOME + +JARPATH=${WORKSPACE}/libs +sed -i "s%JARPATH=.*%JARPATH=${JARPATH}%g" "$TS_HOME/lib/ts.jte" + +API_JAR=${WORKSPACE}/libs/jakarta.mail-api.jar:${WORKSPACE}/libs/jakarta.activation-api.jar +sed -i "s%API_JAR=.*%API_JAR=${API_JAR}%g" "$TS_HOME/lib/ts.jte" + +CI_JAR=${WORKSPACE}/libs/angus-mail.jar:${WORKSPACE}/libs/angus-activation.jar +sed -i "s%CI_JAR=.*%CI_JAR=${CI_JAR}%g" "$TS_HOME/lib/ts.jte" + +sed -i "s%JAVA_HOME=.*%JAVA_HOME=${JAVA_HOME}%g" "$TS_HOME/lib/ts.jte" +sed -i "s%TS_HOME=.*%TS_HOME=${TS_HOME}%g" "$TS_HOME/lib/ts.jte" + +MAIL_PASSWORD=1234 +MAIL_USER=user01@james.local +MAIL_USER_MAIL_URL_ENCODED=user01%40james.local +SMTP_DOMAIN=james.local +MAIL_HOST=localhost +IMAP_PORT=1143 +SMTP_PORT=1025 +SMTP_FROM=$MAIL_USER +SMTP_TO=$MAIL_USER +SMTP_DOMAIN=james.local + +sed -i "s#^JARPATH=.*#JARPATH=$JARPATH#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_SERVER=.*#JAVAMAIL_SERVER=$MAIL_HOST -pn $IMAP_PORT#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_PROTOCOL=.*#JAVAMAIL_PROTOCOL=imap#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_TRANSPORT_PROTOCOL=.*#JAVAMAIL_TRANSPORT_PROTOCOL=smtp#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_TRANSPORT_SERVER=.*#JAVAMAIL_TRANSPORT_SERVER=$MAIL_HOST -tpn $SMTP_PORT#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_USERNAME=.*#JAVAMAIL_USERNAME=$MAIL_USER#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^JAVAMAIL_PASSWORD=.*#JAVAMAIL_PASSWORD=$MAIL_PASSWORD#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^SMTP_DOMAIN=.*#SMTP_DOMAIN=$SMTP_DOMAIN#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^SMTP_FROM=.*#SMTP_FROM=$SMTP_FROM#g" "$TS_HOME/lib/ts.jte" +sed -i "s#^SMTP_TO=.*#SMTP_TO=$SMTP_TO#g" "$TS_HOME/lib/ts.jte" + +sed -i 's%$testDebug% %g' "$TS_HOME/lib/ts.jte" + + +# --------------------------------------------------------------------------- +# Stop the container in case the Job is stopped or at the end +# --------------------------------------------------------------------------- + +function cleanup { + echo "Cleaning up resources ...." + docker stop cts-mailserver + exit 1 +} + +trap cleanup EXIT SIGTERM SIGINT + +cd ${WORKSPACE} +# --------------------------------------------------------------------------- +# launch.sh launches the Apache James and adds a mark to know when it's done +# --------------------------------------------------------------------------- + +cat > launch.sh<> /root/initialdata.sh + +/root/startup.sh | tee /root/mailserver.log +EOF + +# --------------------------------------------------------------------------- +# The Docker file we use for Apache James +# --------------------------------------------------------------------------- + +cat > Dockerfile<