use of org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager in project cas by apereo.
the class EmailMessageBodyBuilderTests method verifyGroovyOperation.
@Test
public void verifyGroovyOperation() {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val cacheMgr = new GroovyScriptResourceCacheManager();
ApplicationContextProvider.registerBeanIntoApplicationContext(appCtx, cacheMgr, ScriptResourceCacheManager.BEAN_NAME);
ApplicationContextProvider.holdApplicationContext(appCtx);
val props = new EmailProperties().setText("classpath:/GroovyMessageBody.groovy");
val results = EmailMessageBodyBuilder.builder().properties(props).locale(Optional.of(Locale.CANADA)).parameters(CollectionUtils.wrap("key", "Hello")).build().addParameter("key2", "World");
val result = results.produce();
assertEquals("Hello, World", result);
}
use of org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager in project cas by apereo.
the class LdapUtilsTests method verifyScriptedFilter.
@Test
public void verifyScriptedFilter() {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
ApplicationContextProvider.holdApplicationContext(appCtx);
assertThrows(RuntimeException.class, () -> LdapUtils.newLdaptiveSearchFilter("classpath:LdapFilterQuery.groovy", List.of("p1", "p2"), List.of("v1", "v2")));
val cacheMgr = new GroovyScriptResourceCacheManager();
ApplicationContextProvider.registerBeanIntoApplicationContext(appCtx, cacheMgr, ScriptResourceCacheManager.BEAN_NAME);
var filter = LdapUtils.newLdaptiveSearchFilter("classpath:LdapFilterQuery.groovy", List.of("p1", "p2"), List.of("v1", "v2"));
assertNotNull(filter);
assertNotNull(filter.getFilter());
filter = LdapUtils.newLdaptiveSearchFilter("classpath:LdapFilterQuery.groovy", List.of("p1", "p2"), List.of("v1", "v2"));
assertNotNull(filter);
assertNotNull(filter.getFilter());
filter = LdapUtils.newLdaptiveSearchFilter("classpath:UnknownLdapFilterQuery.groovy", List.of("p1", "p2"), List.of("v1", "v2"));
assertNotNull(filter);
}
use of org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager in project cas by apereo.
the class ReturnMappedAttributeReleasePolicyTests method beforeEach.
@BeforeEach
public void beforeEach() {
ApplicationContextProvider.holdApplicationContext(applicationContext);
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, new GroovyScriptResourceCacheManager(), ScriptResourceCacheManager.BEAN_NAME);
ApplicationContextProvider.getScriptResourceCacheManager().ifPresent(ScriptResourceCacheManager::clear);
}
Aggregations