Last active
August 29, 2015 14:20
-
-
Save seykron/eb87f7292daa48a324df to your computer and use it in GitHub Desktop.
eclipse-jetty #465700 test case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo.test; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.server.handler.ResourceHandler; | |
import org.eclipse.jetty.servlet.ServletContextHandler; | |
import org.eclipse.jetty.util.resource.Resource; | |
/** Steps to reproduce the issue: | |
* | |
* 1. Run the application | |
* 2. Access http://localhost:8000/test | |
* | |
* Expected result: it must render the index.html file | |
* Actual result: ResourceHandler throws a NPE. | |
*/ | |
public class AppTest { | |
private static final String TEST_CONTEXT = "/test"; | |
public static void main(String[] args) throws Exception { | |
AppTest app = new AppTest(); | |
app.init(8000); | |
} | |
private Server server; | |
public void init(int port) { | |
server = new Server(port); | |
ServletContextHandler handler = new ServletContextHandler(server, TEST_CONTEXT, false, false); | |
ResourceHandler resourceHandler = new ResourceHandler(); | |
resourceHandler.setBaseResource(Resource.newClassPathResource("/public")); | |
handler.setWelcomeFiles(new String[] { "index.html" }); | |
handler.setHandler(resourceHandler); | |
server.setHandler(handler); | |
try { | |
server.start(); | |
server.join(); | |
} catch (Exception cause) { | |
throw new RuntimeException(cause); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment