1 4 package com.tctest.spring; 5 6 import org.springframework.context.support.ClassPathXmlApplicationContext; 7 8 import com.tc.object.config.ConfigVisitor; 9 import com.tc.object.config.DSOClientConfigHelper; 10 import com.tc.object.config.DSOSpringConfigHelper; 11 import com.tc.object.config.StandardDSOSpringConfigHelper; 12 import com.tc.simulator.app.ApplicationConfig; 13 import com.tc.simulator.listener.ListenerProvider; 14 import com.tctest.TransparentTestBase; 15 import com.tctest.runner.AbstractTransparentApp; 16 import com.tctest.spring.bean.ActiveBean; 17 18 import java.util.List ; 19 20 23 public class ActiveBean_Test extends TransparentTestBase { 24 private static final int LOOP_ITERATIONS = 1; 25 private static final int EXECUTION_COUNT = 1; 26 private static final int NODE_COUNT = 2; 27 28 public ActiveBean_Test() { 29 disableAllUntil("2008-01-01"); 30 } 31 32 protected void setUp() throws Exception { 33 super.setUp(); 34 getTransparentAppConfig().setClientCount(NODE_COUNT).setApplicationInstancePerClientCount(EXECUTION_COUNT) 35 .setIntensity(LOOP_ITERATIONS); 36 initializeTestRunner(); 37 } 38 39 protected Class getApplicationClass() { 40 return ActiveBeanApp.class; 41 } 42 43 44 public static class ActiveBeanApp extends AbstractTransparentApp { 45 46 public ActiveBeanApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 47 super(appId, cfg, listenerProvider); 48 } 49 50 public void run() { 51 testActiveBean(); 52 } 53 54 private void testActiveBean() { 55 try { 56 moveToStageAndWait(10); 57 58 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("com/tctest/spring/beanfactory-active.xml"); 59 60 ActiveBean activeBean = (ActiveBean) ctx.getBean("activeBean"); 61 62 moveToStageAndWait(11); 63 64 Thread.sleep(500L); 66 List instances = activeBean.getInstances(); 67 assertEquals("Expecting single bean instance "+instances, 1, instances.size()); 68 69 moveToStageAndWait(12); 70 71 ctx.close(); 72 73 moveToStageAndWait(13); 74 75 instances = activeBean.getInstances(); 76 77 assertTrue("Active bean is not stopped", activeBean.isStopped()); 78 79 moveToStageAndWait(14); 80 81 assertEquals("Expecting no instances "+instances, 0, instances.size()); 82 83 } catch (Throwable e) { 84 moveToStage(10); 85 moveToStage(11); 86 moveToStage(12); 87 moveToStage(13); 88 moveToStage(14); 89 notifyError(e); 90 91 } finally { 92 } 94 } 95 96 97 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 98 DSOSpringConfigHelper springConfig = new StandardDSOSpringConfigHelper(); 99 springConfig.addApplicationNamePattern(SpringTestConstants.APPLICATION_NAME); springConfig.addConfigPattern("*/beanfactory-active.xml"); 101 springConfig.addBean("activeBean"); 102 103 config.addDSOSpringConfig(springConfig); 104 } 105 106 } 107 108 } 109 110 | Popular Tags |