From ca4bc6da7f5a93ebda585bef5f1a533d7076f6dc Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Nov 2026 19:39:36 +0100 Subject: [PATCH] fixes wrong import in e4 application manifest --- .../META-INF/MANIFEST.MF | 3 +- .../META-INF/MANIFEST.MF | 1 - .../handlers/ApplicationDependenciesTest.java | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/com.minres.scviewer.e4.application.test/src/com/minres/scviewer/e4/application/handlers/ApplicationDependenciesTest.java diff --git a/plugins/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/plugins/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 6faf5aca..0beea089 100644 --- a/plugins/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/plugins/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -39,7 +39,8 @@ Require-Bundle: jakarta.inject.jakarta.inject-api;bundle-version="2.0.1", org.eclipse.help.base;bundle-version="4.2.900", com.minres.scviewer.e4.application.help;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-21 -Import-Package: org.osgi.service.prefs;version="1.1.0", +Import-Package: org.osgi.service.event;version="1.4.0", + org.osgi.service.prefs;version="1.1.0", com.minres.scviewer.database, jakarta.annotation;version="3.0.0", jakarta.inject;version="2.0.0" diff --git a/tests/com.minres.scviewer.e4.application.test/META-INF/MANIFEST.MF b/tests/com.minres.scviewer.e4.application.test/META-INF/MANIFEST.MF index 0f8478f6..b7c54e09 100644 --- a/tests/com.minres.scviewer.e4.application.test/META-INF/MANIFEST.MF +++ b/tests/com.minres.scviewer.e4.application.test/META-INF/MANIFEST.MF @@ -4,7 +4,6 @@ Bundle-Name: SCViewer application tests Bundle-Vendor: MINRES Technologies GmbH Bundle-SymbolicName: com.minres.scviewer.e4.application.test Bundle-Version: 2.20.0 -Import-Package: org.osgi.service.event;version="1.4.0" Fragment-Host: com.minres.scviewer.e4.application Bundle-RequiredExecutionEnvironment: JavaSE-21 Require-Bundle: org.eclipse.e4.ui.bindings, diff --git a/tests/com.minres.scviewer.e4.application.test/src/com/minres/scviewer/e4/application/handlers/ApplicationDependenciesTest.java b/tests/com.minres.scviewer.e4.application.test/src/com/minres/scviewer/e4/application/handlers/ApplicationDependenciesTest.java new file mode 100644 index 00000000..b54b5883 --- /dev/null +++ b/tests/com.minres.scviewer.e4.application.test/src/com/minres/scviewer/e4/application/handlers/ApplicationDependenciesTest.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2026 MINRES Technologies GmbH and others. + * + * SPDX-License-Identifier: EPL-1.0 + * + * Contributors: + * MINRES Technologies GmbH - initial API and implementation + *******************************************************************************/ +package com.minres.scviewer.e4.application.handlers; + +import static org.junit.Assert.*; + +import java.util.Arrays; + +import org.eclipse.osgi.util.ManifestElement; +import org.junit.Test; +import org.osgi.framework.Constants; +import org.osgi.framework.FrameworkUtil; + +import com.minres.scviewer.e4.application.E4LifeCycle; + +public class ApplicationDependenciesTest { + @Test + public void lifecycleEventTypesAreDeclaredByTheProductionBundle() throws Exception { + var application = FrameworkUtil.getBundle(E4LifeCycle.class); + var imports = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, + application.getHeaders().get(Constants.IMPORT_PACKAGE)); + // A fragment import also makes these classes visible during tests, but + // the product does not contain the test fragment. + assertTrue("The application must import Event Admin without the test fragment", + Arrays.stream(imports).anyMatch(element -> element.getValue().equals("org.osgi.service.event"))); + assertNotNull(application.loadClass("org.osgi.service.event.Event")); + assertNotNull(application.loadClass("org.osgi.service.event.EventHandler")); + assertTrue(E4LifeCycle.class.getDeclaredMethods().length > 0); + } +}