fix testcase

This commit is contained in:
astroshim 2016-10-30 23:26:50 +09:00
parent 34fe0a6773
commit 086dfdab58
2 changed files with 10 additions and 6 deletions

View file

@ -76,6 +76,8 @@ public class JDBCInterpreter extends Interpreter {
private Logger logger = LoggerFactory.getLogger(JDBCInterpreter.class);
static final String INTERPRETER_NAME = "jdbc";
static final String JDBC_DEFAULT_USER_KEY = "default.user";
static final String JDBC_DEFAULT_PASSWORD_KEY = "default.password";
static final String COMMON_KEY = "common";
static final String MAX_LINE_KEY = "max_count";
static final String MAX_LINE_DEFAULT = "1000";
@ -330,15 +332,11 @@ public class JDBCInterpreter extends Interpreter {
}
}
private boolean existAccountInProperty() {
return property.containsKey("default.user") && property.containsKey("default.password");
}
private UsernamePassword getUsernamePassword(InterpreterContext interpreterContext,
String replName) {
UserCredentials uc = interpreterContext.getAuthenticationInfo().getUserCredentials();
if (uc != null) {
return uc.existUsernamePassword(replName) ? uc.getUsernamePassword(replName) : null;
return uc.getUsernamePassword(replName);
}
return null;
}
@ -351,6 +349,11 @@ public class JDBCInterpreter extends Interpreter {
return entityName.toString();
}
private boolean existAccountInProperty() {
return property.containsKey(JDBC_DEFAULT_USER_KEY) &&
property.containsKey(JDBC_DEFAULT_PASSWORD_KEY);
}
public void setAccountOfCredential(String propertyKey, InterpreterContext interpreterContext) {
UsernamePassword usernamePassword = getUsernamePassword(interpreterContext,
getEntityName(interpreterContext.getReplName()));

View file

@ -265,11 +265,12 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
public void testMultiTenant() throws SQLException, IOException {
String replName1 = "jdbc1";
String replName2 = "jdbc2";
String entityName = "jdbc.jdbc1";
// create an user credential with replName1(entity name).
UserCredentials userCredentials = new UserCredentials();
UsernamePassword up = new UsernamePassword("user2", "pass2");
userCredentials.putUsernamePassword(replName1, up);
userCredentials.putUsernamePassword(entityName, up);
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserCredentials(userCredentials);
assertEquals(up.getUsername(), "user2");