Class MockConnection
- java.lang.Object
-
- com.yahoo.config.subscription.impl.MockConnection
-
- All Implemented Interfaces:
Connection
,ConnectionPool
,java.lang.AutoCloseable
public class MockConnection extends java.lang.Object implements ConnectionPool, Connection
For unit testing- Author:
- hmusum
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MockConnection.AbstractResponseHandler
static interface
MockConnection.ResponseHandler
-
Constructor Summary
Constructors Constructor Description MockConnection()
MockConnection(MockConnection.ResponseHandler responseHandler)
MockConnection(MockConnection.ResponseHandler responseHandler, int numSpecs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
getAddress()
Connection
getCurrent()
int
getNumberOfRequests()
com.yahoo.jrt.Request
getRequest()
int
getSize()
com.yahoo.jrt.Supervisor
getSupervisor()
void
invokeAsync(com.yahoo.jrt.Request request, double jrtTimeout, com.yahoo.jrt.RequestWaiter requestWaiter)
void
invokeSync(com.yahoo.jrt.Request request, double jrtTimeout)
void
setError(Connection connection, int errorCode)
Sets the supplied Connection to have an error, implementations are expected to callConnectionPool.switchConnection(Connection)
after setting state for the supplied Connection.Connection
switchConnection(Connection connection)
Switches to another (healthy, if one exists) Connection instance.
-
-
-
Constructor Detail
-
MockConnection
public MockConnection()
-
MockConnection
public MockConnection(MockConnection.ResponseHandler responseHandler)
-
MockConnection
public MockConnection(MockConnection.ResponseHandler responseHandler, int numSpecs)
-
-
Method Detail
-
invokeAsync
public void invokeAsync(com.yahoo.jrt.Request request, double jrtTimeout, com.yahoo.jrt.RequestWaiter requestWaiter)
- Specified by:
invokeAsync
in interfaceConnection
-
invokeSync
public void invokeSync(com.yahoo.jrt.Request request, double jrtTimeout)
- Specified by:
invokeSync
in interfaceConnection
-
getAddress
public java.lang.String getAddress()
- Specified by:
getAddress
in interfaceConnection
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceConnectionPool
-
setError
public void setError(Connection connection, int errorCode)
Description copied from interface:ConnectionPool
Sets the supplied Connection to have an error, implementations are expected to callConnectionPool.switchConnection(Connection)
after setting state for the supplied Connection.- Specified by:
setError
in interfaceConnectionPool
-
getCurrent
public Connection getCurrent()
- Specified by:
getCurrent
in interfaceConnectionPool
-
switchConnection
public Connection switchConnection(Connection connection)
Description copied from interface:ConnectionPool
Switches to another (healthy, if one exists) Connection instance. Returns the resulting Connection. See alsoConnectionPool.setError(Connection, int)
- Specified by:
switchConnection
in interfaceConnectionPool
- Returns:
- a Connection
-
getSize
public int getSize()
- Specified by:
getSize
in interfaceConnectionPool
-
getSupervisor
public com.yahoo.jrt.Supervisor getSupervisor()
- Specified by:
getSupervisor
in interfaceConnectionPool
-
getNumberOfRequests
public int getNumberOfRequests()
-
getRequest
public com.yahoo.jrt.Request getRequest()
-
-