Examples of StaticApplicationContext


Examples of org.springframework.context.support.StaticApplicationContext

public class MockStrategiesHelperTest {

    @Test
    public void none() {
        StaticApplicationContext applicationContext = new StaticApplicationContext();

        MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
        assertNull(helper.getStrategy(IMyBean.class));
    }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        assertNull(helper.getStrategy(IMyBean.class));
    }

    @Test
    public void one() {
        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("myBean", MyBean.class);

        MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
        assertNotNull(helper.getStrategy(IMyBean.class));
    }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        assertNotNull(helper.getStrategy(IMyBean.class));
    }

    @Test(expected = BeanInitializationException.class)
    public void many() {
        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("myBean1", MyBean.class);
        applicationContext.registerSingleton("myBean2", MyBean.class);

        MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
        helper.getStrategy(IMyBean.class);
    }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        helper.getStrategy(IMyBean.class);
    }
   
    @Test
    public void noneWithDefault() {
        StaticApplicationContext applicationContext = new StaticApplicationContext();


        MockStrategiesHelper helper = new MockStrategiesHelper(applicationContext);
        assertNotNull(helper.getStrategy(IMyBean.class, MyBean.class));
    }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        jettyContext.addServlet(new ServletHolder(new EchoServlet()), "/");
        jettyServer.start();
        WebServiceConnection connection = null;
        try {

            StaticApplicationContext appContext = new StaticApplicationContext();
            appContext.registerSingleton("messageSender", HttpComponentsMessageSender.class);
            appContext.refresh();

            HttpComponentsMessageSender messageSender = appContext
                    .getBean("messageSender", HttpComponentsMessageSender.class);
            connection = messageSender.createConnection(new URI("http://localhost:" + port));

            connection.send(new SaajSoapMessage(messageFactory.createMessage()));
            connection.receive(new SaajSoapMessageFactory(messageFactory));

            appContext.close();
        }
        finally {
            if (connection != null) {
                try {
                    connection.close();
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        jettyContext.addServlet(new ServletHolder(new EchoServlet()), "/");
        jettyServer.start();
        WebServiceConnection connection = null;
        try {

            StaticApplicationContext appContext = new StaticApplicationContext();
            appContext.registerSingleton("messageSender", CommonsHttpMessageSender.class);
            appContext.refresh();

            CommonsHttpMessageSender messageSender = appContext
                    .getBean("messageSender", CommonsHttpMessageSender.class);
            connection = messageSender.createConnection(new URI("http://localhost:" + port));

            appContext.close();

            connection.send(new SaajSoapMessage(messageFactory.createMessage()));
            connection.receive(new SaajSoapMessageFactory(messageFactory));
        }
        finally {
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        Properties strategies = new Properties();
        strategies.put(Strategy.class.getName(),
                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        List<Strategy> result = helper.getDefaultStrategies(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertEquals("Invalid amount of strategies", 2, result.size());
        Assert.assertTrue("Result not a Strategy implementation", result.get(0) != null);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

    public void testGetDefaultStrategy() throws Exception {
        Properties strategies = new Properties();
        strategies.put(Strategy.class.getName(), StrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        Object result = helper.getDefaultStrategy(Strategy.class, applicationContext);
        Assert.assertNotNull("No result", result);
        Assert.assertTrue("Result not a Strategy implementation", result instanceof Strategy);
        Assert.assertTrue("Result not a StrategyImpl implementation", result instanceof StrategyImpl);
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

        Properties strategies = new Properties();
        strategies.put(Strategy.class.getName(),
                StrategyImpl.class.getName() + "," + ContextAwareStrategyImpl.class.getName());
        DefaultStrategiesHelper helper = new DefaultStrategiesHelper(strategies);

        StaticApplicationContext applicationContext = new StaticApplicationContext();
        applicationContext.registerSingleton("strategy1", StrategyImpl.class);
        applicationContext.registerSingleton("strategy2", ContextAwareStrategyImpl.class);

        try {
            helper.getDefaultStrategy(Strategy.class, applicationContext);
            Assert.fail("Expected BeanInitializationException");
        }
View Full Code Here

Examples of org.springframework.context.support.StaticApplicationContext

*/
public class SpringBeanFactoryTest {

  @Test
  public void newInstance() throws Exception {
    StaticApplicationContext oContext = new StaticApplicationContext();
    String oClassName = MyAction.class.getName();
    oContext.registerSingleton(oClassName, MyAction.class);
   
    SpringBeanFactory oFactory = new SpringBeanFactory();
    oFactory.setApplicationContext(oContext);
    Object oActual = oFactory.newInstance(MyAction.class, oClassName);
    assertNotNull(oActual);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.