|
| 1 | +/* |
| 2 | + * Copyright 2012-2019 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.test.autoconfigure.webservices.client; |
| 18 | + |
| 19 | +import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| 20 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| 21 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| 22 | +import org.springframework.boot.autoconfigure.webservices.client.WebServiceTemplateAutoConfiguration; |
| 23 | +import org.springframework.boot.test.webservices.client.DefaultMockWebServiceServers; |
| 24 | +import org.springframework.boot.test.webservices.client.MockWebServiceServerRegistry; |
| 25 | +import org.springframework.boot.test.webservices.client.MockWebServiceServers; |
| 26 | +import org.springframework.boot.webservices.client.WebServiceTemplateCustomizer; |
| 27 | +import org.springframework.context.annotation.Bean; |
| 28 | +import org.springframework.context.annotation.Configuration; |
| 29 | +import org.springframework.ws.client.core.WebServiceTemplate; |
| 30 | +import org.springframework.ws.test.client.MockWebServiceServer; |
| 31 | + |
| 32 | +/** |
| 33 | + * Auto-configuration for {@link MockWebServiceServers} support. |
| 34 | + * |
| 35 | + * @author Dmytro Nosan |
| 36 | + * @see AutoConfigureMockWebServiceServer |
| 37 | + * @since 2.2.0 |
| 38 | + */ |
| 39 | +@Configuration(proxyBeanMethods = false) |
| 40 | +@ConditionalOnProperty(prefix = "spring.test.webservice.client.mock-server", name = "enabled") |
| 41 | +@AutoConfigureBefore(WebServiceTemplateAutoConfiguration.class) |
| 42 | +@ConditionalOnClass({ MockWebServiceServer.class, WebServiceTemplate.class }) |
| 43 | +public class MockWebServiceServersAutoConfiguration { |
| 44 | + |
| 45 | + @Bean |
| 46 | + public WebServiceTemplateCustomizer mockWebServiceServersWebServiceTemplateCustomizer( |
| 47 | + MockWebServiceServerRegistry registry) { |
| 48 | + return registry::bindTo; |
| 49 | + } |
| 50 | + |
| 51 | + @Bean |
| 52 | + public DefaultMockWebServiceServers mockWebServiceServers() { |
| 53 | + return new DefaultMockWebServiceServers(); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments