From: Arjen J.W. P. <po...@us...> - 2008-10-20 19:44:34
|
Update of /cvsroot/springframework/spring/test/org/springframework/context/config In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv739/test/org/springframework/context/config Added Files: contextNamespaceHandlerTests.xml ContextNamespaceHandlerTests.java Log Message: SPR-5203 --- NEW FILE: contextNamespaceHandlerTests.xml --- <?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:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"> <util:properties id="placeholderProps"> <prop key="foo">bar</prop> </util:properties> <context:property-placeholder properties-ref="placeholderProps"/> <bean id="string" class="java.lang.String"> <constructor-arg value="${foo}"/> </bean> <util:properties id="overrideProps"> <prop key="date.minutes">42</prop> </util:properties> <context:property-override properties-ref="overrideProps"/> <bean id="date" class="java.util.Date"> <property name="minutes" value="10"/> </bean> </beans> --- NEW FILE: ContextNamespaceHandlerTests.java --- /* * Copyright 2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.context.config; import java.util.Date; import java.util.Map; import junit.framework.TestCase; import org.springframework.beans.factory.config.PropertyOverrideConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Arjen Poutsma * @since 2.5.6 */ public class ContextNamespaceHandlerTests extends TestCase { private ApplicationContext applicationContext; protected void setUp() throws Exception { applicationContext = new ClassPathXmlApplicationContext("contextNamespaceHandlerTests.xml", getClass()); } public void testPropertyPlaceholder() throws Exception { Map beans = applicationContext.getBeansOfType(PropertyPlaceholderConfigurer.class); assertFalse("No PropertyPlaceHolderConfigurer found", beans.isEmpty()); String s = (String) applicationContext.getBean("string"); assertEquals("No properties replaced", "bar", s); } public void testPropertyOverride() throws Exception { Map beans = applicationContext.getBeansOfType(PropertyOverrideConfigurer.class); assertFalse("No PropertyOverrideConfigurer found", beans.isEmpty()); Date date = (Date) applicationContext.getBean("date"); assertEquals("No properties overriden", 42, date.getMinutes()); } } |