[java-idp-plugin-duo] branch main updated: Add AnnotationParameterNameDiscoverer to support named constructor injection in tests
Phil Smart
philip.smart at jisc.ac.uk
Wed Mar 10 15:15:48 UTC 2021
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=6e3101334662d24b8c28b0393a7b426eaf6a7daf
The following commit(s) were added to refs/heads/main by this push:
new 6e31013 Add AnnotationParameterNameDiscoverer to support named constructor injection in tests
6e31013 is described below
commit 6e3101334662d24b8c28b0393a7b426eaf6a7daf
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Mar 10 15:15:46 2021 +0000
Add AnnotationParameterNameDiscoverer to support named constructor
injection in tests
---
.../impl/AbstractAuthnXmlFlowExecutionTests.java | 31 +++++++++++-----------
.../authn/spring/CustomFlowModelFlowBuilder.java | 3 +++
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
index 8f3bb25..9cde3b4 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
@@ -57,6 +57,7 @@ import org.springframework.webflow.test.execution.AbstractExternalizedFlowExecut
import com.google.common.net.HttpHeaders;
+import net.shibboleth.ext.spring.util.AnnotationParameterNameDiscoverer;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.authn.context.SubjectCanonicalizationContext;
@@ -85,19 +86,22 @@ import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
* <p>
* Extends the {@link CustomAbstractXmlFlowExecutionTests} over the standard
* {@link AbstractExternalizedFlowExecutionTests} for the sole reason of being able to set a
- * {@link CustomFlowModelFlowBuilder} with a placeholder prefix of <code>%{</code> to be compatible with those used by the
- * IdP. We also set this prefix in various other locations, but those are either ignored by the inbuilt SWF flow builder
- * when it substitutes the placeholder inside the bean import, or do not share the same Mock properties source as is set
- * in the {@link #registerMockPropertySource(MockFlowBuilderContext)} method. If a better way is found to support that,
- * switch back to the {@link AbstractExternalizedFlowExecutionTests}.
+ * {@link CustomFlowModelFlowBuilder} with a placeholder prefix of <code>%{</code> to be compatible with those used by
+ * the IdP. We also set this prefix in various other locations, but those are either ignored by the inbuilt SWF flow
+ * builder when it substitutes the placeholder inside the bean import, or do not share the same Mock properties source
+ * as is set in the {@link #registerMockPropertySource(MockFlowBuilderContext)} method. If a better way is found to
+ * support that, switch back to the {@link AbstractExternalizedFlowExecutionTests}.
* </p>
+ * <p>
+ * In addition, the {@link AnnotationParameterNameDiscoverer} class is also registered with the
+ * {@link DefaultListableBeanFactory} for the context created by the {@link CustomFlowModelFlowBuilder}.
*
* <p>
* Note, you can not use test context creation annotations e.g. @SpringJUnitWebConfig to help build the application
* context because the {@link AbstractExternalizedFlowExecutionTests} creates a new {@link StaticApplicationContext}
- * when building the flow (see buildFlow). This is different from the {@link ApplicationContext} created by {@link
- * ContextConfiguration} annotation processors. As a result, those bean configurations and environment variables need to
- * be injected inside {@link #configureFlowBuilderContext(MockFlowBuilderContext)}
+ * when building the flow (see buildFlow). This is different from the {@link ApplicationContext} created by
+ * {@link ContextConfiguration} annotation processors. As a result, those bean configurations and environment variables
+ * need to be injected inside {@link #configureFlowBuilderContext(MockFlowBuilderContext)}
* </p>
*
* <p>
@@ -107,13 +111,13 @@ import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractXmlFlowExecutionTests{
/** Mock request. */
- @Nonnull protected MockHttpServletRequest mockRequest;
+ protected MockHttpServletRequest mockRequest;
/** Mock response. */
- @Nonnull protected MockHttpServletResponse mockResponse;
+ protected MockHttpServletResponse mockResponse;
/** Mock external context. */
- @Nonnull protected MockExternalContext externalContext;
+ protected MockExternalContext externalContext;
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(AbstractAuthnXmlFlowExecutionTests.class);
@@ -280,11 +284,8 @@ public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractX
//create a real JSON parser
builderContext.registerBean("shibboleth.JSONObjectMapper", new com.fasterxml.jackson.databind.ObjectMapper());
-
-
-
//create converter for Durations
- ConversionServiceFactoryBean conversationService = new ConversionServiceFactoryBean();
+ final ConversionServiceFactoryBean conversationService = new ConversionServiceFactoryBean();
//unable to register the spring-ext converter even though it is the same!
final Converter<String,Duration> durationConverter = new Converter<String,Duration>(){
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
index 9590c69..0ef4efe 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
@@ -116,6 +116,7 @@ import org.springframework.webflow.scope.ViewScope;
import org.springframework.webflow.security.SecurityRule;
import net.shibboleth.ext.spring.resource.ConditionalResourceResolver;
+import net.shibboleth.ext.spring.util.AnnotationParameterNameDiscoverer;
/**
* Copy of {@link FlowModelFlowBuilder} for setting the property placeholder prefix of <code>%{</code>, and
@@ -368,6 +369,8 @@ public class CustomFlowModelFlowBuilder extends AbstractFlowBuilder {
flowContext.getBeanFactory().registerScope("view", new ViewScope());
flowContext.getBeanFactory().registerScope("flow", new FlowScope());
flowContext.getBeanFactory().registerScope("conversation", new ConversationScope());
+
+ flowContext.getDefaultListableBeanFactory().setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
// Ensure the current ClassLoader is used, or otherwise setting the ResourceLoader would suppress it
ClassLoader classLoaderToUse = flowContext.getClassLoader();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list