From 861968fa1abafb32f995969f62285d155d2fd7cd Mon Sep 17 00:00:00 2001 From: Nicola Timeus Date: Thu, 9 Jan 2025 15:24:10 +0100 Subject: [PATCH] Updated tests Signed-off-by: Nicola Timeus --- .../pom.xml | 9 - .../pom.xml | 9 - .../pom.xml | 9 - kura/examples/test/pom.xml | 9 - .../META-INF/MANIFEST.MF | 1 + .../META-INF/MANIFEST.MF | 1 + .../provider/ServletContainerBridgeFix.java | 113 ---- kura/pom.xml | 6 +- .../core/system/test/SystemServiceTest.java | 62 -- .../META-INF/MANIFEST.MF | 10 +- .../kura/core/testutil/http/TestServer.java | 10 +- .../requesthandler/RestTransport.java | 28 +- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 5 +- .../build.properties | 1 - .../META-INF/MANIFEST.MF | 1 + .../pom.xml | 594 ------------------ .../test/PackagesRestServiceTest.java | 4 +- .../test/DeploymentRestServiceUnitTest.java | 26 +- .../rest/provider/test/RestServiceTest.java | 5 +- .../pom.xml | 9 - kura/test/pom.xml | 58 +- .../kura.target-platform.build.properties | 2 +- 23 files changed, 87 insertions(+), 888 deletions(-) delete mode 100644 kura/org.eclipse.kura.rest.provider/src/main/java/org/eclipse/kura/internal/rest/provider/ServletContainerBridgeFix.java diff --git a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml index 7ee50716898..8542943ecb4 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.logic.multiport.provider.test/pom.xml @@ -118,11 +118,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - log4j2-api-config 4 @@ -288,10 +283,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit org.eclipse.equinox.wireadmin diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml index d1997993541..94bd25ab58a 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.math.singleport.provider.test/pom.xml @@ -122,11 +122,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - log4j2-api-config 4 @@ -292,10 +287,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit org.eclipse.equinox.wireadmin diff --git a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml index 4ed0fb41e47..74d78a6f78f 100644 --- a/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml +++ b/kura/examples/test/org.eclipse.kura.example.wire.math.trig.test/pom.xml @@ -122,11 +122,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - log4j2-api-config 4 @@ -292,10 +287,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit org.eclipse.equinox.wireadmin diff --git a/kura/examples/test/pom.xml b/kura/examples/test/pom.xml index ceb86825cbf..cec3ccb7f8b 100644 --- a/kura/examples/test/pom.xml +++ b/kura/examples/test/pom.xml @@ -181,10 +181,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit slf4j.api @@ -330,11 +326,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - slf4j.api 4 diff --git a/kura/org.eclipse.kura.http.server.manager/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.http.server.manager/META-INF/MANIFEST.MF index decc5114c8d..feb6784546f 100644 --- a/kura/org.eclipse.kura.http.server.manager/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.http.server.manager/META-INF/MANIFEST.MF @@ -27,3 +27,4 @@ Import-Package: jakarta.servlet;version="5.0.0", org.osgi.service.component;version="1.3.0", org.osgi.service.event;version="1.4.0", org.slf4j;version="1.7.21" +Require-Bundle: org.apache.felix.http.bridge;bundle-version="5.1.8" diff --git a/kura/org.eclipse.kura.rest.provider/META-INF/MANIFEST.MF b/kura/org.eclipse.kura.rest.provider/META-INF/MANIFEST.MF index c5dc5f57cd5..f6fc3997bb2 100644 --- a/kura/org.eclipse.kura.rest.provider/META-INF/MANIFEST.MF +++ b/kura/org.eclipse.kura.rest.provider/META-INF/MANIFEST.MF @@ -30,5 +30,6 @@ Import-Package: com.google.gson;version="2.9.0", org.osgi.service.useradmin;version="1.1.0", org.osgi.util.tracker;version="1.5.2", org.slf4j;version="1.7.21" +Require-Bundle: org.eclipse.osgitech.rest.servlet.whiteboard;bundle-version="1.2.3" Export-Package: org.eclipse.kura.rest.auth;version="1.0.0", org.eclipse.kura.rest.utils;version="1.0.0" diff --git a/kura/org.eclipse.kura.rest.provider/src/main/java/org/eclipse/kura/internal/rest/provider/ServletContainerBridgeFix.java b/kura/org.eclipse.kura.rest.provider/src/main/java/org/eclipse/kura/internal/rest/provider/ServletContainerBridgeFix.java deleted file mode 100644 index aa96ccca3c7..00000000000 --- a/kura/org.eclipse.kura.rest.provider/src/main/java/org/eclipse/kura/internal/rest/provider/ServletContainerBridgeFix.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - *******************************************************************************/ -package org.eclipse.kura.internal.rest.provider; - -import java.lang.reflect.Field; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTrackerCustomizer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ServletContainerBridgeFix implements ServiceTrackerCustomizer { - - private static final Logger logger = LoggerFactory.getLogger(ServletContainerBridgeFix.class); - - private final BundleContext bundleContext; - - public ServletContainerBridgeFix(final BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - @Override - public Thread addingService(ServiceReference reference) { - final Object service = this.bundleContext.getService(reference); - - logger.info("found service: {}", service.getClass()); - - final Thread worker = new Worker(service); - worker.start(); - - return worker; - } - - @Override - public void modifiedService(ServiceReference reference, Thread worker) { - // do nothing - } - - @Override - public void removedService(ServiceReference reference, Thread worker) { - worker.interrupt(); - - try { - worker.join(2000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - this.bundleContext.ungetService(reference); - - } - - private static class Worker extends Thread { - - private final Object servlet; - - public Worker(final Object servlet) { - this.servlet = servlet; - } - - @Override - public void run() { - - Thread.currentThread().setName("ServletContainerBridgeFixWorker"); - - try { - - while (!isInterrupted()) { - - final Field servletField = servlet.getClass().getDeclaredField("servlet"); - servletField.setAccessible(true); - - final Object bridge = servletField.get(servlet); - - final Field servletConfigField = bridge.getClass().getDeclaredField("servletConfig"); - servletConfigField.setAccessible(true); - - final Object servletConfig = servletConfigField.get(bridge); - - if (servletConfig == null) { - sleep(200); - continue; - } - - final Field configField = bridge.getClass().getSuperclass().getSuperclass() - .getDeclaredField("config"); - configField.setAccessible(true); - - configField.set(bridge, servletConfig); - - return; - } - - } catch (final InterruptedException e) { - interrupt(); - } catch (final Exception e) { - logger.warn("failed to fix ServletContainerHolder", e); - } - } - } - -} diff --git a/kura/pom.xml b/kura/pom.xml index 6a4374d4782..ae68d801aaf 100644 --- a/kura/pom.xml +++ b/kura/pom.xml @@ -197,7 +197,7 @@ -DbuildingWithTycho=true -Dosgi.locking=none -Dds.showtrace=true -Djava.io.tmpdir=/tmp - -Dorg.osgi.framework.storage=/tmp/osgi/framework_storage + -Dorg.osgi.framework.storage=${project.basedir}/osgi/framework_storage -Dosgi.clean=true -Dkura.home=${project.basedir}/target/kura -Dkura.plugins=${project.basedir}/target/kura/plugins @@ -240,7 +240,7 @@ -DbuildingWithTycho=true -Dosgi.locking=none -Dds.showtrace=true -Djava.io.tmpdir=/tmp - -Dorg.osgi.framework.storage=/tmp/osgi/framework_storage + -Dorg.osgi.framework.storage=${project.basedir}/osgi/framework_storage -Dosgi.clean=true -Dkura.home=${project.basedir}/target/kura -Dkura.plugins=${project.basedir}/target/kura/plugins @@ -251,11 +251,9 @@ -Dkura.configuration=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/kura.properties -Dlog4j.configurationFile=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/log4j.xml -Dorg.eclipse.kura.mode=emulator - -Dorg.eclipse.equinox.http.jetty.customizer.class=org.eclipse.kura.jetty.customizer.KuraJettyCustomizer -Ddpa.configuration=/tmp/kura/dpa.properties -Dosgi.console=5002 --add-opens java.base/java.lang=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED diff --git a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java index 1f83f99bed3..7ecd76af67e 100644 --- a/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java +++ b/kura/test/org.eclipse.kura.core.system.test/src/main/java/org/eclipse/kura/core/system/test/SystemServiceTest.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -24,16 +23,12 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Properties; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.kura.core.testutil.TestUtil; -import org.eclipse.kura.executor.Command; import org.eclipse.kura.executor.CommandExecutorService; -import org.eclipse.kura.executor.CommandStatus; import org.eclipse.kura.system.SystemService; import org.eclipse.kura.test.annotation.TestTarget; import org.junit.BeforeClass; @@ -306,69 +301,12 @@ public void getModelId() { assertNotNull(systemService.getModelId()); } - @TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL }) - @Test - public void getModelName() throws NoSuchFieldException { - // remove the default value so that the command is run - Properties def = (Properties) TestUtil.getFieldValue(systemService.getProperties(), "defaults"); - def.remove(SystemService.KEY_MODEL_NAME); - - String modelName = systemService.getModelName(); - - assertNotNull(modelName); - - String osName = systemService.getOsName(); - if (!osName.contains("indows")) { - if (LINUX.equals(osName)) { - CommandStatus status = executorService.execute(new Command(new String[] { "dmidecode" })); - if (!status.getExitStatus().isSuccessful()) { - assertEquals(UNKNOWN, modelName); - } - - // note: this assert works locally and on travis, but not on hudson - // assertNotEquals("UNKNOWN", modelName); - - assertNotEquals("DevModelName", modelName); - } - } else { - assertEquals(UNKNOWN, modelName); - } - } - @TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL }) @Test public void getPartNumber() { assertNotNull(systemService.getPartNumber()); } - @TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL }) - @Test - public void getSerialNumber() throws NoSuchFieldException { - // remove the default value so that the command is run - Properties def = (Properties) TestUtil.getFieldValue(systemService.getProperties(), "defaults"); - def.remove(SystemService.KEY_SERIAL_NUM); - - String serialNumber = systemService.getSerialNumber(); - - assertNotNull(serialNumber); - - String osName = systemService.getOsName(); - if (!osName.contains("indows")) { - if (LINUX.equals(osName)) { - CommandStatus status = executorService.execute(new Command(new String[] { "dmidecode" })); - if (!status.getExitStatus().isSuccessful()) { - assertEquals(UNKNOWN, serialNumber); - } - // note: this assert works locally and on travis, but not on hudson - // assertNotEquals("UNKNOWN", serialNumber); - - assertNotEquals("DevSerialNumber", serialNumber); - } - } else { - assertEquals(UNKNOWN, serialNumber); - } - } - @TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL }) @Test public void shouldGetDefaultLogManagerProperty() { diff --git a/kura/test/org.eclipse.kura.core.testutil/META-INF/MANIFEST.MF b/kura/test/org.eclipse.kura.core.testutil/META-INF/MANIFEST.MF index fdf7494b86d..07552708ee9 100644 --- a/kura/test/org.eclipse.kura.core.testutil/META-INF/MANIFEST.MF +++ b/kura/test/org.eclipse.kura.core.testutil/META-INF/MANIFEST.MF @@ -6,6 +6,8 @@ Bundle-Version: 6.0.0.qualifier Bundle-Vendor: Eclipse Kura Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" Import-Package: com.eclipsesource.json;version="0.9.5", + jakarta.servlet;version="[6.0.0,7.0.0)", + jakarta.servlet.http;version="[6.0.0,7.0.0)", javax.servlet;version="3.1.0", javax.servlet.http;version="3.1.0", junit.framework;version="[4.12.0,5.0.0)", @@ -22,11 +24,9 @@ Import-Package: com.eclipsesource.json;version="0.9.5", org.bouncycastle.operator;version="1.78.1", org.bouncycastle.operator.jcajce;version="1.78.1", org.bouncycastle.x509.extension;version="1.78.1", - org.eclipse.jetty.server;version="9.4.41", - org.eclipse.jetty.server.handler;version="9.4.41", - org.eclipse.jetty.servlet;version="9.4.41", - org.eclipse.jetty.util;version="9.4.41", - org.eclipse.jetty.util.component;version="9.4.41", + org.eclipse.jetty.ee10.servlet;version="[12.0.0,13.0.0)", + org.eclipse.jetty.server;version="[12.0.0,13.0.0)", + org.eclipse.jetty.util;version="[12.0.0,13.0.0)", org.eclipse.kura;version="[1.6,2.0)", org.eclipse.kura.configuration;version="[1.2,2.0)", org.eclipse.kura.core.data.util;version="[1.0,2.0)", diff --git a/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/http/TestServer.java b/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/http/TestServer.java index d3cd68551eb..468efc42aff 100644 --- a/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/http/TestServer.java +++ b/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/http/TestServer.java @@ -20,16 +20,16 @@ import java.util.Optional; import java.util.function.Consumer; +import org.eclipse.jetty.ee10.servlet.ServletContextHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; + import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; - public class TestServer implements Closeable { private final Server server; diff --git a/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/requesthandler/RestTransport.java b/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/requesthandler/RestTransport.java index d2e11c95f27..c50673578e8 100644 --- a/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/requesthandler/RestTransport.java +++ b/kura/test/org.eclipse.kura.core.testutil/src/main/java/org/eclipse/kura/core/testutil/requesthandler/RestTransport.java @@ -158,26 +158,33 @@ public Response runRequest(final String urlPrefix, final String relativeUri, fin connection.setRequestMethod(method.getRestMethod()); if (requestBody != null) { - connection.setDoOutput(true); + connection.setChunkedStreamingMode(0); connection.setRequestProperty("Content-Type", "application/json"); - IOUtils.write(requestBody, connection.getOutputStream()); + connection.setDoOutput(true); + uploadBody(requestBody, connection); } - connection.connect(); - final int status = connection.getResponseCode(); - final String body = getBody(connection); + final Optional body = getBody(connection); storeCookies(urlPrefix, relativeUri, connection); connection.disconnect(); - return new Response(status, Optional.ofNullable(body).filter(b -> !b.isEmpty())); + return new Response(status, body.filter(b -> !b.isEmpty())); } catch (final Exception e) { throw new IllegalStateException("request failed", e); } } + private void uploadBody(final String requestBody, final HttpURLConnection connection) { + try { + IOUtils.write(requestBody, connection.getOutputStream()); + } catch (final Exception e) { + logger.warn("failed to send body", e); + } + } + private void setHeaders(final HttpURLConnection connection) { for (final Entry e : this.headers.entrySet()) { connection.setRequestProperty(e.getKey(), e.getValue()); @@ -207,10 +214,15 @@ public CookieManager getCookieManager() { return cookieManager; } - private String getBody(final HttpURLConnection connection) throws IOException { + private Optional getBody(final HttpURLConnection connection) throws IOException { try (final InputStream in = ((connection.getResponseCode() / 200) == 1) ? connection.getInputStream() : connection.getErrorStream()) { - return IOUtils.toString(in, StandardCharsets.UTF_8); + + if (in == null) { + return Optional.empty(); + } + + return Optional.of(IOUtils.toString(in, StandardCharsets.UTF_8)); } } diff --git a/kura/test/org.eclipse.kura.event.publisher.test/META-INF/MANIFEST.MF b/kura/test/org.eclipse.kura.event.publisher.test/META-INF/MANIFEST.MF index faf2d01ed91..0d30ec16e16 100644 --- a/kura/test/org.eclipse.kura.event.publisher.test/META-INF/MANIFEST.MF +++ b/kura/test/org.eclipse.kura.event.publisher.test/META-INF/MANIFEST.MF @@ -6,8 +6,7 @@ Bundle-Version: 6.0.0.qualifier Bundle-Vendor: Eclipse Kura Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" Fragment-Host: org.eclipse.kura.event.publisher -Import-Package: junit.framework;version="[4.12.0,5.0.0)", - org.junit;version="[4.12.0,5.0.0)", +Import-Package: org.junit;version="[4.12.0,5.0.0)", org.junit.runner;version="[4.12.0,5.0.0)", org.junit.runners;version="[4.12.0,5.0.0)", org.mockito;version="[4.0.0,5.0.0)", diff --git a/kura/test/org.eclipse.kura.event.publisher.test/build.properties b/kura/test/org.eclipse.kura.event.publisher.test/build.properties index 301c325c734..64085eb0920 100644 --- a/kura/test/org.eclipse.kura.event.publisher.test/build.properties +++ b/kura/test/org.eclipse.kura.event.publisher.test/build.properties @@ -13,7 +13,4 @@ source.. = src/main/java output.. = target/classes/ bin.includes = META-INF/,\ - . -additional.bundles = slf4j.api,\ - org.junit,\ - org.apache.logging.log4j.api \ No newline at end of file + . \ No newline at end of file diff --git a/kura/test/org.eclipse.kura.http.server.manager.test/build.properties b/kura/test/org.eclipse.kura.http.server.manager.test/build.properties index 4992d618e6d..2cfb08af6b9 100644 --- a/kura/test/org.eclipse.kura.http.server.manager.test/build.properties +++ b/kura/test/org.eclipse.kura.http.server.manager.test/build.properties @@ -15,5 +15,4 @@ bin.includes = .,\ about.html,\ OSGI-INF/,\ META-INF/ -extra.. = platform:/fragment/org.eclipse.kura.jetty.customizer source.. = src/main/java/ diff --git a/kura/test/org.eclipse.kura.rest.packages.provider.test/META-INF/MANIFEST.MF b/kura/test/org.eclipse.kura.rest.packages.provider.test/META-INF/MANIFEST.MF index 53b656df0df..eccb79f69a7 100644 --- a/kura/test/org.eclipse.kura.rest.packages.provider.test/META-INF/MANIFEST.MF +++ b/kura/test/org.eclipse.kura.rest.packages.provider.test/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: jakarta.annotation;version="2.1.1", org.eclipse.kura.data.transport.listener;version="1.0.1", org.eclipse.kura.marshalling;version="1.0.0", org.eclipse.kura.message;version="1.4.0", + org.glassfish.jersey.client;version="[3.1.0,4.0.0)", org.glassfish.jersey.client.authentication;version="3.1.9", org.glassfish.jersey.media.multipart;version="3.1.9", org.glassfish.jersey.media.multipart.file;version="3.1.9", diff --git a/kura/test/org.eclipse.kura.rest.packages.provider.test/pom.xml b/kura/test/org.eclipse.kura.rest.packages.provider.test/pom.xml index 2e738229728..9573b45c17d 100644 --- a/kura/test/org.eclipse.kura.rest.packages.provider.test/pom.xml +++ b/kura/test/org.eclipse.kura.rest.packages.provider.test/pom.xml @@ -54,417 +54,6 @@ org.eclipse.tycho tycho-surefire-plugin - - false - junit4 - false - - ${tycho.testArgLine} - ${tycho.surefire.testenv.args} - - - - p2-installable-unit - moquette-broker - - - p2-installable-unit - org.eclipse.equinox.ds - - - p2-installable-unit - org.apache.felix.scr - - - p2-installable-unit - org.eclipse.equinox.console - - - p2-installable-unit - org.eclipse.core.runtime - - - p2-installable-unit - org.eclipse.equinox.io - - - p2-installable-unit - org.eclipse.equinox.app - - - p2-installable-unit - org.eclipse.equinox.cm - - - p2-installable-unit - org.eclipse.equinox.common - - - p2-installable-unit - org.eclipse.equinox.event - - - p2-installable-unit - org.eclipse.equinox.metatype - - - p2-installable-unit - org.eclipse.equinox.preferences - - - p2-installable-unit - org.eclipse.equinox.registry - - - p2-installable-unit - org.eclipse.equinox.util - - - p2-installable-unit - org.eclipse.osgi - - - p2-installable-unit - org.eclipse.osgi.services - - - p2-installable-unit - org.eclipse.osgi.util - - - p2-installable-unit - org.hamcrest.core - - - p2-installable-unit - org.eclipse.equinox.launcher - - - p2-installable-unit - slf4j.api - - - p2-installable-unit - org.junit - - - p2-installable-unit - org.apache.commons.commons-io - - - p2-installable-unit - org.apache.logging.log4j.api - - - p2-installable-unit - org.eclipse.kura.core - - - p2-installable-unit - org.eclipse.kura.core.system - - - p2-installable-unit - com.h2database - - - p2-installable-unit - org.eclipse.equinox.wireadmin - - - p2-installable-unit - org.apache.activemq.artemis-mqtt-protocol - - - p2-installable-unit - org.eclipse.kura.core.keystore - - - p2-installable-unit - org.apache.felix.dependencymanager - - - p2-installable-unit - org.apache.felix.deploymentadmin - - - p2-installable-unit - org.eclipse.kura.emulator.position - - - - - moquette-broker - 3 - true - - - org.eclipse.equinox.ds - 4 - true - - - org.apache.felix.scr - 4 - true - - - org.eclipse.core.runtime - 4 - true - - - org.eclipse.equinox.io - 4 - true - - - org.eclipse.equinox.app - 4 - true - - - org.eclipse.equinox.cm - 4 - true - - - org.eclipse.equinox.common - 4 - true - - - org.eclipse.equinox.event - 4 - true - - - org.eclipse.equinox.metatype - 4 - true - - - org.eclipse.equinox.preferences - 4 - true - - - org.eclipse.equinox.registry - 4 - true - - - org.eclipse.equinox.console - 4 - true - - - org.eclipse.equinox.util - 4 - true - - - org.eclipse.equinox.wireadmin - 4 - true - - - org.eclipse.osgi.services - 4 - true - - - org.eclipse.osgi.util - 4 - true - - - org.hamcrest.core - 4 - true - - - org.eclipse.equinox.launcher - 4 - true - - - slf4j.api - 4 - true - - - log4j2-api-config - 4 - false - - - org.apache.logging.log4j.api - 4 - true - - - org.apache.logging.log4j.core - 4 - true - - - org.apache.logging.log4j.slf4j.impl - 4 - true - - - mqtt-client - 4 - true - - - com.h2database - 4 - true - - - org.junit - 4 - true - - - org.apache.commons.io - 4 - true - - - org.eclipse.kura.api - 4 - true - - - org.eclipse.kura.core.configuration - 4 - true - - - org.eclipse.kura.core.crypto - 4 - true - - - org.eclipse.kura.json.marshaller.unmarshaller.provider - 4 - true - - - org.eclipse.kura.xml.marshaller.unmarshaller.provider - 4 - true - - - com.sun.xml.bind.jaxb-osgi - 1 - true - - - org.glassfish.hk2.osgi-resource-locator - 1 - true - - - org.apache.camel.camel-core - true - 2 - - - org.eclipse.kura.camel - true - 3 - - - org.eclipse.kura.core.status - 4 - true - - - org.eclipse.kura.emulator - 4 - true - - - org.eclipse.kura.emulator.net - 4 - true - - - org.eclipse.kura.emulator.gpio - 4 - true - - - org.eclipse.kura.emulator.watchdog - 4 - true - - - org.eclipse.kura.emulator.usb - 4 - true - - - org.eclipse.kura.broker.artemis.core - 4 - true - - - org.eclipse.kura.broker.artemis.simple.mqtt - 4 - true - - - org.eclipse.kura.broker.artemis.xml - 4 - true - - - org.apache.activemq.artemis-mqtt-protocol - 4 - true - - - org.eclipse.kura.http.server.manager - 4 - true - - - org.apache.felix.useradmin - 4 - true - - - org.eclipse.kura.useradmin.store - 4 - true - - - org.eclipse.kura.rest.provider - 4 - true - - - org.apache.felix.dependencymanager - 4 - true - - - org.apache.felix.deploymentadmin - 4 - true - - - org.eclipse.kura.emulator.position - 4 - true - - - org.apache.maven.plugins @@ -473,189 +62,6 @@ org.eclipse.tycho target-platform-configuration - - -consoleLog - p2 - - - - eclipse-plugin - org.hamcrest - 0.0.0 - - - p2-installable-unit - org.apache.logging.log4j.api - 0.0.0 - - - p2-installable-unit - org.apache.logging.log4j.core - 0.0.0 - - - eclipse-plugin - log4j2-api-config - 0.0.0 - - - p2-installable-unit - org.apache.logging.log4j.slf4j.impl - 0.0.0 - - - p2-installable-unit - jakarta.xml.bind-api - 0.0.0 - - - p2-installable-unit - jakarta.activation-api - 0.0.0 - - - p2-installable-unit - com.sun.xml.bind.jaxb-osgi - 0.0.0 - - - p2-installable-unit - org.glassfish.hk2.osgi-resource-locator - 0.0.0 - - - eclipse-plugin - org.eclipse.equinox.cm - 1 - - - eclipse-plugin - org.eclipse.kura.api - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.emulator - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.emulator.net - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.emulator.watchdog - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.emulator.gpio - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.cloud.factory - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.comm - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.xml.marshaller.unmarshaller.provider - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.json.marshaller.unmarshaller.provider - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.system - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.configuration - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.crypto - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.status - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.deployment - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.net - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.deployment.agent - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.rest.provider - 0.0.0 - - - eclipse-plugin - org.apache.felix.useradmin - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.useradmin.store - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.rest.provider - 0.0.0 - - - eclipse-plugin - org.apache.felix.useradmin - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.core.keystore - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.emulator.position - 0.0.0 - - - eclipse-plugin - org.eclipse.kura.cloudconnection.kapua.mqtt.provider - 0.0.0 - - - - diff --git a/kura/test/org.eclipse.kura.rest.packages.provider.test/src/main/java/org/eclipse/kura/rest/packages/provider/test/PackagesRestServiceTest.java b/kura/test/org.eclipse.kura.rest.packages.provider.test/src/main/java/org/eclipse/kura/rest/packages/provider/test/PackagesRestServiceTest.java index df1e2eb8f4f..12e056a918c 100644 --- a/kura/test/org.eclipse.kura.rest.packages.provider.test/src/main/java/org/eclipse/kura/rest/packages/provider/test/PackagesRestServiceTest.java +++ b/kura/test/org.eclipse.kura.rest.packages.provider.test/src/main/java/org/eclipse/kura/rest/packages/provider/test/PackagesRestServiceTest.java @@ -45,6 +45,7 @@ import org.eclipse.kura.deployment.agent.DeploymentAgentService; import org.eclipse.kura.deployment.agent.MarketplacePackageDescriptor; import org.eclipse.kura.internal.rest.deployment.agent.DeploymentRestService; +import org.glassfish.jersey.client.JerseyClientBuilder; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.glassfish.jersey.media.multipart.MultiPartFeature; @@ -64,7 +65,6 @@ import org.osgi.service.deploymentadmin.DeploymentPackage; import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Response; @@ -338,7 +338,7 @@ private void givenDeploymentAgentServiceThrowsExceptionOnGetMarketplacePackageDe private void whenUploadIsPerformedWith(String filePath) { HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder().credentials(USERNAME, PASSWORD) .build(); - final Client client = ClientBuilder.newBuilder().register(MultiPartFeature.class).register(feature).build(); + final Client client = new JerseyClientBuilder().register(MultiPartFeature.class).register(feature).build(); FormDataMultiPart formDataMultiPart = new FormDataMultiPart(); final FileDataBodyPart filePart = new FileDataBodyPart("file", new File(filePath)); diff --git a/kura/test/org.eclipse.kura.rest.packages.provider.test/src/test/java/org/eclipse/kura/internal/rest/deployment/agent/test/DeploymentRestServiceUnitTest.java b/kura/test/org.eclipse.kura.rest.packages.provider.test/src/test/java/org/eclipse/kura/internal/rest/deployment/agent/test/DeploymentRestServiceUnitTest.java index 99f7a94179b..b8a97a4546d 100644 --- a/kura/test/org.eclipse.kura.rest.packages.provider.test/src/test/java/org/eclipse/kura/internal/rest/deployment/agent/test/DeploymentRestServiceUnitTest.java +++ b/kura/test/org.eclipse.kura.rest.packages.provider.test/src/test/java/org/eclipse/kura/internal/rest/deployment/agent/test/DeploymentRestServiceUnitTest.java @@ -35,8 +35,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; - -import jakarta.ws.rs.WebApplicationException; +import java.util.Optional; import org.eclipse.kura.KuraErrorCode; import org.eclipse.kura.KuraException; @@ -47,7 +46,6 @@ import org.eclipse.kura.rest.deployment.agent.api.DeploymentRequestStatus; import org.eclipse.kura.rest.deployment.agent.api.DescriptorRequest; import org.eclipse.kura.rest.deployment.agent.api.InstallRequest; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.junit.Test; import org.osgi.framework.Version; import org.osgi.service.deploymentadmin.DeploymentAdmin; @@ -55,6 +53,9 @@ import org.osgi.service.useradmin.Role; import org.osgi.service.useradmin.UserAdmin; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.EntityPart; + public class DeploymentRestServiceUnitTest { private static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; @@ -69,7 +70,7 @@ public class DeploymentRestServiceUnitTest { private DeploymentAdmin mockDeploymentAdmin = mock(DeploymentAdmin.class); private UserAdmin mockUserAdmin = mock(UserAdmin.class); private InputStream mockInputStream = mock(InputStream.class); - private FormDataContentDisposition mockFormDataContent = mock(FormDataContentDisposition.class); + private EntityPart mockEntityPart = mock(EntityPart.class); private final ArrayList installedDeploymentPackages = new ArrayList<>(); @@ -192,7 +193,7 @@ public void installUploadedDeploymentPackageWorks() throws Exception { givenAMockInputStream(); givenAMockFormDataContentWithFileName("mock.dp"); - whenInstallUploadedDeploymentPackageIsCalledWith(this.mockInputStream, this.mockFormDataContent); + whenInstallUploadedDeploymentPackageIsCalledWith(this.mockEntityPart, this.mockInputStream); thenNoExceptionOccurred(); thenDeploymentRequestStatusIs(DeploymentRequestStatus.REQUEST_RECEIVED); @@ -205,7 +206,7 @@ public void installUploadedDeploymentPackageThrowsOnInputStreamReadFailure() thr givenAMockInputStreamThrowingOnRead(); givenAMockFormDataContentWithFileName("mock.dp"); - whenInstallUploadedDeploymentPackageIsCalledWith(this.mockInputStream, this.mockFormDataContent); + whenInstallUploadedDeploymentPackageIsCalledWith(this.mockEntityPart, this.mockInputStream); thenExceptionOccurred(WebApplicationException.class); thenDeploymentAgentServiceIsNeverCalledToInstallDeploymentPackage(); @@ -334,7 +335,7 @@ private void givenDeploymentAgentServiceThrowsExceptionOnInstall() throws Except } private void givenAMockFormDataContentWithFileName(String fileName) { - when(this.mockFormDataContent.getFileName()).thenReturn(fileName); + when(this.mockEntityPart.getFileName()).thenReturn(Optional.of(fileName)); } private void givenAMockInputStream() throws IOException { @@ -345,13 +346,13 @@ private void givenAMockInputStreamThrowingOnRead() throws IOException { when(this.mockInputStream.read(any())).thenThrow(new IOException()); } - private void givenDeploymentAgentServiceReturnsMarketplacePackageDescriptor(MarketplacePackageDescriptor descriptorToBeReturned) { + private void givenDeploymentAgentServiceReturnsMarketplacePackageDescriptor( + MarketplacePackageDescriptor descriptorToBeReturned) { when(this.mockDeploymentAgentService.getMarketplacePackageDescriptor(any())).thenReturn(descriptorToBeReturned); } private void givenDeploymentAgentServiceThrowsExceptionOnGetMarketplacePackageDescriptor() { - when(this.mockDeploymentAgentService.getMarketplacePackageDescriptor(any())) - .thenThrow(new RuntimeException()); + when(this.mockDeploymentAgentService.getMarketplacePackageDescriptor(any())).thenThrow(new RuntimeException()); } /* @@ -382,11 +383,10 @@ private void whenListDeploymentPackagesIsCalled() { } } - private void whenInstallUploadedDeploymentPackageIsCalledWith(InputStream mockInputStream, - FormDataContentDisposition mockFormDataContent) { + private void whenInstallUploadedDeploymentPackageIsCalledWith(EntityPart entityPart, InputStream mockInputStream) { try { this.resultingDeploymentRequestStatus = this.deploymentRestService - .installUploadedDeploymentPackage(mockInputStream, mockFormDataContent); + .installUploadedDeploymentPackage(entityPart, mockInputStream); } catch (Exception e) { this.occurredException = e; } diff --git a/kura/test/org.eclipse.kura.rest.provider.test/src/main/java/org/eclipse/kura/rest/provider/test/RestServiceTest.java b/kura/test/org.eclipse.kura.rest.provider.test/src/main/java/org/eclipse/kura/rest/provider/test/RestServiceTest.java index 12bd04b6fb0..274171915a6 100644 --- a/kura/test/org.eclipse.kura.rest.provider.test/src/main/java/org/eclipse/kura/rest/provider/test/RestServiceTest.java +++ b/kura/test/org.eclipse.kura.rest.provider.test/src/main/java/org/eclipse/kura/rest/provider/test/RestServiceTest.java @@ -1268,7 +1268,10 @@ private void givenClientKeystore(final String keystorePid) { private void givenService(final T service) { final BundleContext bundleContext = FrameworkUtil.getBundle(RestServiceTest.class).getBundleContext(); - registeredServices.add(bundleContext.registerService((Class) service.getClass(), service, null)); + final Dictionary properties = new Hashtable<>(); + properties.put("osgi.jakartars.resource", true); + + registeredServices.add(bundleContext.registerService((Class) service.getClass(), service, properties)); final RestTransport restTransport = (RestTransport) this.transport; diff --git a/kura/test/org.eclipse.kura.wire.script.filter.provider.test/pom.xml b/kura/test/org.eclipse.kura.wire.script.filter.provider.test/pom.xml index 2a81af7ffe9..b6bf7a0e86a 100644 --- a/kura/test/org.eclipse.kura.wire.script.filter.provider.test/pom.xml +++ b/kura/test/org.eclipse.kura.wire.script.filter.provider.test/pom.xml @@ -347,10 +347,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit slf4j.api @@ -495,11 +491,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - slf4j.api 4 diff --git a/kura/test/pom.xml b/kura/test/pom.xml index cd61bc5629d..790baf5202d 100644 --- a/kura/test/pom.xml +++ b/kura/test/pom.xml @@ -149,10 +149,6 @@ p2-installable-unit moquette-broker - - p2-installable-unit - org.eclipse.equinox.ds - p2-installable-unit org.apache.felix.scr @@ -205,10 +201,6 @@ p2-installable-unit org.eclipse.osgi - - p2-installable-unit - org.eclipse.osgi.services - p2-installable-unit org.eclipse.osgi.util @@ -217,10 +209,6 @@ p2-installable-unit org.hamcrest.core - - p2-installable-unit - org.eclipse.equinox.launcher - p2-installable-unit slf4j.api @@ -381,11 +369,6 @@ 4 true - - org.eclipse.equinox.launcher - 4 - true - slf4j.api 4 @@ -441,6 +424,11 @@ 4 true + + org.eclipse.kura.core.deployment + 4 + true + org.eclipse.kura.core.crypto 4 @@ -546,12 +534,6 @@ 4 true - - - org.eclipse.equinox.http.jetty - 3 - false - org.eclipse.kura.http.server.manager 4 @@ -597,6 +579,31 @@ 4 true + + org.apache.felix.http.bridge + 4 + true + + + org.apache.aries.spifly.dynamic.bundle + 4 + true + + + org.eclipse.osgitech.rest + 4 + true + + + org.eclipse.osgitech.rest.servlet.whiteboard + 4 + true + + + jersey-client + 4 + true + @@ -769,11 +776,6 @@ org.eclipse.kura.deployment.agent 0.0.0 - - eclipse-plugin - org.eclipse.equinox.http.jetty - 0.0.0 - eclipse-plugin org.eclipse.kura.rest.provider diff --git a/target-platform/config/kura.target-platform.build.properties b/target-platform/config/kura.target-platform.build.properties index 8cd22829f4b..a109e2485fb 100644 --- a/target-platform/config/kura.target-platform.build.properties +++ b/target-platform/config/kura.target-platform.build.properties @@ -92,7 +92,7 @@ libsocket-can-osgi.version=2.0.0-SNAPSHOT org.apache.servicemix.bundles.c3p0.version=0.9.5.5_1 hikaricp.version=2.7.9 -quartz.version=2.5.0 +quartz.version=2.3.2 org.apache.felix.dependencymanager.version=3.0.0 org.apache.felix.deploymentadmin.version=0.9.5