diff --git a/org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-2.5.xsd b/org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-2.5.xsd index 03b9a5e3ed..728c7520e1 100644 --- a/org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-2.5.xsd +++ b/org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-2.5.xsd @@ -372,13 +372,13 @@ - - - + + - - + ]]> + + - - - + + - - + ]]> + + containers = context.getBeansOfType(DefaultMessageListenerContainer.class); + ConnectionFactory defaultConnectionFactory = context.getBean(DEFAULT_CONNECTION_FACTORY, ConnectionFactory.class); + ConnectionFactory explicitConnectionFactory = context.getBean(EXPLICIT_CONNECTION_FACTORY, ConnectionFactory.class); int defaultConnectionFactoryCount = 0; int explicitConnectionFactoryCount = 0; - Iterator iter = containers.values().iterator(); - while (iter.hasNext()) { - DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) iter.next(); + for (DefaultMessageListenerContainer container : containers.values()) { if (container.getConnectionFactory().equals(defaultConnectionFactory)) { defaultConnectionFactoryCount++; } @@ -99,9 +95,9 @@ public class JmsNamespaceHandlerTests extends TestCase { } public void testListeners() throws Exception { - TestBean testBean1 = (TestBean) context.getBean("testBean1"); - TestBean testBean2 = (TestBean) context.getBean("testBean2"); - TestMessageListener testBean3 = (TestMessageListener) context.getBean("testBean3"); + TestBean testBean1 = context.getBean("testBean1", TestBean.class); + TestBean testBean2 = context.getBean("testBean2", TestBean.class); + TestMessageListener testBean3 = context.getBean("testBean3", TestMessageListener.class); assertNull(testBean1.getName()); assertNull(testBean2.getName()); @@ -138,7 +134,7 @@ public class JmsNamespaceHandlerTests extends TestCase { } private MessageListener getListener(String containerBeanName) { - DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) this.context.getBean(containerBeanName); + DefaultMessageListenerContainer container = this.context.getBean(containerBeanName, DefaultMessageListenerContainer.class); return (MessageListener) container.getMessageListener(); } @@ -156,19 +152,15 @@ public class JmsNamespaceHandlerTests extends TestCase { Iterator iterator = context.getRegisteredComponents(); while (iterator.hasNext()) { ComponentDefinition compDef = (ComponentDefinition) iterator.next(); - if (compDef instanceof CompositeComponentDefinition) { - assertNotNull("CompositeComponentDefinition '" + compDef.getName()+ "' has no source attachment", ((CompositeComponentDefinition) compDef).getSource()); - } + assertNotNull("CompositeComponentDefinition '" + compDef.getName()+ "' has no source attachment", compDef.getSource()); validateComponentDefinition(compDef); } } private void validateComponentDefinition(ComponentDefinition compDef) { BeanDefinition[] beanDefs = compDef.getBeanDefinitions(); - for (int i = 0; i < beanDefs.length; i++) { - if (beanDefs[i] instanceof AbstractBeanDefinition) { - assertNotNull("AbstractBeanDefinition has no source attachment", ((AbstractBeanDefinition) beanDefs[i]).getSource()); - } + for (BeanDefinition beanDef : beanDefs) { + assertNotNull("BeanDefinition has no source attachment", beanDef.getSource()); } } @@ -189,28 +181,24 @@ public class JmsNamespaceHandlerTests extends TestCase { */ private static class ToolingTestApplicationContext extends ClassPathXmlApplicationContext { - private static final Set REGISTERED_COMPONENTS = new HashSet(); - - public ToolingTestApplicationContext(String path, Class clazz) - throws BeansException { + private Set registeredComponents; + + public ToolingTestApplicationContext(String path, Class clazz) { super(path, clazz); } - protected void initBeanDefinitionReader( - XmlBeanDefinitionReader beanDefinitionReader) { - beanDefinitionReader.setEventListener(new StoringReaderEventListener(REGISTERED_COMPONENTS)); + protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { + this.registeredComponents = new HashSet(); + beanDefinitionReader.setEventListener(new StoringReaderEventListener(this.registeredComponents)); beanDefinitionReader.setSourceExtractor(new PassThroughSourceExtractor()); } public boolean containsComponentDefinition(String name) { - Iterator iterator = REGISTERED_COMPONENTS.iterator(); - while (iterator.hasNext()) { - ComponentDefinition cd = (ComponentDefinition) iterator.next(); + for (ComponentDefinition cd : this.registeredComponents) { if (cd instanceof CompositeComponentDefinition) { - ComponentDefinition[] innerCds = ((CompositeComponentDefinition) cd) - .getNestedComponents(); - for (int i = 0; i < innerCds.length; i++) { - if (innerCds[i].getName().equals(name)) { + ComponentDefinition[] innerCds = ((CompositeComponentDefinition) cd).getNestedComponents(); + for (ComponentDefinition innerCd : innerCds) { + if (innerCd.getName().equals(name)) { return true; } } @@ -224,19 +212,18 @@ public class JmsNamespaceHandlerTests extends TestCase { return false; } - public Iterator getRegisteredComponents() { - return REGISTERED_COMPONENTS.iterator(); + public Iterator getRegisteredComponents() { + return this.registeredComponents.iterator(); } } private static class StoringReaderEventListener extends EmptyReaderEventListener { - protected Set registeredComponents = null; + protected final Set registeredComponents; - public StoringReaderEventListener(Set registeredComponents) { + public StoringReaderEventListener(Set registeredComponents) { this.registeredComponents = registeredComponents; - this.registeredComponents.clear(); } public void componentRegistered(ComponentDefinition componentDefinition) { diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTest.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTests.java similarity index 97% rename from org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTest.java rename to org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTests.java index ce946354c2..ab55ae7a6b 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTest.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/RequestMappingInfoComparatorTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; @@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestMethod; /** * @author Arjen Poutsma */ -public class RequestMappingInfoComparatorTest { +public class RequestMappingInfoComparatorTests { private AnnotationMethodHandlerAdapter.RequestMappingInfoComparator comparator; @@ -44,6 +44,7 @@ public class RequestMappingInfoComparatorTest { private AnnotationMethodHandlerAdapter.RequestMappingInfo oneMethodTwoParamsInfo; + @Before public void setUp() throws NoSuchMethodException { comparator = new AnnotationMethodHandlerAdapter.RequestMappingInfoComparator(new MockComparator()); @@ -84,6 +85,7 @@ public class RequestMappingInfoComparatorTest { assertEquals(emptyInfo, infos.get(4)); } + private static class MockComparator implements Comparator { public int compare(String s1, String s2) { diff --git a/org.springframework.web/src/test/java/org/springframework/beans/TestBean.java b/org.springframework.web/src/test/java/org/springframework/beans/TestBean.java index 4670b8c78b..4dd6960743 100644 --- a/org.springframework.web/src/test/java/org/springframework/beans/TestBean.java +++ b/org.springframework.web/src/test/java/org/springframework/beans/TestBean.java @@ -104,6 +104,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt private List pets; + public TestBean() { } @@ -396,9 +397,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt } - /** - * @see org.springframework.beans.ITestBean#exceptional(Throwable) - */ public void exceptional(Throwable t) throws Throwable { if (t != null) { throw t; @@ -408,16 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt public void unreliableFileOperation() throws IOException { throw new IOException(); } - /** - * @see org.springframework.beans.ITestBean#returnsThis() - */ + public Object returnsThis() { return this; } - /** - * @see org.springframework.beans.IOther#absquatulate() - */ public void absquatulate() { }