Browse Source

Renamed ShortcutTests to SimplePropertyNamespaceHandlerTests

conversation
Arjen Poutsma 16 years ago
parent
commit
1b6c4929ad
  1. 42
      org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java
  2. 0
      org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml
  3. 17
      org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml

42
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ShortcutTests.java → org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java

@ -16,22 +16,25 @@ @@ -16,22 +16,25 @@
package org.springframework.beans.factory.xml;
import junit.framework.TestCase;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import test.beans.ITestBean;
import test.beans.TestBean;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.core.io.ClassPathResource;
import test.beans.ITestBean;
import test.beans.TestBean;
/**
* @author Rob Harrop
* @author Juergen Hoeller
* @author Arjen Poutsma
*/
public class ShortcutTests extends TestCase {
public class SimplePropertyNamespaceHandlerTests {
public void testSimpleBeanConfigured() throws Exception {
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.xml", getClass()));
@Test
public void simpleBeanConfigured() throws Exception {
XmlBeanFactory beanFactory =
new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
ITestBean rob = (TestBean) beanFactory.getBean("rob");
ITestBean sally = (TestBean) beanFactory.getBean("sally");
assertEquals("Rob Harrop", rob.getName());
@ -39,27 +42,26 @@ public class ShortcutTests extends TestCase { @@ -39,27 +42,26 @@ public class ShortcutTests extends TestCase {
assertEquals(rob.getSpouse(), sally);
}
public void testInnerBeanConfigured() throws Exception {
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.xml", getClass()));
@Test
public void innerBeanConfigured() throws Exception {
XmlBeanFactory beanFactory =
new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
TestBean sally = (TestBean) beanFactory.getBean("sally2");
ITestBean rob = (TestBean) sally.getSpouse();
ITestBean rob = sally.getSpouse();
assertEquals("Rob Harrop", rob.getName());
assertEquals(24, rob.getAge());
assertEquals(rob.getSpouse(), sally);
}
public void testWithPropertyDefinedTwice() throws Exception {
try {
new XmlBeanFactory(new ClassPathResource("shortcutTestsWithErrors.xml", getClass()));
fail("Should not be able to load a file with property specified twice.");
}
catch (BeanDefinitionStoreException e) {
// success
}
@Test(expected = BeanDefinitionStoreException.class)
public void withPropertyDefinedTwice() throws Exception {
new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTestsWithErrors.xml", getClass()));
}
public void testPropertyWithNameEndingInRef() throws Exception {
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("shortcutTests.xml", getClass()));
@Test
public void propertyWithNameEndingInRef() throws Exception {
XmlBeanFactory beanFactory =
new XmlBeanFactory(new ClassPathResource("simplePropertyNamespaceHandlerTests.xml", getClass()));
ITestBean sally = (TestBean) beanFactory.getBean("derivedSally");
assertEquals("r", sally.getSpouse().getName());
}

0
org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/shortcutTests.xml → org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTests.xml

17
org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/simplePropertyNamespaceHandlerTestsWithErrors.xml

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="rob" class="org.springframework.beans.TestBean" p:name="Rob Harrop" p:spouse-ref="sally">
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="sally" class="org.springframework.beans.TestBean" p:name="Sally Greenwood" p:spouse-ref="rob"/>
</beans>
Loading…
Cancel
Save