diff --git a/activation-bundle/pom.xml b/activation-bundle/pom.xml new file mode 100644 index 0000000..875104f --- /dev/null +++ b/activation-bundle/pom.xml @@ -0,0 +1,165 @@ + + + + + + + + org.eclipse.angus + angus-activation-project + 2.1.0-SNAPSHOT + ../pom.xml + + + 4.0.0 + jakarta.activation + jar + Angus Activation OSGi Bundle (jakarta.activation) + + + + jakarta.activation + jakarta.activation-api + + + org.eclipse.angus + angus-activation + + + org.graalvm.sdk + graal-sdk + true + provided + + + org.junit.jupiter + junit-jupiter-api + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-metadata + process-resources + + unpack + + + + + org.eclipse.angus + angus-activation + ${project.build.outputDirectory} + + + META-INF/services/** + + true + + + jakarta.activation + jakarta.activation-api + ${project.build.outputDirectory} + + META-INF/jakarta.mailcap.default,META-INF/jakarta.mimetypes.default + + true + + + + + + unpack-sources + generate-sources + + unpack-dependencies + + + jakarta.activation-api,angus-activation + sources + ${project.build.directory}/merged-sources + + + **/module-info.java + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-merged-sources + generate-sources + + add-source + + + + ${project.build.directory}/merged-sources + src/main/java + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + jakarta.activation + Jakarta Activation (Angus Implementation) + + Combined bundle containing Jakarta Activation API and Angus Activation implementation. + + + jakarta.activation.*;version=${project.version}, + com.sun.activation.*;version=${project.version} + + + org.eclipse.angus.activation.* + + *;resolution:=optional + Angus Activation + ${project.version} + The Eclipse Foundation + + + + + org.apache.maven.plugins + maven-surefire-plugin + + 1 + false + true + + jakarta.activation:jakarta.activation-api,org.eclipse.angus:angus-activation + + + + + + \ No newline at end of file diff --git a/activation-bundle/src/main/java/module-info.java b/activation-bundle/src/main/java/module-info.java new file mode 100644 index 0000000..877909b --- /dev/null +++ b/activation-bundle/src/main/java/module-info.java @@ -0,0 +1,28 @@ +/* + * 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 + */ + +module jakarta.activation { + + requires java.logging; + requires static org.graalvm.sdk; + + exports jakarta.activation; + exports jakarta.activation.spi; + exports org.eclipse.angus.activation; + + uses jakarta.activation.spi.MailcapRegistryProvider; + uses jakarta.activation.spi.MimeTypeRegistryProvider; + + provides jakarta.activation.spi.MailcapRegistryProvider + with org.eclipse.angus.activation.MailcapRegistryProviderImpl; + + provides jakarta.activation.spi.MimeTypeRegistryProvider + with org.eclipse.angus.activation.MimeTypeRegistryProviderImpl; +} diff --git a/activation-bundle/src/test/java/user/code/test/ActivationBundleTest.java b/activation-bundle/src/test/java/user/code/test/ActivationBundleTest.java new file mode 100644 index 0000000..6cbd6db --- /dev/null +++ b/activation-bundle/src/test/java/user/code/test/ActivationBundleTest.java @@ -0,0 +1,65 @@ +/* + * 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 user.code.test; + +import jakarta.activation.DataHandler; +import jakarta.activation.DataSource; +import jakarta.activation.MailcapCommandMap; +import jakarta.activation.MimeType; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; + +import static org.junit.jupiter.api.Assertions.*; + +public class ActivationBundleTest { + + @Test + void testDataHandlerCreation() throws Exception { + String content = "Hello, Angus Activation!"; + DataSource ds = new DataSource() { + @Override + public InputStream getInputStream() { + return new ByteArrayInputStream(content.getBytes()); + } + + @Override + public OutputStream getOutputStream() { + throw new UnsupportedOperationException("write not supported"); + } + + @Override + public String getContentType() { + return "text/plain"; + } + + @Override + public String getName() { + return "test.txt"; + } + }; + + DataHandler handler = new DataHandler(ds); + assertNotNull(handler); + assertEquals("text/plain", handler.getContentType()); + + // Test MIME type parsing + MimeType mt = new MimeType("text/plain"); + assertEquals("text", mt.getPrimaryType()); + assertEquals("plain", mt.getSubType()); + + // Test MailcapCommandMap default handling + MailcapCommandMap map = (MailcapCommandMap) MailcapCommandMap.getDefaultCommandMap(); + assertNotNull(map); + } +} diff --git a/activation-bundle/src/test/java/user/code/test/module-info.java b/activation-bundle/src/test/java/user/code/test/module-info.java new file mode 100644 index 0000000..94d1151 --- /dev/null +++ b/activation-bundle/src/test/java/user/code/test/module-info.java @@ -0,0 +1,19 @@ +/* + * 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 + */ + +module user.code.test { + + requires jakarta.activation; + requires java.logging; + requires org.junit.jupiter.api; + + exports user.code.test; + opens user.code.test to org.junit.platform.commons; +} diff --git a/pom.xml b/pom.xml index 42ac953..f62c4ef 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ 2.2.0-M1 ${project.version} 23.1.2 + 5.14.0 11 ${maven.compiler.release} @@ -101,6 +102,7 @@ Copyright © 2019, ${current.year} Eclipse Foundation. All rights reserved.] activation-registry + activation-bundle @@ -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} + @@ -248,6 +255,11 @@ Copyright © 2019, ${current.year} Eclipse Foundation. All rights reserved.] jacoco-maven-plugin 0.8.11 + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.4 +