Source Code Cross Referenced for KeyManagementExceptionTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » security » tests » java » security » 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 » Apache Harmony Java SE » org package » org.apache.harmony.security.tests.java.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Vera Y. Petrashkova
020:         * @version $Revision$
021:         */package org.apache.harmony.security.tests.java.security;
022:
023:        import java.security.KeyManagementException;
024:
025:        import junit.framework.TestCase;
026:
027:        /**
028:         * Tests for <code>KeyManagementException</code> class constructors and
029:         * methods.
030:         * 
031:         */
032:        public class KeyManagementExceptionTest extends TestCase {
033:
034:            public static void main(String[] args) {
035:            }
036:
037:            /**
038:             * Constructor for KeyManagementExceptionTests.
039:             * 
040:             * @param arg0
041:             */
042:            public KeyManagementExceptionTest(String arg0) {
043:                super (arg0);
044:            }
045:
046:            private static String[] msgs = {
047:                    "",
048:                    "Check new message",
049:                    "Check new message Check new message Check new message Check new message Check new message" };
050:
051:            private static Throwable tCause = new Throwable(
052:                    "Throwable for exception");
053:
054:            /**
055:             * Test for <code>KeyManagementException()</code> constructor Assertion:
056:             * constructs KeyManagementException with no detail message
057:             */
058:            public void testKeyManagementException01() {
059:                KeyManagementException tE = new KeyManagementException();
060:                assertNull("getMessage() must return null.", tE.getMessage());
061:                assertNull("getCause() must return null", tE.getCause());
062:            }
063:
064:            /**
065:             * Test for <code>KeyManagementException(String)</code> constructor
066:             * Assertion: constructs KeyManagementException with detail message msg.
067:             * Parameter <code>msg</code> is not null.
068:             */
069:            public void testKeyManagementException02() {
070:                KeyManagementException tE;
071:                for (int i = 0; i < msgs.length; i++) {
072:                    tE = new KeyManagementException(msgs[i]);
073:                    assertEquals("getMessage() must return: ".concat(msgs[i]),
074:                            tE.getMessage(), msgs[i]);
075:                    assertNull("getCause() must return null", tE.getCause());
076:                }
077:            }
078:
079:            /**
080:             * Test for <code>KeyManagementException(String)</code> constructor
081:             * Assertion: constructs KeyManagementException when <code>msg</code> is
082:             * null
083:             */
084:            public void testKeyManagementException03() {
085:                String msg = null;
086:                KeyManagementException tE = new KeyManagementException(msg);
087:                assertNull("getMessage() must return null.", tE.getMessage());
088:                assertNull("getCause() must return null", tE.getCause());
089:            }
090:
091:            /**
092:             * Test for <code>KeyManagementException(Throwable)</code> constructor
093:             * Assertion: constructs KeyManagementException when <code>cause</code> is
094:             * null
095:             */
096:            public void testKeyManagementException04() {
097:                Throwable cause = null;
098:                KeyManagementException tE = new KeyManagementException(cause);
099:                assertNull("getMessage() must return null.", tE.getMessage());
100:                assertNull("getCause() must return null", tE.getCause());
101:            }
102:
103:            /**
104:             * Test for <code>KeyManagementException(Throwable)</code> constructor
105:             * Assertion: constructs KeyManagementException when <code>cause</code> is
106:             * not null
107:             */
108:            public void testKeyManagementException05() {
109:                KeyManagementException tE = new KeyManagementException(tCause);
110:                if (tE.getMessage() != null) {
111:                    String toS = tCause.toString();
112:                    String getM = tE.getMessage();
113:                    assertTrue("getMessage() should contain ".concat(toS),
114:                            (getM.indexOf(toS) != -1));
115:                }
116:                assertNotNull("getCause() must not return null", tE.getCause());
117:                assertEquals("getCause() must return "
118:                        .concat(tCause.toString()), tE.getCause(), tCause);
119:            }
120:
121:            /**
122:             * Test for <code>KeyManagementException(String, Throwable)</code>
123:             * constructor Assertion: constructs KeyManagementException when
124:             * <code>cause</code> is null <code>msg</code> is null
125:             */
126:            public void testKeyManagementException06() {
127:                KeyManagementException tE = new KeyManagementException(null,
128:                        null);
129:                assertNull("getMessage() must return null", tE.getMessage());
130:                assertNull("getCause() must return null", tE.getCause());
131:            }
132:
133:            /**
134:             * Test for <code>KeyManagementException(String, Throwable)</code>
135:             * constructor Assertion: constructs KeyManagementException when
136:             * <code>cause</code> is null <code>msg</code> is not null
137:             */
138:            public void testKeyManagementException07() {
139:                KeyManagementException tE;
140:                for (int i = 0; i < msgs.length; i++) {
141:                    tE = new KeyManagementException(msgs[i], null);
142:                    assertEquals("getMessage() must return: ".concat(msgs[i]),
143:                            tE.getMessage(), msgs[i]);
144:                    assertNull("getCause() must return null", tE.getCause());
145:                }
146:            }
147:
148:            /**
149:             * Test for <code>KeyManagementException(String, Throwable)</code>
150:             * constructor Assertion: constructs KeyManagementException when
151:             * <code>cause</code> is not null <code>msg</code> is null
152:             */
153:            public void testKeyManagementException08() {
154:                KeyManagementException tE = new KeyManagementException(null,
155:                        tCause);
156:                if (tE.getMessage() != null) {
157:                    String toS = tCause.toString();
158:                    String getM = tE.getMessage();
159:                    assertTrue("getMessage() must should ".concat(toS), (getM
160:                            .indexOf(toS) != -1));
161:                }
162:                assertNotNull("getCause() must not return null", tE.getCause());
163:                assertEquals("getCause() must return "
164:                        .concat(tCause.toString()), tE.getCause(), tCause);
165:            }
166:
167:            /**
168:             * Test for <code>KeyManagementException(String, Throwable)</code>
169:             * constructor Assertion: constructs KeyManagementException when
170:             * <code>cause</code> is not null <code>msg</code> is not null
171:             */
172:            public void testKeyManagementException09() {
173:                KeyManagementException tE;
174:                for (int i = 0; i < msgs.length; i++) {
175:                    tE = new KeyManagementException(msgs[i], tCause);
176:                    String getM = tE.getMessage();
177:                    String toS = tCause.toString();
178:                    if (msgs[i].length() > 0) {
179:                        assertTrue(
180:                                "getMessage() must contain ".concat(msgs[i]),
181:                                getM.indexOf(msgs[i]) != -1);
182:                        if (!getM.equals(msgs[i])) {
183:                            assertTrue("getMessage() should contain "
184:                                    .concat(toS), getM.indexOf(toS) != -1);
185:                        }
186:                    }
187:                    assertNotNull("getCause() must not return null", tE
188:                            .getCause());
189:                    assertEquals("getCause() must return ".concat(tCause
190:                            .toString()), tE.getCause(), tCause);
191:                }
192:            }
193:        }
w__w__w___.___j___a___va_2s.___c___om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.