servlettester-jetty


License

License

Categories

Categories

Jetty Container Application Servers
GroupId

GroupId

me.geso
ArtifactId

ArtifactId

servlettester-jetty
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

servlettester-jetty
servlettester-jetty
Project URL

Project URL

https://github.com/tokuhirom/servlettester-jetty/
Source Code Management

Source Code Management

https://github.com/tokuhirom/servlettester-jetty/

Download servlettester-jetty

How to add to project

<!-- https://jarcasting.com/artifacts/me.geso/servlettester-jetty/ -->
<dependency>
    <groupId>me.geso</groupId>
    <artifactId>servlettester-jetty</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/me.geso/servlettester-jetty/
implementation 'me.geso:servlettester-jetty:0.1.1'
// https://jarcasting.com/artifacts/me.geso/servlettester-jetty/
implementation ("me.geso:servlettester-jetty:0.1.1")
'me.geso:servlettester-jetty:jar:0.1.1'
<dependency org="me.geso" name="servlettester-jetty" rev="0.1.1">
  <artifact name="servlettester-jetty" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.geso', module='servlettester-jetty', version='0.1.1')
)
libraryDependencies += "me.geso" % "servlettester-jetty" % "0.1.1"
[me.geso/servlettester-jetty "0.1.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.eclipse.jetty : jetty-servlet jar 9.4.12.v20180830
commons-io : commons-io jar 2.6

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.2

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.apache.httpcomponents : httpclient jar 4.5.6

Project Modules

There are no modules declared in this project.

servlettester-jetty

Build Status Maven Central

SYNOPSIS

JettyServletTester.runServlet((req, resp) -> {
	resp.getWriter().print("Hey");
}, (uri) -> {
	try (CloseableHttpClient client = HttpClientBuilder.create()
			.build()) {
		HttpGet request = new HttpGet(uri);
		try (CloseableHttpResponse resp = client.execute(request)) {
			String body = EntityUtils.toString(resp.getEntity(),
					StandardCharsets.UTF_8);
			assertEquals("Hey", body);
		}
	}
});

or

JettyServletTester.runServlet(MyServlet.class, (uri) -> {
      // your test code
    }
);

or

JettyServletTester.runServlet(new MyServlet(), (uri) -> {
      // your test code
    }
);

DESCRIPTION

ServletTester is a utility class for writing test cases for HTTP servlets. It based on Java8's lambda.

Run jetty process by yourself

If you want to use low level API, you can call this library with following form:

	try (JettyServletRunner jettyServletRunner = new JettyServletRunner(servletHolder)) {
		// do something with `jettyServletRunner.getBaseURI()`
	}

LICENSE

The MIT License (MIT)
Copyright © 2014 Tokuhiro Matsuno, http://64p.org/ <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Versions

Version
0.1.1
0.1.0
0.0.2