Java tutorial
/* * Copyright (c) 2015, OpinionLab * * This file is part of The Wall of Awesome. * * The Wall of Awesome is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The Wall of Awesome is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with The Wall of Awesome. If not, see <http://www.gnu.org/licenses/>. */ package com.opinionlab.woa; import org.apache.commons.io.IOUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClients; import org.junit.BeforeClass; import org.junit.Test; import java.io.IOException; import static org.junit.Assert.assertEquals; public class WallOfAwesomeTest { @BeforeClass public static void startServer() { WallOfAwesome.startServer(9999); } @Test public void hello() throws IOException { CloseableHttpResponse response = HttpClients.createDefault() .execute(new HttpGet("http://localhost:9999/hello")); assertEquals("Hello World!", IOUtils.toString(response.getEntity().getContent())); } }