Package com.jcabi.http.mock
Class MkGrizzlyContainer
- java.lang.Object
-
- com.jcabi.http.mock.MkGrizzlyContainer
-
- All Implemented Interfaces:
MkContainer
,Closeable
,AutoCloseable
@Loggable(1) public final class MkGrizzlyContainer extends Object implements MkContainer
Implementation ofMkContainer
based on Grizzly Server.- Since:
- 0.10
- See Also:
MkContainer
-
-
Constructor Summary
Constructors Constructor Description MkGrizzlyContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
URI
home()
Get its home.MkContainer
next(MkAnswer answer)
Give this answer on the next request.MkContainer
next(MkAnswer answer, org.hamcrest.Matcher<MkQuery> condition)
Give this answer on the next request if the matcher condition is satisfied.MkContainer
next(MkAnswer answer, org.hamcrest.Matcher<MkQuery> condition, int count)
Give this answer on the next request(s) if the matcher condition is satisfied up to a certain number of requests.int
queries()
How many queries we have left.MkContainer
start()
Start it on the first available TCP port.MkContainer
start(int prt)
Start it on a provided port.void
stop()
Stop container.MkQuery
take()
Get the oldest request received (NoSuchElementException
if no more elements in the list).MkQuery
take(org.hamcrest.Matcher<MkAnswer> matcher)
Get the oldest request received subject to the matching condition.Collection<MkQuery>
takeAll(org.hamcrest.Matcher<MkAnswer> matcher)
Get the all requests received satisfying the given matcher.
-
-
-
Method Detail
-
next
public MkContainer next(MkAnswer answer)
Description copied from interface:MkContainer
Give this answer on the next request.- Specified by:
next
in interfaceMkContainer
- Parameters:
answer
- Next answer to give- Returns:
- This object
-
next
public MkContainer next(MkAnswer answer, org.hamcrest.Matcher<MkQuery> condition)
Description copied from interface:MkContainer
Give this answer on the next request if the matcher condition is satisfied.- Specified by:
next
in interfaceMkContainer
- Parameters:
answer
- Next answer to givecondition
- The condition to match- Returns:
- This object
-
next
public MkContainer next(MkAnswer answer, org.hamcrest.Matcher<MkQuery> condition, int count)
Description copied from interface:MkContainer
Give this answer on the next request(s) if the matcher condition is satisfied up to a certain number of requests.- Specified by:
next
in interfaceMkContainer
- Parameters:
answer
- Next answer to givecondition
- The condition to matchcount
- Number of requests to match- Returns:
- This object
-
take
public MkQuery take()
Description copied from interface:MkContainer
Get the oldest request received (NoSuchElementException
if no more elements in the list).- Specified by:
take
in interfaceMkContainer
- Returns:
- Request received
-
take
public MkQuery take(org.hamcrest.Matcher<MkAnswer> matcher)
Description copied from interface:MkContainer
Get the oldest request received subject to the matching condition. (NoSuchElementException
if no elements satisfy the condition).- Specified by:
take
in interfaceMkContainer
- Parameters:
matcher
- The matcher specifying the condition- Returns:
- Request received satisfying the matcher
-
takeAll
public Collection<MkQuery> takeAll(org.hamcrest.Matcher<MkAnswer> matcher)
Description copied from interface:MkContainer
Get the all requests received satisfying the given matcher. (NoSuchElementException
if no elements satisfy the condition).- Specified by:
takeAll
in interfaceMkContainer
- Parameters:
matcher
- The matcher specifying the condition- Returns:
- Collection of all requests satisfying the matcher, ordered from oldest to newest.
-
queries
public int queries()
Description copied from interface:MkContainer
How many queries we have left.- Specified by:
queries
in interfaceMkContainer
- Returns:
- Total number of queries you can retrieve with
MkContainer.take()
-
start
public MkContainer start() throws IOException
Description copied from interface:MkContainer
Start it on the first available TCP port.- Specified by:
start
in interfaceMkContainer
- Returns:
- This object
- Throws:
IOException
- If fails
-
start
public MkContainer start(int prt) throws IOException
Description copied from interface:MkContainer
Start it on a provided port.- Specified by:
start
in interfaceMkContainer
- Parameters:
prt
- The port where it should start listening- Returns:
- This object
- Throws:
IOException
- If fails
-
stop
public void stop()
Description copied from interface:MkContainer
Stop container.- Specified by:
stop
in interfaceMkContainer
-
home
public URI home()
Description copied from interface:MkContainer
Get its home.- Specified by:
home
in interfaceMkContainer
- Returns:
- URI of the started container
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-