donovan

Deadly simple Java 8 web application framework for mocking and testing

License

License

Categories

Categories

Net
GroupId

GroupId

net.moznion
ArtifactId

ArtifactId

donovan
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

donovan
Deadly simple Java 8 web application framework for mocking and testing
Project URL

Project URL

https://github.com/moznion/donovan
Source Code Management

Source Code Management

https://github.com/moznion/donovan

Download donovan

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
me.geso : webscrew jar 0.10.0
me.geso : routes jar 0.4.0
com.fasterxml.jackson.core : jackson-core jar 2.5.1
com.fasterxml.jackson.core : jackson-databind jar 2.5.1
org.apache.httpcomponents : httpclient jar 4.4
org.slf4j : slf4j-api jar 1.7.12

provided (5)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.14.8
javax.servlet : javax.servlet-api jar 3.1.0
org.eclipse.jetty : jetty-server jar 9.2.10.v20150310
org.apache.tomcat.embed : tomcat-embed-core jar 8.0.21
org.apache.tomcat : tomcat-catalina jar 8.0.21

test (3)

Group / Artifact Type Version
junit : junit jar 4.11
com.google.code.findbugs : findbugs jar 3.0.0
me.geso : mech2 jar 0.2.1

Project Modules

There are no modules declared in this project.

donovan Build Status Maven Central javadoc.io

Description

Deadly simple Java 8 web application framework for mocking and testing.

This framework aims to bootstrap a web application by single java file. Donovan uses embedded Jetty or Tomcat to realize this purpose.

This framework is inspired by avans.

Synopsis

With Embedded Jetty

App.java

@Slf4j
public class App {
    public static void main(String[] args) throws Exception {
        try (DonovanJetty dj = new DonovanJetty()) {
            dj.get("/", (c) -> {
                return c.renderJSON(new BasicAPIResponse(200, "hello!"));
            });

            dj.start();

            String url = dj.getURL();
            log.info(url);

            Mech2WithBase mech = new Mech2WithBase(Mech2.builder().build(), new URI(url));
            Mech2Result result = mech.get("/").execute();

            log.debug("{}", result.getResponse().getStatusLine().getStatusCode()); // <= 200
            log.debug("{}", result.getResponseBodyAsString()); // <= {"code":200,"messages":["hello!"]}
        }
    }
}

pom.xml

...
<dependencies>
    ...
    <dependency>
        <groupId>net.moznion</groupId>
        <artifactId>donovan</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>me.geso</groupId>
        <artifactId>mech2</artifactId>
        <version>0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>9.2.10.v20150310</version>
    </dependency>
</dependencies>

You must specify jetty-server if you want to use donovan with jetty.

With Embedded Tomcat

App.java

@Slf4j
public class App {
    public static void main(String[] args) throws Exception {
        try (DonovanTomcat dt = new DonovanTomcat()) {
            dt.get("/", (c) -> {
                return c.renderJSON(new BasicAPIResponse());
            });

            dt.start();

            String url = dt.getURL();
            log.info(url);

            Mech2WithBase mech = new Mech2WithBase(Mech2.builder().build(), new URI(url));
            Mech2Result result = mech.get("/").execute();

            log.debug("{}", result.getResponse().getStatusLine().getStatusCode()); // <= 200
            log.debug("{}", result.getResponseBodyAsString()); // <= {"code":200,"messages":["hello!"]}
        }
    }
}

pom.xml

...
<dependencies>
    ...
    <dependency>
        <groupId>net.moznion</groupId>
        <artifactId>donovan</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>me.geso</groupId>
        <artifactId>mech2</artifactId>
        <version>0.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>8.0.21</version>
    </dependency>
        <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>8.0.21</version>
    </dependency>
</dependencies>

You must specify tomcat-embed-core and tomcat-catalina if you want to use donovan with tomcat.

Run a web app

$ mvn compile
$ mvn exec:java -Dexec.mainClass="com.example.App"

FAQ

Q. Can I use this framework in production?
A. You'd better not do it.

Author

moznion ([email protected])

License

The MIT License (MIT)
Copyright © 2015 moznion, http://moznion.net/ <[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
1.0.0