Java Doc for TestMap.java in  » Ajax » GWT » org » apache » commons » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » GWT » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.collections.TestObject
   org.apache.commons.collections.TestMap

All known Subclasses:   com.google.gwt.user.maptests.FastStringMapTest,  com.google.gwt.emultest.java.util.ApacheMapTest,  com.google.gwt.emultest.java.util.HashMapTest,
TestMap
abstract public class TestMap extends TestObject (Code)
Tests base java.util.Map methods and contracts.

The forces at work here are similar to those in TestCollection . If your class implements the full Map interface, including optional operations, simply extend this class, and implement the TestMap.makeEmptyMap() method.

On the other hand, if your map implemenation is wierd, you may have to override one or more of the other protected methods. They're described below.

Entry Population Methods

Override these methods if your map requires special entries:

Supported Operation Methods

Override these methods if your map doesn't support certain operations:

Fixture Methods

For tests on modification operations (puts and removes), fixtures are used to verify that that operation results in correct state for the map and its collection views. Basically, the modification is performed against your map implementation, and an identical modification is performed against a confirmed map implementation. A confirmed map implementation is something like java.util.HashMap, which is known to conform exactly to the Map contract. After the modification takes place on both your map implementation and the confirmed map implementation, the two maps are compared to see if their state is identical. The comparison also compares the collection views to make sure they're still the same.

The upshot of all that is that any test that modifies the map in any way will verify that all of the map's state is still correct, including the state of its collection views. So for instance if a key is removed by the map's key set's iterator, then the entry set is checked to make sure the key/value pair no longer appears.

The TestMap.map field holds an instance of your collection implementation. The TestMap.entrySet , TestMap.keySet and TestMap.collectionValues fields hold that map's collection views. And the TestMap.confirmed field holds an instance of the confirmed collection implementation. The TestMap.resetEmpty() and TestMap.resetFull() methods set these fields to empty or full maps, so that tests can proceed from a known state.

After a modification operation to both TestMap.map and TestMap.confirmed , the TestMap.verify() method is invoked to compare the results. The * verify() method calls separate methods to verify the map and its three collection views ( verifyMap(), verifyEntrySet() , * verifyKeySet() , and verifyValues() ). You may want to override one of the verification methodsto perform additional verifications. For instance, TestDoubleOrderedMap would want override its TestMap.verifyValues() method to verify that the values are unique and in ascending order.

Other Notes

If your Map fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your Map fails and/or the methods that define the assumptions used by the test cases. For example, if your map does not allow duplicate values, override TestMap.useDuplicateValues() and have it return false
author:
   Michael Smith
author:
   Rodney Waldhoff
author:
   Paul Jack
version:
   $Id: TestMap.java,v 1.20.2.1 2004/05/22 12:14:05 scolebourne Exp $


Inner Class :class TestMapEntrySet extends TestSet
Inner Class :class TestMapKeySet extends TestSet
Inner Class :class TestMapValues extends TestCollection

Field Summary
protected  CollectioncollectionValues
     Values collection of map created by reset().
protected  Mapconfirmed
     HashMap created by reset().
protected  SetentrySet
     Entry set of map created by reset().
protected  SetkeySet
     Key set of map created by reset().
protected  Mapmap
     Map created by reset().


Method Summary
protected  voidaddSampleMappings(Map m)
     Helper method to add all the mappings described by TestMap.getSampleKeys() and TestMap.getSampleValues() .
protected  Object[]getNewSampleValues()
     Returns a the set of values that can be used to replace the values returned from TestMap.getSampleValues() .
protected  Object[]getOtherKeys()
    
protected  Object[]getOtherValues()
    
protected  Object[]getSampleKeys()
     Returns the set of keys in the mappings used to test the map.
protected  Object[]getSampleValues()
     Returns the set of values in the mappings used to test the map.
protected  booleanisAddRemoveModifiable()
     Override if your map does not allow add/remove modifications.
protected  booleanisChangeable()
     Override if your map allows its mappings to be changed to new values.
abstract protected  MapmakeEmptyMap()
     Return a new, empty Map to be used for testing.
protected  MapmakeFullMap()
     Return a new, populated map.
public  ObjectmakeObject()
    
protected  voidresetEmpty()
     Resets the TestMap.map , TestMap.entrySet , TestMap.keySet , TestMap.collectionValues and TestMap.confirmed fields to empty.
protected  voidresetFull()
     Resets the TestMap.map , TestMap.entrySet , TestMap.keySet , TestMap.collectionValues and TestMap.confirmed fields to full.
public  voidtestMakeMap()
     Test to ensure that makeEmptyMap and makeFull returns a new non-null map with each invocation.
public  voidtestMapClear()
     Tests Map.clear .
public  voidtestMapContainsKey()
     Tests Map.containsKey(Object) by verifying it returns false for all sample keys on a map created using an empty map and returns true for all sample keys returned on a full map.
public  voidtestMapContainsValue()
     Tests Map.containsValue(Object) by verifying it returns false for all sample values on an empty map and returns true for all sample values on a full map.
public  voidtestMapEquals()
    
public  voidtestMapGet()
    
public  voidtestMapHashCode()
    
public  voidtestMapIsEmpty()
    
public  voidtestMapPut()
    
public  voidtestMapPutAll()
    
public  voidtestMapRemove()
    
public  voidtestMapSize()
    
public  voidtestMapToString()
     Tests Map.toString().
public  voidtestSampleMappings()
     Test to ensure the test setup is working properly.
protected  booleanuseDuplicateValues()
     Override if your map does not allow duplicate values.
protected  booleanuseNullKey()
     Override if your map does not allow a null key.
protected  booleanuseNullValue()
     Override if your map does not allow null values.
protected  voidverify()
     Verifies that TestMap.map is still equal to TestMap.confirmed . This method checks that the map is equal to the HashMap, and that the map's collection views are still equal to the HashMap's collection views.
protected  voidverifyEntrySet()
    
protected  voidverifyKeySet()
    
protected  voidverifyMap()
    

Field Detail
collectionValues
protected Collection collectionValues(Code)
Values collection of map created by reset().



confirmed
protected Map confirmed(Code)
HashMap created by reset().



entrySet
protected Set entrySet(Code)
Entry set of map created by reset().



keySet
protected Set keySet(Code)
Key set of map created by reset().



map
protected Map map(Code)
Map created by reset().





Method Detail
addSampleMappings
protected void addSampleMappings(Map m)(Code)
Helper method to add all the mappings described by TestMap.getSampleKeys() and TestMap.getSampleValues() .



getNewSampleValues
protected Object[] getNewSampleValues()(Code)
Returns a the set of values that can be used to replace the values returned from TestMap.getSampleValues() . This method must return an array with the same length as TestMap.getSampleValues() . The values returned from this method should not be the same as those returned from TestMap.getSampleValues() . The default implementation constructs a set of String values and includes a single null value if TestMap.useNullValue() returns true, and includes two values that are the same if TestMap.useDuplicateValues() returns true.



getOtherKeys
protected Object[] getOtherKeys()(Code)



getOtherValues
protected Object[] getOtherValues()(Code)



getSampleKeys
protected Object[] getSampleKeys()(Code)
Returns the set of keys in the mappings used to test the map. This method must return an array with the same length as TestMap.getSampleValues() and all array elements must be different. The default implementation constructs a set of String keys, and includes a single null key if TestMap.useNullKey() returns true.



getSampleValues
protected Object[] getSampleValues()(Code)
Returns the set of values in the mappings used to test the map. This method must return an array with the same length as TestMap.getSampleKeys() . The default implementation contructs a set of String values and includes a single null value if TestMap.useNullValue() returns true, and includes two values that are the same if TestMap.useDuplicateValues() returns true.



isAddRemoveModifiable
protected boolean isAddRemoveModifiable()(Code)
Override if your map does not allow add/remove modifications. The default implementation returns true.



isChangeable
protected boolean isChangeable()(Code)
Override if your map allows its mappings to be changed to new values. The default implementation returns true.



makeEmptyMap
abstract protected Map makeEmptyMap()(Code)
Return a new, empty Map to be used for testing.



makeFullMap
protected Map makeFullMap()(Code)
Return a new, populated map. The mappings in the map should match the keys and values returned from TestMap.getSampleKeys() and TestMap.getSampleValues() . The default implementation uses makeEmptyMap() and calls TestMap.addSampleMappings() to add all the mappings to the map.



makeObject
public Object makeObject()(Code)



resetEmpty
protected void resetEmpty()(Code)
Resets the TestMap.map , TestMap.entrySet , TestMap.keySet , TestMap.collectionValues and TestMap.confirmed fields to empty.



resetFull
protected void resetFull()(Code)
Resets the TestMap.map , TestMap.entrySet , TestMap.keySet , TestMap.collectionValues and TestMap.confirmed fields to full.



testMakeMap
public void testMakeMap()(Code)
Test to ensure that makeEmptyMap and makeFull returns a new non-null map with each invocation.



testMapClear
public void testMapClear()(Code)
Tests Map.clear . If the map TestMap.isAddRemoveModifiable()can add and remove elements , then Map.size and Map.isEmpty are used to ensure that map has no elements after a call to clear. If the map does not support adding and removing elements, this method checks to ensure clear throws an UnsupportedOperationException.



testMapContainsKey
public void testMapContainsKey()(Code)
Tests Map.containsKey(Object) by verifying it returns false for all sample keys on a map created using an empty map and returns true for all sample keys returned on a full map.



testMapContainsValue
public void testMapContainsValue()(Code)
Tests Map.containsValue(Object) by verifying it returns false for all sample values on an empty map and returns true for all sample values on a full map.



testMapEquals
public void testMapEquals()(Code)
Tests Map.equals(Object)



testMapGet
public void testMapGet()(Code)
Tests Map.get(Object)



testMapHashCode
public void testMapHashCode()(Code)
Tests Map.hashCode()



testMapIsEmpty
public void testMapIsEmpty()(Code)
Tests Map.isEmpty()



testMapPut
public void testMapPut()(Code)
Tests Map.put(Object, Object)



testMapPutAll
public void testMapPutAll()(Code)
Tests Map.putAll(Collection)



testMapRemove
public void testMapRemove()(Code)
Tests Map.remove(Object)



testMapSize
public void testMapSize()(Code)
Tests Map.size()



testMapToString
public void testMapToString()(Code)
Tests Map.toString(). Since the format of the string returned by the toString() method is not defined in the Map interface, there is no common way to test the results of the toString() method. Thereforce, it is encouraged that Map implementations override this test with one that checks the format matches any format defined in its API. This default implementation just verifies that the toString() method does not return null.



testSampleMappings
public void testSampleMappings()(Code)
Test to ensure the test setup is working properly. This method checks to ensure that the getSampleKeys and getSampleValues methods are returning results that look appropriate. That is, they both return a non-null array of equal length. The keys array must not have any duplicate values, and may only contain a (single) null key if useNullKey() returns true. The values array must only have a null value if useNullValue() is true and may only have duplicate values if useDuplicateValues() returns true.



useDuplicateValues
protected boolean useDuplicateValues()(Code)
Override if your map does not allow duplicate values. The default implementation returns true.



useNullKey
protected boolean useNullKey()(Code)
Override if your map does not allow a null key. The default implementation returns true



useNullValue
protected boolean useNullValue()(Code)
Override if your map does not allow null values. The default implementation returns true.



verify
protected void verify()(Code)
Verifies that TestMap.map is still equal to TestMap.confirmed . This method checks that the map is equal to the HashMap, and that the map's collection views are still equal to the HashMap's collection views. An equals test is done on the maps and their collection views; their size and isEmpty results are compared; their hashCodes are compared; and containsAll tests are run on the collection views.



verifyEntrySet
protected void verifyEntrySet()(Code)



verifyKeySet
protected void verifyKeySet()(Code)



verifyMap
protected void verifyMap()(Code)



Fields inherited from org.apache.commons.collections.TestObject
final public static int COLLECTIONS_MAJOR_VERSION(Code)(Java Doc)

Methods inherited from org.apache.commons.collections.TestObject
public String getCanonicalEmptyCollectionName(Object object)(Code)(Java Doc)
public String getCanonicalFullCollectionName(Object object)(Code)(Java Doc)
public int getCompatibilityVersion()(Code)(Java Doc)
abstract public Object makeObject()(Code)(Java Doc)
public boolean supportsEmptyCollections()(Code)(Java Doc)
public boolean supportsFullCollections()(Code)(Java Doc)
public void testObjectEqualsSelf()(Code)(Java Doc)
public void testObjectHashCodeEqualsContract()(Code)(Java Doc)
public void testObjectHashCodeEqualsSelfHashCode()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.