This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 1c3a2b0348 KARAF-7905: Upgrade to Pax Tinybundles 4.0.1 (#1918)
1c3a2b0348 is described below

commit 1c3a2b0348ba6cbe6c6126a233d0e2d5cdd75b1c
Author: JB Onofré <[email protected]>
AuthorDate: Thu Jul 24 11:27:44 2025 +0200

    KARAF-7905: Upgrade to Pax Tinybundles 4.0.1 (#1918)
    
    * KARAF-7905: Upgrade to Pax TinyBundles 4.0.1
    
    * KARAF-7903: Upgrade to Pax Exam 4.14.0
    
    * Remove use of hamcrest in ConfigTest
---
 .../java/org/apache/karaf/itests/ConfigTest.java   | 13 +++++------
 .../org/apache/karaf/itests/ImportServiceTest.java | 23 +++++++++---------
 .../KarafMinimalMonitoredTestSupport.java          | 15 ++++++------
 ...ryptableConfigAdminPropertyPlaceholderTest.java | 27 +++++++++++-----------
 .../EncryptablePropertyPlaceholderTest.java        | 27 +++++++++++-----------
 .../org/apache/karaf/main/MainLockingTest.java     | 26 +++++++++------------
 pom.xml                                            |  4 ++--
 7 files changed, 65 insertions(+), 70 deletions(-)

diff --git a/itests/test/src/test/java/org/apache/karaf/itests/ConfigTest.java 
b/itests/test/src/test/java/org/apache/karaf/itests/ConfigTest.java
index 20a6d0f193..f53014ff8e 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/ConfigTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/ConfigTest.java
@@ -13,11 +13,6 @@
  */
 package org.apache.karaf.itests;
 
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasKey;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-
 import java.lang.management.ManagementFactory;
 import java.util.List;
 import java.util.Map;
@@ -31,6 +26,8 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import static org.junit.Assert.*;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class ConfigTest extends BaseTest {
@@ -66,10 +63,12 @@ public class ConfigTest extends BaseTest {
         MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
         ObjectName name = new 
ObjectName("org.apache.karaf:type=config,name=root");
         List<String> configs = (List<String>) mbeanServer.getAttribute(name, 
"Configs");
-        assertThat(configs, hasItem("org.apache.karaf.features"));
+        String found = configs.stream().filter(c -> 
c.equals("org.apache.karaf.features")).findAny().orElse(null);
+        assertNotNull(found);
         Map<String, String> properties = (Map<String, String>) mbeanServer
             .invoke(name, "listProperties", new 
Object[]{"org.apache.karaf.features"}, new String[]{"java.lang.String"});
-        assertThat(properties, hasKey("featuresRepositories"));
+        String key = properties.keySet().stream().filter(c -> 
c.equals("featuresRepositories")).findAny().orElse(null);
+        assertNotNull(key);
     }
 
 }
diff --git 
a/itests/test/src/test/java/org/apache/karaf/itests/ImportServiceTest.java 
b/itests/test/src/test/java/org/apache/karaf/itests/ImportServiceTest.java
index acaad0234b..5b4ca1bcb5 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/ImportServiceTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/ImportServiceTest.java
@@ -13,8 +13,6 @@
  */
 package org.apache.karaf.itests;
 
-import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
-
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -29,6 +27,7 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.tinybundles.TinyBundles;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 
@@ -43,18 +42,18 @@ public class ImportServiceTest extends BaseTest {
     @Configuration
     public Option[] config() {
         List<Option> options = new ArrayList<>(Arrays.asList(super.config()));
-        InputStream testBundleImportService = bundle()
-            .set(Constants.IMPORT_SERVICE, "FooService")
-            .set(Constants.BUNDLE_SYMBOLICNAME, BUNDLE1_NAME)
-            .set(Constants.BUNDLE_VERSION, "1.0.0")
-            .set(Constants.BUNDLE_MANIFESTVERSION, "2")
+        InputStream testBundleImportService = TinyBundles.bundle()
+            .setHeader(Constants.IMPORT_SERVICE, "FooService")
+            .setHeader(Constants.BUNDLE_SYMBOLICNAME, BUNDLE1_NAME)
+            .setHeader(Constants.BUNDLE_VERSION, "1.0.0")
+            .setHeader(Constants.BUNDLE_MANIFESTVERSION, "2")
             .build();
         options.add(CoreOptions.streamBundle(testBundleImportService));
-        InputStream testBundleRequireService = bundle()
-            .set(Constants.REQUIRE_CAPABILITY, 
"osgi.service;effective:=active;filter:=\"(objectClass=FooService)\"")
-            .set(Constants.BUNDLE_SYMBOLICNAME, BUNDLE2_NAME)
-            .set(Constants.BUNDLE_VERSION, "1.0.0")
-            .set(Constants.BUNDLE_MANIFESTVERSION, "2")
+        InputStream testBundleRequireService = TinyBundles.bundle()
+            .setHeader(Constants.REQUIRE_CAPABILITY, 
"osgi.service;effective:=active;filter:=\"(objectClass=FooService)\"")
+            .setHeader(Constants.BUNDLE_SYMBOLICNAME, BUNDLE2_NAME)
+            .setHeader(Constants.BUNDLE_VERSION, "1.0.0")
+            .setHeader(Constants.BUNDLE_MANIFESTVERSION, "2")
             .build();
         options.add(CoreOptions.streamBundle(testBundleRequireService));
         return options.toArray(new Option[] {});
diff --git 
a/itests/test/src/test/java/org/apache/karaf/itests/mavenresolver/KarafMinimalMonitoredTestSupport.java
 
b/itests/test/src/test/java/org/apache/karaf/itests/mavenresolver/KarafMinimalMonitoredTestSupport.java
index be7a443743..679efd5f48 100644
--- 
a/itests/test/src/test/java/org/apache/karaf/itests/mavenresolver/KarafMinimalMonitoredTestSupport.java
+++ 
b/itests/test/src/test/java/org/apache/karaf/itests/mavenresolver/KarafMinimalMonitoredTestSupport.java
@@ -24,8 +24,6 @@ import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
-import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
-import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
 import static org.osgi.framework.Constants.OBJECTCLASS;
 
 import java.io.File;
@@ -45,6 +43,7 @@ import 
org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption;
 import org.ops4j.pax.exam.options.extra.VMOption;
 import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
+import org.ops4j.pax.tinybundles.TinyBundles;
 import org.ops4j.store.Handle;
 import org.ops4j.store.Store;
 import org.ops4j.store.intern.TemporaryStore;
@@ -139,12 +138,12 @@ public abstract class KarafMinimalMonitoredTestSupport {
     }
 
     private InputStream createMonitorBundle() {
-        return bundle()
-                .set(Constants.BUNDLE_ACTIVATOR, Activator.class.getName())
-                .set(Constants.EXPORT_PACKAGE, 
ServiceMonitor.class.getPackage().getName())
-                .add(Activator.class)
-                .add(ServiceMonitor.class)
-                .build(withBnd());
+        return TinyBundles.bundle()
+                .setHeader(Constants.BUNDLE_ACTIVATOR, 
Activator.class.getName())
+                .setHeader(Constants.EXPORT_PACKAGE, 
ServiceMonitor.class.getPackage().getName())
+                .addClass(Activator.class)
+                .addClass(ServiceMonitor.class)
+                .build(TinyBundles.bndBuilder());
     }
 
     protected long numberOfServiceEventsFor(String serviceName) {
diff --git 
a/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptableConfigAdminPropertyPlaceholderTest.java
 
b/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptableConfigAdminPropertyPlaceholderTest.java
index b7acd8c488..1db8617256 100644
--- 
a/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptableConfigAdminPropertyPlaceholderTest.java
+++ 
b/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptableConfigAdminPropertyPlaceholderTest.java
@@ -26,7 +26,8 @@ import 
org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.TinyBundle;
+import org.ops4j.pax.tinybundles.TinyBundles;
 import org.osgi.framework.*;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -36,8 +37,6 @@ import java.io.*;
 import java.util.*;
 import java.util.jar.JarInputStream;
 
-import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
-
 public class EncryptableConfigAdminPropertyPlaceholderTest extends TestCase {
 
     public static final long DEFAULT_TIMEOUT = 30000;
@@ -64,18 +63,20 @@ public class EncryptableConfigAdminPropertyPlaceholderTest 
extends TestCase {
         List<BundleDescriptor> bundles = new 
ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
         bundles.add(getBundleDescriptor(
                 "target/jasypt2.jar",
-                bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", 
getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml"))
-                        .set("Manifest-Version", "2")
-                        .set("Bundle-ManifestVersion", "2")
-                        .set("Bundle-SymbolicName", "jasypt")
-                        .set("Bundle-Version", "0.0.0")));
+                TinyBundles.bundle()
+                        
.addResource("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", 
getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml"))
+                        .setHeader("Manifest-Version", "2")
+                        .setHeader("Bundle-ManifestVersion", "2")
+                        .setHeader("Bundle-SymbolicName", "jasypt")
+                        .setHeader("Bundle-Version", "0.0.0")));
         bundles.add(getBundleDescriptor(
                 "target/test2.jar",
-                bundle().add("OSGI-INF/blueprint/configadmin-test.xml", 
getClass().getResource("configadmin-test.xml"))
-                        .set("Manifest-Version", "2")
-                        .set("Bundle-ManifestVersion", "2")
-                        .set("Bundle-SymbolicName", "configtest")
-                        .set("Bundle-Version", "0.0.0")));
+                TinyBundles.bundle()
+                        
.addResource("OSGI-INF/blueprint/configadmin-test.xml", 
getClass().getResource("configadmin-test.xml"))
+                        .setHeader("Manifest-Version", "2")
+                        .setHeader("Bundle-ManifestVersion", "2")
+                        .setHeader("Bundle-SymbolicName", "configtest")
+                        .setHeader("Bundle-Version", "0.0.0")));
 
         Map config = new HashMap();
         config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
diff --git 
a/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptablePropertyPlaceholderTest.java
 
b/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptablePropertyPlaceholderTest.java
index f0be971ecb..9eeb2f580f 100644
--- 
a/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptablePropertyPlaceholderTest.java
+++ 
b/jaas/blueprint/jasypt/src/test/java/org/apache/karaf/jaas/blueprint/jasypt/handler/EncryptablePropertyPlaceholderTest.java
@@ -40,7 +40,8 @@ import 
org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.TinyBundle;
+import org.ops4j.pax.tinybundles.TinyBundles;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -50,8 +51,6 @@ import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
-import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
-
 public class EncryptablePropertyPlaceholderTest extends TestCase {
 
     public static final long DEFAULT_TIMEOUT = 30000;
@@ -75,18 +74,20 @@ public class EncryptablePropertyPlaceholderTest extends 
TestCase {
         List<BundleDescriptor> bundles = new 
ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
         bundles.add(getBundleDescriptor(
                 "target/jasypt.jar",
-                bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", 
getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml"))
-                           .set("Manifest-Version", "2")
-                           .set("Bundle-ManifestVersion", "2")
-                           .set("Bundle-SymbolicName", "jasypt")
-                           .set("Bundle-Version", "0.0.0")));
+                TinyBundles.bundle()
+                        
.addResource("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", 
getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml"))
+                        .setHeader("Manifest-Version", "2")
+                        .setHeader("Bundle-ManifestVersion", "2")
+                        .setHeader("Bundle-SymbolicName", "jasypt")
+                        .setHeader("Bundle-Version", "0.0.0")));
         bundles.add(getBundleDescriptor(
                 "target/test.jar",
-                bundle().add("OSGI-INF/blueprint/test.xml", 
getClass().getResource("test.xml"))
-                           .set("Manifest-Version", "2")
-                           .set("Bundle-ManifestVersion", "2")
-                           .set("Bundle-SymbolicName", "test")
-                           .set("Bundle-Version", "0.0.0")));
+                TinyBundles.bundle()
+                        .addResource("OSGI-INF/blueprint/test.xml", 
getClass().getResource("test.xml"))
+                        .setHeader("Manifest-Version", "2")
+                        .setHeader("Bundle-ManifestVersion", "2")
+                        .setHeader("Bundle-SymbolicName", "test")
+                        .setHeader("Bundle-Version", "0.0.0")));
 
         Map config = new HashMap();
         config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
diff --git a/main/src/test/java/org/apache/karaf/main/MainLockingTest.java 
b/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
index 0b93f7226f..edcad4607d 100644
--- a/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
+++ b/main/src/test/java/org/apache/karaf/main/MainLockingTest.java
@@ -18,8 +18,6 @@
  */
 package org.apache.karaf.main;
 
-import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
-
 import java.io.File;
 import java.io.IOException;
 
@@ -28,7 +26,7 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.ops4j.pax.tinybundles.TinyBundles;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.launch.Framework;
@@ -84,12 +82,11 @@ public class MainLockingTest {
         Main main = new Main(args);
         main.launch();
         Framework framework = main.getFramework();
-        String activatorName = 
TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
         Bundle bundle = framework.getBundleContext().installBundle("foo",
                 TinyBundles.bundle()
-                    .set( Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName() )
-                    .add( activatorName, 
getClass().getClassLoader().getResourceAsStream( activatorName ) )
-                    .build( withBnd() )
+                .addClass(TimeoutShutdownActivator.class)
+                .setHeader(Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName())
+                .build(TinyBundles.bndBuilder())
         );
         
         bundle.start();
@@ -130,12 +127,11 @@ public class MainLockingTest {
         Main main = new Main(args);
         main.launch();
         Framework framework = main.getFramework();
-        String activatorName = 
TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
         Bundle bundle = framework.getBundleContext().installBundle("foo",
                 TinyBundles.bundle()
-                    .set( Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName() )
-                    .add( activatorName, 
getClass().getClassLoader().getResourceAsStream( activatorName ) )
-                    .build( withBnd() )
+                        .setHeader(Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName())
+                        .addClass(TimeoutShutdownActivator.class)
+                        .build(TinyBundles.bndBuilder())
         );
 
         bundle.start();       
@@ -176,11 +172,11 @@ public class MainLockingTest {
         Main main = new Main(args);
         main.launch();
         Framework framework = main.getFramework();
-        String activatorName = 
TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
         Bundle bundle = framework.getBundleContext().installBundle("foo",
-                TinyBundles.bundle().set(Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName())
-                        .add(activatorName, 
getClass().getClassLoader().getResourceAsStream(activatorName))
-                        .build(withBnd()));
+                TinyBundles.bundle()
+                        .setHeader(Constants.BUNDLE_ACTIVATOR, 
TimeoutShutdownActivator.class.getName())
+                        .addClass(TimeoutShutdownActivator.class)
+                        .build(TinyBundles.bndBuilder()));
 
         bundle.start();
 
diff --git a/pom.xml b/pom.xml
index 2739374a63..dd5e3437f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -322,14 +322,14 @@
         <org.osgi.util.tracker.version>1.5.4</org.osgi.util.tracker.version>
 
         <pax.cdi.version>1.1.4</pax.cdi.version>
-        <pax.exam.version>4.13.5</pax.exam.version>
+        <pax.exam.version>4.14.0</pax.exam.version>
         <pax.logging.version>2.2.8</pax.logging.version>
         <pax.base.version>1.5.1</pax.base.version>
         <pax.swissbox.version>1.8.5</pax.swissbox.version>
         <pax.url.version>2.6.16</pax.url.version>
         <pax.web.version>8.0.32</pax.web.version>
         <jetty.version>9.4.57.v20241219</jetty.version>
-        <pax.tinybundle.version>3.0.0</pax.tinybundle.version>
+        <pax.tinybundle.version>4.0.1</pax.tinybundle.version>
         <pax.jdbc.version>1.5.7</pax.jdbc.version>
         <pax.jms.version>1.1.3</pax.jms.version>
         <pax.transx.version>0.5.4</pax.transx.version>

Reply via email to