mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
支持PasswordCallback
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@87 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -1,33 +1,60 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class PasswordCallbackTest extends TestCase {
|
||||
|
||||
public void test_0 () throws Exception {
|
||||
public void test_0() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mock:");
|
||||
dataSource.setPasswordCallback(new TestPasswordCallback());
|
||||
|
||||
|
||||
TestPasswordCallback passwordCallback = new TestPasswordCallback();
|
||||
dataSource.setPasswordCallback(passwordCallback);
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(dataSource.getUrl(), passwordCallback.getUrl());
|
||||
Assert.assertEquals(dataSource.getConnectionProperties(), passwordCallback.getProperties());
|
||||
}
|
||||
|
||||
public static class TestPasswordCallback extends PasswordCallback {
|
||||
public TestPasswordCallback() {
|
||||
super ("test", false);
|
||||
|
||||
private String url;
|
||||
private Properties properties;
|
||||
|
||||
public TestPasswordCallback(){
|
||||
super("test", false);
|
||||
}
|
||||
|
||||
public TestPasswordCallback(String prompt, boolean echoOn){
|
||||
super(prompt, echoOn);
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user