Issue #4683 Fix jetty-slf4j-impl for osgi (#4684)

* Issue #4683 Fix jetty-slf4j-impl for osgi

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2020-04-06 11:35:57 +02:00 committed by GitHub
parent e00560c36d
commit 3e2f27c197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 212 additions and 99 deletions

View File

@ -56,9 +56,77 @@
<Bundle-Classpath />
<Fragment-Host>org.eclipse.jetty.osgi.boot</Fragment-Host>
<Export-Package>!org.eclipse.jetty.osgi.boot.*</Export-Package>
<Import-Package>org.eclipse.jdt.*;resolution:=optional, org.eclipse.jdt.core.compiler.*;resolution:=optional, com.sun.el;resolution:=optional, com.sun.el.lang;resolution:=optional, com.sun.el.parser;resolution:=optional, com.sun.el.util;resolution:=optional, javax.el;version="[3.0,3.1)", javax.servlet;version="[3.1,4.1)", javax.servlet.resources;version="[3.1,4.1)", javax.servlet.jsp.resources;version="[2.3,4.1)", javax.servlet.jsp;version="[2.3,2.4.1)", javax.servlet.jsp.el;version="[2.3,2.4.1)", javax.servlet.jsp.tagext;version="[2.3,2.4.1)", javax.servlet.jsp.jstl.core;version="1.2";resolution:=optional, javax.servlet.jsp.jstl.fmt;version="1.2";resolution:=optional, javax.servlet.jsp.jstl.sql;version="1.2";resolution:=optional, javax.servlet.jsp.jstl.tlv;version="1.2";resolution:=optional, org.apache.el;version="[8.0.23,10)";resolution:=optional, org.apache.el.lang;version="[8.0.23,10)";resolution:=optional, org.apache.el.stream;version="[8.0.23,10)";resolution:=optional, org.apache.el.util;version="[8.0.23,10)";resolution:=optional, org.apache.el.parser;version="[8.0.23,10)";resolution:=optional, org.apache.jasper;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.compiler;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.compiler.tagplugin;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.runtime;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.security;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.servlet;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.tagplugins.jstl;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.util;version="[8.0.23,10)";resolution:=optional, org.apache.jasper.xmlparser;version="[8.0.23,10)";resolution:=optional, org.apache.taglibs.standard;version="1.2";resolution:=optional, org.apache.taglibs.standard.extra.spath;version="1.2";resolution:=optional, org.apache.taglibs.standard.functions;version="1.2";resolution:=optional, org.apache.taglibs.standard.lang.jstl;version="1.2";resolution:=optional, org.apache.taglibs.standard.lang.jstl.parser;version="1.2";resolution:=optional, org.apache.taglibs.standard.lang.jstl.test;version="1.2";resolution:=optional, org.apache.taglibs.standard.lang.jstl.test.beans;version="1.2";resolution:=optional, org.apache.taglibs.standard.lang.support;version="1.2";resolution:=optional, org.apache.taglibs.standard.resources;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.common.core;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.common.fmt;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.common.sql;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.common.xml;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.el.core;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.el.fmt;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.el.sql;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.el.xml;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.rt.core;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.rt.fmt;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.rt.sql;version="1.2";resolution:=optional, org.apache.taglibs.standard.tag.rt.xml;version="1.2";resolution:=optional, org.apache.taglibs.standard.tei;version="1.2";resolution:=optional, org.apache.taglibs.standard.tlv;version="1.2";resolution:=optional, org.apache.tomcat;version="[8.0.23,10)";resolution:=optional, org.eclipse.jetty.jsp;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:=optional, org.osgi.*, org.xml.*;resolution:=optional, org.xml.sax.*;resolution:=optional, javax.xml.*;resolution:=optional, org.w3c.dom;resolution:=optional, org.w3c.dom.ls;resolution:=optional, javax.xml.parser;resolution:=optional
<Import-Package>
org.eclipse.jdt.*;resolution:=optional,
org.eclipse.jdt.core.compiler.*;resolution:=optional,
com.sun.el;resolution:=optional,
com.sun.el.lang;resolution:=optional,
com.sun.el.parser;resolution:=optional,
com.sun.el.util;resolution:=optional,
javax.el;version="[3.0,3.1)",
javax.servlet;version="[3.1,4.1)",
javax.servlet.resources;version="[3.1,4.1)",
javax.servlet.jsp.resources;version="[2.3,4.1)",
javax.servlet.jsp;version="[2.3,2.4.1)",
javax.servlet.jsp.el;version="[2.3,2.4.1)",
javax.servlet.jsp.tagext;version="[2.3,2.4.1)",
javax.servlet.jsp.jstl.core;version="1.2";resolution:=optional,
javax.servlet.jsp.jstl.fmt;version="1.2";resolution:=optional,
javax.servlet.jsp.jstl.sql;version="1.2";resolution:=optional,
javax.servlet.jsp.jstl.tlv;version="1.2";resolution:=optional,
org.apache.el;version="[8.0.23,10)";resolution:=optional,
org.apache.el.lang;version="[8.0.23,10)";resolution:=optional,
org.apache.el.stream;version="[8.0.23,10)";resolution:=optional,
org.apache.el.util;version="[8.0.23,10)";resolution:=optional,
org.apache.el.parser;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.compiler;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.compiler.tagplugin;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.runtime;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.security;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.servlet;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.tagplugins.jstl;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.util;version="[8.0.23,10)";resolution:=optional,
org.apache.jasper.xmlparser;version="[8.0.23,10)";resolution:=optional,
org.apache.taglibs.standard;version="1.2";resolution:=optional,
org.apache.taglibs.standard.extra.spath;version="1.2";resolution:=optional,
org.apache.taglibs.standard.functions;version="1.2";resolution:=optional,
org.apache.taglibs.standard.lang.jstl;version="1.2";resolution:=optional,
org.apache.taglibs.standard.lang.jstl.parser;version="1.2";resolution:=optional,
org.apache.taglibs.standard.lang.jstl.test;version="1.2";resolution:=optional,
org.apache.taglibs.standard.lang.jstl.test.beans;version="1.2";resolution:=optional,
org.apache.taglibs.standard.lang.support;version="1.2";resolution:=optional,
org.apache.taglibs.standard.resources;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.common.core;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.common.fmt;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.common.sql;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.common.xml;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.el.core;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.el.fmt;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.el.sql;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.el.xml;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.rt.core;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.rt.fmt;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.rt.sql;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tag.rt.xml;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tei;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tlv;version="1.2";resolution:=optional,
org.apache.tomcat;version="[8.0.23,10)";resolution:=optional,
org.eclipse.jetty.jsp;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:=optional,
org.slf4j.*,
org.osgi.*,
org.xml.*;resolution:=optional,
org.xml.sax.*;resolution:=optional,
javax.xml.*;resolution:=optional,
org.w3c.dom;resolution:=optional,
org.w3c.dom.ls;resolution:=optional,
javax.xml.parser;resolution:=optional
</Import-Package>
<DynamicImport-Package>org.eclipse.jetty.jsp.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",org.apache.jasper.*;version="8.0.23",org.apache.el.*;version="8.0.23"</DynamicImport-Package>
<DynamicImport-Package>
org.eclipse.jetty.jsp.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",
org.apache.jasper.*;version="8.0.23",
org.apache.el.*;version="8.0.23"
</DynamicImport-Package>
</instructions>
</configuration>
</plugin>

View File

@ -71,7 +71,7 @@
<Bundle-SymbolicName>org.eclipse.jetty.osgi.boot;singleton:=true</Bundle-SymbolicName>
<Bundle-Activator>org.eclipse.jetty.osgi.boot.JettyBootstrapActivator</Bundle-Activator>
<DynamicImport-Package>org.eclipse.jetty.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))"</DynamicImport-Package>
<Import-Package>javax.mail;version="1.4.0";resolution:=optional, javax.mail.event;version="1.4.0";resolution:=optional, javax.mail.internet;version="1.4.0";resolution:=optional, javax.mail.search;version="1.4.0";resolution:=optional, javax.mail.util;version="1.4.0";resolution:=optional, javax.servlet;version="[3.1,4.1)", javax.servlet.http;version="[3.1,4.1)", javax.transaction;version="1.1.0";resolution:=optional, javax.transaction.xa;version="1.1.0";resolution:=optional, org.objectweb.asm;version="5";resolution:=optional, org.osgi.framework, org.osgi.service.cm;version="1.2.0", org.osgi.service.packageadmin, org.osgi.service.startlevel;version="1.0.0", org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.slf4j;resolution:=optional, org.slf4j.spi;resolution:=optional, org.slf4j.helpers;resolution:=optional, org.xml.sax, org.xml.sax.helpers, org.eclipse.jetty.annotations;resolution:=optional, *
<Import-Package>javax.mail;version="1.4.0";resolution:=optional, javax.mail.event;version="1.4.0";resolution:=optional, javax.mail.internet;version="1.4.0";resolution:=optional, javax.mail.search;version="1.4.0";resolution:=optional, javax.mail.util;version="1.4.0";resolution:=optional, javax.servlet;version="[3.1,4.1)", javax.servlet.http;version="[3.1,4.1)", javax.transaction;version="1.1.0";resolution:=optional, javax.transaction.xa;version="1.1.0";resolution:=optional, org.objectweb.asm;version="5";resolution:=optional, org.osgi.framework, org.osgi.service.cm;version="1.2.0", org.osgi.service.packageadmin, org.osgi.service.startlevel;version="1.0.0", org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.xml.sax, org.xml.sax.helpers, org.eclipse.jetty.annotations;resolution:=optional, *
</Import-Package>
<Require-Capability>
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"

View File

@ -0,0 +1,32 @@
Unit Tests with OSGi
--------------------
The unit tests use PaxExam https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/overview
to fork a jvm to start an OSGi container (currently eclipse) and deploy the jetty
jars as osgi bundles, along with the jetty-osgi infrastructure (like jetty-osgi-boot).
To run all the tests:
mvn test
To run a particular test:
mvn test -Dtest=[name of test]
At the time of writing, PaxExam only works with junit-4, so you may not be
able to invoke them easily from your IDE.
Logging
-------
By default, very little log info comes out of the tests. If you wish to see more
logging information, you can control this from the command line.
There are 2 sources of logging information: 1) the pax environment and 2) jetty logs.
To set the logging level for the pax environment use the following system property:
mvn -Dpax.exam.LEVEL=[log level]
INFO, WARN and TRACE are known to work.
To set the logging level for the jetty logs edit the src/test/resources/jetty-logging.properties
to set the logging level you want and rerun your tests. The usual jetty logging levels apply.

View File

@ -72,18 +72,31 @@
<dependency>
<groupId>org.ops4j.pax.tinybundles</groupId>
<artifactId>tinybundles</artifactId>
<version>2.1.1</version>
<version>3.0.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-wrap</artifactId>
<version>${pax.url.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
<version>2.4.0</version>
<artifactId>biz.aQute.bndlib</artifactId>
<version>5.0.0</version>
<exclusions>
<exclusion>
<groupId>org.osgi</groupId>
@ -105,6 +118,12 @@
</dependency>
<!-- Jetty OSGi Deps -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-boot</artifactId>
@ -409,18 +428,6 @@
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>

View File

@ -1 +0,0 @@
org.eclipse.jetty.LEVEL=INFO

View File

@ -51,8 +51,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
public class TestJettyOSGiBootContextAsService
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -60,6 +58,9 @@ public class TestJettyOSGiBootContextAsService
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-context-as-service.xml"));
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*"));
@ -69,8 +70,7 @@ public class TestJettyOSGiBootContextAsService
// a bundle that registers a webapp as a service for the jetty osgi core to pick up and deploy
options.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("test-jetty-osgi-context").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.add(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(System.getProperty("mavenRepoPath")));
return options.toArray(new Option[0]);

View File

@ -50,15 +50,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class TestJettyOSGiBootHTTP2Conscrypt
{
private static final String LOG_LEVEL = "WARN";
@Inject
private BundleContext bundleContext;
@ -66,6 +63,9 @@ public class TestJettyOSGiBootHTTP2Conscrypt
public Option[] config()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(true, "jetty-http2.xml"));
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
@ -84,8 +84,6 @@ public class TestJettyOSGiBootHTTP2Conscrypt
options.add(mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("http2-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("http2-http-client-transport").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.add(CoreOptions.cleanCaches(true));
return options.toArray(new Option[0]);
}

View File

@ -49,14 +49,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class TestJettyOSGiBootHTTP2JDK9
{
private static final String LOG_LEVEL = "WARN";
@Inject
private BundleContext bundleContext;
@ -64,6 +61,9 @@ public class TestJettyOSGiBootHTTP2JDK9
public Option[] config()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(true, "jetty-http2-jdk9.xml"));
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
@ -81,8 +81,6 @@ public class TestJettyOSGiBootHTTP2JDK9
options.add(mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("http2-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty.http2").artifactId("http2-http-client-transport").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.add(CoreOptions.cleanCaches(true));
return options.toArray(new Option[0]);
}

View File

@ -38,7 +38,6 @@ import org.osgi.framework.ServiceReference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
/**
* TestJettyOSGiBootWebAppAsService
@ -54,8 +53,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
public class TestJettyOSGiBootWebAppAsService
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -63,6 +60,9 @@ public class TestJettyOSGiBootWebAppAsService
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(TestOSGiUtil.optionalRemoteDebug());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-webapp-as-service.xml"));
@ -74,8 +74,6 @@ public class TestJettyOSGiBootWebAppAsService
options.addAll(TestOSGiUtil.coreJettyDependencies());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(TestOSGiUtil.jspDependencies());
options.addAll(testDependencies());

View File

@ -39,7 +39,6 @@ import org.osgi.framework.BundleContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
/**
* Pax-Exam to make sure the jetty-osgi-boot can be started along with the
@ -49,8 +48,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
public class TestJettyOSGiBootWithAnnotations
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -58,6 +55,9 @@ public class TestJettyOSGiBootWithAnnotations
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(TestOSGiUtil.optionalRemoteDebug());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-annotations.xml"));
@ -67,12 +67,9 @@ public class TestJettyOSGiBootWithAnnotations
"com.sun.org.apache.xpath.internal.jaxp", "com.sun.org.apache.xpath.internal.objects"));
options.addAll(TestOSGiUtil.coreJettyDependencies());
// TODO uncomment and update the following once 9.4.19 is released with a fix for #3726
// options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-util").version("9.4.19.v????????").noStart());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(jspDependencies());
options.addAll(annotationDependencies());
options.add(mavenBundle().groupId("org.eclipse.jetty.osgi").artifactId("test-jetty-osgi-fragment").versionAsInProject().noStart());

View File

@ -22,7 +22,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
@ -45,7 +44,6 @@ import org.osgi.framework.Constants;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
/**
@ -59,7 +57,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
public class TestJettyOSGiBootWithBundle
{
private static final String TEST_JETTY_HOME_BUNDLE = "test-jetty-xml-bundle";
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -68,6 +65,9 @@ public class TestJettyOSGiBootWithBundle
public static Option[] configure() throws IOException
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(configureJettyHomeAndPort());
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*"));
@ -75,9 +75,6 @@ public class TestJettyOSGiBootWithBundle
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.addAll(Arrays.asList(options(systemProperty("pax.exam.logging").value("none"))));
options.addAll(Arrays.asList(options(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL))));
options.addAll(Arrays.asList(options(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL))));
TinyBundle bundle = TinyBundles.bundle();
bundle.add(SomeCustomBean.class);
bundle.set(Constants.BUNDLE_SYMBOLICNAME, TEST_JETTY_HOME_BUNDLE);

View File

@ -41,7 +41,6 @@ import org.osgi.framework.BundleException;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
/**
* Test using websocket in osgi
@ -49,8 +48,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
public class TestJettyOSGiBootWithJavaxWebSocket
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -58,6 +55,9 @@ public class TestJettyOSGiBootWithJavaxWebSocket
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
// options.add(TestOSGiUtil.optionalRemoteDebug());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-javax-websocket.xml"));
@ -69,8 +69,6 @@ public class TestJettyOSGiBootWithJavaxWebSocket
options.addAll(TestOSGiUtil.coreJettyDependencies());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(jspDependencies());
options.addAll(testJettyWebApp());
options.addAll(extraDependencies());
@ -93,8 +91,8 @@ public class TestJettyOSGiBootWithJavaxWebSocket
public static List<Option> extraDependencies()
{
List<Option> res = new ArrayList<>();
res.add(mavenBundle().groupId("biz.aQute.bnd").artifactId("bndlib").versionAsInProject().start());
res.add(mavenBundle().groupId("org.ops4j.pax.tinybundles").artifactId("tinybundles").version("2.1.1").start());
res.add(mavenBundle().groupId("biz.aQute.bnd").artifactId("biz.aQute.bndlib").versionAsInProject().start());
res.add(mavenBundle().groupId("org.ops4j.pax.tinybundles").artifactId("tinybundles").versionAsInProject().start());
return res;
}

View File

@ -47,8 +47,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@RunWith(PaxExam.class)
public class TestJettyOSGiBootWithJsp
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -56,6 +54,9 @@ public class TestJettyOSGiBootWithJsp
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-jsp.xml"));
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
@ -66,8 +67,6 @@ public class TestJettyOSGiBootWithJsp
options.addAll(TestOSGiUtil.coreJettyDependencies());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(jspDependencies());
options.add(CoreOptions.cleanCaches(true));
return options.toArray(new Option[0]);

View File

@ -37,7 +37,6 @@ import org.osgi.framework.BundleContext;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
/**
*
@ -46,8 +45,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
public class TestJettyOSGiBootWithWebSocket
{
private static final String LOG_LEVEL = "WARN";
@Inject
BundleContext bundleContext = null;
@ -55,6 +52,9 @@ public class TestJettyOSGiBootWithWebSocket
public static Option[] configure()
{
ArrayList<Option> options = new ArrayList<>();
options.addAll(TestOSGiUtil.configurePaxExamLogging());
options.add(CoreOptions.junitBundles());
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-websocket.xml"));
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.sql.*", "javax.xml.*", "javax.activation.*"));
@ -65,8 +65,6 @@ public class TestJettyOSGiBootWithWebSocket
options.addAll(TestOSGiUtil.coreJettyDependencies());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-java-client").versionAsInProject().start());
options.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-alpn-client").versionAsInProject().start());
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(jspDependencies());
options.addAll(testJettyWebApp());
return options.toArray(new Option[0]);

View File

@ -40,9 +40,14 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.WrappedUrlProvisionOption.OverwriteMode;
import org.ops4j.pax.tinybundles.core.TinyBundle;
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.ops4j.pax.url.mvn.internal.AetherBasedResolver;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
@ -52,6 +57,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
/**
* Helper methods for pax-exam tests
@ -59,6 +65,24 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
public class TestOSGiUtil
{
public static final String BUNDLE_DEBUG = "bundle.debug";
/**
* Null FragmentActivator for the fake bundle
* that exposes src/test/resources/jetty-logging.properties in
* the osgi container
*/
public static class FragmentActivator implements BundleActivator
{
@Override
public void start(BundleContext context) throws Exception
{
}
@Override
public void stop(BundleContext context) throws Exception
{
}
}
public static List<Option> configureJettyHomeAndPort(boolean ssl, String jettySelectorFileName)
{
@ -90,6 +114,16 @@ public class TestOSGiUtil
options.add(systemProperty("jetty.base").value(etc.getParentFile().getAbsolutePath()));
return options;
}
public static List<Option> configurePaxExamLogging()
{
//sort out logging from the pax-exam environment
List<Option> options = new ArrayList<>();
options.add(systemProperty("pax.exam.logging").value("none"));
String paxExamLogLevel = System.getProperty("pax.exam.LEVEL", "WARN");
options.add(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(paxExamLogLevel));
return options;
}
public static List<Option> provisionCoreJetty()
{
@ -108,9 +142,11 @@ public class TestOSGiUtil
public static List<Option> coreJettyDependencies()
{
AetherBasedResolver l;
List<Option> res = new ArrayList<>();
//enables a dump of the status of all deployed bundles
res.add(systemProperty("bundle.debug").value(Boolean.toString(Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))));
//add locations to look for jars to deploy
String mavenRepoPath = System.getProperty("mavenRepoPath");
if (!StringUtil.isBlank(mavenRepoPath))
{
@ -124,6 +160,14 @@ public class TestOSGiUtil
{
res.add(systemProperty("org.ops4j.pax.url.mvn.settings").value(System.getProperty("settingsFilePath")));
}
//make src/test/resources/jetty-logging.properties visible to jetty in the osgi container
TinyBundle loggingPropertiesBundle = TinyBundles.bundle();
loggingPropertiesBundle.add("jetty-logging.properties", ClassLoader.getSystemResource("jetty-logging.properties"));
loggingPropertiesBundle.set(Constants.BUNDLE_SYMBOLICNAME, "jetty-logging-properties");
loggingPropertiesBundle.set(Constants.FRAGMENT_HOST, "org.eclipse.jetty.logging");
loggingPropertiesBundle.add(FragmentActivator.class);
res.add(CoreOptions.streamBundle(loggingPropertiesBundle.build()).noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-servlet-api").versionAsInProject().start());
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm").versionAsInProject().start());
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm-commons").versionAsInProject().start());
@ -131,8 +175,12 @@ public class TestOSGiUtil
res.add(mavenBundle().groupId("org.apache.aries.spifly").artifactId("org.apache.aries.spifly.dynamic.bundle").versionAsInProject().start());
res.add(mavenBundle().groupId("jakarta.annotation").artifactId("jakarta.annotation-api").versionAsInProject().start());
res.add(mavenBundle().groupId("org.apache.geronimo.specs").artifactId("geronimo-jta_1.1_spec").version("1.1.1").start());
res.add(mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.slf4j").artifactId("slf4j-log4j12").versionAsInProject().noStart());
//the slf4j-api jar does not have support for ServiceLoader in osgi in its manifest, so add it now
res.add(wrappedBundle(mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject())
.instructions("Require-Capability=osgi.serviceloader;filter:=\"(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)\",osgi.extender;filter:=\"(osgi.extender=osgi.serviceloader.processor)\"")
.overwriteManifest(OverwriteMode.MERGE)
.start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-slf4j-impl").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-util").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-deploy").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-server").versionAsInProject().start());

View File

@ -0,0 +1 @@
org.eclipse.jetty.LEVEL=INFO

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%p] :%t: (%c) - %m%n" />
</layout>
</appender>
<logger name="shaded.org.eclipse.aether">
<level value="WARN" />
</logger>
<logger name="shaded.org.apache.http">
<level value="WARN" />
</logger>
<logger name="shaded.org.ops4j">
<level value="WARN" />
</logger>
<logger name="org.ops4j">
<level value="INFO" />
</logger>
<root>
<level value="DEBUG" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@ -20,7 +20,10 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=org.eclipse.jetty.util.security.CredentialProvider)";resolution:=optional;cardinality:=multiple, osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional</Require-Capability>
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
<Provide-Capability>
osgi.serviceloader;osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider
</Provide-Capability>
</instructions>
</configuration>
</plugin>