/Ak47

Ak47 - an easy Network Service Testing Framework.

Primary LanguageJavaApache License 2.0Apache-2.0

Ak47

Ak47 is an easy Network Service Testing Framework. It is a Test-Specific Framework, designed for better Automation-Testing, Performance-Testing, Mock-Testing and with the same code style.

Ak47 can support almost all network protocols, such as HTTP, Hession, ISO8583, Dubbo, Thrift, and other RPC protocols, only if there is a corresponding Pipe.

Ak47 is base on Netty/NIO, and its design philosophy is simple to use, scalable, and high performance.

Examples

A Simple Http Driver

// new a Pipe
SimpleHttpPipe pipe = new SimpleHttpPipe();

// create a simple driver
SimpleDriver<SimpleHttpRequest, SimpleHttpResponse> driver = 
        pipe.createSimpleDriver("www.jd.com", 80);

// prepare a request
SimpleHttpRequest httpreq = new SimpleHttpRequest("GET", "/");

// send it, and get a response
SimpleHttpResponse httpres = driver.send(httpreq);

// finally check the res.
System.out.println(httpres.getStatusCode());
System.out.println(httpres.getContent().length);

A Simple Http Stub

// new a Pipe
SimpleHttpPipe pipe = new SimpleHttpPipe();

// create a stub
SimpleStub<SimpleHttpRequest, SimpleHttpResponse> stub = pipe.createSimpleStub(8055);

// add a service
stub.addService("myservice", new Service<SimpleHttpRequest, SimpleHttpResponse>(){
    @Override
    public void doService(Request<SimpleHttpRequest> request,
            Response<SimpleHttpResponse> response) throws Exception {
        SimpleHttpRequest httpreq = request.pojo();
        
        SimpleHttpResponse httpres = new SimpleHttpResponse();
        String content = "Hello Ak47! Your request url is "+httpreq.getUrl();
        httpres.setContent(content.getBytes());
        response.pojo(httpres);
    }
});

// finally start and hold it.
stub.start();
stub.hold();

How to build

You require the following to build AK47:

Note that this is build-time requirement. JDK 6 is enough to run your AK47-based application.

Contributing

Ak47 is free software/open source, and is distributed under the Apache License 2.0.

Please feel free to contribute code or documentation. Welcome to Pull Requests.

Here is the code contributors so fa: hannyu, xwliang, nabokil.

Questions?

You can try creating an issue, or searching issues, or email to hannyu.

WIKI

Welcome to the AK47 wiki. Please head to [User Guide].

欢迎来到Ak47主页,请转到[用户指南]