commit
5938f7cdee
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,25 +18,25 @@ package org.springframework.security.test.aot.hint;
|
||||||
|
|
||||||
import org.springframework.aot.hint.MemberCategory;
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.security.web.FilterChainProxy;
|
import org.springframework.security.web.FilterChainProxy;
|
||||||
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
||||||
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
||||||
import org.springframework.security.web.csrf.CsrfFilter;
|
import org.springframework.security.web.csrf.CsrfFilter;
|
||||||
import org.springframework.test.context.aot.TestRuntimeHintsRegistrar;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link TestRuntimeHintsRegistrar} implementation that register runtime hints for
|
* {@link RuntimeHintsRegistrar} implementation that register runtime hints for
|
||||||
* {@link org.springframework.security.test.web.support.WebTestUtils}.
|
* {@link org.springframework.security.test.web.support.WebTestUtils}.
|
||||||
*
|
*
|
||||||
* @author Marcus da Coregio
|
* @author Marcus da Coregio
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
*/
|
*/
|
||||||
class WebTestUtilsTestRuntimeHints implements TestRuntimeHintsRegistrar {
|
class WebTestUtilsRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerHints(RuntimeHints hints, Class<?> testClass, ClassLoader classLoader) {
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
if (!ClassUtils.isPresent("jakarta.servlet.Filter", classLoader)) {
|
if (!ClassUtils.isPresent("jakarta.servlet.Filter", classLoader)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
org.springframework.test.context.aot.TestRuntimeHintsRegistrar=\
|
org.springframework.test.context.aot.TestRuntimeHintsRegistrar=\
|
||||||
org.springframework.security.test.aot.hint.WithSecurityContextTestRuntimeHints,\
|
org.springframework.security.test.aot.hint.WithSecurityContextTestRuntimeHints
|
||||||
org.springframework.security.test.aot.hint.WebTestUtilsTestRuntimeHints
|
|
||||||
|
org.springframework.aot.hint.RuntimeHintsRegistrar=\
|
||||||
|
org.springframework.security.test.aot.hint.WebTestUtilsRuntimeHints
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.aot.hint.MemberCategory;
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
|
@ -28,26 +29,24 @@ import org.springframework.security.web.FilterChainProxy;
|
||||||
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
import org.springframework.security.web.context.SecurityContextHolderFilter;
|
||||||
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
|
||||||
import org.springframework.security.web.csrf.CsrfFilter;
|
import org.springframework.security.web.csrf.CsrfFilter;
|
||||||
import org.springframework.test.context.aot.TestRuntimeHintsRegistrar;
|
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link WebTestUtilsTestRuntimeHints}.
|
* Tests for {@link WebTestUtilsRuntimeHints}.
|
||||||
*
|
*
|
||||||
* @author Marcus da Coregio
|
* @author Marcus da Coregio
|
||||||
*/
|
*/
|
||||||
class WebTestUtilsTestRuntimeHintsTests {
|
class WebTestUtilsRuntimeHintsTests {
|
||||||
|
|
||||||
private final RuntimeHints hints = new RuntimeHints();
|
private final RuntimeHints hints = new RuntimeHints();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup() {
|
||||||
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
|
||||||
.load(TestRuntimeHintsRegistrar.class)
|
.load(RuntimeHintsRegistrar.class)
|
||||||
.forEach((registrar) -> registrar.registerHints(this.hints, WebTestUtilsTestRuntimeHintsTests.class,
|
.forEach((registrar) -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
|
||||||
ClassUtils.getDefaultClassLoader()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
Loading…
Reference in New Issue