diff --git a/activation-registry/pom.xml b/activation-registry/pom.xml index 35119ee..381b012 100644 --- a/activation-registry/pom.xml +++ b/activation-registry/pom.xml @@ -38,6 +38,11 @@ true provided + + org.junit.jupiter + junit-jupiter-api + test + @@ -74,6 +79,10 @@ + + org.apache.maven.plugins + maven-surefire-plugin + diff --git a/activation-registry/src/test/java/org/eclipse/angus/activation/MailcapCommandMapTest.java b/activation-registry/src/test/java/org/eclipse/angus/activation/MailcapCommandMapTest.java new file mode 100644 index 0000000..a75f707 --- /dev/null +++ b/activation-registry/src/test/java/org/eclipse/angus/activation/MailcapCommandMapTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0, which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.angus.activation; + +import jakarta.activation.MailcapCommandMap; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MailcapCommandMapTest { + + @Test + public void jakartaAndLegacyResources() { + MailcapCommandMap mailcapCommandMap = new MailcapCommandMap(); + // Same class in mailcap and jakarta.mailcap + assertEquals("com.sun.activation.viewers.ImageViewer", mailcapCommandMap.getCommand("image/gif", "view").getCommandClass()); + // Conflict, mailcap wins + assertEquals("com.sun.activation.viewers.ImageViewer", mailcapCommandMap.getCommand("image/jpeg", "view").getCommandClass()); + // Only exists in mailcap + assertEquals("com.sun.activation.viewers.TextEditor", mailcapCommandMap.getCommand("text/plain", "edit").getCommandClass()); + // Only exists in jakarta.mailcap + assertEquals("com.sun.activation.viewers.TextViewer", mailcapCommandMap.getCommand("text/json", "view").getCommandClass()); + } +} diff --git a/activation-registry/src/test/java/org/eclipse/angus/activation/MimetypesFileTypeMapTest.java b/activation-registry/src/test/java/org/eclipse/angus/activation/MimetypesFileTypeMapTest.java new file mode 100644 index 0000000..d9176f5 --- /dev/null +++ b/activation-registry/src/test/java/org/eclipse/angus/activation/MimetypesFileTypeMapTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0, which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +package org.eclipse.angus.activation; + +import jakarta.activation.MimetypesFileTypeMap; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MimetypesFileTypeMapTest { + + @Test + public void jakartaAndLegacyResources() { + MimetypesFileTypeMap mimetypesFileTypeMap = new MimetypesFileTypeMap(); + // Same value in mime.types and jakarta.mime.types + assertEquals("aaa/aaa", mimetypesFileTypeMap.getContentType("foo.aaa")); + // Conflict, mime.types wins + assertEquals("bbb/bbb", mimetypesFileTypeMap.getContentType("foo.bbb")); + // Only exists in mime.types + assertEquals("ccc/ccc", mimetypesFileTypeMap.getContentType("foo.ccc")); + // Only exists in jakarta.mime.types + assertEquals("ddd/ddd", mimetypesFileTypeMap.getContentType("foo.ddd")); + } +} diff --git a/activation-registry/src/test/resources/META-INF/jakarta.mailcap b/activation-registry/src/test/resources/META-INF/jakarta.mailcap new file mode 100644 index 0000000..e3f4b62 --- /dev/null +++ b/activation-registry/src/test/resources/META-INF/jakarta.mailcap @@ -0,0 +1,17 @@ +# +# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# This is a very simple 'jakarta.mailcap' file as an example. +# Example JavaBean viewers and editors are no longer +# provided as they conflicted with applications. +# +image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer +image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer2 +text/json;; x-java-view=com.sun.activation.viewers.TextViewer diff --git a/activation-registry/src/test/resources/META-INF/jakarta.mime.types b/activation-registry/src/test/resources/META-INF/jakarta.mime.types new file mode 100644 index 0000000..1ea59d8 --- /dev/null +++ b/activation-registry/src/test/resources/META-INF/jakarta.mime.types @@ -0,0 +1,16 @@ +# +# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# +# A simple, old format, jakarta.mime.types file +# +aaa/aaa aaa AAA +bbb/bbb vvv VVV +ddd/ddd ddd DDD diff --git a/activation-registry/src/test/resources/META-INF/mailcap b/activation-registry/src/test/resources/META-INF/mailcap new file mode 100644 index 0000000..8619ec2 --- /dev/null +++ b/activation-registry/src/test/resources/META-INF/mailcap @@ -0,0 +1,17 @@ +# +# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# This is a very simple 'jakarta.mailcap' file as an example. +# Example JavaBean viewers and editors are no longer +# provided as they conflicted with applications. +# +image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer +image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer +text/plain;; x-java-edit=com.sun.activation.viewers.TextEditor diff --git a/activation-registry/src/test/resources/META-INF/mime.types b/activation-registry/src/test/resources/META-INF/mime.types new file mode 100644 index 0000000..c9f4530 --- /dev/null +++ b/activation-registry/src/test/resources/META-INF/mime.types @@ -0,0 +1,16 @@ +# +# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# +# A simple, old format, jakarta.mime.types file +# +aaa/aaa aaa AAA +bbb/bbb bbb BBB +ccc/ccc ccc CCC diff --git a/pom.xml b/pom.xml index 42ac953..91c9cd2 100644 --- a/pom.xml +++ b/pom.xml @@ -33,9 +33,11 @@ 2.2 Jakarta Activation Specification - 2.2.0-M1 + + 2.2.0-SNAPSHOT ${project.version} 23.1.2 + 6.0.0 11 ${maven.compiler.release} @@ -142,6 +144,11 @@ Copyright © 2019, ${current.year} Eclipse Foundation. All rights reserved.] collections ${graal.sdk.version} + + org.junit.jupiter + junit-jupiter-api + ${junit.version} +