Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Deliberately execute problematic insert SQL `INSERT INTO t_order_item…
Browse files Browse the repository at this point in the history
…_does_not_exist (test_id_does_not_exist) VALUES (2024)`
  • Loading branch information
linghengqian committed Sep 25, 2024
1 parent 9a78f43 commit aa2365a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sdk use java 8.0.422-tem
- The unit tests execute fine.

```shell
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 14.55 s -- in com.hulalaga.ShardingSphereTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.55 s -- in com.hulalaga.ShardingSphereTest
[INFO]
[INFO] Results:
[INFO]
Expand All @@ -24,7 +24,7 @@ sdk use java 8.0.422-tem
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.956 s
[INFO] Finished at: 2024-09-25T12:06:17+08:00
[INFO] Total time: 16.236 s (Wall Clock)
[INFO] Finished at: 2024-09-25T12:25:36+08:00
[INFO] ------------------------------------------------------------------------
```
3 changes: 3 additions & 0 deletions src/test/java/com/hulalaga/ShardingSphereTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.driver.ShardingSphereDriver;
import org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -18,6 +19,7 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SuppressWarnings({"SqlNoDataSourceInspection", "resource"})
@Testcontainers
Expand Down Expand Up @@ -60,6 +62,7 @@ public void testDruidConnectionDisabled() {
IntStream.range(0, 50).forEachOrdered(i -> {
assertDoesNotThrow(() -> JDBC_TEMPLATE.execute("select ''"));
assertDoesNotThrow(() -> JDBC_TEMPLATE.execute("insert into the_table(id) values(1)"));
assertThrows(TableNotFoundException.class, () -> JDBC_TEMPLATE.execute("INSERT INTO t_order_item_does_not_exist (test_id_does_not_exist) VALUES (2024)"));
});
}
}

0 comments on commit aa2365a

Please # to comment.