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 Alexander V. Esin
020: * @version $Revision$
021: */package org.ietf.jgss;
022:
023: import junit.framework.TestCase;
024:
025: /**
026: * Tests GSSException class
027: */
028: public class GSSExceptionTest extends TestCase {
029:
030: public void testGetMajor() {
031: GSSException gssException = new GSSException(
032: GSSException.BAD_NAME);
033: assertEquals(GSSException.BAD_NAME, gssException.getMajor());
034: }
035:
036: public void testGetMajor_0() {
037: GSSException gssException = new GSSException(0);
038: assertEquals(GSSException.FAILURE, gssException.getMajor());
039: }
040:
041: public void testGetMajor_1() {
042: GSSException gssException = new GSSException(
043: GSSException.BAD_NAME, GSSException.BAD_NAME,
044: "Bad day today");
045: assertEquals(GSSException.BAD_NAME, gssException.getMajor());
046: }
047:
048: public void testGetMajor_2() {
049: GSSException gssException = new GSSException(0, 0,
050: "Bad day today");
051: assertEquals(GSSException.FAILURE, gssException.getMajor());
052: }
053:
054: public void testGetMajor_3() {
055: GSSException gssException = new GSSException(
056: GSSException.NO_CRED);
057: assertEquals(GSSException.NO_CRED, gssException.getMajor());
058: }
059:
060: public void testGetMajor_4() {
061: GSSException gssException = new GSSException(-1, -1,
062: "Bad day today");
063: assertEquals(GSSException.FAILURE, gssException.getMajor());
064: }
065:
066: public void testGetMajorString() {
067: GSSException gssException = new GSSException(
068: GSSException.BAD_NAME);
069: String majorString = gssException.getMajorString();
070: assertEquals("BAD NAME", majorString);
071: }
072:
073: public void testGetMinor() {
074: GSSException gssException = new GSSException(
075: GSSException.BAD_NAME);
076: assertEquals(0, gssException.getMinor());
077: }
078:
079: public void testGetMinor_0() {
080: GSSException gssException = new GSSException(
081: GSSException.BAD_NAME, GSSException.BAD_NAME,
082: "Bad day today");
083: assertEquals(GSSException.BAD_NAME, gssException.getMinor());
084: }
085:
086: public void testGetMinor_1() {
087: GSSException gssException = new GSSException(
088: GSSException.BAD_NAME);
089: gssException.setMinor(GSSException.BAD_NAME, "Unclear reason");
090: assertEquals(GSSException.BAD_NAME, gssException.getMinor());
091: }
092:
093: public void testGetMinor_2() {
094: GSSException gssException = new GSSException(-1, -1,
095: "Bad day today");
096: assertEquals(-1, gssException.getMinor());
097: }
098:
099: public void testGetMinor_3() {
100: GSSException gssException = new GSSException(
101: GSSException.BAD_NAME);
102: gssException.setMinor(-1, "Unclear reason");
103: assertEquals(-1, gssException.getMinor());
104: }
105:
106: public void testGetMinorString() {
107: GSSException gssException = new GSSException(
108: GSSException.BAD_NAME);
109: String minorString = gssException.getMinorString();
110: assertNull(minorString);
111: }
112:
113: public void testGetMinorString_0() {
114: GSSException gssException = new GSSException(
115: GSSException.BAD_NAME, GSSException.BAD_NAME,
116: "Bad day today");
117: String minorString = gssException.getMinorString();
118: assertEquals("Bad day today", minorString);
119: }
120:
121: public void testGetMinorString_1() {
122: GSSException gssException = new GSSException(
123: GSSException.BAD_NAME);
124: gssException.setMinor(-1, "Bad day today");
125: String minorString = gssException.getMinorString();
126: assertEquals("Bad day today", minorString);
127: }
128:
129: public void testGetMinorString_2() {
130: GSSException gssException = new GSSException(
131: GSSException.BAD_NAME, 0, "Bad day today");
132: String minorString = gssException.getMinorString();
133: assertNull(minorString);
134: }
135:
136: public void testGetMinorString_3() {
137: GSSException gssException = new GSSException(
138: GSSException.BAD_NAME);
139: gssException.setMinor(0, "Bad day today");
140: String minorString = gssException.getMinorString();
141: assertNull(minorString);
142: }
143:
144: public void testGetMessage() {
145: GSSException gssException = new GSSException(
146: GSSException.BAD_NAME);
147: assertEquals("BAD NAME", gssException.getMessage());
148: }
149:
150: public void testGetMessage_0() {
151: GSSException gssException = new GSSException(
152: GSSException.BAD_NAME, GSSException.BAD_NAME,
153: "Bad day today");
154: assertEquals("BAD NAME (Bad day today)", gssException
155: .getMessage());
156: }
157:
158: public void testGetMessage_1() {
159: GSSException gssException = new GSSException(
160: GSSException.BAD_NAME);
161: gssException.setMinor(GSSException.BAD_NAME, "Unclear reason");
162: assertEquals("BAD NAME (Unclear reason)", gssException
163: .getMessage());
164: }
165:
166: public void testGetMessage_2() {
167: GSSException gssException = new GSSException(
168: GSSException.BAD_NAME, GSSException.BAD_NAME,
169: "Bad day today");
170: gssException.setMinor(GSSException.BAD_NAME, "Unclear reason");
171: assertEquals("BAD NAME (Unclear reason)", gssException
172: .getMessage());
173: }
174:
175: public void testToString() {
176: GSSException gssException = new GSSException(
177: GSSException.BAD_NAME);
178: assertEquals("GSSException: BAD NAME", gssException.toString());
179: }
180:
181: public void testToString_0() {
182: GSSException gssException = new GSSException(
183: GSSException.BAD_NAME, GSSException.BAD_NAME,
184: "Bad day today");
185: assertEquals("GSSException: BAD NAME (Bad day today)",
186: gssException.toString());
187: }
188: }
|