Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +26,8 @@
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 {
Expand Down Expand Up @@ -66,10 +63,12 @@ public void configsViaMBean() throws Exception {
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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +27,7 @@
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;

Expand All @@ -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[] {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
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;
Expand All @@ -45,6 +43,7 @@
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;
Expand Down Expand Up @@ -139,12 +138,12 @@ public Option[] baseConfig() throws Exception {
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
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;
Expand All @@ -36,8 +37,6 @@
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;
Expand All @@ -64,18 +63,20 @@ public void setUp() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
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;
Expand All @@ -50,8 +51,6 @@
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;
Expand All @@ -75,18 +74,20 @@ public void setUp() throws Exception {
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);
Expand Down
26 changes: 11 additions & 15 deletions main/src/test/java/org/apache/karaf/main/MainLockingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -28,7 +26,7 @@
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;
Expand Down Expand Up @@ -84,12 +82,11 @@ public void testLostMasterLock() throws Exception {
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();
Expand Down Expand Up @@ -130,12 +127,11 @@ public void testRetainsMasterLockOverFluctuation() throws Exception {
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();
Expand Down Expand Up @@ -176,11 +172,11 @@ public void testLostMasterLockAfterThreshold() throws Exception {
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();

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down