Skip to content
Draft
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
9 changes: 9 additions & 0 deletions activation-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -74,6 +79,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
17 changes: 17 additions & 0 deletions activation-registry/src/test/resources/META-INF/jakarta.mailcap
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions activation-registry/src/test/resources/META-INF/jakarta.mime.types
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions activation-registry/src/test/resources/META-INF/mailcap
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions activation-registry/src/test/resources/META-INF/mime.types
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
<properties>
<spec.version>2.2</spec.version>
<spec.title>Jakarta Activation Specification</spec.title>
<activation-api.version>2.2.0-M1</activation-api.version>
<!-- TODO: Version will need to be updated with JAF containing fix https://github.com/jakartaee/jaf-api/issues/186 -->
<activation-api.version>2.2.0-SNAPSHOT</activation-api.version>
<angus-activation.version>${project.version}</angus-activation.version>
<graal.sdk.version>23.1.2</graal.sdk.version>
<junit.version>6.0.0</junit.version>

<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease>
Expand Down Expand Up @@ -142,6 +144,11 @@ Copyright &#169; 2019, ${current.year} Eclipse Foundation. All rights reserved.]
<artifactId>collections</artifactId>
<version>${graal.sdk.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Loading