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 ofMkContainerbased 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 voidclose()URIhome()Get its home.MkContainernext(MkAnswer answer)Give this answer on the next request.MkContainernext(MkAnswer answer, org.hamcrest.Matcher<MkQuery> condition)Give this answer on the next request if the matcher condition is satisfied.MkContainernext(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.intqueries()How many queries we have left.MkContainerstart()Start it on the first available TCP port.MkContainerstart(int prt)Start it on a provided port.voidstop()Stop container.MkQuerytake()Get the oldest request received (NoSuchElementExceptionif no more elements in the list).MkQuerytake(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:MkContainerGive this answer on the next request.- Specified by:
nextin 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:MkContainerGive this answer on the next request if the matcher condition is satisfied.- Specified by:
nextin 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:MkContainerGive this answer on the next request(s) if the matcher condition is satisfied up to a certain number of requests.- Specified by:
nextin 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:MkContainerGet the oldest request received (NoSuchElementExceptionif no more elements in the list).- Specified by:
takein interfaceMkContainer- Returns:
- Request received
-
take
public MkQuery take(org.hamcrest.Matcher<MkAnswer> matcher)
Description copied from interface:MkContainerGet the oldest request received subject to the matching condition. (NoSuchElementExceptionif no elements satisfy the condition).- Specified by:
takein 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:MkContainerGet the all requests received satisfying the given matcher. (NoSuchElementExceptionif no elements satisfy the condition).- Specified by:
takeAllin 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:MkContainerHow many queries we have left.- Specified by:
queriesin interfaceMkContainer- Returns:
- Total number of queries you can retrieve with
MkContainer.take()
-
start
public MkContainer start() throws IOException
Description copied from interface:MkContainerStart it on the first available TCP port.- Specified by:
startin interfaceMkContainer- Returns:
- This object
- Throws:
IOException- If fails
-
start
public MkContainer start(int prt) throws IOException
Description copied from interface:MkContainerStart it on a provided port.- Specified by:
startin 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:MkContainerStop container.- Specified by:
stopin interfaceMkContainer
-
home
public URI home()
Description copied from interface:MkContainerGet its home.- Specified by:
homein interfaceMkContainer- Returns:
- URI of the started container
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-