|
17 | 17 |
|
18 | 18 | import java.math.BigDecimal; |
19 | 19 | import java.math.BigInteger; |
| 20 | +import java.sql.Array; |
20 | 21 | import java.sql.Date; |
| 22 | +import java.sql.SQLException; |
21 | 23 | import java.sql.Time; |
22 | 24 | import java.sql.Timestamp; |
23 | 25 | import java.time.LocalDate; |
|
27 | 29 | import java.util.concurrent.atomic.AtomicLong; |
28 | 30 |
|
29 | 31 | import org.assertj.db.common.AbstractTest; |
| 32 | +import org.assertj.db.common.SimpleArray; |
30 | 33 | import org.assertj.db.exception.AssertJDBException; |
31 | 34 | import org.assertj.db.type.DateTimeValue; |
32 | 35 | import org.assertj.db.type.DateValue; |
@@ -545,4 +548,30 @@ public void test_are_equal_for_datestimes() throws Exception { |
545 | 548 | public void should_fail_because_string_is_not_parseable_in_datetime() throws Exception { |
546 | 549 | Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 09:01:06.000000003")), (Object) "***"); |
547 | 550 | } |
| 551 | + |
| 552 | + /** |
| 553 | + * This method tests the {@code areEqual} method for {@code java.sql.Array}s. |
| 554 | + */ |
| 555 | + @Test |
| 556 | + public void test_are_equal_for_arrays() throws Exception { |
| 557 | + assertThat(Values.areEqual(getValue(null, (Array) null), (Array) null)).isTrue(); |
| 558 | + assertThat(Values.areEqual(getValue(null, new SimpleArray(new String[]{"value1"})), (Array) null)).isFalse(); |
| 559 | + assertThat(Values.areEqual(getValue(null, new SimpleArray(new String[]{"value1"})), new SimpleArray(new String[]{"value2"}))).isFalse(); |
| 560 | + assertThat(Values.areEqual(getValue(null, new SimpleArray(new String[]{"value1"})), new SimpleArray(new String[]{"value1"}))).isTrue(); |
| 561 | + assertThat(Values.areEqual(getValue(null, new SimpleArray(new String[]{"value1"})), new SimpleArray(new String[]{"value1", "value2"}))).isFalse(); |
| 562 | + } |
| 563 | + |
| 564 | + /** |
| 565 | + * This method should fail because the object is already closed |
| 566 | + */ |
| 567 | + @Test(expected = AssertJDBException.class) |
| 568 | + public void should_fail_because_array_not_readable() throws Exception { |
| 569 | + Array array = new SimpleArray(null) { |
| 570 | + @Override |
| 571 | + public Object getArray() throws SQLException { |
| 572 | + throw new SQLException(); |
| 573 | + } |
| 574 | + }; |
| 575 | + Values.areEqual(getValue(null, (Array) array), array); |
| 576 | + } |
548 | 577 | } |
0 commit comments