john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

junit spring dependency injection list

package net.kittyandbear;

import static org.junit.Assert.assertEquals;
import java.util.List;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.oxygen.authgateway.AuthGatewayService;
import com.oxygen.commontest.TestLoggingUtil;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( locations = { "/test.spring.xml" } )


public class LDAPAuthGatewayServiceImplTest
{
    private final int AUTHGATEWAYSERVICECOUNT = 3;
    private List<AuthGatewayService> authGatewayServices ;

    @Autowired
    public void setAuthGatewayServices(List<AuthGatewayService> authGatewayServices)
    {
        this.authGatewayServices = authGatewayServices;
    }

    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
        TestLoggingUtil.configureLogging(LDAPAuthGatewayServiceTest.class, LDAPAuthenticationAgent.class);
    }

    @Before
    public void setUp() throws Exception
    {
    }

    @Test
    public void testIsActive()
    {
        assertEquals( AUTHGATEWAYSERVICECOUNT , authGatewayServices.size() );
    }

} // end class





<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <!--
        ========================= RESOURCE DEFINITIONS
        =========================
    -->

    <!--
        Configurer that replaces ${...} placeholders with values from a
        properties file
    -->
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>test.app.properties</value>
            </list>
        </property>
    </bean>

    <bean id="authgatewayServlet" class="net.kittyandbear.AuthGatewayServlet" init-method="init">
        <property name="authGatewayServices">
            <list>
                <ref bean="ldapAuthGatewayService" />
            </list>
        </property>
        <property name="loginExpirationInMinutes" value="${authgateway.loginExpirationInMinutes}" />
    </bean>

    <!--
        ========================= BUSINESS OBJECT DEFINITIONS =========================
    -->

    <bean id="ldapAuthGatewayService" class="net.kittyandbear.LDAPAuthGatewayServiceImpl">
        <property name="activeAuthAgents">
            <list>
                <ref bean="ldapAuthAgent1" />
            </list>
        </property>
    </bean>


</beans>




test.app.properties

    authgateway.loginExpirationInMinutes=60
    authgateway.service1.active=true
    authgateway.service1.ldapServerHost=10.10.10.235
    authgateway.service1.ldapServerPort=389
    authgateway.service1.ldapSSL=false

  • « LdapSearch.pom.xml
  • Report CloudStorageGateway »

Published

Oct 12, 2012

Category

java

~148 words

Tags

  • dependency 3
  • injection 2
  • java 252
  • junit 8
  • list 23
  • spring 3