Search in sources :

Example 1 with GroovyScriptResourceCacheManager

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);
}
Also used : lombok.val(lombok.val) EmailProperties(org.apereo.cas.configuration.model.support.email.EmailProperties) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) GroovyScriptResourceCacheManager(org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager) Test(org.junit.jupiter.api.Test)

Example 2 with GroovyScriptResourceCacheManager

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);
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) GroovyScriptResourceCacheManager(org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager) Test(org.junit.jupiter.api.Test)

Example 3 with GroovyScriptResourceCacheManager

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);
}
Also used : ScriptResourceCacheManager(org.apereo.cas.util.scripting.ScriptResourceCacheManager) GroovyScriptResourceCacheManager(org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager) GroovyScriptResourceCacheManager(org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

GroovyScriptResourceCacheManager (org.apereo.cas.util.scripting.GroovyScriptResourceCacheManager)3 lombok.val (lombok.val)2 Test (org.junit.jupiter.api.Test)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 EmailProperties (org.apereo.cas.configuration.model.support.email.EmailProperties)1 ScriptResourceCacheManager (org.apereo.cas.util.scripting.ScriptResourceCacheManager)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1