/external/apache-harmony/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLDataExceptionTest.java

https://gitlab.com/brian0218/rk3066_r-box_android4.2.2_sdk · Java · 1067 lines · 806 code · 68 blank · 193 comment · 0 complexity · a7ccc9ad6010829ec3322dc5b8f4deee MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * 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. package org.apache.harmony.sql.tests.java.sql;
  18. import java.sql.SQLDataException;
  19. import junit.framework.TestCase;
  20. import org.apache.harmony.testframework.serialization.SerializationTest;
  21. public class SQLDataExceptionTest extends TestCase {
  22. private SQLDataException sQLDataException;
  23. @Override
  24. protected void setUp() throws Exception {
  25. sQLDataException = new SQLDataException("MYTESTSTRING", "MYTESTSTRING",
  26. 1, new Exception("MYTHROWABLE"));
  27. }
  28. @Override
  29. protected void tearDown() throws Exception {
  30. sQLDataException = null;
  31. }
  32. /**
  33. * @test java.sql.SQLDataException(String)
  34. */
  35. public void test_Constructor_LString() {
  36. SQLDataException sQLDataException = new SQLDataException("MYTESTSTRING");
  37. assertNotNull(sQLDataException);
  38. assertNull("The SQLState of SQLDataException should be null",
  39. sQLDataException.getSQLState());
  40. assertEquals(
  41. "The reason of SQLDataException set and get should be equivalent",
  42. "MYTESTSTRING", sQLDataException.getMessage());
  43. assertEquals("The error code of SQLDataException should be 0",
  44. sQLDataException.getErrorCode(), 0);
  45. }
  46. /**
  47. * @test java.sql.SQLDataException(String)
  48. */
  49. public void test_Constructor_LString_1() {
  50. SQLDataException sQLDataException = new SQLDataException((String) null);
  51. assertNotNull(sQLDataException);
  52. assertNull("The SQLState of SQLDataException should be null",
  53. sQLDataException.getSQLState());
  54. assertNull("The reason of SQLDataException should be null",
  55. sQLDataException.getMessage());
  56. assertEquals("The error code of SQLDataException should be 0",
  57. sQLDataException.getErrorCode(), 0);
  58. }
  59. /**
  60. * @test java.sql.SQLDataException(String, String)
  61. */
  62. public void test_Constructor_LStringLString() {
  63. SQLDataException sQLDataException = new SQLDataException(
  64. "MYTESTSTRING1", "MYTESTSTRING2");
  65. assertNotNull(sQLDataException);
  66. assertEquals(
  67. "The SQLState of SQLDataException set and get should be equivalent",
  68. "MYTESTSTRING2", sQLDataException.getSQLState());
  69. assertEquals(
  70. "The reason of SQLDataException set and get should be equivalent",
  71. "MYTESTSTRING1", sQLDataException.getMessage());
  72. assertEquals("The error code of SQLDataException should be 0",
  73. sQLDataException.getErrorCode(), 0);
  74. }
  75. /**
  76. * @test java.sql.SQLDataException(String, String)
  77. */
  78. public void test_Constructor_LStringLString_1() {
  79. SQLDataException sQLDataException = new SQLDataException(
  80. "MYTESTSTRING", (String) null);
  81. assertNotNull(sQLDataException);
  82. assertNull("The SQLState of SQLDataException should be null",
  83. sQLDataException.getSQLState());
  84. assertEquals(
  85. "The reason of SQLDataException set and get should be equivalent",
  86. "MYTESTSTRING", sQLDataException.getMessage());
  87. assertEquals("The error code of SQLDataException should be 0",
  88. sQLDataException.getErrorCode(), 0);
  89. }
  90. /**
  91. * @test java.sql.SQLDataException(String, String)
  92. */
  93. public void test_Constructor_LStringLString_2() {
  94. SQLDataException sQLDataException = new SQLDataException(null,
  95. "MYTESTSTRING");
  96. assertNotNull(sQLDataException);
  97. assertEquals(
  98. "The SQLState of SQLDataException set and get should be equivalent",
  99. "MYTESTSTRING", sQLDataException.getSQLState());
  100. assertNull("The reason of SQLDataException should be null",
  101. sQLDataException.getMessage());
  102. assertEquals("The error code of SQLDataException should be 0",
  103. sQLDataException.getErrorCode(), 0);
  104. }
  105. /**
  106. * @test java.sql.SQLDataException(String, String)
  107. */
  108. public void test_Constructor_LStringLString_3() {
  109. SQLDataException sQLDataException = new SQLDataException((String) null,
  110. (String) null);
  111. assertNotNull(sQLDataException);
  112. assertNull("The SQLState of SQLDataException should be null",
  113. sQLDataException.getSQLState());
  114. assertNull("The reason of SQLDataException should be null",
  115. sQLDataException.getMessage());
  116. assertEquals("The error code of SQLDataException should be 0",
  117. sQLDataException.getErrorCode(), 0);
  118. }
  119. /**
  120. * @test java.sql.SQLDataException(String, String, int)
  121. */
  122. public void test_Constructor_LStringLStringI() {
  123. SQLDataException sQLDataException = new SQLDataException(
  124. "MYTESTSTRING1", "MYTESTSTRING2", 1);
  125. assertNotNull(sQLDataException);
  126. assertEquals(
  127. "The SQLState of SQLDataException set and get should be equivalent",
  128. "MYTESTSTRING2", sQLDataException.getSQLState());
  129. assertEquals(
  130. "The reason of SQLDataException set and get should be equivalent",
  131. "MYTESTSTRING1", sQLDataException.getMessage());
  132. assertEquals("The error code of SQLDataException should be 1",
  133. sQLDataException.getErrorCode(), 1);
  134. }
  135. /**
  136. * @test java.sql.SQLDataException(String, String, int)
  137. */
  138. public void test_Constructor_LStringLStringI_1() {
  139. SQLDataException sQLDataException = new SQLDataException(
  140. "MYTESTSTRING1", "MYTESTSTRING2", 0);
  141. assertNotNull(sQLDataException);
  142. assertEquals(
  143. "The SQLState of SQLDataException set and get should be equivalent",
  144. "MYTESTSTRING2", sQLDataException.getSQLState());
  145. assertEquals(
  146. "The reason of SQLDataException set and get should be equivalent",
  147. "MYTESTSTRING1", sQLDataException.getMessage());
  148. assertEquals("The error code of SQLDataException should be 0",
  149. sQLDataException.getErrorCode(), 0);
  150. }
  151. /**
  152. * @test java.sql.SQLDataException(String, String, int)
  153. */
  154. public void test_Constructor_LStringLStringI_2() {
  155. SQLDataException sQLDataException = new SQLDataException(
  156. "MYTESTSTRING1", "MYTESTSTRING2", -1);
  157. assertNotNull(sQLDataException);
  158. assertEquals(
  159. "The SQLState of SQLDataException set and get should be equivalent",
  160. "MYTESTSTRING2", sQLDataException.getSQLState());
  161. assertEquals(
  162. "The reason of SQLDataException set and get should be equivalent",
  163. "MYTESTSTRING1", sQLDataException.getMessage());
  164. assertEquals("The error code of SQLDataException should be -1",
  165. sQLDataException.getErrorCode(), -1);
  166. }
  167. /**
  168. * @test java.sql.SQLDataException(String, String, int)
  169. */
  170. public void test_Constructor_LStringLStringI_3() {
  171. SQLDataException sQLDataException = new SQLDataException(
  172. "MYTESTSTRING", null, 1);
  173. assertNotNull(sQLDataException);
  174. assertNull("The SQLState of SQLDataException should be null",
  175. sQLDataException.getSQLState());
  176. assertEquals(
  177. "The reason of SQLDataException set and get should be equivalent",
  178. "MYTESTSTRING", sQLDataException.getMessage());
  179. assertEquals("The error code of SQLDataException should be 1",
  180. sQLDataException.getErrorCode(), 1);
  181. }
  182. /**
  183. * @test java.sql.SQLDataException(String, String, int)
  184. */
  185. public void test_Constructor_LStringLStringI_4() {
  186. SQLDataException sQLDataException = new SQLDataException(
  187. "MYTESTSTRING", null, 0);
  188. assertNotNull(sQLDataException);
  189. assertNull("The SQLState of SQLDataException should be null",
  190. sQLDataException.getSQLState());
  191. assertEquals(
  192. "The reason of SQLDataException set and get should be equivalent",
  193. "MYTESTSTRING", sQLDataException.getMessage());
  194. assertEquals("The error code of SQLDataException should be 0",
  195. sQLDataException.getErrorCode(), 0);
  196. }
  197. /**
  198. * @test java.sql.SQLDataException(String, String, int)
  199. */
  200. public void test_Constructor_LStringLStringI_5() {
  201. SQLDataException sQLDataException = new SQLDataException(
  202. "MYTESTSTRING", null, -1);
  203. assertNotNull(sQLDataException);
  204. assertNull("The SQLState of SQLDataException should be null",
  205. sQLDataException.getSQLState());
  206. assertEquals(
  207. "The reason of SQLDataException set and get should be equivalent",
  208. "MYTESTSTRING", sQLDataException.getMessage());
  209. assertEquals("The error code of SQLDataException should be -1",
  210. sQLDataException.getErrorCode(), -1);
  211. }
  212. /**
  213. * @test java.sql.SQLDataException(String, String, int)
  214. */
  215. public void test_Constructor_LStringLStringI_6() {
  216. SQLDataException sQLDataException = new SQLDataException(null,
  217. "MYTESTSTRING", 1);
  218. assertNotNull(sQLDataException);
  219. assertEquals(
  220. "The SQLState of SQLDataException set and get should be equivalent",
  221. "MYTESTSTRING", sQLDataException.getSQLState());
  222. assertNull("The reason of SQLDataException should be null",
  223. sQLDataException.getMessage());
  224. assertEquals("The error code of SQLDataException should be 1",
  225. sQLDataException.getErrorCode(), 1);
  226. }
  227. /**
  228. * @test java.sql.SQLDataException(String, String, int)
  229. */
  230. public void test_Constructor_LStringLStringI_7() {
  231. SQLDataException sQLDataException = new SQLDataException(null,
  232. "MYTESTSTRING", 0);
  233. assertNotNull(sQLDataException);
  234. assertEquals(
  235. "The SQLState of SQLDataException set and get should be equivalent",
  236. "MYTESTSTRING", sQLDataException.getSQLState());
  237. assertNull("The reason of SQLDataException should be null",
  238. sQLDataException.getMessage());
  239. assertEquals("The error code of SQLDataException should be 0",
  240. sQLDataException.getErrorCode(), 0);
  241. }
  242. /**
  243. * @test java.sql.SQLDataException(String, String, int)
  244. */
  245. public void test_Constructor_LStringLStringI_8() {
  246. SQLDataException sQLDataException = new SQLDataException(null,
  247. "MYTESTSTRING", -1);
  248. assertNotNull(sQLDataException);
  249. assertEquals(
  250. "The SQLState of SQLDataException set and get should be equivalent",
  251. "MYTESTSTRING", sQLDataException.getSQLState());
  252. assertNull("The reason of SQLDataException should be null",
  253. sQLDataException.getMessage());
  254. assertEquals("The error code of SQLDataException should be -1",
  255. sQLDataException.getErrorCode(), -1);
  256. }
  257. /**
  258. * @test java.sql.SQLDataException(String, String, int)
  259. */
  260. public void test_Constructor_LStringLStringI_9() {
  261. SQLDataException sQLDataException = new SQLDataException(null, null, 1);
  262. assertNotNull(sQLDataException);
  263. assertNull("The SQLState of SQLDataException should be null",
  264. sQLDataException.getSQLState());
  265. assertNull("The reason of SQLDataException should be null",
  266. sQLDataException.getMessage());
  267. assertEquals("The error code of SQLDataException should be 1",
  268. sQLDataException.getErrorCode(), 1);
  269. }
  270. /**
  271. * @test java.sql.SQLDataException(String, String, int)
  272. */
  273. public void test_Constructor_LStringLStringI_10() {
  274. SQLDataException sQLDataException = new SQLDataException(null, null, 0);
  275. assertNotNull(sQLDataException);
  276. assertNull("The SQLState of SQLDataException should be null",
  277. sQLDataException.getSQLState());
  278. assertNull("The reason of SQLDataException should be null",
  279. sQLDataException.getMessage());
  280. assertEquals("The error code of SQLDataException should be 0",
  281. sQLDataException.getErrorCode(), 0);
  282. }
  283. /**
  284. * @test java.sql.SQLDataException(String, String, int)
  285. */
  286. public void test_Constructor_LStringLStringI_11() {
  287. SQLDataException sQLDataException = new SQLDataException(null, null, -1);
  288. assertNotNull(sQLDataException);
  289. assertNull("The SQLState of SQLDataException should be null",
  290. sQLDataException.getSQLState());
  291. assertNull("The reason of SQLDataException should be null",
  292. sQLDataException.getMessage());
  293. assertEquals("The error code of SQLDataException should be -1",
  294. sQLDataException.getErrorCode(), -1);
  295. }
  296. /**
  297. * @test java.sql.SQLDataException(Throwable)
  298. */
  299. public void test_Constructor_LThrowable() {
  300. Throwable cause = new Exception("MYTHROWABLE");
  301. SQLDataException sQLDataException = new SQLDataException(cause);
  302. assertNotNull(sQLDataException);
  303. assertEquals(
  304. "The reason of SQLDataException should be equals to cause.toString()",
  305. "java.lang.Exception: MYTHROWABLE", sQLDataException
  306. .getMessage());
  307. assertNull("The SQLState of SQLDataException should be null",
  308. sQLDataException.getSQLState());
  309. assertEquals("The error code of SQLDataException should be 0",
  310. sQLDataException.getErrorCode(), 0);
  311. assertEquals(
  312. "The cause of SQLDataException set and get should be equivalent",
  313. cause, sQLDataException.getCause());
  314. }
  315. /**
  316. * @test java.sql.SQLDataException(Throwable)
  317. */
  318. public void test_Constructor_LThrowable_1() {
  319. SQLDataException sQLDataException = new SQLDataException(
  320. (Throwable) null);
  321. assertNotNull(sQLDataException);
  322. assertNull("The SQLState of SQLDataException should be null",
  323. sQLDataException.getSQLState());
  324. assertNull("The reason of SQLDataException should be null",
  325. sQLDataException.getMessage());
  326. assertEquals("The error code of SQLDataException should be 0",
  327. sQLDataException.getErrorCode(), 0);
  328. assertNull("The cause of SQLDataException should be null",
  329. sQLDataException.getCause());
  330. }
  331. /**
  332. * @test java.sql.SQLDataException(String, Throwable)
  333. */
  334. public void test_Constructor_LStringLThrowable() {
  335. Throwable cause = new Exception("MYTHROWABLE");
  336. SQLDataException sQLDataException = new SQLDataException(
  337. "MYTESTSTRING", cause);
  338. assertNotNull(sQLDataException);
  339. assertEquals(
  340. "The reason of SQLDataException set and get should be equivalent",
  341. "MYTESTSTRING", sQLDataException.getMessage());
  342. assertNull("The SQLState of SQLDataException should be null",
  343. sQLDataException.getSQLState());
  344. assertEquals("The error code of SQLDataException should be 0",
  345. sQLDataException.getErrorCode(), 0);
  346. assertEquals(
  347. "The cause of SQLDataException set and get should be equivalent",
  348. cause, sQLDataException.getCause());
  349. }
  350. /**
  351. * @test java.sql.SQLDataException(String, Throwable)
  352. */
  353. public void test_Constructor_LStringLThrowable_1() {
  354. SQLDataException sQLDataException = new SQLDataException(
  355. "MYTESTSTRING", (Throwable) null);
  356. assertNotNull(sQLDataException);
  357. assertEquals(
  358. "The reason of SQLDataException set and get should be equivalent",
  359. "MYTESTSTRING", sQLDataException.getMessage());
  360. assertNull("The SQLState of SQLDataException should be null",
  361. sQLDataException.getSQLState());
  362. assertEquals("The error code of SQLDataException should be 0",
  363. sQLDataException.getErrorCode(), 0);
  364. assertNull("The cause of SQLDataException should be null",
  365. sQLDataException.getCause());
  366. }
  367. /**
  368. * @test java.sql.SQLDataException(String, Throwable)
  369. */
  370. public void test_Constructor_LStringLThrowable_2() {
  371. Throwable cause = new Exception("MYTHROWABLE");
  372. SQLDataException sQLDataException = new SQLDataException(null, cause);
  373. assertNotNull(sQLDataException);
  374. assertNull("The reason of SQLDataException should be null",
  375. sQLDataException.getMessage());
  376. assertNull("The SQLState of SQLDataException should be null",
  377. sQLDataException.getSQLState());
  378. assertEquals("The error code of SQLDataException should be 0",
  379. sQLDataException.getErrorCode(), 0);
  380. }
  381. /**
  382. * @test java.sql.SQLDataException(String, Throwable)
  383. */
  384. public void test_Constructor_LStringLThrowable_3() {
  385. SQLDataException sQLDataException = new SQLDataException((String) null,
  386. (Throwable) null);
  387. assertNotNull(sQLDataException);
  388. assertNull("The SQLState of SQLDataException should be null",
  389. sQLDataException.getSQLState());
  390. assertNull("The reason of SQLDataException should be null",
  391. sQLDataException.getMessage());
  392. assertEquals("The error code of SQLDataException should be 0",
  393. sQLDataException.getErrorCode(), 0);
  394. assertNull("The cause of SQLDataException should be null",
  395. sQLDataException.getCause());
  396. }
  397. /**
  398. * @test java.sql.SQLDataException(String, String, Throwable)
  399. */
  400. public void test_Constructor_LStringLStringLThrowable() {
  401. Throwable cause = new Exception("MYTHROWABLE");
  402. SQLDataException sQLDataException = new SQLDataException(
  403. "MYTESTSTRING1", "MYTESTSTRING2", cause);
  404. assertNotNull(sQLDataException);
  405. assertEquals(
  406. "The SQLState of SQLDataException set and get should be equivalent",
  407. "MYTESTSTRING2", sQLDataException.getSQLState());
  408. assertEquals(
  409. "The reason of SQLDataException set and get should be equivalent",
  410. "MYTESTSTRING1", sQLDataException.getMessage());
  411. assertEquals("The error code of SQLDataException should be 0",
  412. sQLDataException.getErrorCode(), 0);
  413. assertEquals(
  414. "The cause of SQLDataException set and get should be equivalent",
  415. cause, sQLDataException.getCause());
  416. }
  417. /**
  418. * @test java.sql.SQLDataException(String, String, Throwable)
  419. */
  420. public void test_Constructor_LStringLStringLThrowable_1() {
  421. SQLDataException sQLDataException = new SQLDataException(
  422. "MYTESTSTRING1", "MYTESTSTRING2", null);
  423. assertNotNull(sQLDataException);
  424. assertEquals(
  425. "The SQLState of SQLDataException set and get should be equivalent",
  426. "MYTESTSTRING2", sQLDataException.getSQLState());
  427. assertEquals(
  428. "The reason of SQLDataException set and get should be equivalent",
  429. "MYTESTSTRING1", sQLDataException.getMessage());
  430. assertEquals("The error code of SQLDataException should be 0",
  431. sQLDataException.getErrorCode(), 0);
  432. assertNull("The cause of SQLDataException should be null",
  433. sQLDataException.getCause());
  434. }
  435. /**
  436. * @test java.sql.SQLDataException(String, String, Throwable)
  437. */
  438. public void test_Constructor_LStringLStringLThrowable_2() {
  439. Throwable cause = new Exception("MYTHROWABLE");
  440. SQLDataException sQLDataException = new SQLDataException(
  441. "MYTESTSTRING", null, cause);
  442. assertNotNull(sQLDataException);
  443. assertNull("The SQLState of SQLDataException should be null",
  444. sQLDataException.getSQLState());
  445. assertEquals(
  446. "The reason of SQLDataException set and get should be equivalent",
  447. "MYTESTSTRING", sQLDataException.getMessage());
  448. assertEquals("The error code of SQLDataException should be 0",
  449. sQLDataException.getErrorCode(), 0);
  450. assertEquals(
  451. "The cause of SQLDataException set and get should be equivalent",
  452. cause, sQLDataException.getCause());
  453. }
  454. /**
  455. * @test java.sql.SQLDataException(String, String, Throwable)
  456. */
  457. public void test_Constructor_LStringLStringLThrowable_3() {
  458. SQLDataException sQLDataException = new SQLDataException(
  459. "MYTESTSTRING", null, null);
  460. assertNotNull(sQLDataException);
  461. assertNull("The SQLState of SQLDataException should be null",
  462. sQLDataException.getSQLState());
  463. assertEquals(
  464. "The reason of SQLDataException set and get should be equivalent",
  465. "MYTESTSTRING", sQLDataException.getMessage());
  466. assertEquals("The error code of SQLDataException should be 0",
  467. sQLDataException.getErrorCode(), 0);
  468. assertNull("The cause of SQLDataException should be null",
  469. sQLDataException.getCause());
  470. }
  471. /**
  472. * @test java.sql.SQLDataException(String, String, Throwable)
  473. */
  474. public void test_Constructor_LStringLStringLThrowable_4() {
  475. Throwable cause = new Exception("MYTHROWABLE");
  476. SQLDataException sQLDataException = new SQLDataException(null,
  477. "MYTESTSTRING", cause);
  478. assertNotNull(sQLDataException);
  479. assertEquals(
  480. "The SQLState of SQLDataException set and get should be equivalent",
  481. "MYTESTSTRING", sQLDataException.getSQLState());
  482. assertNull("The reason of SQLDataException should be null",
  483. sQLDataException.getMessage());
  484. assertEquals("The error code of SQLDataException should be 0",
  485. sQLDataException.getErrorCode(), 0);
  486. assertEquals(
  487. "The cause of SQLDataException set and get should be equivalent",
  488. cause, sQLDataException.getCause());
  489. }
  490. /**
  491. * @test java.sql.SQLDataException(String, String, Throwable)
  492. */
  493. public void test_Constructor_LStringLStringLThrowable_5() {
  494. SQLDataException sQLDataException = new SQLDataException(null,
  495. "MYTESTSTRING", null);
  496. assertNotNull(sQLDataException);
  497. assertEquals(
  498. "The SQLState of SQLDataException set and get should be equivalent",
  499. "MYTESTSTRING", sQLDataException.getSQLState());
  500. assertNull("The reason of SQLDataException should be null",
  501. sQLDataException.getMessage());
  502. assertEquals("The error code of SQLDataException should be 0",
  503. sQLDataException.getErrorCode(), 0);
  504. assertNull("The cause of SQLDataException should be null",
  505. sQLDataException.getCause());
  506. }
  507. /**
  508. * @test java.sql.SQLDataException(String, String, Throwable)
  509. */
  510. public void test_Constructor_LStringLStringLThrowable_6() {
  511. Throwable cause = new Exception("MYTHROWABLE");
  512. SQLDataException sQLDataException = new SQLDataException(null, null,
  513. cause);
  514. assertNotNull(sQLDataException);
  515. assertNull("The SQLState of SQLDataException should be null",
  516. sQLDataException.getSQLState());
  517. assertNull("The reason of SQLDataException should be null",
  518. sQLDataException.getMessage());
  519. assertEquals("The error code of SQLDataException should be 0",
  520. sQLDataException.getErrorCode(), 0);
  521. assertEquals(
  522. "The cause of SQLDataException set and get should be equivalent",
  523. cause, sQLDataException.getCause());
  524. }
  525. /**
  526. * @test java.sql.SQLDataException(String, String, Throwable)
  527. */
  528. public void test_Constructor_LStringLStringLThrowable_7() {
  529. SQLDataException sQLDataException = new SQLDataException(null, null,
  530. null);
  531. assertNotNull(sQLDataException);
  532. assertNull("The SQLState of SQLDataException should be null",
  533. sQLDataException.getSQLState());
  534. assertNull("The reason of SQLDataException should be null",
  535. sQLDataException.getMessage());
  536. assertEquals("The error code of SQLDataException should be 0",
  537. sQLDataException.getErrorCode(), 0);
  538. assertNull("The cause of SQLDataException should be null",
  539. sQLDataException.getCause());
  540. }
  541. /**
  542. * @test java.sql.SQLDataException(String, String, int, Throwable)
  543. */
  544. public void test_Constructor_LStringLStringILThrowable() {
  545. Throwable cause = new Exception("MYTHROWABLE");
  546. SQLDataException sQLDataException = new SQLDataException(
  547. "MYTESTSTRING1", "MYTESTSTRING2", 1, cause);
  548. assertNotNull(sQLDataException);
  549. assertEquals(
  550. "The SQLState of SQLDataException set and get should be equivalent",
  551. "MYTESTSTRING2", sQLDataException.getSQLState());
  552. assertEquals(
  553. "The reason of SQLDataException set and get should be equivalent",
  554. "MYTESTSTRING1", sQLDataException.getMessage());
  555. assertEquals("The error code of SQLDataException should be 1",
  556. sQLDataException.getErrorCode(), 1);
  557. assertEquals(
  558. "The cause of SQLDataException set and get should be equivalent",
  559. cause, sQLDataException.getCause());
  560. }
  561. /**
  562. * @test java.sql.SQLDataException(String, String, int, Throwable)
  563. */
  564. public void test_Constructor_LStringLStringILThrowable_1() {
  565. SQLDataException sQLDataException = new SQLDataException(
  566. "MYTESTSTRING1", "MYTESTSTRING2", 1, null);
  567. assertNotNull(sQLDataException);
  568. assertEquals(
  569. "The SQLState of SQLDataException set and get should be equivalent",
  570. "MYTESTSTRING2", sQLDataException.getSQLState());
  571. assertEquals(
  572. "The reason of SQLDataException set and get should be equivalent",
  573. "MYTESTSTRING1", sQLDataException.getMessage());
  574. assertEquals("The error code of SQLDataException should be 1",
  575. sQLDataException.getErrorCode(), 1);
  576. assertNull("The cause of SQLDataException should be null",
  577. sQLDataException.getCause());
  578. }
  579. /**
  580. * @test java.sql.SQLDataException(String, String, int, Throwable)
  581. */
  582. public void test_Constructor_LStringLStringILThrowable_2() {
  583. Throwable cause = new Exception("MYTHROWABLE");
  584. SQLDataException sQLDataException = new SQLDataException(
  585. "MYTESTSTRING1", "MYTESTSTRING2", 0, cause);
  586. assertNotNull(sQLDataException);
  587. assertEquals(
  588. "The SQLState of SQLDataException set and get should be equivalent",
  589. "MYTESTSTRING2", sQLDataException.getSQLState());
  590. assertEquals(
  591. "The reason of SQLDataException set and get should be equivalent",
  592. "MYTESTSTRING1", sQLDataException.getMessage());
  593. assertEquals("The error code of SQLDataException should be 0",
  594. sQLDataException.getErrorCode(), 0);
  595. assertEquals(
  596. "The cause of SQLDataException set and get should be equivalent",
  597. cause, sQLDataException.getCause());
  598. }
  599. /**
  600. * @test java.sql.SQLDataException(String, String, int, Throwable)
  601. */
  602. public void test_Constructor_LStringLStringILThrowable_3() {
  603. SQLDataException sQLDataException = new SQLDataException(
  604. "MYTESTSTRING1", "MYTESTSTRING2", 0, null);
  605. assertNotNull(sQLDataException);
  606. assertEquals(
  607. "The SQLState of SQLDataException set and get should be equivalent",
  608. "MYTESTSTRING2", sQLDataException.getSQLState());
  609. assertEquals(
  610. "The reason of SQLDataException set and get should be equivalent",
  611. "MYTESTSTRING1", sQLDataException.getMessage());
  612. assertEquals("The error code of SQLDataException should be 0",
  613. sQLDataException.getErrorCode(), 0);
  614. assertNull("The cause of SQLDataException should be null",
  615. sQLDataException.getCause());
  616. }
  617. /**
  618. * @test java.sql.SQLDataException(String, String, int, Throwable)
  619. */
  620. public void test_Constructor_LStringLStringILThrowable_4() {
  621. Throwable cause = new Exception("MYTHROWABLE");
  622. SQLDataException sQLDataException = new SQLDataException(
  623. "MYTESTSTRING1", "MYTESTSTRING2", -1, cause);
  624. assertNotNull(sQLDataException);
  625. assertEquals(
  626. "The SQLState of SQLDataException set and get should be equivalent",
  627. "MYTESTSTRING2", sQLDataException.getSQLState());
  628. assertEquals(
  629. "The reason of SQLDataException set and get should be equivalent",
  630. "MYTESTSTRING1", sQLDataException.getMessage());
  631. assertEquals("The error code of SQLDataException should be -1",
  632. sQLDataException.getErrorCode(), -1);
  633. assertEquals(
  634. "The cause of SQLDataException set and get should be equivalent",
  635. cause, sQLDataException.getCause());
  636. }
  637. /**
  638. * @test java.sql.SQLDataException(String, String, int, Throwable)
  639. */
  640. public void test_Constructor_LStringLStringILThrowable_5() {
  641. SQLDataException sQLDataException = new SQLDataException(
  642. "MYTESTSTRING1", "MYTESTSTRING2", -1, null);
  643. assertNotNull(sQLDataException);
  644. assertEquals(
  645. "The SQLState of SQLDataException set and get should be equivalent",
  646. "MYTESTSTRING2", sQLDataException.getSQLState());
  647. assertEquals(
  648. "The reason of SQLDataException set and get should be equivalent",
  649. "MYTESTSTRING1", sQLDataException.getMessage());
  650. assertEquals("The error code of SQLDataException should be -1",
  651. sQLDataException.getErrorCode(), -1);
  652. assertNull("The cause of SQLDataException should be null",
  653. sQLDataException.getCause());
  654. }
  655. /**
  656. * @test java.sql.SQLDataException(String, String, int, Throwable)
  657. */
  658. public void test_Constructor_LStringLStringILThrowable_6() {
  659. Throwable cause = new Exception("MYTHROWABLE");
  660. SQLDataException sQLDataException = new SQLDataException(
  661. "MYTESTSTRING", null, 1, cause);
  662. assertNotNull(sQLDataException);
  663. assertNull("The SQLState of SQLDataException should be null",
  664. sQLDataException.getSQLState());
  665. assertEquals(
  666. "The reason of SQLDataException set and get should be equivalent",
  667. "MYTESTSTRING", sQLDataException.getMessage());
  668. assertEquals("The error code of SQLDataException should be 1",
  669. sQLDataException.getErrorCode(), 1);
  670. assertEquals(
  671. "The cause of SQLDataException set and get should be equivalent",
  672. cause, sQLDataException.getCause());
  673. }
  674. /**
  675. * @test java.sql.SQLDataException(String, String, int, Throwable)
  676. */
  677. public void test_Constructor_LStringLStringILThrowable_7() {
  678. SQLDataException sQLDataException = new SQLDataException(
  679. "MYTESTSTRING", null, 1, null);
  680. assertNotNull(sQLDataException);
  681. assertNotNull(sQLDataException);
  682. assertNull("The SQLState of SQLDataException should be null",
  683. sQLDataException.getSQLState());
  684. assertEquals(
  685. "The reason of SQLDataException set and get should be equivalent",
  686. "MYTESTSTRING", sQLDataException.getMessage());
  687. assertEquals("The error code of SQLDataException should be 1",
  688. sQLDataException.getErrorCode(), 1);
  689. assertNull("The cause of SQLDataException should be null",
  690. sQLDataException.getCause());
  691. }
  692. /**
  693. * @test java.sql.SQLDataException(String, String, int, Throwable)
  694. */
  695. public void test_Constructor_LStringLStringILThrowable_8() {
  696. Throwable cause = new Exception("MYTHROWABLE");
  697. SQLDataException sQLDataException = new SQLDataException(
  698. "MYTESTSTRING", null, 0, cause);
  699. assertNotNull(sQLDataException);
  700. assertNull("The SQLState of SQLDataException should be null",
  701. sQLDataException.getSQLState());
  702. assertEquals(
  703. "The reason of SQLDataException set and get should be equivalent",
  704. "MYTESTSTRING", sQLDataException.getMessage());
  705. assertEquals("The error code of SQLDataException should be 0",
  706. sQLDataException.getErrorCode(), 0);
  707. assertEquals(
  708. "The cause of SQLDataException set and get should be equivalent",
  709. cause, sQLDataException.getCause());
  710. }
  711. /**
  712. * @test java.sql.SQLDataException(String, String, int, Throwable)
  713. */
  714. public void test_Constructor_LStringLStringILThrowable_9() {
  715. SQLDataException sQLDataException = new SQLDataException(
  716. "MYTESTSTRING", null, 0, null);
  717. assertNotNull(sQLDataException);
  718. assertNull("The SQLState of SQLDataException should be null",
  719. sQLDataException.getSQLState());
  720. assertEquals(
  721. "The reason of SQLDataException set and get should be equivalent",
  722. "MYTESTSTRING", sQLDataException.getMessage());
  723. assertEquals("The error code of SQLDataException should be 0",
  724. sQLDataException.getErrorCode(), 0);
  725. assertNull("The cause of SQLDataException should be null",
  726. sQLDataException.getCause());
  727. }
  728. /**
  729. * @test java.sql.SQLDataException(String, String, int, Throwable)
  730. */
  731. public void test_Constructor_LStringLStringILThrowable_10() {
  732. Throwable cause = new Exception("MYTHROWABLE");
  733. SQLDataException sQLDataException = new SQLDataException(
  734. "MYTESTSTRING", null, -1, cause);
  735. assertNotNull(sQLDataException);
  736. assertNull("The SQLState of SQLDataException should be null",
  737. sQLDataException.getSQLState());
  738. assertEquals(
  739. "The reason of SQLDataException set and get should be equivalent",
  740. "MYTESTSTRING", sQLDataException.getMessage());
  741. assertEquals("The error code of SQLDataException should be -1",
  742. sQLDataException.getErrorCode(), -1);
  743. assertEquals(
  744. "The cause of SQLDataException set and get should be equivalent",
  745. cause, sQLDataException.getCause());
  746. }
  747. /**
  748. * @test java.sql.SQLDataException(String, String, int, Throwable)
  749. */
  750. public void test_Constructor_LStringLStringILThrowable_11() {
  751. SQLDataException sQLDataException = new SQLDataException(
  752. "MYTESTSTRING", null, -1, null);
  753. assertNotNull(sQLDataException);
  754. assertNull("The SQLState of SQLDataException should be null",
  755. sQLDataException.getSQLState());
  756. assertEquals(
  757. "The reason of SQLDataException set and get should be equivalent",
  758. "MYTESTSTRING", sQLDataException.getMessage());
  759. assertEquals("The error code of SQLDataException should be -1",
  760. sQLDataException.getErrorCode(), -1);
  761. assertNull("The cause of SQLDataException should be null",
  762. sQLDataException.getCause());
  763. }
  764. /**
  765. * @test java.sql.SQLDataException(String, String, int, Throwable)
  766. */
  767. public void test_Constructor_LStringLStringILThrowable_12() {
  768. Throwable cause = new Exception("MYTHROWABLE");
  769. SQLDataException sQLDataException = new SQLDataException(null,
  770. "MYTESTSTRING", 1, cause);
  771. assertNotNull(sQLDataException);
  772. assertEquals(
  773. "The SQLState of SQLDataException set and get should be equivalent",
  774. "MYTESTSTRING", sQLDataException.getSQLState());
  775. assertNull("The reason of SQLDataException should be null",
  776. sQLDataException.getMessage());
  777. assertEquals("The error code of SQLDataException should be 1",
  778. sQLDataException.getErrorCode(), 1);
  779. assertEquals(
  780. "The cause of SQLDataException set and get should be equivalent",
  781. cause, sQLDataException.getCause());
  782. }
  783. /**
  784. * @test java.sql.SQLDataException(String, String, int, Throwable)
  785. */
  786. public void test_Constructor_LStringLStringILThrowable_13() {
  787. SQLDataException sQLDataException = new SQLDataException(null,
  788. "MYTESTSTRING", 1, null);
  789. assertNotNull(sQLDataException);
  790. assertEquals(
  791. "The SQLState of SQLDataException set and get should be equivalent",
  792. "MYTESTSTRING", sQLDataException.getSQLState());
  793. assertNull("The reason of SQLDataException should be null",
  794. sQLDataException.getMessage());
  795. assertEquals("The error code of SQLDataException should be 1",
  796. sQLDataException.getErrorCode(), 1);
  797. assertNull("The cause of SQLDataException should be null",
  798. sQLDataException.getCause());
  799. }
  800. /**
  801. * @test java.sql.SQLDataException(String, String, int, Throwable)
  802. */
  803. public void test_Constructor_LStringLStringILThrowable_14() {
  804. Throwable cause = new Exception("MYTHROWABLE");
  805. SQLDataException sQLDataException = new SQLDataException(null,
  806. "MYTESTSTRING", 0, cause);
  807. assertNotNull(sQLDataException);
  808. assertEquals(
  809. "The SQLState of SQLDataException set and get should be equivalent",
  810. "MYTESTSTRING", sQLDataException.getSQLState());
  811. assertNull("The reason of SQLDataException should be null",
  812. sQLDataException.getMessage());
  813. assertEquals("The error code of SQLDataException should be 0",
  814. sQLDataException.getErrorCode(), 0);
  815. assertEquals(
  816. "The cause of SQLDataException set and get should be equivalent",
  817. cause, sQLDataException.getCause());
  818. }
  819. /**
  820. * @test java.sql.SQLDataException(String, String, int, Throwable)
  821. */
  822. public void test_Constructor_LStringLStringILThrowable_15() {
  823. SQLDataException sQLDataException = new SQLDataException(null,
  824. "MYTESTSTRING", 0, null);
  825. assertNotNull(sQLDataException);
  826. assertEquals(
  827. "The SQLState of SQLDataException set and get should be equivalent",
  828. "MYTESTSTRING", sQLDataException.getSQLState());
  829. assertNull("The reason of SQLDataException should be null",
  830. sQLDataException.getMessage());
  831. assertEquals("The error code of SQLDataException should be 0",
  832. sQLDataException.getErrorCode(), 0);
  833. assertNull("The cause of SQLDataException should be null",
  834. sQLDataException.getCause());
  835. }
  836. /**
  837. * @test java.sql.SQLDataException(String, String, int, Throwable)
  838. */
  839. public void test_Constructor_LStringLStringILThrowable_16() {
  840. Throwable cause = new Exception("MYTHROWABLE");
  841. SQLDataException sQLDataException = new SQLDataException(null,
  842. "MYTESTSTRING", -1, cause);
  843. assertNotNull(sQLDataException);
  844. assertEquals(
  845. "The SQLState of SQLDataException set and get should be equivalent",
  846. "MYTESTSTRING", sQLDataException.getSQLState());
  847. assertNull("The reason of SQLDataException should be null",
  848. sQLDataException.getMessage());
  849. assertEquals("The error code of SQLDataException should be -1",
  850. sQLDataException.getErrorCode(), -1);
  851. assertEquals(
  852. "The cause of SQLDataException set and get should be equivalent",
  853. cause, sQLDataException.getCause());
  854. }
  855. /**
  856. * @test java.sql.SQLDataException(String, String, int, Throwable)
  857. */
  858. public void test_Constructor_LStringLStringILThrowable_17() {
  859. SQLDataException sQLDataException = new SQLDataException(null,
  860. "MYTESTSTRING", -1, null);
  861. assertNotNull(sQLDataException);
  862. assertEquals(
  863. "The SQLState of SQLDataException set and get should be equivalent",
  864. "MYTESTSTRING", sQLDataException.getSQLState());
  865. assertNull("The reason of SQLDataException should be null",
  866. sQLDataException.getMessage());
  867. assertEquals("The error code of SQLDataException should be -1",
  868. sQLDataException.getErrorCode(), -1);
  869. assertNull("The cause of SQLDataException should be null",
  870. sQLDataException.getCause());
  871. }
  872. /**
  873. * @test java.sql.SQLDataException(String, String, int, Throwable)
  874. */
  875. public void test_Constructor_LStringLStringILThrowable_18() {
  876. Throwable cause = new Exception("MYTHROWABLE");
  877. SQLDataException sQLDataException = new SQLDataException(null, null, 1,
  878. cause);
  879. assertNotNull(sQLDataException);
  880. assertNull("The SQLState of SQLDataException should be null",
  881. sQLDataException.getSQLState());
  882. assertNull("The reason of SQLDataException should be null",
  883. sQLDataException.getMessage());
  884. assertEquals("The error code of SQLDataException should be 1",
  885. sQLDataException.getErrorCode(), 1);
  886. assertEquals(
  887. "The cause of SQLDataException set and get should be equivalent",
  888. cause, sQLDataException.getCause());
  889. }
  890. /**
  891. * @test java.sql.SQLDataException(String, String, int, Throwable)
  892. */
  893. public void test_Constructor_LStringLStringILThrowable_19() {
  894. SQLDataException sQLDataException = new SQLDataException(null, null, 1,
  895. null);
  896. assertNotNull(sQLDataException);
  897. assertNull("The SQLState of SQLDataException should be null",
  898. sQLDataException.getSQLState());
  899. assertNull("The reason of SQLDataException should be null",
  900. sQLDataException.getMessage());
  901. assertEquals("The error code of SQLDataException should be 1",
  902. sQLDataException.getErrorCode(), 1);
  903. assertNull("The cause of SQLDataException should be null",
  904. sQLDataException.getCause());
  905. }
  906. /**
  907. * @test java.sql.SQLDataException(String, String, int, Throwable)
  908. */
  909. public void test_Constructor_LStringLStringILThrowable_20() {
  910. Throwable cause = new Exception("MYTHROWABLE");
  911. SQLDataException sQLDataException = new SQLDataException(null, null, 0,
  912. cause);
  913. assertNotNull(sQLDataException);
  914. assertNull("The SQLState of SQLDataException should be null",
  915. sQLDataException.getSQLState());
  916. assertNull("The reason of SQLDataException should be null",
  917. sQLDataException.getMessage());
  918. assertEquals("The error code of SQLDataException should be 0",
  919. sQLDataException.getErrorCode(), 0);
  920. assertEquals(
  921. "The cause of SQLDataException set and get should be equivalent",
  922. cause, sQLDataException.getCause());
  923. }
  924. /**
  925. * @test java.sql.SQLDataException(String, String, int, Throwable)
  926. */
  927. public void test_Constructor_LStringLStringILThrowable_21() {
  928. SQLDataException sQLDataException = new SQLDataException(null, null, 0,
  929. null);
  930. assertNotNull(sQLDataException);
  931. assertNull("The SQLState of SQLDataException should be null",
  932. sQLDataException.getSQLState());
  933. assertNull("The reason of SQLDataException should be null",
  934. sQLDataException.getMessage());
  935. assertEquals("The error code of SQLDataException should be 0",
  936. sQLDataException.getErrorCode(), 0);
  937. assertNull("The cause of SQLDataException should be null",
  938. sQLDataException.getCause());
  939. }
  940. /**
  941. * @test java.sql.SQLDataException(String, String, int, Throwable)
  942. */
  943. public void test_Constructor_LStringLStringILThrowable_22() {
  944. Throwable cause = new Exception("MYTHROWABLE");
  945. SQLDataException sQLDataException = new SQLDataException(null, null,
  946. -1, cause);
  947. assertNotNull(sQLDataException);
  948. assertNull("The SQLState of SQLDataException should be null",
  949. sQLDataException.getSQLState());
  950. assertNull("The reason of SQLDataException should be null",
  951. sQLDataException.getMessage());
  952. assertEquals("The error code of SQLDataException should be -1",
  953. sQLDataException.getErrorCode(), -1);
  954. assertEquals(
  955. "The cause of SQLDataException set and get should be equivalent",
  956. cause, sQLDataException.getCause());
  957. }
  958. /**
  959. * @test java.sql.SQLDataException(String, String, int, Throwable)
  960. */
  961. public void test_Constructor_LStringLStringILThrowable_23() {
  962. SQLDataException sQLDataException = new SQLDataException(null, null,
  963. -1, null);
  964. assertNotNull(sQLDataException);
  965. assertNull("The SQLState of SQLDataException should be null",
  966. sQLDataException.getSQLState());
  967. assertNull("The reason of SQLDataException should be null",
  968. sQLDataException.getMessage());
  969. assertEquals("The error code of SQLDataException should be -1",
  970. sQLDataException.getErrorCode(), -1);
  971. assertNull("The cause of SQLDataException should be null",
  972. sQLDataException.getCause());
  973. }
  974. /**
  975. * @test java.sql.SQLDataException()
  976. */
  977. public void test_Constructor() {
  978. SQLDataException sQLDataException = new SQLDataException();
  979. assertNotNull(sQLDataException);
  980. assertNull("The SQLState of SQLDataException should be null",
  981. sQLDataException.getSQLState());
  982. assertNull("The reason of SQLDataException should be null",
  983. sQLDataException.getMessage());
  984. assertEquals("The error code of SQLDataException should be 0",
  985. sQLDataException.getErrorCode(), 0);
  986. }
  987. /**
  988. * @test serialization/deserialization compatibility.
  989. */
  990. public void test_serialization() throws Exception {
  991. SerializationTest.verifySelf(sQLDataException);
  992. }
  993. /**
  994. * @test serialization/deserialization compatibility with RI.
  995. */
  996. public void test_compatibilitySerialization() throws Exception {
  997. SerializationTest.verifyGolden(this, sQLDataException);
  998. }
  999. }