mech


License

License

GroupId

GroupId

me.geso
ArtifactId

ArtifactId

mech
Last Version

Last Version

0.11.8
Release Date

Release Date

Type

Type

jar
Description

Description

mech
mech
Project URL

Project URL

http://github.com/tokuhirom/mech
Source Code Management

Source Code Management

https://github.com/tokuhirom/mech/

Download mech

How to add to project

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

Dependencies

compile (8)

Group / Artifact Type Version
junit : junit jar 4.11
com.fasterxml.jackson.core : jackson-core jar 2.4.2
com.fasterxml.jackson.core : jackson-databind jar 2.3.3
org.eclipse.jetty : jetty-server jar 9.2.3.v20140905
org.eclipse.jetty : jetty-servlet jar 9.2.3.v20140905
org.apache.httpcomponents : httpclient jar 4.3.5
org.apache.httpcomponents : httpmime jar 4.3.5
me.geso : tinyvalidator jar 0.6.0

provided (1)

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

test (1)

Group / Artifact Type Version
commons-fileupload : commons-fileupload jar 1.3.1

Project Modules

There are no modules declared in this project.

mech

Build Status

Testing library for web applications. You can test web application based on servlet API very easy.

SYNOPSIS

Access to the external service.

@Test
public void testGoogle() throws Exception {
    try (Mech mech = new Mech("http://google.com/")) {
        try (MechResponse res = mech.get("/").execute()) {
            assertEquals(200, res.getStatusCode());
        }
    }
}

Testing with MechJettyServlet.

class MyServlet extends HttpServlet {
    protected void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.getWriter().write("Hello");
    }

}

public class ServletTest {
    @Test
    public void test() throws Exception {
        try (MechJettyServlet mech = new MechJettyServlet(new MyServlet())) {
            try (MechResponse res = mech.get("/").execute()) {
                assertEquals(200, res.getStatusCode());
                assertEquals("Hello", res.getContentString());
            }
        }
    }
}

Features

  • Really easy Servlet testing
  • POST with application/json
  • POST with multipart/form-data
  • fluent interface.

Install with maven

See http://tokuhirom.github.io/maven/

DEPENDENCIES

  • jetty
  • Java 1.8+
  • apache httpclient
  • jackson

API Stability

I will change API without notice. But I may respect the semver.

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.11.8