Source Code Cross Referenced for SignatureExceptionTest.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.SignatureException;
024:
025:        import junit.framework.TestCase;
026:
027:        /**
028:         * Tests for <code>SignatureException</code> class constructors and methods.
029:         * 
030:         */
031:        public class SignatureExceptionTest extends TestCase {
032:
033:            public static void main(String[] args) {
034:            }
035:
036:            /**
037:             * Constructor for SignatureExceptionTests.
038:             * 
039:             * @param arg0
040:             */
041:            public SignatureExceptionTest(String arg0) {
042:                super (arg0);
043:            }
044:
045:            private static String[] msgs = {
046:                    "",
047:                    "Check new message",
048:                    "Check new message Check new message Check new message Check new message Check new message" };
049:
050:            private static Throwable tCause = new Throwable(
051:                    "Throwable for exception");
052:
053:            /**
054:             * Test for <code>SignatureException()</code> constructor Assertion:
055:             * constructs SignatureException with no detail message
056:             */
057:            public void testSignatureException01() {
058:                SignatureException tE = new SignatureException();
059:                assertNull("getMessage() must return null.", tE.getMessage());
060:                assertNull("getCause() must return null", tE.getCause());
061:            }
062:
063:            /**
064:             * Test for <code>SignatureException(String)</code> constructor Assertion:
065:             * constructs SignatureException with detail message msg. Parameter
066:             * <code>msg</code> is not null.
067:             */
068:            public void testSignatureException02() {
069:                SignatureException tE;
070:                for (int i = 0; i < msgs.length; i++) {
071:                    tE = new SignatureException(msgs[i]);
072:                    assertEquals("getMessage() must return: ".concat(msgs[i]),
073:                            tE.getMessage(), msgs[i]);
074:                    assertNull("getCause() must return null", tE.getCause());
075:                }
076:            }
077:
078:            /**
079:             * Test for <code>SignatureException(String)</code> constructor Assertion:
080:             * constructs SignatureException when <code>msg</code> is null
081:             */
082:            public void testSignatureException03() {
083:                String msg = null;
084:                SignatureException tE = new SignatureException(msg);
085:                assertNull("getMessage() must return null.", tE.getMessage());
086:                assertNull("getCause() must return null", tE.getCause());
087:            }
088:
089:            /**
090:             * Test for <code>SignatureException(Throwable)</code> constructor
091:             * Assertion: constructs SignatureException when <code>cause</code> is
092:             * null
093:             */
094:            public void testSignatureException04() {
095:                Throwable cause = null;
096:                SignatureException tE = new SignatureException(cause);
097:                assertNull("getMessage() must return null.", tE.getMessage());
098:                assertNull("getCause() must return null", tE.getCause());
099:            }
100:
101:            /**
102:             * Test for <code>SignatureException(Throwable)</code> constructor
103:             * Assertion: constructs SignatureException when <code>cause</code> is not
104:             * null
105:             */
106:            public void testSignatureException05() {
107:                SignatureException tE = new SignatureException(tCause);
108:                if (tE.getMessage() != null) {
109:                    String toS = tCause.toString();
110:                    String getM = tE.getMessage();
111:                    assertTrue("getMessage() should contain ".concat(toS),
112:                            (getM.indexOf(toS) != -1));
113:                }
114:                assertNotNull("getCause() must not return null", tE.getCause());
115:                assertEquals("getCause() must return "
116:                        .concat(tCause.toString()), tE.getCause(), tCause);
117:            }
118:
119:            /**
120:             * Test for <code>SignatureException(String, Throwable)</code> constructor
121:             * Assertion: constructs SignatureException when <code>cause</code> is
122:             * null <code>msg</code> is null
123:             */
124:            public void testSignatureException06() {
125:                SignatureException tE = new SignatureException(null, null);
126:                assertNull("getMessage() must return null", tE.getMessage());
127:                assertNull("getCause() must return null", tE.getCause());
128:            }
129:
130:            /**
131:             * Test for <code>SignatureException(String, Throwable)</code> constructor
132:             * Assertion: constructs SignatureException when <code>cause</code> is
133:             * null <code>msg</code> is not null
134:             */
135:            public void testSignatureException07() {
136:                SignatureException tE;
137:                for (int i = 0; i < msgs.length; i++) {
138:                    tE = new SignatureException(msgs[i], null);
139:                    assertEquals("getMessage() must return: ".concat(msgs[i]),
140:                            tE.getMessage(), msgs[i]);
141:                    assertNull("getCause() must return null", tE.getCause());
142:                }
143:            }
144:
145:            /**
146:             * Test for <code>SignatureException(String, Throwable)</code> constructor
147:             * Assertion: constructs SignatureException when <code>cause</code> is not
148:             * null <code>msg</code> is null
149:             */
150:            public void testSignatureException08() {
151:                SignatureException tE = new SignatureException(null, tCause);
152:                if (tE.getMessage() != null) {
153:                    String toS = tCause.toString();
154:                    String getM = tE.getMessage();
155:                    assertTrue("getMessage() must should ".concat(toS), (getM
156:                            .indexOf(toS) != -1));
157:                }
158:                assertNotNull("getCause() must not return null", tE.getCause());
159:                assertEquals("getCause() must return "
160:                        .concat(tCause.toString()), tE.getCause(), tCause);
161:            }
162:
163:            /**
164:             * Test for <code>SignatureException(String, Throwable)</code> constructor
165:             * Assertion: constructs SignatureException when <code>cause</code> is not
166:             * null <code>msg</code> is not null
167:             */
168:            public void testSignatureException09() {
169:                SignatureException tE;
170:                for (int i = 0; i < msgs.length; i++) {
171:                    tE = new SignatureException(msgs[i], tCause);
172:                    String getM = tE.getMessage();
173:                    String toS = tCause.toString();
174:                    if (msgs[i].length() > 0) {
175:                        assertTrue(
176:                                "getMessage() must contain ".concat(msgs[i]),
177:                                getM.indexOf(msgs[i]) != -1);
178:                        if (!getM.equals(msgs[i])) {
179:                            assertTrue("getMessage() should contain "
180:                                    .concat(toS), getM.indexOf(toS) != -1);
181:                        }
182:                    }
183:                    assertNotNull("getCause() must not return null", tE
184:                            .getCause());
185:                    assertEquals("getCause() must return ".concat(tCause
186:                            .toString()), tE.getCause(), tCause);
187:                }
188:            }
189:        }
w___w_w__._ja__v___a_2_s__.__c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.