Example usage for org.springframework.context.support ClassPathXmlApplicationContext getBeanDefinitionCount

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBeanDefinitionCount

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext getBeanDefinitionCount.

Prototype

@Override
    public int getBeanDefinitionCount() 

Source Link

Usage

From source file:org.passay.SpringTest.java

/**
 * Attempts to load all Spring application context XML files to verify proper wiring.
 *
 * @throws  Exception  On test failure.//w  w w . j  a v a  2s.  c o m
 */
@Test(groups = { "passtest" })
public void testSpringWiring() throws Exception {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "/spring-context.xml", });
    AssertJUnit.assertTrue(context.getBeanDefinitionCount() > 0);

    final PasswordValidator validator = new PasswordValidator(
            new ArrayList<>(context.getBeansOfType(Rule.class).values()));
    final PasswordData pd = new PasswordData("springtest");
    pd.setUsername("springuser");

    final RuleResult result = validator.validate(pd);
    AssertJUnit.assertNotNull(result);
}

From source file:edu.vt.middleware.password.SpringTest.java

/**
 * Attempts to load all Spring application context XML files to verify proper
 * wiring./*w  w  w .j av  a 2  s. c o  m*/
 *
 * @throws  Exception  On test failure.
 */
@Test(groups = { "passtest" })
public void testSpringWiring() throws Exception {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "/spring-context.xml", });
    AssertJUnit.assertTrue(context.getBeanDefinitionCount() > 0);

    final PasswordValidator validator = new PasswordValidator(
            new ArrayList<Rule>(context.getBeansOfType(Rule.class).values()));
    final PasswordData pd = new PasswordData(new Password("springtest"));
    pd.setUsername("springuser");

    final RuleResult result = validator.validate(pd);
    AssertJUnit.assertNotNull(result);
}

From source file:edu.vt.middleware.ldap.SpringTest.java

/**
 * Attempts to load all Spring application context XML files to
 * verify proper wiring.//from www  .j  av a  2  s . com
 *
 * @throws  Exception  On test failure.
 */
@Test(groups = { "spring" })
public void testSpringWiring() throws Exception {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "/spring-context.xml", });
    AssertJUnit.assertTrue(context.getBeanDefinitionCount() > 0);
    final ConnectionFactory cf = (ConnectionFactory) context.getBean("connectionFactory");
    final Connection conn = cf.getConnection();
    try {
        conn.open();
    } finally {
        conn.close();
    }

    final ClassPathXmlApplicationContext poolContext = new ClassPathXmlApplicationContext(
            new String[] { "/spring-pool-context.xml", });
    AssertJUnit.assertTrue(poolContext.getBeanDefinitionCount() > 0);
    BlockingConnectionPool pool = null;
    try {
        pool = (BlockingConnectionPool) poolContext.getBean("pool");
    } finally {
        pool.close();
    }
}

From source file:org.ldaptive.SpringTest.java

/**
 * Attempts to load all Spring application context XML files to
 * verify proper wiring.//from   ww  w . ja v a 2 s  .  c om
 *
 * @throws  Exception  On test failure.
 */
@Test(groups = { "spring" })
public void testSpringWiring() throws Exception {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "/spring-context.xml", });
    AssertJUnit.assertTrue(context.getBeanDefinitionCount() > 0);
    ConnectionFactory cf = context.getBean("connectionFactory", ConnectionFactory.class);
    Connection conn = cf.getConnection();
    try {
        conn.open();
    } finally {
        conn.close();
    }

    final ClassPathXmlApplicationContext factoryContext = new ClassPathXmlApplicationContext(
            new String[] { "/spring-factory-context.xml", });
    AssertJUnit.assertTrue(factoryContext.getBeanDefinitionCount() > 0);
    cf = factoryContext.getBean("connectionFactory", ConnectionFactory.class);
    conn = cf.getConnection();
    try {
        conn.open();
    } finally {
        conn.close();
    }

    final ClassPathXmlApplicationContext poolContext = new ClassPathXmlApplicationContext(
            new String[] { "/spring-pool-context.xml", });
    AssertJUnit.assertTrue(poolContext.getBeanDefinitionCount() > 0);
    BlockingConnectionPool pool = null;
    try {
        pool = poolContext.getBean("pool", BlockingConnectionPool.class);
    } finally {
        pool.close();
    }
}

From source file:org.jasig.cas.adaptors.x509.authentication.handler.support.WiringTests.java

@Test
public void testWiring() {
    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "deployerConfigContext.xml");
    Assert.assertTrue(context.getBeanDefinitionCount() > 0);
    IOUtils.closeQuietly(context);//  ww  w.  j  a v a  2s .  c o m
}