Issue #3162 - Introducing more convenience Options for PaxExam

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2018-12-03 17:35:08 -06:00
parent 231892e276
commit 24e680e272
2 changed files with 27 additions and 11 deletions

View File

@ -57,6 +57,7 @@ public class TestJettyOSGiBootWithWebSocket
{
ArrayList<Option> options = new ArrayList<>();
options.add(TestOSGiUtil.optionalRemoteDebug());
options.addAll(TestOSGiUtil.jettyLogging());
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.*"));
@ -69,6 +70,7 @@ public class TestJettyOSGiBootWithWebSocket
options.add(systemProperty("org.eclipse.jetty.LEVEL").value(LOG_LEVEL));
options.addAll(jspDependencies());
options.addAll(annotationDependencies());
options.add(CoreOptions.cleanCaches(true));
return options.toArray(new Option[options.size()]);
}
@ -95,21 +97,18 @@ public class TestJettyOSGiBootWithWebSocket
TestOSGiUtil.debugBundles(bundleContext);
}
@Test
public void testWebsocket() throws Exception
{
String port = System.getProperty("boot.websocket.port");
assertNotNull(port);
URI uri = new URI("ws://127.0.0.1:" + port+"/ws/foo");
URI uri = new URI("ws://127.0.0.1:" + port + "/ws/foo");
WebSocketClient client = new WebSocketClient();
try
{
SimpleEchoSocket socket = new SimpleEchoSocket();
client.start();

View File

@ -18,6 +18,13 @@
package org.eclipse.jetty.osgi.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
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 java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -36,6 +43,7 @@ import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
@ -44,13 +52,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
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;
/**
* Helper methods for pax-exam tests
*/
@ -280,6 +281,22 @@ public class TestOSGiUtil
return sslContextFactory;
}
public static List<Option> jettyLogging()
{
List<Option> options = new ArrayList<>();
// SLF4J Specific (possible set of options)
/*
options.add(mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject().start());
options.add(mavenBundle().groupId("org.slf4j").artifactId("jul-to-slf4j").versionAsInProject().start());
options.add(mavenBundle().groupId("org.slf4j").artifactId("slf4j-log4j12").versionAsInProject().start());
options.add(mavenBundle().groupId("log4j").artifactId("log4j").versionAsInProject().start());
options.add(systemProperty("org.eclipse.jetty.util.log.class").value(Slf4jLog.class.getName()));
*/
options.add(systemProperty("org.eclipse.jetty.util.log.class").value(StdErrLog.class.getName()));
options.add(systemProperty("org.eclipse.jetty.LEVEL").value("INFO"));
return options;
}
protected static void testHttpServiceGreetings(BundleContext bundleContext, String protocol, int port) throws Exception
{
assertActiveBundle(bundleContext, "org.eclipse.jetty.osgi.boot");