Java tutorial
/** * Wabi-Sabi DAM solution * Open source Digital Asset Management platform of great simplicity and beauty. * Copyright (C) 2016 Urchinly <wabi-sabi@urchinly.uk> * * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ package uk.urchinly.wabi.expose; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import uk.urchinly.wabi.expose.Application; import static org.junit.Assert.assertEquals; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest("server.port=0") @DirtiesContext public class ApplicationConfigurationTests { @Value("${local.server.port}") private int port; @Test public void testServerStatus() throws Exception { ResponseEntity<String> entity = new TestRestTemplate() .getForEntity("http://localhost:" + this.port + "/info", String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); } }