org.apache.curator.test
Class TestingServer

java.lang.Object
  extended by org.apache.curator.test.TestingServer
All Implemented Interfaces:
Closeable

public class TestingServer
extends Object
implements Closeable

manages an internally running ZooKeeper server. FOR TESTING PURPOSES ONLY


Constructor Summary
TestingServer()
          Create the server using a random port
TestingServer(boolean start)
          Create the server using a random port
TestingServer(InstanceSpec spec, boolean start)
          Create the server using the given port
TestingServer(int port)
          Create and start the server using the given port
TestingServer(int port, boolean start)
          Create the server using the given port
TestingServer(int port, File tempDirectory)
          Create and start the server using the given port
TestingServer(int port, File tempDirectory, boolean start)
          Create the server using the given port
 
Method Summary
 void close()
          Close the server and any open clients and delete the temp directory
 String getConnectString()
          Returns the connection string to use
 int getPort()
          Return the port being used
 File getTempDirectory()
          Returns the temp directory being used
 void restart()
          Restart the server.
 void start()
          Start the server
 void stop()
          Stop the server without deleting the temp directory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestingServer

public TestingServer()
              throws Exception
Create the server using a random port

Throws:
Exception - errors

TestingServer

public TestingServer(boolean start)
              throws Exception
Create the server using a random port

Parameters:
start - True if the server should be started, false otherwise
Throws:
Exception - errors

TestingServer

public TestingServer(int port)
              throws Exception
Create and start the server using the given port

Parameters:
port - the port
Throws:
Exception - errors

TestingServer

public TestingServer(int port,
                     boolean start)
              throws Exception
Create the server using the given port

Parameters:
port - the port
start - True if the server should be started, false otherwise
Throws:
Exception - errors

TestingServer

public TestingServer(int port,
                     File tempDirectory)
              throws Exception
Create and start the server using the given port

Parameters:
port - the port
tempDirectory - directory to use
Throws:
Exception - errors

TestingServer

public TestingServer(int port,
                     File tempDirectory,
                     boolean start)
              throws Exception
Create the server using the given port

Parameters:
port - the port
tempDirectory - directory to use
start - True if the server should be started, false otherwise
Throws:
Exception - errors

TestingServer

public TestingServer(InstanceSpec spec,
                     boolean start)
              throws Exception
Create the server using the given port

Parameters:
spec - instance details
start - True if the server should be started, false otherwise
Throws:
Exception - errors
Method Detail

getPort

public int getPort()
Return the port being used

Returns:
port

getTempDirectory

public File getTempDirectory()
Returns the temp directory being used

Returns:
directory

start

public void start()
           throws Exception
Start the server

Throws:
Exception

stop

public void stop()
          throws IOException
Stop the server without deleting the temp directory

Throws:
IOException

restart

public void restart()
             throws Exception
Restart the server. If the server is currently running it will be stopped and restarted. If it's not currently running then it will be started. If it has been closed (had close() called on it) then an exception will be thrown.

Throws:
Exception

close

public void close()
           throws IOException
Close the server and any open clients and delete the temp directory

Specified by:
close in interface Closeable
Throws:
IOException

getConnectString

public String getConnectString()
Returns the connection string to use

Returns:
connection string


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.