Package xmpptest provides utilities for XMPP testing.



This section is empty.


This section is empty.


func NewSession

func NewSession(state xmpp.SessionState, rw io.ReadWriter) *xmpp.Session

NewSession returns a new client-to-client XMPP session with the state bits set to state|xmpp.Ready, the origin JID set to "" and the location JID set to "".

NewSession panics on error for ease of use in testing, where a panic is acceptable.

func NopNegotiator

func NopNegotiator(state xmpp.SessionState) xmpp.Negotiator

NopNegotiator marks the state as ready (by returning state|xmpp.Ready) and pops the first token (likely <stream:stream>) but does not perform any validation on the token, transmit any data over the wire, or perform any other session negotiation.


type ClientServer

type ClientServer struct {
	Client *xmpp.Session
	Server *xmpp.Session
	// contains filtered or unexported fields

ClientServer is two coupled xmpp.Session's that can respond to one another in tests.

func NewClientServer

func NewClientServer(opts ...Option) *ClientServer

NewClientServer returns a ClientServer with the client and server goroutines started. Both serve goroutines are started when NewClient is called and shut down when Client is closed.

func (*ClientServer) Close

func (cs *ClientServer) Close() error

Close calls the client and server sessions' close methods.

type Option

type Option func(*ClientServer)

Option is a type for configuring a ClientServer.

func ClientHandler

func ClientHandler(handler xmpp.Handler) Option

ClientHandler sets up the client side of a ClientServer.

func ClientHandlerFunc

func ClientHandlerFunc(handler xmpp.HandlerFunc) Option

ClientHandlerFunc sets up the client side of a ClientServer using an xmpp.HandlerFunc.

func ClientState

func ClientState(state xmpp.SessionState) Option

ClientState configures extra state bits to add to the client session.

func ServerHandler

func ServerHandler(handler xmpp.Handler) Option

ServerHandler sets up the server side of a ClientServer.

func ServerHandlerFunc

func ServerHandlerFunc(handler xmpp.HandlerFunc) Option

ServerHandlerFunc sets up the server side of a ClientServer using an xmpp.HandlerFunc.

func ServerState

func ServerState(state xmpp.SessionState) Option

ServerState configures extra state bits to add to the server session.

Source Files