|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (5)
View Page History @Test
public void testUsingWebServer() throws IOException {
public void testUsingWebServer() throws IOException {
// ...
this.webServer.addServlet(servlet, servletPath);
this.webServer.addServlet(servlet, servletPath);
@Test
public void testUsingWebServer() throws IOException {
public void testUsingWebServer() throws IOException {
// ...
this.webServer.addServlet(servlet, servletPath);
this.webServer.addServlet(servlet, servletPath);
The reply of this servlet is:
* the content-type that has been set when creating the servlet,
* the content-type that has been set when creating the servlet,
* the reply content is the content of the given file when creating the servlet.
{code}
public static class HasWebServer {
public static class HasWebServer {
@Test
public void testUsingWebServer() throws IOException {
public void testUsingWebServer() throws IOException {
// ...
final AbstractHttpServlet fileServlet = new FileServlet(
final AbstractHttpServlet fileServlet = new FileServlet(
}
{code}
{code}
h4. Working with {{TextServlet}}
The reply of this servlet is:
* the content-type is '{{text/plain}}',
* the reply content is '{{A plain text}}'.
{code}
public static class HasWebServer {
@Rule
public WebServer webServer = new WebServer();
@Test
public void testUsingWebServer() throws IOException {
// ...
final AbstractHttpServlet textServlet = new textServlet();
this.webServer.addServlet(fileServlet, fileServlet.getPath());
// ...
}
}
{code}
h2. Getting the URL of a servlet to invoke
Some facilities was included to build the URL of a servlet to invoke:
* {{WebServer.getHttpBaseUrl()}} : returns the base part of URLs served by the web server,
* {{AbstractHttpServlet.getPath()}} : returns the URL path part of the servlet.
Combining both methods builds easily the URL of the servlet to invoke:
{code}
public static class HasWebServer {
@Rule
public WebServer webServer = new WebServer();
@Test
public void testUsingWebServer() throws IOException {
// ...
final AbstractHttpServlet textServlet = new textServlet();
this.webServer.addServlet(fileServlet, fileServlet.getPath());
// ...
final URL urlToInvoke = new URL(this.webServer.getHttpBaseUrl()
+ textServlet.getPath());
// ...
}
}
{code}