Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java')
-rw-r--r--jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java123
1 files changed, 62 insertions, 61 deletions
diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java
index 5879da9f82..3f552e74fb 100644
--- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java
+++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/boot/TestJettyOSGiBootWithJsp.java
@@ -18,24 +18,28 @@
package org.eclipse.jetty.osgi.boot;
-import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
-import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.HttpExchange;
-import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.client.HttpContentResponse;
+import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
@@ -51,20 +55,27 @@ import org.osgi.framework.BundleContext;
@RunWith( JUnit4TestRunner.class )
public class TestJettyOSGiBootWithJsp
{
- private static final boolean LOGGING_ENABLED = false;
+ private static final boolean LOGGING_ENABLED = true;
private static final boolean REMOTE_DEBUGGING = false;
-
+
@Inject
BundleContext bundleContext = null;
@Configuration
public static Option[] configure()
{
- File testrealm = new File("src/test/config/etc/jetty-testrealm.xml");
-
+ File etcFolder = new File("src/test/config/etc");
+ String etc = "file://" + etcFolder.getAbsolutePath();
+
ArrayList<Option> options = new ArrayList<Option>();
- options.addAll(TestJettyOSGiBootCore.provisionCoreJetty());
-
+ options.add(PaxRunnerOptions.vmOption("-Djetty.port=9876 -Djetty.home="+ etcFolder.getParentFile().getAbsolutePath() +
+ " -D" + OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS +
+ "="+etc+"/jetty.xml;"+etc+"/jetty-selector.xml;"+etc+"/jetty-deployer.xml;" + etc + "/jetty-testrealm.xml"));
+ options.add(CoreOptions.equinox());
+ options.add(CoreOptions.bootDelegationPackages("org.xml.sax", "org.xml.*",
+ "org.w3c.*", "javax.xml.*"));
+ options.addAll(TestJettyOSGiBootCore.coreJettyDependencies());
+
// Enable Logging
if(LOGGING_ENABLED) {
options.addAll(Arrays.asList(options(
@@ -75,6 +86,8 @@ public class TestJettyOSGiBootWithJsp
)));
}
+ options.addAll(jspDependencies());
+
// Remote JDWP Debugging
if(REMOTE_DEBUGGING) {
options.addAll(Arrays.asList(options(
@@ -83,80 +96,68 @@ public class TestJettyOSGiBootWithJsp
)));
}
- // Standard Options
- options.addAll(Arrays.asList(options(
- PaxRunnerOptions.vmOption("-Djetty.port=9876 -D" + OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS +
- "=etc/jetty.xml;" + testrealm.getAbsolutePath()),
-
- /* orbit deps */
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.servlet.jsp" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.servlet.jsp.jstl" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.el" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "com.sun.el" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.apache.jasper.glassfish" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.apache.taglibs.standard.glassfish" ).versionAsInProject(),
- mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.eclipse.jdt.core" ).versionAsInProject(),
-
- /* jetty-osgi deps */
- mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot" ).versionAsInProject().start(),
- mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot-jsp" ).versionAsInProject().start(),
-
- mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "test-jetty-webapp" ).classifier("webbundle").versionAsInProject()
-
- // mavenBundle().groupId( "org.eclipse.equinox.http" ).artifactId( "servlet" ).versionAsInProject().start()
- )));
-
return options.toArray(new Option[options.size()]);
}
+
+ public static List<Option> jspDependencies() {
+ List<Option> res = new ArrayList<Option>();
+ /* orbit deps */
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.servlet.jsp" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.servlet.jsp.jstl" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "javax.el" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "com.sun.el" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.apache.jasper.glassfish" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.apache.taglibs.standard.glassfish" ).versionAsInProject());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.orbit" ).artifactId( "org.eclipse.jdt.core" ).versionAsInProject());
+
+ /* jetty-osgi deps */
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot-jsp" ).versionAsInProject().noStart());
+ res.add(mavenBundle().groupId( "org.eclipse.jetty.osgi" ).artifactId( "jetty-osgi-boot" ).versionAsInProject().start());
+
+ res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "test-jetty-webapp" ).classifier("webbundle").versionAsInProject());
+
+ res.add(mavenBundle().groupId( "org.eclipse.equinox.http" ).artifactId( "servlet" ).versionAsInProject().start());
+ return res;
+ }
/**
* You will get a list of bundles installed by default
* plus your testcase, wrapped into a bundle called pax-exam-probe
*/
@Test
- @Ignore
public void listBundles() throws Exception
{
Map<String,Bundle> bundlesIndexedBySymbolicName = new HashMap<String, Bundle>();
for( Bundle b : bundleContext.getBundles() )
{
bundlesIndexedBySymbolicName.put(b.getSymbolicName(), b);
- //System.err.println("Got " + b.getSymbolicName());
}
-
+ Bundle websocketServer = bundlesIndexedBySymbolicName.get("org.eclipse.jetty.websocket.server");
+ Assert.assertNotNull("Could not find the org.eclipse.jetty.websocket.server bundle", websocketServer);
+ Assert.assertEquals(Bundle.RESOLVED, websocketServer.getState());
+
Bundle osgiBoot = bundlesIndexedBySymbolicName.get("org.eclipse.jetty.osgi.boot");
Assert.assertNotNull("Could not find the org.eclipse.jetty.osgi.boot bundle", osgiBoot);
- Assert.assertTrue(osgiBoot.getState() == Bundle.ACTIVE);
-
+ Assert.assertEquals(Bundle.ACTIVE, osgiBoot.getState());
+
Bundle osgiBootJsp = bundlesIndexedBySymbolicName.get("org.eclipse.jetty.osgi.boot.jsp");
Assert.assertNotNull("Could not find the org.eclipse.jetty.osgi.boot.jsp bundle", osgiBootJsp);
- Assert.assertTrue("The fragment jsp is not correctly resolved", osgiBootJsp.getState() == Bundle.RESOLVED);
-
+ Assert.assertEquals("The fragment jsp is not correctly resolved.",
+ Bundle.RESOLVED, osgiBootJsp.getState());
+
Bundle testWebBundle = bundlesIndexedBySymbolicName.get("org.eclipse.jetty.test-jetty-webapp");
- Assert.assertNotNull("Could not find the org.eclipse.jetty.osgi.boot.jsp bundle", osgiBootJsp);
- Assert.assertTrue("The fragment jsp is not correctly resolved", testWebBundle.getState() == Bundle.ACTIVE);
-
+ Assert.assertNotNull("Could not find the org.eclipse.jetty.test-jetty-webappp bundle", osgiBootJsp);
+ Assert.assertEquals("The test-jetty-webapp is not correctly resolved", Bundle.ACTIVE, testWebBundle.getState());
+
//now test the jsp/dump.jsp
HttpClient client = new HttpClient();
- client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
try
{
client.start();
-
- ContentExchange getExchange = new ContentExchange();
- getExchange.setURL("http://127.0.0.1:9876/jsp/dump.jsp");
- getExchange.setMethod(HttpMethods.GET);
-
- client.send(getExchange);
- int state = getExchange.waitForDone();
- Assert.assertEquals("state should be done", HttpExchange.STATUS_COMPLETED, state);
-
- String content = null;
- int responseStatus = getExchange.getResponseStatus();
- Assert.assertEquals(HttpStatus.OK_200, responseStatus);
- if (responseStatus == HttpStatus.OK_200) {
- content = getExchange.getResponseContent();
- }
+ Response response = client.GET("http://127.0.0.1:9876/jsp/dump.jsp").get(5, TimeUnit.SECONDS);
+ Assert.assertEquals(HttpStatus.OK_200, response.status());
+
+ String content = new String(((HttpContentResponse)response).content());
//System.err.println("content: " + content);
Assert.assertTrue(content.indexOf("<tr><th>ServletPath:</th><td>/jsp/dump.jsp</td></tr>") != -1);
}
@@ -164,8 +165,8 @@ public class TestJettyOSGiBootWithJsp
{
client.stop();
}
-
+
}
-
+
}

Back to the top