Merge branch '1.5.x'
commit
6e02fe59f7
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 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 org.springframework.boot.actuate.metrics.integration;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration;
|
||||||
|
import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
|
||||||
|
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link SpringIntegrationMetricReader}.
|
||||||
|
*
|
||||||
|
* @author Artem Bilan
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest("spring.jmx.enabled=false")
|
||||||
|
@DirtiesContext
|
||||||
|
public class SpringIntegrationMetricReaderNoJmxTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("springIntegrationPublicMetrics")
|
||||||
|
private MetricReaderPublicMetrics integrationMetricReader;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
assertThat(this.integrationMetricReader.metrics().size() > 0).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Import({ IntegrationAutoConfiguration.class, PublicMetricsAutoConfiguration.class })
|
||||||
|
protected static class TestConfiguration {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 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 org.springframework.boot.autoconfigure.integration;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||||
|
import org.springframework.core.type.AnnotationMetadata;
|
||||||
|
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||||
|
import org.springframework.integration.annotation.IntegrationComponentScan;
|
||||||
|
import org.springframework.integration.config.IntegrationComponentScanRegistrar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Variation of {@link IntegrationComponentScanRegistrar} the links
|
||||||
|
* {@link AutoConfigurationPackages}.
|
||||||
|
*
|
||||||
|
* @author Artem Bilan
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class IntegrationAutoConfigurationScanRegistrar extends IntegrationComponentScanRegistrar
|
||||||
|
implements BeanFactoryAware {
|
||||||
|
|
||||||
|
private BeanFactory beanFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||||
|
this.beanFactory = beanFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||||
|
final BeanDefinitionRegistry registry) {
|
||||||
|
super.registerBeanDefinitions(
|
||||||
|
new IntegrationComponentScanConfigurationMetaData(this.beanFactory),
|
||||||
|
registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class IntegrationComponentScanConfigurationMetaData
|
||||||
|
extends StandardAnnotationMetadata {
|
||||||
|
|
||||||
|
private final BeanFactory beanFactory;
|
||||||
|
|
||||||
|
IntegrationComponentScanConfigurationMetaData(BeanFactory beanFactory) {
|
||||||
|
super(IntegrationComponentScanConfiguration.class, true);
|
||||||
|
this.beanFactory = beanFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getAnnotationAttributes(String annotationName) {
|
||||||
|
Map<String, Object> attributes = super.getAnnotationAttributes(
|
||||||
|
annotationName);
|
||||||
|
if (IntegrationComponentScan.class.getName().equals(annotationName)
|
||||||
|
&& AutoConfigurationPackages.has(this.beanFactory)) {
|
||||||
|
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
|
||||||
|
attributes = new LinkedHashMap<String, Object>(attributes);
|
||||||
|
attributes.put("value", packages.toArray(new String[packages.size()]));
|
||||||
|
}
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@IntegrationComponentScan
|
||||||
|
private static class IntegrationComponentScanConfiguration {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 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.integration;
|
||||||
|
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SampleCommandLineRunner implements CommandLineRunner {
|
||||||
|
|
||||||
|
private final SampleMessageGateway gateway;
|
||||||
|
|
||||||
|
public SampleCommandLineRunner(SampleMessageGateway gateway) {
|
||||||
|
this.gateway = gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
for (String arg : args) {
|
||||||
|
this.gateway.echo(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 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.integration;
|
||||||
|
|
||||||
|
import org.springframework.integration.annotation.MessagingGateway;
|
||||||
|
|
||||||
|
@MessagingGateway(defaultRequestChannel = "outputChannel")
|
||||||
|
public interface SampleMessageGateway {
|
||||||
|
|
||||||
|
void echo(String message);
|
||||||
|
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
provides: spring-integration-core,spring-integration-java-dsl,spring-integration-jmx
|
provides: spring-integration-core,spring-integration-java-dsl
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 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 org.springframework.boot.test.context;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link SpringBootTest} configured with {@link WebEnvironment#RANDOM_PORT}.
|
||||||
|
*
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@DirtiesContext
|
||||||
|
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "value=123" })
|
||||||
|
public class SpringBootTestTestRestTemplateDefinedByUser
|
||||||
|
extends AbstractSpringBootTestEmbeddedWebEnvironmentTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void restTemplateIsUserDefined() throws Exception {
|
||||||
|
assertThat(getContext().getBean("testRestTemplate"))
|
||||||
|
.isInstanceOf(RestTemplate.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// gh-7711
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebMvc
|
||||||
|
@RestController
|
||||||
|
protected static class Config extends AbstractConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate testRestTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue