@Before
    public void setupJetty() throws Exception {
        ContextHandlerCollection handlers = new ContextHandlerCollection();

        ServletContextHandler sch = new ServletContextHandler(ServletContextHandler.SESSIONS);
        sch.setSecurityHandler(createSecurityHandler());
        sch.setContextPath("/echo");
        ServletHolder mockEchoServlet = new ServletHolder(new EchoServlet());
        sch.addServlet(mockEchoServlet, "/*");
        sch.addFilter(AuthenticationFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

        handlers.addHandler(sch);

        SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
        sslContextFactory.setTrustStorePath(getResourcePath("common_ts.jks"));
        sslContextFactory.setTrustStorePassword("password");
        sslContextFactory.setKeyStorePath(getResourcePath("service_ks.jks"));
        sslContextFactory.setKeyStorePassword("password");
        sslContextFactory.setKeyManagerPassword("password");
        sslContextFactory.setNeedClientAuth(false);
        sslContextFactory.setWantClientAuth(false);

        // Create the server.
        int serverPort = 8008;
        server = new Server(serverPort);
        server.setStopAtShutdown(true);

        HttpConfiguration http_config = new HttpConfiguration();
        http_config.setSecureScheme("https");
        HttpConfiguration https_config = new HttpConfiguration(http_config);
        https_config.addCustomizer(new SecureRequestCustomizer());
        ServerConnector sslConnector = new ServerConnector(server,
                new SslConnectionFactory(sslContextFactory, "http/1.1"),
                new HttpConnectionFactory(https_config));
        sslConnector.setPort(8009);
        server.addConnector(sslConnector);

        server.setHandler(handlers);
        server.start();

        globalConfig.put(TLSOptions.TLS_DEVMODE, "true");
    }
With thanks to assistance of http://stackoverflow.com/b/20056601/2766538
@throws Exception any exception
gateway/platforms/servlet/src/test/java/io/apiman/gateway/platforms/servlet/auth/basic/BasicAuthTest.java