|
| 1 | +/* |
| 2 | + * Copyright 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 |
| 13 | + * or implied. See the License for the specific language governing |
| 14 | + * permissions and limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.geode.boot.autoconfigure.locator; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.assertThat; |
| 19 | +import static org.mockito.Mockito.mock; |
| 20 | + |
| 21 | +import org.apache.geode.cache.GemFireCache; |
| 22 | +import org.apache.geode.cache.client.ClientCache; |
| 23 | +import org.apache.geode.distributed.Locator; |
| 24 | +import org.junit.Test; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.springframework.beans.factory.annotation.Autowired; |
| 27 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 28 | +import org.springframework.context.annotation.Bean; |
| 29 | +import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; |
| 30 | +import org.springframework.geode.boot.autoconfigure.ContinuousQueryAutoConfiguration; |
| 31 | +import org.springframework.test.context.ContextConfiguration; |
| 32 | +import org.springframework.test.context.junit4.SpringRunner; |
| 33 | + |
| 34 | +/** |
| 35 | + * Integration Tests asserting that a {@link ClientCache} is not auto-configured by SBDG if a {{@link Locator} bean |
| 36 | + * is present in the Spring container. |
| 37 | + * |
| 38 | + * @author John Blum |
| 39 | + * @see org.junit.Test |
| 40 | + * @see org.apache.geode.cache.GemFireCache |
| 41 | + * @see org.apache.geode.cache.client.ClientCache |
| 42 | + * @see org.apache.geode.distributed.Locator |
| 43 | + * @see org.springframework.boot.autoconfigure.SpringBootApplication |
| 44 | + * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects |
| 45 | + * @see org.springframework.test.context.ContextConfiguration |
| 46 | + * @see org.springframework.test.context.junit4.SpringRunner |
| 47 | + * @since 1.1.0 |
| 48 | + */ |
| 49 | +@RunWith(SpringRunner.class) |
| 50 | +@ContextConfiguration |
| 51 | +@SuppressWarnings("unused") |
| 52 | +public class SpringBootLocatorApplicationIntegrationTests { |
| 53 | + |
| 54 | + @Autowired(required = false) |
| 55 | + private GemFireCache clientCache; |
| 56 | + |
| 57 | + @Autowired |
| 58 | + private Locator mockLocator; |
| 59 | + |
| 60 | + @Test |
| 61 | + public void noCacheInstanceIsAutoConfiguredWhenLocatorBeanIsPresent() { |
| 62 | + |
| 63 | + assertThat(this.clientCache).isNull(); |
| 64 | + assertThat(this.mockLocator).isNotNull(); |
| 65 | + } |
| 66 | + |
| 67 | + @EnableGemFireMockObjects |
| 68 | + @SpringBootApplication(exclude = ContinuousQueryAutoConfiguration.class) |
| 69 | + static class TestConfiguration { |
| 70 | + |
| 71 | + @Bean |
| 72 | + Locator mockLocator() { |
| 73 | + return mock(Locator.class); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments