[java-identity-provider] branch main updated: IDP-1967 Some IdP tests run with destroyed beans (because of Context lifetimes)
Rod Widdowson
rdw at steadingsoftware.com
Wed Jun 29 09:00:03 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=f7624cc06de5e192203e751845307a92520c5670
The following commit(s) were added to refs/heads/main by this push:
new f7624cc06 IDP-1967 Some IdP tests run with destroyed beans (because of Context lifetimes)
f7624cc06 is described below
commit f7624cc06de5e192203e751845307a92520c5670
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Jun 29 09:58:17 2022 +0100
IDP-1967 Some IdP tests run with destroyed beans (because of Context lifetimes)
https://shibboleth.atlassian.net/browse/IDP-1967
Defer context teardown.
---
.../impl/FilterByQueriedAttributesTest.java | 48 +++++++++++++---------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributesTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributesTest.java
index 372f3df3b..29abf5efb 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributesTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributesTest.java
@@ -19,6 +19,7 @@ package net.shibboleth.idp.saml.saml2.profile.impl;
import static org.testng.Assert.assertEquals;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -31,6 +32,7 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -55,39 +57,47 @@ import net.shibboleth.utilities.java.support.xml.XMLParserException;
public class FilterByQueriedAttributesTest extends XMLObjectBaseTestCase {
static final String PATH = "/net/shibboleth/idp/saml/impl/profile/";
-
+
private AttributeQuery query;
-
+
private ReloadableService<AttributeTranscoderRegistry> registry;
-
+
private FilterByQueriedAttributes action;
-
+
private RequestContext rc;
-
+
private ProfileRequestContext prc;
+ private List<GenericApplicationContext> contexts = new ArrayList<>();
+
protected <Type> Type getBean(String fileName, Class<Type> claz) {
- try (final GenericApplicationContext context = new GenericApplicationContext()) {
- SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
- new SchemaTypeAwareXMLBeanDefinitionReader(context);
-
- beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
- beanDefinitionReader.loadBeanDefinitions(fileName);
-
- context.refresh();
-
- Collection<Type> beans = context.getBeansOfType(claz).values();
- Assert.assertEquals(beans.size(), 1);
-
- return beans.iterator().next();
- }
+ final GenericApplicationContext context = new GenericApplicationContext();
+ contexts.add(context);
+ SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
+ new SchemaTypeAwareXMLBeanDefinitionReader(context);
+
+ beanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
+ beanDefinitionReader.loadBeanDefinitions(fileName);
+
+ context.refresh();
+
+ Collection<Type> beans = context.getBeansOfType(claz).values();
+ Assert.assertEquals(beans.size(), 1);
+
+ return beans.iterator().next();
}
@BeforeClass public void setup() {
registry = new MockReloadableService<>(getBean(PATH + "saml2Mapper.xml", AttributeTranscoderRegistryImpl.class));
}
+ @AfterClass public void teardown() {
+ for (final GenericApplicationContext ctx : contexts) {
+ ctx.close();
+ }
+ }
+
@BeforeMethod public void setUpMethod() throws ComponentInitializationException, XMLParserException, UnmarshallingException {
query = unmarshallElement(PATH + "AttributeQuery.xml", true);
action = new FilterByQueriedAttributes();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list