1 18 19 package org.apache.activemq; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 import org.springframework.context.support.AbstractApplicationContext; 24 25 import java.util.Arrays ; 26 import java.util.HashSet ; 27 import java.util.Set ; 28 29 import junit.framework.TestCase; 30 31 36 public abstract class SpringTestSupport extends TestCase { 37 38 protected final Log log = LogFactory.getLog(getClass()); 39 40 protected AbstractApplicationContext context; 41 42 protected void setUp() throws Exception { 43 context = createApplicationContext(); 44 } 45 46 protected abstract AbstractApplicationContext createApplicationContext();; 47 48 protected void tearDown() throws Exception { 49 if (context != null) { 50 context.destroy(); 51 } 52 } 53 54 protected Object getBean(String name) { 55 Object bean = context.getBean(name); 56 if (bean == null) { 57 fail("Should have found bean named '" + name + "' in the Spring ApplicationContext"); 58 } 59 return bean; 60 } 61 62 protected void assertSetEquals(String description, Object [] expected, Set actual) { 63 Set expectedSet = new HashSet (); 64 expectedSet.addAll(Arrays.asList(expected)); 65 assertEquals(description, expectedSet, actual); 66 } 67 68 } 69 | Popular Tags |