Browse Source

fix: #734 github: oracle pagination test case

yuxiaobin 6 years ago
parent
commit
679ffa8786

+ 8 - 1
mybatis-plus-core/build.gradle

@@ -1,3 +1,9 @@
+repositories {
+    flatDir {
+        dirs 'libs'
+    }
+}
+
 dependencies {
     compile project(":mybatis-plus-support")
     compile rootProject.ext.dependencies["jsqlparser"]
@@ -14,7 +20,7 @@ dependencies {
     }
     testCompile rootProject.ext.dependencies["sqlserver"]
     testCompile rootProject.ext.dependencies["postgresql"]
-    testCompile rootProject.ext.dependencies["oracle"]
+//    testCompile rootProject.ext.dependencies["oracle"]
     testCompile rootProject.ext.dependencies["h2"]
     testCompile rootProject.ext.dependencies["mysql"]
     testCompile rootProject.ext.dependencies["slf4j-api"]
@@ -27,4 +33,5 @@ dependencies {
     testCompile rootProject.ext.dependencies["druid"]
     testCompile rootProject.ext.dependencies["fastjson"]
     testCompile rootProject.ext.dependencies["tomcatjdbc"]
+    testCompile name: 'ojdbc-11.2.0.3-jdk16'
 }

BIN
mybatis-plus-core/libs/ojdbc-11.2.0.3-jdk16.jar


+ 11 - 1
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/test/oracle/OracleUserTest.java

@@ -10,6 +10,7 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.test.oracle.config.OracleDBConfig;
 import com.baomidou.mybatisplus.test.oracle.config.OracleMybatisPlusConfig;
 import com.baomidou.mybatisplus.test.oracle.entity.TestSequser;
@@ -55,8 +56,17 @@ public class OracleUserTest {
         sequserMapper.insert(user);
         Long id = user.getId();
         Assert.assertNotNull(id);
+    }
 
-
+    @Test
+    public void testPagination() {
+        Page<TestSequser> page = new Page<>(1, 10);
+        EntityWrapper<TestSequser> ew = new EntityWrapper<>();
+        ew.orderBy("TEST_ID");
+        List<TestSequser> list = sequserMapper.selectPage(page, ew);
+        System.out.println("Id in DB: 1,2,3,4,5,6,7,8,9,10");
+        Assert.assertEquals("Id should start from 1", 1, list.get(0).getId().longValue());
+        Assert.assertEquals("Id should end with 10", 10, list.get(9).getId().longValue());
     }
 
 }

+ 1 - 1
mybatis-plus-core/src/test/java/com/baomidou/mybatisplus/test/oracle/config/OracleDBConfig.java

@@ -26,7 +26,7 @@ public class OracleDBConfig {
     public DataSource dataSource() throws SQLException {
         SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
         dataSource.setDriver(new OracleDriver());
-        dataSource.setUrl("jdbc:oracle:thin:@192.168.10.169:1521:orcl");
+        dataSource.setUrl("jdbc:oracle:thin:@localhost:1521:orcl");
         dataSource.setUsername("sa");
         dataSource.setPassword("sa");
         return dataSource;