本文整理汇总了Java中org.springframework.boot.WebApplicationType类的典型用法代码示例。如果您正苦于以下问题:Java WebApplicationType类的具体用法?Java WebApplicationType怎么用?Java WebApplicationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebApplicationType类属于org.springframework.boot包,在下文中一共展示了WebApplicationType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: springSocialUserInfo
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void springSocialUserInfo() {
TestPropertyValues
.of("security.oauth2.resource.userInfoUri:http://example.com",
"spring.social.facebook.app-id=foo",
"spring.social.facebook.app-secret=bar")
.applyTo(this.environment);
this.context = new SpringApplicationBuilder(SocialResourceConfiguration.class)
.environment(this.environment).web(WebApplicationType.SERVLET).run();
ConnectionFactoryLocator connectionFactory = this.context
.getBean(ConnectionFactoryLocator.class);
assertThat(connectionFactory).isNotNull();
SpringSocialTokenServices services = this.context
.getBean(SpringSocialTokenServices.class);
assertThat(services).isNotNull();
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:17,代码来源:ResourceServerTokenServicesConfigurationTests.java
示例2: testParentConnectionFactoryInheritedIfOverridden
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void testParentConnectionFactoryInheritedIfOverridden() {
context = new SpringApplicationBuilder(SimpleProcessor.class, ConnectionFactoryConfiguration.class)
.web(WebApplicationType.NONE)
.run("--server.port=0");
BinderFactory binderFactory = context.getBean(BinderFactory.class);
Binder<?, ?, ?> binder = binderFactory.getBinder(null, MessageChannel.class);
assertThat(binder).isInstanceOf(RabbitMessageChannelBinder.class);
DirectFieldAccessor binderFieldAccessor = new DirectFieldAccessor(binder);
ConnectionFactory binderConnectionFactory = (ConnectionFactory) binderFieldAccessor
.getPropertyValue("connectionFactory");
assertThat(binderConnectionFactory).isSameAs(MOCK_CONNECTION_FACTORY);
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(binderConnectionFactory).isSameAs(connectionFactory);
CompositeHealthIndicator bindersHealthIndicator = context.getBean("bindersHealthIndicator",
CompositeHealthIndicator.class);
assertThat(bindersHealthIndicator).isNotNull();
DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(bindersHealthIndicator);
@SuppressWarnings("unchecked")
Map<String, HealthIndicator> healthIndicators = (Map<String, HealthIndicator>) directFieldAccessor
.getPropertyValue("indicators");
assertThat(healthIndicators).containsKey("rabbit");
// mock connection factory behaves as if down
assertThat(healthIndicators.get("rabbit").health().getStatus()).isEqualTo(Status.DOWN);
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:26,代码来源:RabbitBinderModuleTests.java
示例3: createBinderTestContext
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
public static ConfigurableApplicationContext createBinderTestContext(
String[] additionalClasspathDirectories, String... properties)
throws IOException {
URL[] urls = ObjectUtils.isEmpty(additionalClasspathDirectories) ? new URL[0]
: new URL[additionalClasspathDirectories.length];
if (!ObjectUtils.isEmpty(additionalClasspathDirectories)) {
for (int i = 0; i < additionalClasspathDirectories.length; i++) {
urls[i] = new URL(new ClassPathResource(additionalClasspathDirectories[i])
.getURL().toString() + "/");
}
}
ClassLoader classLoader = new URLClassLoader(urls,
BinderFactoryConfigurationTests.class.getClassLoader());
return new SpringApplicationBuilder(SimpleSource.class)
.resourceLoader(new DefaultResourceLoader(classLoader))
.properties(properties).web(WebApplicationType.NONE).run();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:18,代码来源:HealthIndicatorsConfigurationTests.java
示例4: bootstrapPropertiesAvailableInInitializer
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void bootstrapPropertiesAvailableInInitializer() {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.sources(BareConfiguration.class).initializers(
new ApplicationContextInitializer<ConfigurableApplicationContext>() {
@Override
public void initialize(
ConfigurableApplicationContext applicationContext) {
// This property is defined in bootstrap.properties
assertEquals("child", applicationContext.getEnvironment()
.getProperty("info.name"));
}
})
.run();
assertTrue(this.context.getEnvironment().getPropertySources().contains(
PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:18,代码来源:BootstrapConfigurationTests.java
示例5: applicationNameInBootstrapAndMain
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void applicationNameInBootstrapAndMain() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.cloud.bootstrap.name:other",
"spring.config.name:plain")
.sources(BareConfiguration.class).run();
assertEquals("app",
this.context.getEnvironment().getProperty("spring.application.name"));
// The parent is called "main" because spring.application.name is specified in
// other.properties (the bootstrap properties)
assertEquals("main", this.context.getParent().getEnvironment()
.getProperty("spring.application.name"));
// The bootstrap context has the same "bootstrap" property source
assertEquals(this.context.getEnvironment().getPropertySources().get("bootstrap"),
((ConfigurableEnvironment) this.context.getParent().getEnvironment())
.getPropertySources().get("bootstrap"));
assertEquals("main-1", this.context.getId());
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:20,代码来源:BootstrapConfigurationTests.java
示例6: applicationNameOnlyInBootstrap
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void applicationNameOnlyInBootstrap() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.cloud.bootstrap.name:other")
.sources(BareConfiguration.class).run();
// The main context is called "main" because spring.application.name is specified
// in other.properties (and not in the main config file)
assertEquals("main",
this.context.getEnvironment().getProperty("spring.application.name"));
// The parent is called "main" because spring.application.name is specified in
// other.properties (the bootstrap properties this time)
assertEquals("main", this.context.getParent().getEnvironment()
.getProperty("spring.application.name"));
assertEquals("main-1", this.context.getId());
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:17,代码来源:BootstrapConfigurationTests.java
示例7: bootstrapContextSharedBySiblings
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void bootstrapContextSharedBySiblings() {
TestHigherPriorityBootstrapConfiguration.count.set(0);
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
SpringApplicationBuilder builder = new SpringApplicationBuilder()
.sources(BareConfiguration.class);
this.sibling = builder.child(BareConfiguration.class)
.properties("spring.application.name=sibling")
.web(WebApplicationType.NONE).run();
this.context = builder.child(BareConfiguration.class)
.properties("spring.application.name=context")
.web(WebApplicationType.NONE).run();
assertEquals(1, TestHigherPriorityBootstrapConfiguration.count.get());
assertNotNull(context.getParent());
assertEquals("bootstrap", context.getParent().getParent().getId());
assertNull(context.getParent().getParent().getParent());
assertEquals("context", context.getEnvironment().getProperty("custom.foo"));
assertEquals("context",
context.getEnvironment().getProperty("spring.application.name"));
assertNotNull(sibling.getParent());
assertEquals("bootstrap", sibling.getParent().getParent().getId());
assertNull(sibling.getParent().getParent().getParent());
assertEquals("sibling", sibling.getEnvironment().getProperty("custom.foo"));
assertEquals("sibling",
sibling.getEnvironment().getProperty("spring.application.name"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:27,代码来源:BootstrapConfigurationTests.java
示例8: nonExistentKeystoreLocationShouldNotBeAllowed
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void nonExistentKeystoreLocationShouldNotBeAllowed() {
try {
new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)
.web(WebApplicationType.NONE)
.properties("encrypt.key-store.location:classpath:/server.jks1",
"encrypt.key-store.password:letmein",
"encrypt.key-store.alias:mytestkey",
"encrypt.key-store.secret:changeme")
.run();
assertThat(false).as(
"Should not create an application context with invalid keystore location")
.isTrue();
}
catch (Exception e) {
assertThat(e).hasRootCauseInstanceOf(IllegalStateException.class);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:19,代码来源:EncryptionBootstrapConfigurationTests.java
示例9: keysComputedWhenChangesInExternalProperties
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void keysComputedWhenChangesInExternalProperties() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
TestPropertyValues
.of("spring.cloud.bootstrap.sources="
+ ExternalPropertySourceLocator.class.getName())
.applyTo(this.context.getEnvironment(), Type.MAP, "defaultProperties");
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertTrue("Wrong keys: " + keys, keys.contains("external.message"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:17,代码来源:RefreshEndpointTests.java
示例10: springMainSourcesEmptyInRefreshCycle
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void springMainSourcesEmptyInRefreshCycle() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class)
.web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
// spring.main.sources should be empty when the refresh cycle starts (we don't
// want any config files from the application context getting into the one used to
// construct the environment for refresh)
TestPropertyValues
.of("spring.main.sources="
+ ExternalPropertySourceLocator.class.getName())
.applyTo(this.context);
ContextRefresher contextRefresher = new ContextRefresher(this.context, scope);
RefreshEndpoint endpoint = new RefreshEndpoint(contextRefresher);
Collection<String> keys = endpoint.refresh();
assertFalse("Wrong keys: " + keys, keys.contains("external.message"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:20,代码来源:RefreshEndpointTests.java
示例11: setUp
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Before
public void setUp() {
instance = new SpringApplicationBuilder().sources(AdminApplicationTest.TestAdminApplication.class)
.web(WebApplicationType.REACTIVE)
.run("--server.port=0", "--eureka.client.enabled=false");
localPort = instance.getEnvironment().getProperty("local.server.port", Integer.class, 0);
this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + localPort).build();
this.register_as_test = "{ \"name\": \"test\", \"healthUrl\": \"http://localhost:" +
localPort +
"/application/health\" }";
this.register_as_twice = "{ \"name\": \"twice\", \"healthUrl\": \"http://localhost:" +
localPort +
"/application/health\" }";
}
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:17,代码来源:InstancesControllerIntegrationTest.java
示例12: setUp
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
System.setProperty("hazelcast.wait.seconds.before.join", "0");
instance1 = new SpringApplicationBuilder().sources(TestAdminApplication.class)
.web(WebApplicationType.REACTIVE)
.run("--server.port=0", "--management.endpoints.web.base-path=/mgmt",
"--endpoints.health.enabled=true", "--info.test=foobar",
"--spring.jmx.enabled=false",
"--eureka.client.enabled=false");
instance2 = new SpringApplicationBuilder().sources(TestAdminApplication.class)
.web(WebApplicationType.REACTIVE)
.run("--server.port=0", "--management.endpoints.web.base-path=/mgmt",
"--endpoints.health.enabled=true", "--info.test=foobar",
"--spring.jmx.enabled=false",
"--eureka.client.enabled=false");
super.setUp(instance1.getEnvironment().getProperty("local.server.port", Integer.class, 0));
this.webClient2 = createWebClient(
instance2.getEnvironment().getProperty("local.server.port", Integer.class, 0));
}
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:22,代码来源:AdminApplicationHazelcastTest.java
示例13: findOne
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Override
public Environment findOne(String config, String profile, String label) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(
PropertyPlaceholderAutoConfiguration.class);
ConfigurableEnvironment environment = getEnvironment(profile);
builder.environment(environment);
builder.web(WebApplicationType.NONE).bannerMode(Mode.OFF);
if (!logger.isDebugEnabled()) {
// Make the mini-application startup less verbose
builder.logStartupInfo(false);
}
String[] args = getArgs(config, profile, label);
// Explicitly set the listeners (to exclude logging listener which would change
// log levels in the caller)
builder.application()
.setListeners(Arrays.asList(new ConfigFileApplicationListener()));
ConfigurableApplicationContext context = builder.run(args);
environment.getPropertySources().remove("profiles");
try {
return clean(new PassthruEnvironmentRepository(environment).findOne(config,
profile, label));
}
finally {
context.close();
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:27,代码来源:NativeEnvironmentRepository.java
示例14: mappingRepo
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void mappingRepo() throws IOException {
String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
Map<String, Object> repoMapping = new LinkedHashMap<String, Object>();
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern", "*test1*");
repoMapping.put("spring.cloud.config.server.git.repos[test1].uri", test1RepoUri);
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri)
.properties(repoMapping).run();
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("test1-svc", "staging", "master");
Environment environment = repository.findOne("test1-svc", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:19,代码来源:MultipleJGitEnvironmentRepositoryIntegrationTests.java
示例15: mappingRepoWithProfile
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void mappingRepoWithProfile() throws IOException {
String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
Map<String, Object> repoMapping = new LinkedHashMap<String, Object>();
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern",
"*/staging");
repoMapping.put("spring.cloud.config.server.git.repos[test1].uri", test1RepoUri);
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri)
.properties(repoMapping).run();
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("test1-svc", "staging", "master");
Environment environment = repository.findOne("test1-svc", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:20,代码来源:MultipleJGitEnvironmentRepositoryIntegrationTests.java
示例16: mappingRepoWithProfileDefaultPatterns
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void mappingRepoWithProfileDefaultPatterns() throws IOException {
String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
Map<String, Object> repoMapping = new LinkedHashMap<String, Object>();
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern",
"*/staging");
repoMapping.put("spring.cloud.config.server.git.repos[test1].uri", test1RepoUri);
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri)
.properties(repoMapping).run();
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("test1-svc", "staging", "master");
Environment environment = repository.findOne("test1-svc", "staging,cloud",
"master");
assertEquals(2, environment.getPropertySources().size());
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:21,代码来源:MultipleJGitEnvironmentRepositoryIntegrationTests.java
示例17: mappingRepoWithProfiles
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void mappingRepoWithProfiles() throws IOException {
String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
Map<String, Object> repoMapping = new LinkedHashMap<String, Object>();
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern[0]",
"*/staging,*");
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern[1]",
"*/*,staging");
repoMapping.put("spring.cloud.config.server.git.repos[test1].pattern[2]",
"*/staging");
repoMapping.put("spring.cloud.config.server.git.repos[test1].uri", test1RepoUri);
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri)
.properties(repoMapping).run();
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("test1-svc", "staging", "master");
Environment environment = repository.findOne("test1-svc", "cloud,staging",
"master");
assertEquals(2, environment.getPropertySources().size());
environment = repository.findOne("test1-svc", "staging,cloud", "master");
assertEquals(2, environment.getPropertySources().size());
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:27,代码来源:MultipleJGitEnvironmentRepositoryIntegrationTests.java
示例18: mappingRepoWithJustUri
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void mappingRepoWithJustUri() throws IOException {
String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo");
String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
Map<String, Object> repoMapping = new LinkedHashMap<String, Object>();
repoMapping.put("spring.cloud.config.server.git.repos.test1-svc.uri", test1RepoUri);
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.config.server.git.uri:" + defaultRepoUri)
.properties(repoMapping).run();
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("test1-svc", "staging", "master");
Environment environment = repository.findOne("test1-svc", "staging", "master");
assertEquals(2, environment.getPropertySources().size());
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:18,代码来源:MultipleJGitEnvironmentRepositoryIntegrationTests.java
示例19: update
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void update() throws Exception {
String uri = ConfigServerTestUtils.prepareLocalSvnRepo(
"src/test/resources/svn-config-repo", "target/config");
this.context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE).profiles("subversion")
.run("--spring.cloud.config.server.svn.uri=" + uri);
EnvironmentRepository repository = this.context
.getBean(EnvironmentRepository.class);
repository.findOne("bar", "staging", "trunk");
Environment environment = repository.findOne("bar", "staging", "trunk");
assertEquals("bar",
environment.getPropertySources().get(0).getSource().get("foo"));
updateRepoForUpdate(uri);
environment = repository.findOne("bar", "staging", "trunk");
assertEquals("foo",
environment.getPropertySources().get(0).getSource().get("foo"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:19,代码来源:SVNKitEnvironmentRepositoryIntegrationTests.java
示例20: pull
import org.springframework.boot.WebApplicationType; //导入依赖的package包/类
@Test
public void pull() throws Exception {
ConfigServerTestUtils.prepareLocalRepo();
String uri = ConfigServerTestUtils.copyLocalRepo("config-copy");
this.context = new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE)
.run("--spring.cloud.config.server.git.uri=" + uri);
EnvironmentRepository repository = this.context.getBean(EnvironmentRepository.class);
repository.findOne("bar", "staging", "master");
Environment environment = repository.findOne("bar", "staging", "master");
assertEquals("bar", environment.getPropertySources().get(0).getSource().get("foo"));
Git git = Git.open(ResourceUtils.getFile(uri).getAbsoluteFile());
git.checkout().setName("master").call();
StreamUtils.copy("foo: foo", Charset.defaultCharset(),
new FileOutputStream(ResourceUtils.getFile(uri + "/bar.properties")));
git.add().addFilepattern("bar.properties").call();
git.commit().setMessage("Updated for pull").call();
environment = repository.findOne("bar", "staging", "master");
assertEquals("foo", environment.getPropertySources().get(0).getSource().get("foo"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:20,代码来源:JGitEnvironmentRepositoryIntegrationTests.java
注:本文中的org.springframework.boot.WebApplicationType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论