lidongy
4 years ago
2 changed files with 48 additions and 0 deletions
@ -0,0 +1,40 @@
|
||||
package com.fr.third.alibaba.druid.pool; |
||||
|
||||
import com.fr.invoke.Reflect; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author lidongy |
||||
* @version 10.0 |
||||
* Created by lidongy on 2020/9/27 |
||||
*/ |
||||
public class DruidDataSourceTest { |
||||
|
||||
@Test |
||||
public void testInitException() { |
||||
DruidDataSource dataSource = new DruidDataSource(); |
||||
Reflect.on(dataSource).set("maxEvictableIdleTimeMillis", 1); |
||||
Reflect.on(dataSource).set("minEvictableIdleTimeMillis", 2); |
||||
|
||||
|
||||
boolean flag1 = false; |
||||
boolean flag2 = false; |
||||
|
||||
try { |
||||
dataSource.init(); |
||||
} catch (Exception e) { |
||||
flag1 = true; |
||||
} |
||||
|
||||
//按照以前错误的逻辑,第二次init时就不会报错
|
||||
try { |
||||
dataSource.init(); |
||||
} catch (Exception e) { |
||||
flag2 = true; |
||||
} |
||||
|
||||
Assert.assertTrue(flag1); |
||||
Assert.assertTrue(flag2); |
||||
} |
||||
} |
Loading…
Reference in new issue