ClientServletApplicationTest.java 1.89 KB
Newer Older
1
/*
Johannes Edmeier committed
2
 * Copyright 2014-2018 the original author or authors.
3 4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

17
package de.codecentric.boot.admin.client;
18 19 20 21

import org.junit.After;
import org.junit.Before;
import org.springframework.boot.SpringApplication;
22
import org.springframework.boot.WebApplicationType;
23 24
import org.springframework.context.ConfigurableApplicationContext;

25
public class ClientServletApplicationTest extends AbstractClientApplicationTest {
26 27 28
    private ConfigurableApplicationContext instance;

    @Before
Johannes Edmeier committed
29
    @Override
30
    public void setUp() throws Exception {
31
        super.setUp();
32

33 34 35
        SpringApplication application = new SpringApplication(TestClientApplication.class);
        application.setWebApplicationType(WebApplicationType.SERVLET);
        instance = application.run("--spring.application.name=Test-Client", "--server.port=0",
36
                "--management.endpoints.web.base-path=/mgmt", "--endpoints.health.enabled=true",
37
                "--spring.boot.admin.client.url=" + wireMock.url("/"));
38 39 40 41 42
    }

    @After
    public void shutdown() {
        instance.close();
43 44 45 46 47 48 49 50 51 52 53
    }

    @Override
    protected int getServerPort() {
        return instance.getEnvironment().getProperty("local.server.port", Integer.class, 0);
    }

    @Override
    protected int getManagementPort() {
        return instance.getEnvironment().getProperty("local.management.port", Integer.class, 0);

54 55 56 57
    }

}