use of org.eclipse.jetty.server.Server in project jetty.project by eclipse.
the class DataRateLimitedServletTest method init.
@Before
public void init() throws Exception {
server = new Server();
connector = new LocalConnector(server);
connector.getConnectionFactory(HttpConfiguration.ConnectionFactory.class).getHttpConfiguration().setSendServerVersion(false);
context = new ServletContextHandler();
context.setContextPath("/context");
context.setWelcomeFiles(new String[] { "index.html", "index.jsp", "index.htm" });
File baseResourceDir = testdir.getEmptyPathDir().toFile();
// Use resolved real path for Windows and OSX
Path baseResourcePath = baseResourceDir.toPath().toRealPath();
context.setBaseResource(Resource.newResource(baseResourcePath.toFile()));
ServletHolder holder = context.addServlet(DataRateLimitedServlet.class, "/stream/*");
holder.setInitParameter("buffersize", "" + BUFFER);
holder.setInitParameter("pause", "" + PAUSE);
server.setHandler(context);
server.addConnector(connector);
server.start();
}
use of org.eclipse.jetty.server.Server in project jetty.project by eclipse.
the class MemoryUsageTest method prepare.
@Before
public void prepare() throws Exception {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(server, "/", true, false);
ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(BasicEchoEndpoint.class, "/").build();
container.addEndpoint(config);
server.start();
client = ContainerProvider.getWebSocketContainer();
server.addBean(client, true);
}
use of org.eclipse.jetty.server.Server in project jetty.project by eclipse.
the class JsrBatchModeTest method prepare.
@Before
public void prepare() throws Exception {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(server, "/", true, false);
ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(BasicEchoEndpoint.class, "/").build();
container.addEndpoint(config);
server.start();
client = ContainerProvider.getWebSocketContainer();
server.addBean(client, true);
}
use of org.eclipse.jetty.server.Server in project jetty.project by eclipse.
the class StreamTest method startServer.
@BeforeClass
public static void startServer() throws Exception {
server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(0);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context);
// Prepare Server Side Output directory for uploaded files
outputDir = MavenTestingUtils.getTargetTestingDir(StreamTest.class.getName());
FS.ensureEmpty(outputDir);
// Create Server Endpoint with output directory configuration
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(UploadSocket.class, "/upload/{filename}").configurator(new ServerUploadConfigurator(outputDir)).build();
wsContainer.addEndpoint(config);
server.start();
String host = connector.getHost();
if (host == null) {
host = "localhost";
}
int port = connector.getLocalPort();
serverUri = new URI(String.format("ws://%s:%d/", host, port));
if (LOG.isDebugEnabled())
LOG.debug("Server started on {}", serverUri);
}
use of org.eclipse.jetty.server.Server in project jetty.project by eclipse.
the class TextStreamTest method prepare.
@Before
public void prepare() throws Exception {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(server, "/", true, false);
ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(ServerTextStreamer.class, PATH).build();
container.addEndpoint(config);
server.start();
wsClient = ContainerProvider.getWebSocketContainer();
server.addBean(wsClient, true);
}
Aggregations