From 3bfd3f69411b53661949ad2594bf51f7e783d22f Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 23 Mar 2016 15:05:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=A3=E5=BA=93=E6=95=A3?= =?UTF-8?q?=E8=A1=A8=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mango/partition/TupleShardStrategyTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/jfaster/mango/partition/TupleShardStrategyTest.java b/src/test/java/org/jfaster/mango/partition/TupleShardStrategyTest.java index 5fefadbd..767652b5 100644 --- a/src/test/java/org/jfaster/mango/partition/TupleShardStrategyTest.java +++ b/src/test/java/org/jfaster/mango/partition/TupleShardStrategyTest.java @@ -33,7 +33,9 @@ import javax.sql.DataSource; import java.sql.Connection; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; @@ -65,6 +67,7 @@ public void before() throws Exception { @Test public void test() throws Exception { int price = 0; + List orders = new ArrayList(); for (int cid = 0; cid < 10; cid++) { for (int intUid = 10; intUid < 20; intUid++) { String uid = String.valueOf(intUid); @@ -75,8 +78,14 @@ public void test() throws Exception { o.setPrice(price); orderDao.insert(o); assertThat(orderDao.getOrder(cid, uid), equalTo(o)); + o.setPrice(9527); + orders.add(o); } } + orderDao.batchUpdate(orders); + for (Order o : orders) { + assertThat(orderDao.getOrder(o.getCid(), o.getUid()), equalTo(o)); + } } @DB(table = "order", dataSourceRouter = OrderShardStrategy.class, tablePartition = OrderShardStrategy.class) @@ -88,6 +97,9 @@ interface OrderDao { @SQL("select cid, uid, price from #table where cid = :1 and uid = :2") public Order getOrder(@DataSourceShardBy int cid, @TableShardBy String uid); + @SQL("update #table set price = :price where cid = :cid and uid = :uid") + public int batchUpdate(@DataSourceShardBy("cid") @TableShardBy("uid") List orders); + } static class OrderShardStrategy implements TupleShardStrategy {