PageRenderTime 25ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/test/ru/adv/test/repository/test/OracleEnvironment.java

http://mozart.googlecode.com/
Java | 105 lines | 52 code | 16 blank | 37 comment | 2 complexity | 2f35011f633a9b946aa329d87af6af63 MD5 | raw file
Possible License(s): Apache-2.0, GPL-3.0
  1. /* =================================================================
  2. Copyright (C) 2009 ADV/web-engineering All rights reserved.
  3. This file is part of Mozart.
  4. Mozart is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Mozart is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Foobar. If not, see <http://www.gnu.org/licenses/>.
  14. Mozart
  15. http://www.mozartcms.ru
  16. ================================================================= */
  17. package ru.adv.test.repository.test;
  18. import ru.adv.db.DBUser;
  19. import ru.adv.db.adapter.DBAdapter;
  20. import ru.adv.db.adapter.DBAdapterException;
  21. import ru.adv.util.UnreachableCodeReachedException;
  22. /**
  23. * -*- java -*-
  24. * $Id:
  25. * $Name:
  26. * User: vic
  27. * Date: 18.02.2004
  28. * Time: 17:38:43
  29. */
  30. public class OracleEnvironment extends DBEnvironment{
  31. public static final String CMD_PARAM_HOST = "ora.host";
  32. private static final String ADMIN_PASSWD = "x3";
  33. private String dbPrefix;
  34. public OracleEnvironment(String databasesPrefix) {
  35. this.dbPrefix = databasesPrefix;
  36. }
  37. public String getAdapterName() {
  38. return "oracle";
  39. }
  40. private String getUserName(String uniqId){
  41. return dbPrefix + uniqId +"_" + System.getProperty("user.name");
  42. }
  43. @Override
  44. public DBInfo getDb(String name) {
  45. return null;
  46. }
  47. private String getName(String uniqId){
  48. return getUserName(uniqId)+"@orcl";
  49. }
  50. private DBInfo createDBInfo(String uniqueId) {
  51. try {
  52. return new DBInfo(getName(uniqueId), DBAdapter.create(getAdapterName()), new DBUser(getUserName(uniqueId),ADMIN_PASSWD), "".equals(uniqueId));
  53. }
  54. catch (DBAdapterException e) {
  55. throw new UnreachableCodeReachedException(e);
  56. }
  57. }
  58. public DBInfo getDb01() {
  59. return createDBInfo("01");
  60. }
  61. public DBInfo getDb02() {
  62. return createDBInfo("02");
  63. }
  64. public DBInfo getDb03() {
  65. return createDBInfo("03");
  66. }
  67. public DBInfo getDbRemote () {
  68. return createDBInfo("");
  69. }
  70. /**
  71. * ?????????? ???? ?? ?? ????????? ??????
  72. * @return
  73. */
  74. public boolean isHostSet() {
  75. return System.getProperty(CMD_PARAM_HOST) != null && !System.getProperty(CMD_PARAM_HOST).equals("${" + CMD_PARAM_HOST + "}");
  76. }
  77. /**
  78. * ???????? ????? ??
  79. * @return
  80. */
  81. public String getHost() {
  82. return System.getProperty(CMD_PARAM_HOST, "localhost");
  83. }
  84. }