Package ru.iopump.qa.support.http
Class LocalSimpleHtmlServer
- java.lang.Object
-
- ru.iopump.qa.support.http.LocalSimpleHtmlServer
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class LocalSimpleHtmlServer extends java.lang.Object implements java.io.CloseableJDK http server. To provide simple html page on localhost. This page can be gotten on local host via http get request on specified endpoint. Provided Html page can be specified as well as port and path. Use it in your unit (integration) tests withWebDriver. Also pay attention on methodasTestRule().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classLocalSimpleHtmlServer.TestHtmlServer
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalSimpleHtmlServer.TestHtmlServerasTestRule()Create junit rule from server with default htmlLocalSimpleHtmlServer.TestHtmlServer.HTML.LocalSimpleHtmlServer.TestHtmlServerasTestRule(@NonNull java.lang.String html)Create junit rule from server.voidclose()booleanisPublished()static LocalSimpleHtmlServerof()static LocalSimpleHtmlServerof(int port, java.lang.String path)static LocalSimpleHtmlServerof(java.lang.String path)voidpublish(@NonNull java.lang.String html)Publish HTML string on localhost http server with specified path and port.voidsetCharset(java.nio.charset.Charset charset)java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static LocalSimpleHtmlServer of(int port, java.lang.String path)
-
of
public static LocalSimpleHtmlServer of(java.lang.String path)
-
of
public static LocalSimpleHtmlServer of()
-
asTestRule
public final LocalSimpleHtmlServer.TestHtmlServer asTestRule()
Create junit rule from server with default htmlLocalSimpleHtmlServer.TestHtmlServer.HTML.- Returns:
- New object provided junit test rule interface, contains this http server.
- See Also:
publish(String)
-
asTestRule
public final LocalSimpleHtmlServer.TestHtmlServer asTestRule(@NonNull @NonNull java.lang.String html)
Create junit rule from server.- Parameters:
html- seepublish(String)- Returns:
- New object provided junit test rule interface, contains this http server.
-
publish
public void publish(@NonNull @NonNull java.lang.String html)Publish HTML string on localhost http server with specified path and port.- Parameters:
html- Html page as string.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setCharset
public void setCharset(java.nio.charset.Charset charset)
-
isPublished
public boolean isPublished()
-
-