Class TestServer


  • public class TestServer
    extends Object
    A simple test server implementation.
    Author:
    havardpe
    • Constructor Detail

      • TestServer

        public TestServer​(String name,
                          RoutingTableSpec table,
                          com.yahoo.jrt.slobrok.server.Slobrok slobrok,
                          Protocol protocol)
        Create a new test server.
        Parameters:
        name - the service name prefix for this server
        table - the routing table spec to be used, may be null for no routing
        slobrok - the slobrok to register with (local)
        protocol - the protocol that this server should support in addition to SimpleProtocol
      • TestServer

        public TestServer​(MessageBusParams mbusParams)
        Creates a new test server without network setup
    • Method Detail

      • destroy

        public boolean destroy()
        Sets the destroyed flag to true. The very first time this method is called, it cleans up all its dependencies. Even if you retain a reference to this object, all of its content is allowed to be garbage collected.
        Returns:
        true if content existed and was destroyed
      • getSlobrokConfig

        public static String getSlobrokConfig​(com.yahoo.jrt.slobrok.server.Slobrok slobrok)
        Returns the raw config needed to connect to the given slobrok.
        Parameters:
        slobrok - the slobrok whose connection spec to include
        Returns:
        the raw config string
      • waitSlobrok

        public boolean waitSlobrok​(String pattern,
                                   int cnt)
        Wait for some pattern to resolve to some number of services.
        Parameters:
        pattern - pattern to lookup in slobrok
        cnt - number of services it must resolve to
        Returns:
        Whether or not the required state was reached
      • waitState

        public boolean waitState​(SlobrokState slobrokState)
        Wait for a required slobrok state.
        Parameters:
        slobrokState - the state to wait for
        Returns:
        whether or not the required state was reached