Search in sources :

Example 6 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class LdapServerBeanDefinitionParserTests method embeddedServerCreationContainsExpectedContextSourceAndData.

@Test
public void embeddedServerCreationContainsExpectedContextSourceAndData() {
    appCtx = new InMemoryXmlApplicationContext("<ldap-server ldif='classpath:test-server.ldif'/>");
    DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx.getBean(BeanIds.CONTEXT_SOURCE);
    // Check data is loaded
    LdapTemplate template = new LdapTemplate(contextSource);
    template.lookup("uid=ben,ou=people");
}
Also used : DefaultSpringSecurityContextSource(org.springframework.security.ldap.DefaultSpringSecurityContextSource) LdapTemplate(org.springframework.ldap.core.LdapTemplate) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Test(org.junit.Test)

Example 7 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class LdapServerBeanDefinitionParserTests method defaultLdifFileIsSuccessful.

@Test
public void defaultLdifFileIsSuccessful() {
    appCtx = new InMemoryXmlApplicationContext("<ldap-server/>");
    ApacheDSContainer dsContainer = appCtx.getBean(ApacheDSContainer.class);
    assertThat(ReflectionTestUtils.getField(dsContainer, "ldifResources")).isEqualTo("classpath*:*.ldif");
}
Also used : ApacheDSContainer(org.springframework.security.ldap.server.ApacheDSContainer) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Test(org.junit.Test)

Example 8 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class SessionManagementConfigServlet31Tests method loadContext.

private void loadContext(String context) {
    this.context = new InMemoryXmlApplicationContext(context);
    this.springSecurityFilterChain = this.context.getBean("springSecurityFilterChain", Filter.class);
}
Also used : Filter(javax.servlet.Filter) InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext)

Example 9 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class Jsr250AnnotationDrivenBeanDefinitionParserTests method loadContext.

@Before
public void loadContext() {
    appContext = new InMemoryXmlApplicationContext("<b:bean id='target' class='org.springframework.security.access.annotation.Jsr250BusinessServiceImpl'/>" + "<global-method-security jsr250-annotations='enabled'/>" + ConfigTestUtils.AUTH_PROVIDER_XML);
    target = (BusinessService) appContext.getBean("target");
}
Also used : InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Before(org.junit.Before)

Example 10 with InMemoryXmlApplicationContext

use of org.springframework.security.config.util.InMemoryXmlApplicationContext in project spring-security by spring-projects.

the class SecuredAnnotationDrivenBeanDefinitionParserTests method loadContext.

@Before
public void loadContext() {
    SecurityContextHolder.clearContext();
    appContext = new InMemoryXmlApplicationContext("<b:bean id='target' class='org.springframework.security.access.annotation.BusinessServiceImpl'/>" + "<global-method-security secured-annotations='enabled'/>" + ConfigTestUtils.AUTH_PROVIDER_XML);
    target = (BusinessService) appContext.getBean("target");
}
Also used : InMemoryXmlApplicationContext(org.springframework.security.config.util.InMemoryXmlApplicationContext) Before(org.junit.Before)

Aggregations

InMemoryXmlApplicationContext (org.springframework.security.config.util.InMemoryXmlApplicationContext)10 Test (org.junit.Test)6 LdapTemplate (org.springframework.ldap.core.LdapTemplate)3 DefaultSpringSecurityContextSource (org.springframework.security.ldap.DefaultSpringSecurityContextSource)3 Filter (javax.servlet.Filter)2 Before (org.junit.Before)2 ApacheDSContainer (org.springframework.security.ldap.server.ApacheDSContainer)1