|
| 1 | +/* |
| 2 | + * Copyright 2002-2023 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.security.config.aot.hint; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.BeforeEach; |
| 20 | +import org.junit.jupiter.api.Test; |
| 21 | + |
| 22 | +import org.springframework.aot.hint.MemberCategory; |
| 23 | +import org.springframework.aot.hint.RuntimeHints; |
| 24 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
| 25 | +import org.springframework.aot.hint.TypeReference; |
| 26 | +import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
| 27 | +import org.springframework.core.io.support.SpringFactoriesLoader; |
| 28 | +import org.springframework.util.ClassUtils; |
| 29 | + |
| 30 | +import static org.assertj.core.api.Assertions.assertThat; |
| 31 | + |
| 32 | +/** |
| 33 | + * Tests for {@link WebSecurityConfigurationRuntimeHints} |
| 34 | + * |
| 35 | + * @author Marcus da Coregio |
| 36 | + */ |
| 37 | +class WebSecurityConfigurationRuntimeHintsTests { |
| 38 | + |
| 39 | + private final RuntimeHints hints = new RuntimeHints(); |
| 40 | + |
| 41 | + @BeforeEach |
| 42 | + void setup() { |
| 43 | + SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories") |
| 44 | + .load(RuntimeHintsRegistrar.class) |
| 45 | + .forEach((registrar) -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader())); |
| 46 | + } |
| 47 | + |
| 48 | + @Test |
| 49 | + void compositeFilterChainProxyHasHints() { |
| 50 | + assertThat(RuntimeHintsPredicates.reflection() |
| 51 | + .onType(TypeReference |
| 52 | + .of("org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$CompositeFilterChainProxy")) |
| 53 | + .withMemberCategory(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(this.hints); |
| 54 | + } |
| 55 | + |
| 56 | +} |
0 commit comments