public class ProgrammableSink extends Object implements MessageSink
MessageSink
interface which can
be used in unit tests of OpenFlow message interactions.
Constructor and Description |
---|
ProgrammableSink(DataPathId defaultDpid)
Constructs a programmable message sink.
|
Modifier and Type | Method and Description |
---|---|
void |
addError(DataPathId dpid,
List<String> context,
String msg)
Adds an assertion error to the accumulation list for the given
datapath.
|
void |
addError(DataPathId dpid,
List<String> context,
String msg,
Object exp,
Object act)
Adds an assertion error to the accumulation list for the given
datapath.
|
void |
assocXid(DataPathId dpid,
long xid)
Associates an expected transaction id with a datapath.
|
void |
dataPathAdded(DataPathId dpid,
ProtocolVersion negotiated,
IpAddress ip)
Invoked by the controller when a new datapath has completed the
extended handshake sequence and is ready to talk OpenFlow.
|
void |
dataPathReady(DataPathId dpid,
ProtocolVersion negotiated,
IpAddress ip)
Invoked by the controller when a new datapath has completed the
post-handshake task and is ready for some real work.
|
void |
dataPathRemoved(DataPathId dpid,
ProtocolVersion negotiated,
IpAddress ip,
boolean logMsg)
Invoked by the controller when a datapath connection is dropped.
|
void |
dataPathRevoked(DataPathId dpid,
ProtocolVersion negotiated,
IpAddress ip)
Invoked by the controller when a datapath connection is refused
because a datapath with the given ID is already connected.
|
void |
endReplay()
Ends the replay.
|
void |
expect(DataPathId dpid,
MessageType type)
Adds the expectation that the next message is of the specified type.
|
void |
expect(DataPathId dpid,
MessageType type,
AbstractMsgAssertor ma)
Adds the expectation that the next message is of the specified type,
and that the assertions embodied in the message assertor, when run
against the message, are all true.
|
void |
expect(MessageType type)
Adds the expectation that the next message is of the specified type,
(and expected from the default datapath).
|
void |
expect(MessageType type,
AbstractMsgAssertor ma)
Adds the expectation that the next message is of the specified type,
and that the assertions embodied in the message assertor, when run
against the message, are all true, (and expected from the default
datapath).
|
void |
msgRx(OpenflowMessage msg,
DataPathId dpid,
int auxId,
ProtocolVersion negotiated)
Incoming OpenFlow messages are routed through this API method.
|
void |
replay()
Switches the sink into replay mode.
|
ProgrammableSink |
setNonStrict()
Setting the sink to non-strict mode means that the sink will ignore
any message received that it is not expecting, rather than failing
the test.
|
public ProgrammableSink(DataPathId defaultDpid)
expect(...)
method that
explicitly specifies the datapath from which the message is expected.defaultDpid
- the default dpidpublic void expect(MessageType type)
type
- the expected message typepublic void expect(DataPathId dpid, MessageType type)
dpid
- the datapath from which the message is expectedtype
- the expected message typepublic void expect(MessageType type, AbstractMsgAssertor ma)
type
- the expected message typema
- the message assertorpublic void expect(DataPathId dpid, MessageType type, AbstractMsgAssertor ma)
dpid
- the datapath from which the message is expectedtype
- the expected message typema
- the message assertorpublic void replay()
public void endReplay()
public void dataPathAdded(DataPathId dpid, ProtocolVersion negotiated, IpAddress ip)
This default implementation does nothing.
dataPathAdded
in interface MessageSink
dpid
- the datapath idnegotiated
- the negotiated versionip
- the IP address of the switchpublic void dataPathReady(DataPathId dpid, ProtocolVersion negotiated, IpAddress ip)
MessageSink
dataPathReady
in interface MessageSink
dpid
- the datapath idnegotiated
- the negotiated protocol versionip
- the IP address of the switchpublic void dataPathRemoved(DataPathId dpid, ProtocolVersion negotiated, IpAddress ip, boolean logMsg)
This default implementation does nothing.
dataPathRemoved
in interface MessageSink
dpid
- the datapath idnegotiated
- the negotiated versionip
- the IP address of the switchlogMsg
- True if we should log that the datapath is being removed.public void dataPathRevoked(DataPathId dpid, ProtocolVersion negotiated, IpAddress ip)
This default implementation does nothing.
dataPathRevoked
in interface MessageSink
dpid
- the datapath idnegotiated
- the negotiated versionip
- the IP address of the switchpublic void msgRx(OpenflowMessage msg, DataPathId dpid, int auxId, ProtocolVersion negotiated)
msgRx
in interface MessageSink
msg
- the OpenFlow messagedpid
- the source datapath IDauxId
- the auxiliary connection IDnegotiated
- the negotiated versionpublic void addError(DataPathId dpid, List<String> context, String msg)
dpid
- the datapath idcontext
- list of error context messagesmsg
- the error messagepublic void addError(DataPathId dpid, List<String> context, String msg, Object exp, Object act)
dpid
- the datapath idcontext
- list of error context messagesmsg
- the error messageexp
- the expected valueact
- the actual valuepublic void assocXid(DataPathId dpid, long xid)
dpid
- the datapath idxid
- the expected transaction idpublic ProgrammableSink setNonStrict()
Returns a reference to itself to allow for method chaining. For example:
sink.setNonStrict().replay();
Copyright © 2015. All Rights Reserved.