public class StreamMatcher
extends java.lang.Object
StreamMatcher
encapsulates the details of watching a stream for
relevant tuples. Instances of the class are immutable, but can be used
to create customized versions of themselves. The default is equivalent to
StreamMatcher matcher = StreamMatcher.on(dequeuer)
.ordering(Ordering.ORDERED)
.onExtra(ExtraTuples.ERROR)
.reporting(Reports.getBasicReportFactory())
.timeout(Dequeuer.DEFAULT_TIMEOUT, Dequeuer.DEFAULT_TIMEOUT_UNIT);
Modifier and Type | Class and Description |
---|---|
static class |
StreamMatcher.ExtraTuples
How to handle unexpected tuples during a call to
expectTuple(TupleMatcher) ,
expectTuples(TupleMatcher...) , or
expectTuples(List) |
static class |
StreamMatcher.Ordering
How to handle tuple ordering during a call to
expectTuples(TupleMatcher...) or
expectTuples(List) |
Modifier and Type | Method and Description |
---|---|
StreamMatcher |
automaticTimeout()
Create an identical
StreamMatcher except that it will attempt to automatically detect
appropriate timeouts based on server activity. |
void |
expectNothing()
Expect no tuples to become available on the stream for the entire timeout, ensuring
that all tuples current in flight will have time to finish.
|
void |
expectTuple(TupleMatcher m)
Expect a single tuple that matches the provided
TupleMatcher |
void |
expectTuples(int num)
Expect num tuples to become available on the stream before the timeout.
|
void |
expectTuples(java.util.List<? extends TupleMatcher> matchers)
Expect tuples that match each of the given
TupleMatcher s |
void |
expectTuples(TupleMatcher... matchers)
Expect tuples that match each of the given
TupleMatcher s |
protected ErrorReport |
makeErrorReport(int numTuples)
Subclasses wishing to customize the error reporting can override
this method.
|
static StreamMatcher |
on(com.streambase.sb.unittest.Dequeuer dequeuer)
Create a default
StreamMatcher for the stream provided by Dequeuer . |
StreamMatcher |
onExtra(StreamMatcher.ExtraTuples extras)
Create an identical
StreamMatcher except that will handle unexpected Tuples
within expect*() calls according to the provided StreamMatcher.ExtraTuples |
StreamMatcher |
ordering(StreamMatcher.Ordering ordering)
Create an identical
StreamMatcher except that will handle order of tuples
within expect*() calls according to the provided StreamMatcher.Ordering . |
StreamMatcher |
reporting(ErrorReportFactory reportFactory)
Create an identical
StreamMatcher except that will use the provided reporter
within expect*() calls. |
StreamMatcher |
timeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Create an identical
StreamMatcher except that will use the provided timeout
within expect*() calls. |
public static StreamMatcher on(com.streambase.sb.unittest.Dequeuer dequeuer)
StreamMatcher
for the stream provided by Dequeuer
.
Equivalent to:
StreamMatcher matcher = StreamMatcher.on(dequeuer)
.ordering(Ordering.ORDERED)
.onExtra(ExtraTuples.ERROR)
.reporting(Reports.getBasicReportFactory())
.timeout(Dequeuer.DEFAULT_TIMEOUT, Dequeuer.DEFAULT_TIMEOUT_UNIT);
public StreamMatcher onExtra(StreamMatcher.ExtraTuples extras)
StreamMatcher
except that will handle unexpected Tuples
within expect*() calls according to the provided StreamMatcher.ExtraTuples
public StreamMatcher ordering(StreamMatcher.Ordering ordering)
StreamMatcher
except that will handle order of tuples
within expect*() calls according to the provided StreamMatcher.Ordering
.public StreamMatcher timeout(long timeout, java.util.concurrent.TimeUnit timeUnit)
StreamMatcher
except that will use the provided timeout
within expect*() calls.public StreamMatcher reporting(ErrorReportFactory reportFactory)
StreamMatcher
except that will use the provided reporter
within expect*() calls.public StreamMatcher automaticTimeout()
StreamMatcher
except that it will attempt to automatically detect
appropriate timeouts based on server activity.public void expectTuples(TupleMatcher... matchers) throws com.streambase.sb.StreamBaseException, java.lang.AssertionError
TupleMatcher
scom.streambase.sb.StreamBaseException
- if an internal error occursjava.lang.AssertionError
- if the expected tuples do not matchpublic void expectTuples(java.util.List<? extends TupleMatcher> matchers) throws com.streambase.sb.StreamBaseException, java.lang.AssertionError
TupleMatcher
scom.streambase.sb.StreamBaseException
- if an internal error occursjava.lang.AssertionError
- if the expected tuples do not matchpublic void expectTuple(TupleMatcher m) throws com.streambase.sb.StreamBaseException, java.lang.AssertionError
TupleMatcher
com.streambase.sb.StreamBaseException
- if an internal error occursjava.lang.AssertionError
- if the expected tuples do not matchpublic void expectTuples(int num) throws com.streambase.sb.StreamBaseException, java.lang.AssertionError
com.streambase.sb.StreamBaseException
- if an internal error occursjava.lang.AssertionError
- if the expected tuples do not matchpublic void expectNothing() throws com.streambase.sb.StreamBaseException, java.lang.AssertionError
com.streambase.sb.StreamBaseException
- if an internal error occursjava.lang.AssertionError
- if the expected tuples do not matchprotected ErrorReport makeErrorReport(int numTuples)