01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.sql.tests.javax.transaction;
19:
20: import javax.transaction.TransactionRolledbackException;
21:
22: import junit.framework.TestCase;
23:
24: public class TransactionRolledbackExceptionTest extends TestCase {
25:
26: /*
27: * ConstructorTest
28: */
29: public void testTransactionRolledbackExceptionString() {
30:
31: String[] init1 = { "a", "1", "valid1", "----", "&valid*", null,
32: "", " " };
33:
34: String[] theFinalStates1 = init1;
35:
36: Exception[] theExceptions = { null, null, null, null, null,
37: null, null, null };
38:
39: TransactionRolledbackException aTransactionRolledbackException;
40: int loopCount = init1.length;
41: for (int i = 0; i < loopCount; i++) {
42: try {
43: aTransactionRolledbackException = new TransactionRolledbackException(
44: init1[i]);
45: if (theExceptions[i] != null) {
46: fail();
47: }
48: assertEquals(i + " Final state mismatch",
49: aTransactionRolledbackException.getMessage(),
50: theFinalStates1[i]);
51:
52: } catch (Exception e) {
53: if (theExceptions[i] == null) {
54: fail(i + "Unexpected exception");
55: }
56: assertEquals(i + "Exception mismatch", e.getClass(),
57: theExceptions[i].getClass());
58: assertEquals(i + "Exception mismatch", e.getMessage(),
59: theExceptions[i].getMessage());
60: } // end try
61: } // end for
62:
63: } // end method testTransactionRolledbackExceptionString
64:
65: /*
66: * ConstructorTest
67: */
68: public void testTransactionRolledbackException() {
69:
70: String[] theFinalStates1 = { null };
71:
72: Exception[] theExceptions = { null };
73:
74: TransactionRolledbackException aTransactionRolledbackException;
75: int loopCount = 1;
76: for (int i = 0; i < loopCount; i++) {
77: try {
78: aTransactionRolledbackException = new TransactionRolledbackException();
79: if (theExceptions[i] != null) {
80: fail();
81: }
82: assertEquals(i + " Final state mismatch",
83: aTransactionRolledbackException.getMessage(),
84: theFinalStates1[i]);
85:
86: } catch (Exception e) {
87: if (theExceptions[i] == null) {
88: fail(i + "Unexpected exception");
89: }
90: assertEquals(i + "Exception mismatch", e.getClass(),
91: theExceptions[i].getClass());
92: assertEquals(i + "Exception mismatch", e.getMessage(),
93: theExceptions[i].getMessage());
94: } // end try
95: } // end for
96:
97: } // end method testTransactionRolledbackException
98:
99: } // end class TransactionRolledbackExceptionTest
|