Issue #3166 Jetty 10.0.x autobahn test ci (#3221)

*  issue #3166 add autobahn test

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
Olivier Lamy 2018-12-22 21:16:23 +10:00 committed by GitHub
parent ab2a8b0fe3
commit f5eb4864cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 300 additions and 2 deletions

View File

@ -96,4 +96,54 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>autobahn</id>
<activation>
<property>
<name>autobahn</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>me.normanmaurer.maven.autobahntestsuite</groupId>
<artifactId>autobahntestsuite-maven-plugin</artifactId>
<version>0.1.4</version>
<configuration>
<!-- Optional configuration -->
<!-- The port to bind the server on. Default is to choose a random free port. -->
<!--port>9090</port-->
<!-- The number of milliseconds to wait for the server to startup -->
<waitTime>20000</waitTime>
<generateJUnitXml>true</generateJUnitXml>
<cases>
<case>*</case>
</cases>
<excludeCases></excludeCases>
<failOnNonStrict>false</failOnNonStrict>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>fuzzingclient</goal>
</goals>
<configuration>
<!-- The class which contains a main method that accept the port as parameter and startup the -->
<!-- the server. -->
<!--mainClass>org.eclipse.jetty.websocket.autobahn.WebSocketServer</mainClass-->
<mainClass>org.eclipse.jetty.websocket.core.autobahn.AutobahnWebSocketServer</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -67,7 +67,12 @@ public class AutobahnWebSocketServer
{
public static void main(String[] args) throws Exception
{
Server server = new Server();
int port = 9001; // same port as found in fuzzing-client.json
if(args != null && args.length>0)
{
port = Integer.parseInt( args[0] );
}
Server server = new Server( port );
ServerConnector connector = new ServerConnector(
server,
@ -75,7 +80,7 @@ public class AutobahnWebSocketServer
);
connector.addBean(new RFC6455Handshaker());
connector.setPort(9001); // same port as found in fuzzing-client.json
//connector.setPort(9001);
connector.setIdleTimeout(10000);
server.addConnector(connector);

View File

@ -68,5 +68,9 @@
<module>test-quickstart</module>
<module>test-jmx</module>
<module>test-http-client-transport</module>
<!--
autobahn run might be in an other module
<module>test-websocket-autobahn</module>
-->
</modules>
</project>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>tests-parent</artifactId>
<version>10.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>test-websocket-autobahn</artifactId>
<name>Test :: Jetty Websocket Autobahn</name>
<description>Jetty Websocket Autobahn test suite</description>
<url>http://www.eclipse.org/jetty</url>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>autobahn</id>
<activation>
<property>
<name>autobahn</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>me.normanmaurer.maven.autobahntestsuite</groupId>
<artifactId>autobahntestsuite-maven-plugin</artifactId>
<version>0.1.4</version>
<configuration>
<!-- Optional configuration -->
<!-- The port to bind the server on. Default is to choose a random free port. -->
<!--port>9090</port-->
<!-- The number of milliseconds to wait for the server to startup -->
<waitTime>20000</waitTime>
<generateJUnitXml>true</generateJUnitXml>
<cases>
<case>*</case>
</cases>
<excludeCases></excludeCases>
<failOnNonStrict>false</failOnNonStrict>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>fuzzingclient</goal>
</goals>
<configuration>
<!-- The class which contains a main method that accept the port as parameter and startup the -->
<!-- the server. -->
<!--mainClass>org.eclipse.jetty.websocket.autobahn.WebSocketServer</mainClass-->
<mainClass>org.eclipse.jetty.websocket.autobahn.WebSocketJsrServer</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,74 @@
//
// ========================================================================
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.autobahn;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.javax.server.JavaxWebSocketServerContainerInitializer;
import javax.websocket.EndpointConfig;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpoint;
/**
* Example of setting up a javax.websocket server with Jetty embedded
*/
public class WebSocketJsrServer
{
/**
* A server socket endpoint
*/
@ServerEndpoint( value = "/" )
public static class EchoJsrSocket
{
@OnMessage
public void onMessage( Session session, String message )
{
session.getAsyncRemote().sendText( message );
}
@OnOpen
public void onOpen( Session session, EndpointConfig endpointConfig ){
session.setMaxTextMessageBufferSize( Integer.MAX_VALUE );
session.setMaxBinaryMessageBufferSize( Integer.MAX_VALUE );
}
}
public static void main( String[] args )
throws Exception
{
Server server = new Server( Integer.parseInt( args[0] ) );
ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS );
context.setContextPath( "/" );
server.setHandler( context );
ServerContainer wsContainer = JavaxWebSocketServerContainerInitializer.configureContext( context );
wsContainer.addEndpoint( EchoJsrSocket.class );
server.start();
context.dumpStdErr();
server.join();
}
}

View File

@ -0,0 +1,82 @@
//
// ========================================================================
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.autobahn;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
/**
* Example of setting up a Jetty WebSocket server
* <p>
* Note: this uses the Jetty WebSocket API, not the javax.websocket API.
*/
public class WebSocketServer
{
/**
* Example of a Jetty API WebSocket Echo Socket
*/
@WebSocket
public static class EchoSocket
{
@OnWebSocketMessage
public void onMessage( Session session, String message )
{
session.getRemote().sendStringByFuture( message );
}
}
/**
* Servlet layer
*/
@SuppressWarnings( "serial" )
public static class EchoServlet
extends WebSocketServlet
{
@Override
public void configure( WebSocketServletFactory factory )
{
factory.addMapping( factory.parsePathSpec( "/" ), ( req, res ) -> new EchoSocket() );
}
}
public static void main( String[] args )
throws Exception
{
//Log.getLog().setDebugEnabled( true );
Server server = new Server( Integer.parseInt( args[0] ) );
//Server server = new Server(9090);
ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS );
context.setContextPath( "/" );
server.setHandler( context );
// Add the echo socket servlet to the /echo path map
context.addServlet( new ServletHolder( EchoServlet.class ), "/" );
server.start();
context.dumpStdErr();
server.join();
}
}

View File

@ -0,0 +1,6 @@
# Setup default logging implementation for during testing
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.LEVEL=INFO
#org.eclipse.jetty.util.PathWatcher.LEVEL=DEBUG
#org.eclipse.jetty.util.thread.QueuedThreadPool.LEVEL=DEBUG
#org.eclipse.jetty.util.thread.ReservedThreadExecutor.LEVEL=DEBUG