Package restx.specs.server

Source Code of restx.specs.server.SpecsServerTest

package restx.specs.server;

import com.github.kevinsawicki.http.HttpRequest;
import org.junit.Test;
import restx.server.WebServer;
import restx.server.WebServers;

import static org.assertj.core.api.Assertions.*;

/**
* User: xavierhanin
* Date: 4/10/13
* Time: 12:24 PM
*/
public class SpecsServerTest {
    @Test
    public void should_use_spec() throws Exception {
        WebServer server = SpecsServer.getServer(WebServers.findAvailablePort(), "/api", ".");
        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/message?who=xavier");

            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"message\":\"hello xavier, it's 14:33:18\"}");
        } finally {
            server.stop();
        }

    }
}
TOP

Related Classes of restx.specs.server.SpecsServerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.