Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MutablePropertyValuesTests.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 4k
Category:
Java Develop
Development Platform:
Java
- /*
- * Copyright 2002-2004 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.beans;
- /**
- * Test for MutablePropertyValues.
- *
- * @author Rod Johnson
- */
- public class MutablePropertyValuesTests extends AbstractPropertyValuesTests {
- public void testValid() throws Exception {
- MutablePropertyValues pvs = new MutablePropertyValues();
- pvs.addPropertyValue(new PropertyValue("forname", "Tony"));
- pvs.addPropertyValue(new PropertyValue("surname", "Blair"));
- pvs.addPropertyValue(new PropertyValue("age", "50"));
- testTony(pvs);
- MutablePropertyValues deepCopy = new MutablePropertyValues(pvs);
- testTony(deepCopy);
- deepCopy.setPropertyValueAt(new PropertyValue("name", "Gordon"), 0);
- testTony(pvs);
- assertEquals("Gordon", deepCopy.getPropertyValue("name").getValue());
- }
- public void addOrOverride() throws Exception {
- MutablePropertyValues pvs = new MutablePropertyValues();
- pvs.addPropertyValue(new PropertyValue("forname", "Tony"));
- pvs.addPropertyValue(new PropertyValue("surname", "Blair"));
- pvs.addPropertyValue(new PropertyValue("age", "50"));
- testTony(pvs);
- PropertyValue addedPv = new PropertyValue("rod", "Rod");
- pvs.addPropertyValue(addedPv);
- assertTrue(pvs.getPropertyValue("rod").equals(addedPv));
- PropertyValue changedPv = new PropertyValue("forname", "Greg");
- pvs.addPropertyValue(changedPv);
- assertTrue(pvs.getPropertyValue("forename").equals(changedPv));
- }
- public void testChangesOnEquals() throws Exception {
- MutablePropertyValues pvs = new MutablePropertyValues();
- pvs.addPropertyValue(new PropertyValue("forname", "Tony"));
- pvs.addPropertyValue(new PropertyValue("surname", "Blair"));
- pvs.addPropertyValue(new PropertyValue("age", "50"));
- MutablePropertyValues pvs2 = pvs;
- PropertyValues changes = pvs2.changesSince(pvs);
- assertTrue("changes are empty", changes.getPropertyValues().length == 0);
- }
- public void testChangeOfOneField() throws Exception {
- MutablePropertyValues pvs = new MutablePropertyValues();
- pvs.addPropertyValue(new PropertyValue("forname", "Tony"));
- pvs.addPropertyValue(new PropertyValue("surname", "Blair"));
- pvs.addPropertyValue(new PropertyValue("age", "50"));
- MutablePropertyValues pvs2 = new MutablePropertyValues(pvs);
- PropertyValues changes = pvs2.changesSince(pvs);
- assertTrue("changes are empty, not of length " + changes.getPropertyValues().length,
- changes.getPropertyValues().length == 0);
- pvs2.addPropertyValue(new PropertyValue("forname", "Gordon"));
- changes = pvs2.changesSince(pvs);
- assertTrue("1 change", changes.getPropertyValues().length == 1);
- PropertyValue fn = changes.getPropertyValue("forname");
- assertTrue("change is forname", fn != null);
- assertTrue("new value is gordon", fn.getValue().equals("Gordon"));
- MutablePropertyValues pvs3 = new MutablePropertyValues(pvs);
- changes = pvs3.changesSince(pvs);
- assertTrue("changes are empty, not of length " + changes.getPropertyValues().length,
- changes.getPropertyValues().length == 0);
- // add new
- pvs3.addPropertyValue(new PropertyValue("foo", "bar"));
- pvs3.addPropertyValue(new PropertyValue("fi", "fum"));
- changes = pvs3.changesSince(pvs);
- assertTrue("2 change", changes.getPropertyValues().length == 2);
- fn = changes.getPropertyValue("foo");
- assertTrue("change in foo", fn != null);
- assertTrue("new value is bar", fn.getValue().equals("bar"));
- }
- }