Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit f47f0db

Browse files
committed
Configure setup for jsp engine for tests
1 parent 708397f commit f47f0db

File tree

1 file changed

+20
-6
lines changed
  • appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9

1 file changed

+20
-6
lines changed

appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.util.Collections;
2223
import java.util.concurrent.CountDownLatch;
2324
import java.util.concurrent.TimeUnit;
2425
import javax.servlet.jsp.JspFactory;
2526
import org.apache.jasper.runtime.JspFactoryImpl;
2627
import org.apache.tomcat.InstanceManager;
2728
import org.apache.tomcat.SimpleInstanceManager;
28-
29+
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
2930
import org.eclipse.jetty.io.MappedByteBufferPool;
3031
import org.eclipse.jetty.server.Handler;
3132
import org.eclipse.jetty.server.HttpConfiguration;
@@ -37,6 +38,7 @@
3738
import org.eclipse.jetty.server.handler.DefaultHandler;
3839
import org.eclipse.jetty.server.handler.HandlerCollection;
3940
import org.eclipse.jetty.server.handler.RequestLogHandler;
41+
import org.eclipse.jetty.util.component.AbstractLifeCycle;
4042
import org.eclipse.jetty.util.log.Log;
4143
import org.eclipse.jetty.util.thread.QueuedThreadPool;
4244

@@ -135,14 +137,26 @@ public void run() {
135137
new File("target/log.0.1.lck").delete();
136138

137139
// configuration from root.xml
138-
VmRuntimeWebAppContext context = new VmRuntimeWebAppContext();
140+
final VmRuntimeWebAppContext context = new VmRuntimeWebAppContext();
139141
context.setContextPath("/");
140142
context.setConfigurationClasses(preconfigurationClasses);
141143

142-
// Needed for JSP!
143-
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
144-
JspFactory.setDefaultFactory(new JspFactoryImpl());
145-
144+
145+
// Needed to initialize JSP!
146+
context.addBean(new AbstractLifeCycle() {
147+
148+
@Override
149+
public void doStop() throws Exception {
150+
151+
}
152+
153+
@Override
154+
public void doStart() throws Exception {
155+
JettyJasperInitializer jspInit = new JettyJasperInitializer();
156+
jspInit.onStartup(Collections.EMPTY_SET, context.getServletContext());
157+
}
158+
}, true);
159+
146160
// find the sibling testwebapp target
147161
File currentDir = new File("").getAbsoluteFile();
148162
File webAppLocation = new File(currentDir, "target/webapps/testwebapp");

0 commit comments

Comments
 (0)