Package org.takes.facets.fallback
Class RqFallback.Fake
- java.lang.Object
-
- org.takes.facets.fallback.RqFallback.Fake
-
- All Implemented Interfaces:
Body
,RqFallback
,Head
,Request
- Enclosing interface:
- RqFallback
public static final class RqFallback.Fake extends Object implements RqFallback
Fake implementation, for unit tests mostly.Use this class in unit tests, when you need to create a fake version of a request with an exception inside. For example:
new TkIndex().act( new RqFallback.Fake("/(.*)", "/hello") );
- Since:
- 0.13
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.takes.facets.fallback.RqFallback
RqFallback.Fake
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
body()
Body.int
code()
Get HTTP status code suggested.Iterable<String>
head()
All lines above the body.Throwable
throwable()
Get throwable that occurred.
-
-
-
Constructor Detail
-
Fake
public Fake(int code)
Ctor.- Parameters:
code
- HTTP status code
-
Fake
public Fake(int code, Throwable error)
Ctor.- Parameters:
code
- HTTP status codeerror
- Exception
-
-
Method Detail
-
code
public int code()
Description copied from interface:RqFallback
Get HTTP status code suggested.- Specified by:
code
in interfaceRqFallback
- Returns:
- HTTP status code
-
throwable
public Throwable throwable()
Description copied from interface:RqFallback
Get throwable that occurred.- Specified by:
throwable
in interfaceRqFallback
- Returns:
- Throwable
-
head
public Iterable<String> head() throws IOException
Description copied from interface:Head
All lines above the body.- Specified by:
head
in interfaceHead
- Returns:
- List of lines
- Throws:
IOException
- If something goes wrong
-
body
public InputStream body() throws IOException
Description copied from interface:Body
Body.- Specified by:
body
in interfaceBody
- Returns:
- Stream with body
- Throws:
IOException
- If something goes wrong
-
-