/test/ru/adv/test/repository/test/OracleEnvironment.java
Java | 105 lines | 52 code | 16 blank | 37 comment | 2 complexity | 2f35011f633a9b946aa329d87af6af63 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0
- /* =================================================================
- Copyright (C) 2009 ADV/web-engineering All rights reserved.
- This file is part of Mozart.
- Mozart is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- Mozart is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Foobar. If not, see <http://www.gnu.org/licenses/>.
- Mozart
- http://www.mozartcms.ru
- ================================================================= */
- package ru.adv.test.repository.test;
- import ru.adv.db.DBUser;
- import ru.adv.db.adapter.DBAdapter;
- import ru.adv.db.adapter.DBAdapterException;
- import ru.adv.util.UnreachableCodeReachedException;
- /**
- * -*- java -*-
- * $Id:
- * $Name:
- * User: vic
- * Date: 18.02.2004
- * Time: 17:38:43
- */
- public class OracleEnvironment extends DBEnvironment{
- public static final String CMD_PARAM_HOST = "ora.host";
- private static final String ADMIN_PASSWD = "x3";
- private String dbPrefix;
- public OracleEnvironment(String databasesPrefix) {
- this.dbPrefix = databasesPrefix;
- }
- public String getAdapterName() {
- return "oracle";
- }
- private String getUserName(String uniqId){
- return dbPrefix + uniqId +"_" + System.getProperty("user.name");
- }
-
- @Override
- public DBInfo getDb(String name) {
- return null;
- }
- private String getName(String uniqId){
- return getUserName(uniqId)+"@orcl";
- }
- private DBInfo createDBInfo(String uniqueId) {
- try {
- return new DBInfo(getName(uniqueId), DBAdapter.create(getAdapterName()), new DBUser(getUserName(uniqueId),ADMIN_PASSWD), "".equals(uniqueId));
- }
- catch (DBAdapterException e) {
- throw new UnreachableCodeReachedException(e);
- }
- }
- public DBInfo getDb01() {
- return createDBInfo("01");
- }
- public DBInfo getDb02() {
- return createDBInfo("02");
- }
- public DBInfo getDb03() {
- return createDBInfo("03");
- }
- public DBInfo getDbRemote () {
- return createDBInfo("");
- }
- /**
- * ?????????? ???? ?? ?? ????????? ??????
- * @return
- */
- public boolean isHostSet() {
- return System.getProperty(CMD_PARAM_HOST) != null && !System.getProperty(CMD_PARAM_HOST).equals("${" + CMD_PARAM_HOST + "}");
- }
- /**
- * ???????? ????? ??
- * @return
- */
- public String getHost() {
- return System.getProperty(CMD_PARAM_HOST, "localhost");
- }
- }