Added checkstyle
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sample;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -22,28 +38,33 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* Test for gh-975.
|
||||
* org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
|
||||
* 'vaultEnvironmentRepositoryFactory' defined in
|
||||
* org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration: Unsatisfied dependency
|
||||
* No qualifying bean of type 'javax.servlet.http.HttpServletRequest' available:
|
||||
* Test for gh-975. org.springframework.beans.factory.UnsatisfiedDependencyException:
|
||||
* Error creating bean with name 'vaultEnvironmentRepositoryFactory' defined in
|
||||
* org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration:
|
||||
* Unsatisfied dependency No qualifying bean of type
|
||||
* 'javax.servlet.http.HttpServletRequest' available.
|
||||
*
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class,
|
||||
// Normally spring.cloud.config.enabled:true is the default but since we have the config
|
||||
// server on the classpath we need to set it explicitly
|
||||
properties = { "spring.cloud.config.enabled:true", "",
|
||||
"management.security.enabled=false", "management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
|
||||
// Normally spring.cloud.config.enabled:true is the default but since we have the
|
||||
// config
|
||||
// server on the classpath we need to set it explicitly
|
||||
properties = { "spring.cloud.config.enabled:true", "",
|
||||
"management.security.enabled=false",
|
||||
"management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
|
||||
public class ApplicationBootstrapTests {
|
||||
|
||||
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
|
||||
|
||||
private static int configPort = SocketUtils.findAvailableTcpPort();
|
||||
|
||||
private static ConfigurableApplicationContext server;
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private static ConfigurableApplicationContext server;
|
||||
|
||||
@BeforeClass
|
||||
public static void startConfigServer() throws IOException {
|
||||
System.setProperty("spring.cloud.bootstrap.name", "bootstrapservercomposite");
|
||||
@@ -69,20 +90,20 @@ public class ApplicationBootstrapTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void contextLoads() {
|
||||
Map res = new TestRestTemplate()
|
||||
.getForObject("http://localhost:" + port + BASE_PATH + "/env/info.foo", Map.class);
|
||||
assertThat(res).containsKey("propertySources");
|
||||
Map<String, Object> property = (Map<String,Object>) res.get("property");
|
||||
assertThat(property).containsEntry("value", "bar");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
configPort = 8888;
|
||||
startConfigServer();
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void contextLoads() {
|
||||
Map res = new TestRestTemplate().getForObject(
|
||||
"http://localhost:" + this.port + BASE_PATH + "/env/info.foo", Map.class);
|
||||
assertThat(res).containsKey("propertySources");
|
||||
Map<String, Object> property = (Map<String, Object>) res.get("property");
|
||||
assertThat(property).containsEntry("value", "bar");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user