Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions metadata/org.eclipse.angus/jakarta.mail/1.0.0/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"reflect-config.json",
"resource-config.json"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"condition": {
"typeReachable": "jakarta.mail.Session"
},
"allDeclaredConstructors": true,
"name": "com.sun.mail.smtp.SMTPTransport"
}
]
24 changes: 24 additions & 0 deletions metadata/org.eclipse.angus/jakarta.mail/1.0.0/resource-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resources": {
"includes": [
{
"pattern": "\\QMETA-INF/hk2-locator/default\\E"
},
{
"pattern": "\\QMETA-INF/gfprobe-provider.xml\\E"
},
{
"pattern": "\\QMETA-INF/javamail.charset.map\\E"
},
{
"pattern": "\\QMETA-INF/javamail.default.address.map\\E"
},
{
"pattern": "\\QMETA-INF/javamail.default.providers\\E"
},
{
"pattern": "\\QMETA-INF/mailcap\\E"
}
]
}
}
10 changes: 10 additions & 0 deletions metadata/org.eclipse.angus/jakarta.mail/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"latest": true,
"metadata-version": "1.0.0",
"module": "org.eclipse.angus:jakarta.mail",
"tested-versions": [
"1.0.0"
]
}
]
11 changes: 11 additions & 0 deletions tests/src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@
}
]
},
{
"test-project-path": "org.eclipse.angus/jakarta.mail/1.0.0",
"libraries": [
{
"name": "org.eclipse.angus:jakarta.mail",
"versions": [
"1.0.0"
]
}
]
},
{
"test-project-path": "org.glassfish.jaxb/jaxb-runtime/3.0.2",
"libraries": [
Expand Down
31 changes: 31 additions & 0 deletions tests/src/org.eclipse.angus/jakarta.mail/1.0.0/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright and related rights waived via CC0
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

import org.graalvm.internal.tck.TestUtils

plugins {
id "org.graalvm.internal.tck"
}

String libraryVersion = TestUtils.testedLibraryVersion

dependencies {
testImplementation("org.slf4j:slf4j-api:1.7.36")
testImplementation("org.slf4j:slf4j-simple:1.7.36")
testImplementation("org.eclipse.angus:jakarta.mail:$libraryVersion")
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.awaitility:awaitility:4.2.0'
testImplementation 'commons-io:commons-io:2.11.0'
}

graalvmNative {
binaries {
test {
buildArgs.add('--no-fallback')
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
library.version = 1.0.0
metadata.dir = org.eclipse.angus/jakarta.mail/1.0.0/
20 changes: 20 additions & 0 deletions tests/src/org.eclipse.angus/jakarta.mail/1.0.0/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright and related rights waived via CC0
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

pluginManagement {
def tckPath = Objects.requireNonNullElse(
System.getenv("GVM_TCK_TCKDIR"),
"../../../../tck-build-logic"
)
includeBuild(tckPath)
}

plugins {
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT"
}

rootProject.name = 'jakarta-mail-tests'
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright and related rights waived via CC0
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
package com.sun.mail;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Properties;

import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.Session;
import jakarta.mail.Transport;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import org.apache.commons.io.FileUtils;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class JakartaMailTest {

@BeforeAll
static void beforeAll() throws IOException {
System.out.println("Starting email server ...");
new ProcessBuilder("docker", "run", "--cidfile", "greenmail.cid", "-p", "3025:3025", "--rm", "-e",
"GREENMAIL_OPTS=-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose", "greenmail/standalone:1.6.10")
.redirectOutput(new File("greenmail-stdout.txt"))
.redirectError(new File("greenmail-stderr.txt")).start();
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> {
String logs = FileUtils.readFileToString(new File("greenmail-stdout.txt"), StandardCharsets.UTF_8);
return logs.contains("smtp.SmtpServer| Started") && logs.contains("pop3.Pop3Server| Started") && logs.contains("imap.ImapServer| Started");
});
}

@AfterAll
static void tearDown() throws InterruptedException, IOException {
File cidFile = new File("greenmail.cid");
String cid = FileUtils.readFileToString(cidFile, StandardCharsets.UTF_8);
Files.delete(cidFile.toPath());
new ProcessBuilder("docker", "kill", cid).start().waitFor();
Files.delete(Path.of("greenmail-stdout.txt"));
Files.delete(Path.of("greenmail-stderr.txt"));
}

@Test
void sendMailWithSmtp() throws MessagingException {
Properties properties = new Properties();
properties.put("mail.smtp.host", "localhost");
properties.put("mail.smtp.port", "3025");
Session session = Session.getInstance(properties);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("alice@localhost"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("bob@localhost"));
message.setSubject("This is a test");
message.setText("Dear Bob, hello world! Alice.");
Transport.send(message);
}

@Test
void resources() {
ClassLoader classLoader = getClass().getClassLoader();
Assertions.assertThat(classLoader.getResource("META-INF/hk2-locator/default")).isNotNull();
Assertions.assertThat(classLoader.getResource("META-INF/gfprobe-provider.xml")).isNotNull();
Assertions.assertThat(classLoader.getResource("META-INF/javamail.charset.map")).isNotNull();
Assertions.assertThat(classLoader.getResource("META-INF/javamail.default.address.map")).isNotNull();
Assertions.assertThat(classLoader.getResource("META-INF/javamail.default.providers")).isNotNull();
Assertions.assertThat(classLoader.getResource("META-INF/mailcap")).isNotNull();
}

}