[java-shib-shared] branch main updated: JSSH-82 - Implement an alternative to repeated tweaking of MockApplicationContext

Codeberg noreply at shibboleth.net
Fri Oct 23 15:46:07 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/c63e84f6236b025ca1685846afd7145eea564722

The following commit(s) were added to refs/heads/main by this push:
     new c63e84f6 JSSH-82 - Implement an alternative to repeated tweaking of MockApplicationContext
c63e84f6 is described below

commit c63e84f6236b025ca1685846afd7145eea564722
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Fri Oct 23 16:32:58 2026 +0100

    JSSH-82 - Implement an alternative to repeated tweaking of MockApplicationContext
    
    Have MockApplicationContext extend an abstract class that already
    exists in Spring. This means that many methods from the
    ConfigurableApplicationContext interface can be implemented there
    rather than in the Mock.
    
    Remove one of the recently added methods to demonstrate the
    concept.
    
    See https://shibboleth.atlassian.net/browse/JSSH-82
---
 .../shared/testing/MockApplicationContext.java       | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/shib-testing/src/main/java/net/shibboleth/shared/testing/MockApplicationContext.java b/shib-testing/src/main/java/net/shibboleth/shared/testing/MockApplicationContext.java
index 54a5a23d..47693450 100644
--- a/shib-testing/src/main/java/net/shibboleth/shared/testing/MockApplicationContext.java
+++ b/shib-testing/src/main/java/net/shibboleth/shared/testing/MockApplicationContext.java
@@ -35,6 +35,7 @@ import org.springframework.context.ApplicationListener;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.MessageSourceResolvable;
 import org.springframework.context.NoSuchMessageException;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.core.ResolvableType;
 import org.springframework.core.env.ConfigurableEnvironment;
@@ -45,7 +46,7 @@ import org.springframework.core.metrics.ApplicationStartup;
 /**
  * Placeholder, which can be set on test components to stop the "must be null" test firing.
  */
-public class MockApplicationContext implements ConfigurableApplicationContext {
+public class MockApplicationContext extends AbstractApplicationContext {
 
     /** {@inheritDoc} */
     public String getId() {
@@ -152,11 +153,6 @@ public class MockApplicationContext implements ConfigurableApplicationContext {
         throw new IllegalStateException();
     }
 
-    /** {@inheritDoc} */
-    public <T> T getBean(String name, ParameterizedTypeReference<T> typeReference) throws BeansException {
-        throw new IllegalStateException();
-    }
-
     /** {@inheritDoc} */
     public @Nonnull Object getBean(@Nonnull final String name, @Nonnull final Object... args) throws BeansException {
         throw new IllegalStateException();
@@ -409,5 +405,17 @@ public class MockApplicationContext implements ConfigurableApplicationContext {
             @Nonnull final Class<A> annotationType, final boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException {
         throw new IllegalStateException();
     }
+
+    /** {@inheritDoc} */
+    @Override
+    protected void refreshBeanFactory() throws BeansException, IllegalStateException {
+        throw new IllegalStateException();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected void closeBeanFactory() {
+        throw new IllegalStateException();
+    }
     
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list