use of javax.websocket.server.ServerEndpointConfig 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 javax.websocket.server.ServerEndpointConfig 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 javax.websocket.server.ServerEndpointConfig 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 javax.websocket.server.ServerEndpointConfig 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);
}
use of javax.websocket.server.ServerEndpointConfig in project jetty.project by eclipse.
the class ServerAnnotatedEndpointScanner_InvalidSignaturesTest method testScan_InvalidSignature.
@Test
public void testScan_InvalidSignature() throws DeploymentException {
WebSocketContainerScope container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(container, pojo, null);
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
try {
scanner.scan();
Assert.fail("Expected " + InvalidSignatureException.class + " with message that references " + expectedAnnoClass + " annotation");
} catch (InvalidSignatureException e) {
if (LOG.isDebugEnabled())
LOG.debug("{}:{}", e.getClass(), e.getMessage());
Assert.assertThat("Message", e.getMessage(), containsString(expectedAnnoClass.getSimpleName()));
}
}
Aggregations