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