-
Notifications
You must be signed in to change notification settings - Fork 33
Getting Started
You can incorporate jrobotremoteserver into your project or use it as a standalone jar.
public class ServerLauncher { public static void main(String[] args) throws Exception { RemoteServer.configureLogging(); RemoteServer server = new RemoteServer(); server.putLibrary("/", new MyLibrary()); server.putLibrary("/other", new MyOtherLibrary("42")); server.setPort(8270); server.start(); } }
How to add a servlet to a servlet container varies. Here is an example for Tiny Java Web Server:
import java.util.Properties; import Acme.Serve.Serve; public class ServerSetup { private Serve server = null; public void startServer() throws Exception { server = new Serve(); Properties properties = new Properties(); properties.put("port", 9999); server.arguments = properties; RemoteServerServlet servlet = new RemoteServerServlet(); servlet.putLibrary("/", new MyLibrary()); server.addServlet("/jrobotremoteserver", servlet); server.addDefaultServlets(null); server.runInBackground(); }
First configure the CLASSPATH to include your libraries and jrobotremoteserver. Then do something like this:
java org.robotframework.remoteserver.RemoteServer --library org.example.MyLibrary:/ --library org.example.MyOtherLibrary:/other --port 8270
Once the remote server has launched, you can see a status page in a web browser. The page displays what libraries are served on which ports, and is served on every port in use. For example, go to http://localhost:8270/ if you have a library assigned to port 8270.
You can stop the server in one of several ways:
- Execute keyword Stop Remote Server from Robot Framework (can be disabled)
- Raise a keyboard interrupt in the console -- CTRL + C
- Call RemoteServer.stop()
- Call XML-RPC method stop_remote_server() (disabled if the first option is)
<dependency>
<groupId>com.github.ombre42</groupId>
<artifactId>jrobotremoteserver</artifactId>
<version>3.0</version>
</dependency>