Source Code Cross Referenced for TestMapAsListFromIntegerToString.java in  » Testing » KeY » de » uka » ilkd » key » collection » 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 » Testing » KeY » de.uka.ilkd.key.collection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        //
010:
011:        package de.uka.ilkd.key.collection;
012:
013:        /** JUnit test for MapAsListFromIntegerToString implementation */
014:
015:        public class TestMapAsListFromIntegerToString extends
016:                junit.framework.TestCase {
017:
018:            private String[] entryStr;
019:            private Integer[] entryInt;
020:
021:            /** puts i and str in the corresponding arrays at place nr */
022:            private void put(int nr, int i, String str) {
023:                entryInt[nr] = new Integer(i);
024:                entryStr[nr] = str;
025:            }
026:
027:            public TestMapAsListFromIntegerToString(String name) {
028:                super (name);
029:            }
030:
031:            public void setUp() {
032:                entryStr = new String[4];
033:                entryInt = new Integer[4];
034:                put(0, 0, "Null");
035:                put(1, 1, "Eins");
036:                put(2, 2, "Zwei");
037:                put(3, 3, "Drei");
038:            }
039:
040:            private MapFromIntegerToString createMap() {
041:                MapFromIntegerToString map = MapAsListFromIntegerToString.EMPTY_MAP;
042:                // create map with entrys like (1,"Eins")
043:                for (int i = 0; i < entryStr.length; i++) {
044:                    map = map.put(entryInt[i], entryStr[i]);
045:                }
046:                return map;
047:            }
048:
049:            public void testMapEntriesAreTheSameThatHaveBeenPutInside() {
050:                MapFromIntegerToString map = createMap();
051:                // assert that all entries are in list
052:                for (int i = 0; i < entryStr.length; i++) {
053:                    assertEquals("Map does not contain entry(" + entryInt[i]
054:                            + ", " + entryStr[i] + ")", map.get(entryInt[i]),
055:                            entryStr[i]);
056:                }
057:            }
058:
059:            public void testReplaceIfSameKeyWithNewValueIsPutInMap() {
060:                MapFromIntegerToString map = createMap();
061:                map = map.put(new Integer(0), "Zero");
062:                // zero is in list
063:                assertTrue("Zero is not in list.", map.containsValue("Zero"));
064:                // but not so old element Null with same key (0)
065:                assertTrue(
066:                        "Null is in list but should have been replaced by Zero",
067:                        !map.containsValue("Null"));
068:            }
069:
070:            public void testImmutability() {
071:                MapFromIntegerToString map = createMap();
072:                MapFromIntegerToString old = map;
073:                map = map.put(new Integer(5), "Fuenf");
074:                // 5 is in map but not in old
075:                assertTrue("Fuenf is not in map", map.containsValue("Fuenf"));
076:                assertTrue(
077:                        "Fuenf is in old map, but it should not be there. Map is not immutable.",
078:                        !old.containsValue("Fuenf"));
079:            }
080:
081:            public void testMapCanContainSameValueWithDifferentKeys() {
082:                MapFromIntegerToString map = createMap();
083:                // add a mapping with a value that has been mapped to 
084:                // another key before
085:                Integer hundred = new Integer(100);
086:                map = map.put(hundred, entryStr[1]);
087:                assertSame(entryStr[1] + " is not mapped to the newer key 100",
088:                        map.get(hundred), entryStr[1]);
089:                assertSame(entryStr[1] + " is not mapped to the older key "
090:                        + entryInt[1], map.get(entryInt[1]), entryStr[1]);
091:            }
092:
093:            public void testRemoveOneMappingWithSpecifiedKey() {
094:                MapFromIntegerToString map = createMap();
095:                // delete map (1,"Eins")
096:                map = map.remove(entryInt[1]);
097:                assertTrue("Deleted Mapping found in map", !map
098:                        .containsKey(entryInt[1]));
099:            }
100:
101:            public void testRemoveAllMappingToSpecifiedValue() {
102:                MapFromIntegerToString map = createMap();
103:                // add a mapping with a value that has been mapped to 
104:                // another key before
105:                Integer hundred = new Integer(100);
106:                map = map.put(hundred, entryStr[1]);
107:                // delete map (*,"Eins")
108:                map = map.removeAll(entryStr[1]);
109:                assertTrue("Value :" + entryStr[1]
110:                        + " found in map. But I deleted all"
111:                        + " of these values :-(", !map
112:                        .containsValue(entryStr[1]));
113:            }
114:
115:            public void testSpecialCases() {
116:                MapFromIntegerToString map = MapAsListFromIntegerToString.EMPTY_MAP;
117:                map = map.put(new Integer(0), "A");
118:                assertTrue(
119:                        "Map should be empty and therefore equal to the EMPTY_MAP",
120:                        map.remove(new Integer(0)) == MapAsListFromIntegerToString.EMPTY_MAP);
121:
122:                assertTrue(
123:                        "Repeated key removal should not change anything",
124:                        map.remove(new Integer(0)).remove(new Integer(0)) == MapAsListFromIntegerToString.EMPTY_MAP);
125:
126:                map = map.put(new Integer(0), "B");
127:                assertTrue(
128:                        "Map should have only one element with key 0 and value \"B\" ",
129:                        map.size() == 1 && "B".equals(map.get(new Integer(0))));
130:
131:                map = map.removeAll("B");
132:                assertTrue(
133:                        "Map should be empty and therefore equal to the EMPTY_MAP",
134:                        map == MapAsListFromIntegerToString.EMPTY_MAP);
135:
136:                map = map.put(new Integer(0), "B");
137:                map = map.put(new Integer(1), "C");
138:                map = map.put(new Integer(2), "B");
139:
140:                map = map.removeAll("B");
141:                assertTrue("Map should not contain value \"B\" any longer ",
142:                        map.size() == 1 && !map.containsValue("B"));
143:
144:                map = map.removeAll("B");
145:                assertTrue(
146:                        "Removing non-existant values should not change anything",
147:                        map.size() == 1 && !map.containsValue("B"));
148:
149:            }
150:
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.