Package org.elasticsearch.test.transport
Class CapturingTransport
java.lang.Object
org.elasticsearch.test.transport.StubbableTransport
org.elasticsearch.test.transport.MockTransport
org.elasticsearch.test.transport.CapturingTransport
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.elasticsearch.common.component.LifecycleComponent
,org.elasticsearch.common.lease.Releasable
,org.elasticsearch.transport.Transport
public class CapturingTransport extends MockTransport implements org.elasticsearch.transport.Transport
A transport class that doesn't send anything but rather captures all requests for inspection from tests
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CapturingTransport.CapturedRequest
Nested classes/interfaces inherited from class org.elasticsearch.test.transport.StubbableTransport
StubbableTransport.OpenConnectionBehavior, StubbableTransport.RequestHandlingBehavior<Request extends org.elasticsearch.transport.TransportRequest>, StubbableTransport.SendRequestBehavior, StubbableTransport.WrappedConnection
Nested classes/interfaces inherited from interface org.elasticsearch.transport.Transport
org.elasticsearch.transport.Transport.Connection, org.elasticsearch.transport.Transport.RequestHandlers, org.elasticsearch.transport.Transport.ResponseContext<T extends org.elasticsearch.transport.TransportResponse>, org.elasticsearch.transport.Transport.ResponseHandlers
-
Constructor Summary
Constructors Constructor Description CapturingTransport()
-
Method Summary
Modifier and Type Method Description CapturingTransport.CapturedRequest[]
capturedRequests()
returns all requests captured so far.java.util.Map<java.lang.String,java.util.List<CapturingTransport.CapturedRequest>>
capturedRequestsByTargetNode()
returns all requests captured so far, grouped by target node.void
clear()
clears captured requestsCapturingTransport.CapturedRequest[]
getCapturedRequestsAndClear()
Returns all requests captured so far.java.util.Map<java.lang.String,java.util.List<CapturingTransport.CapturedRequest>>
getCapturedRequestsByTargetNodeAndClear()
Returns all requests captured so far, grouped by target node.protected void
onSendRequest(long requestId, java.lang.String action, org.elasticsearch.transport.TransportRequest request, org.elasticsearch.cluster.node.DiscoveryNode node)
Methods inherited from class org.elasticsearch.test.transport.MockTransport
createConnection, createTransportService, handleError, handleLocalError, handleRemoteError, handleResponse, setMessageListener, writeableRegistry
Methods inherited from class org.elasticsearch.test.transport.StubbableTransport
addLifecycleListener, addressesFromString, boundAddress, close, getDefaultSeedAddresses, getRequestHandlers, getResponseHandlers, getStats, lifecycleState, openConnection, profileBoundAddresses, removeLifecycleListener, setDefaultConnectBehavior, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CapturingTransport
public CapturingTransport()
-
-
Method Details
-
capturedRequests
returns all requests captured so far. Doesn't clear the captured request list. Seeclear()
-
getCapturedRequestsAndClear
Returns all requests captured so far. This method does clear the captured requests list. If you do not want the captured requests list cleared, usecapturedRequests()
.- Returns:
- the captured requests
-
capturedRequestsByTargetNode
public java.util.Map<java.lang.String,java.util.List<CapturingTransport.CapturedRequest>> capturedRequestsByTargetNode()returns all requests captured so far, grouped by target node. Doesn't clear the captured request list. Seeclear()
-
getCapturedRequestsByTargetNodeAndClear
public java.util.Map<java.lang.String,java.util.List<CapturingTransport.CapturedRequest>> getCapturedRequestsByTargetNodeAndClear()Returns all requests captured so far, grouped by target node. This method does clear the captured request list. If you do not want the captured requests list cleared, usecapturedRequestsByTargetNode()
.- Returns:
- the captured requests grouped by target node
-
clear
public void clear()clears captured requests -
onSendRequest
protected void onSendRequest(long requestId, java.lang.String action, org.elasticsearch.transport.TransportRequest request, org.elasticsearch.cluster.node.DiscoveryNode node)- Overrides:
onSendRequest
in classMockTransport
-