Issue #2247 Ensure random unused ssl port for osgi tests
Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
parent
48eebacd6c
commit
0b89ffd055
|
@ -69,7 +69,7 @@ public class TestJettyOSGiBootContextAsService
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-http-boot-context-as-service.xml"));
|
||||
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.*"));
|
||||
options.addAll(TestOSGiUtil.coreJettyDependencies());
|
||||
|
||||
|
@ -82,25 +82,7 @@ public class TestJettyOSGiBootContextAsService
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc,"jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TestJettyOSGiBootHTTP2
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(TestJettyOSGiBootWithJsp.configureJettyHomeAndPort(true,"jetty-http2.xml"));
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(true,"jetty-http2.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -98,8 +98,6 @@ public class TestJettyOSGiBootHTTP2
|
|||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
res.add(CoreOptions.systemProperty("jetty.alpn.protocols").value("h2,http/1.1"));
|
||||
res.add(CoreOptions.systemProperty("jetty.http.port").value("0"));
|
||||
res.add(CoreOptions.systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
|
||||
String alpnBoot = System.getProperty("mortbay-alpn-boot");
|
||||
if (alpnBoot == null) { throw new IllegalStateException("Define path to alpn boot jar as system property -Dmortbay-alpn-boot"); }
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TestJettyOSGiBootHTTP2Conscrypt
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(TestJettyOSGiBootWithJsp.configureJettyHomeAndPort(true,"jetty-http2.xml"));
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(true,"jetty-http2.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*", "javax.activation.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -123,8 +123,6 @@ public class TestJettyOSGiBootHTTP2Conscrypt
|
|||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
res.add(CoreOptions.systemProperty("jetty.alpn.protocols").value("h2,http/1.1"));
|
||||
res.add(CoreOptions.systemProperty("jetty.http.port").value("0"));
|
||||
res.add(CoreOptions.systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
res.add(CoreOptions.systemProperty("jetty.sslContext.provider").value("Conscrypt"));
|
||||
|
||||
res.add(wrappedBundle(mavenBundle().groupId("org.conscrypt").artifactId("conscrypt-openjdk-uber").version("1.0.0.RC11"))
|
||||
|
|
|
@ -70,7 +70,7 @@ public class TestJettyOSGiBootWebAppAsService
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-http-boot-webapp-as-service.xml"));
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-webapp-as-service.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.xml.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -85,25 +85,6 @@ public class TestJettyOSGiBootWebAppAsService
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> testDependencies()
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TestJettyOSGiBootWithAnnotations
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-http-boot-with-annotations.xml"));
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-annotations.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.sql.*","javax.xml.*", "javax.activation.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -79,30 +79,6 @@ public class TestJettyOSGiBootWithAnnotations
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc,jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-ssl.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-https.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TestJettyOSGiBootWithJavaxWebSocket
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-http-boot-with-javax-websocket.xml"));
|
||||
options.addAll(TestOSGiUtil.configureJettyHomeAndPort(false, "jetty-http-boot-with-javax-websocket.xml"));
|
||||
options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*", "org.w3c.*", "javax.sql.*","javax.xml.*", "javax.activation.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -83,30 +83,6 @@ public class TestJettyOSGiBootWithJavaxWebSocket
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc,jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-ssl.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-https.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TestJettyOSGiBootWithJsp
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort(false,"jetty-http-boot-with-jsp.xml"));
|
||||
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.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -76,38 +76,7 @@ public class TestJettyOSGiBootWithJsp
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(boolean ssl,String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File(OS.separators("src/test/config/etc"));
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
if (ssl)
|
||||
{
|
||||
|
||||
xmlConfigs.append(new File(etc, "jetty-ssl.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-alpn.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-https.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
|
||||
}
|
||||
xmlConfigs.append(new File(etc, jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
options.add(systemProperty("jetty.base").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TestJettyOSGiBootWithWebSocket
|
|||
{
|
||||
ArrayList<Option> options = new ArrayList<Option>();
|
||||
options.add(CoreOptions.junitBundles());
|
||||
options.addAll(configureJettyHomeAndPort("jetty-http-boot-with-websocket.xml"));
|
||||
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.*"));
|
||||
options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils",
|
||||
"com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal",
|
||||
|
@ -73,31 +73,6 @@ public class TestJettyOSGiBootWithWebSocket
|
|||
return options.toArray(new Option[options.size()]);
|
||||
}
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File("src/test/config/etc");
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc,jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-ssl.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-https.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.ssl.port").value(String.valueOf(TestOSGiUtil.DEFAULT_SSL_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> jspDependencies()
|
||||
{
|
||||
return TestOSGiUtil.jspDependencies();
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.osgi.test;
|
|||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
|
||||
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.ArrayList;
|
||||
|
@ -36,6 +37,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
||||
import org.eclipse.jetty.toolchain.test.OS;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.Assert;
|
||||
import org.ops4j.pax.exam.CoreOptions;
|
||||
|
@ -50,17 +53,44 @@ import org.osgi.service.http.HttpService;
|
|||
*/
|
||||
public class TestOSGiUtil
|
||||
{
|
||||
|
||||
public static final int DEFAULT_SSL_PORT=TestOSGiUtil.findFreePort("jetty.ssl.port");
|
||||
|
||||
public static List<Option> configureJettyHomeAndPort(boolean ssl,String jettySelectorFileName)
|
||||
{
|
||||
File etc = new File(OS.separators("src/test/config/etc"));
|
||||
|
||||
List<Option> options = new ArrayList<Option>();
|
||||
StringBuffer xmlConfigs = new StringBuffer();
|
||||
xmlConfigs.append(new File(etc, "jetty.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
if (ssl)
|
||||
{
|
||||
options.add(CoreOptions.systemProperty("jetty.ssl.port").value("0"));
|
||||
xmlConfigs.append(new File(etc, "jetty-ssl.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-alpn.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-https.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
|
||||
}
|
||||
xmlConfigs.append(new File(etc, jettySelectorFileName).toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-deployer.xml").toURI());
|
||||
xmlConfigs.append(";");
|
||||
xmlConfigs.append(new File(etc, "jetty-testrealm.xml").toURI());
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs.toString()));
|
||||
options.add(systemProperty("jetty.http.port").value("0"));
|
||||
options.add(systemProperty("jetty.home").value(etc.getParentFile().getAbsolutePath()));
|
||||
options.add(systemProperty("jetty.base").value(etc.getParentFile().getAbsolutePath()));
|
||||
return options;
|
||||
}
|
||||
|
||||
public static List<Option> provisionCoreJetty()
|
||||
{
|
||||
List<Option> res = new ArrayList<Option>();
|
||||
// get the jetty home config from the osgi boot bundle.
|
||||
res.add(CoreOptions.systemProperty("jetty.http.port").value("0"));
|
||||
res.add(CoreOptions.systemProperty("jetty.ssl.port").value(String.valueOf(DEFAULT_SSL_PORT)));
|
||||
|
||||
res.add(CoreOptions.systemProperty("jetty.home.bundle").value("org.eclipse.jetty.osgi.boot"));
|
||||
res.addAll(coreJettyDependencies());
|
||||
return res;
|
||||
|
|
Loading…
Reference in New Issue