Ejemplo n.º 1
0
  /**
   * checkEnvのテストケース 異常系:"ASAKUSA_HOME"の設定が不正のケース
   *
   * @throws Exception
   */
  @Test
  public void checkEnvTest04() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Map<String, String> m = new HashMap<String, String>();
    m.put(Constants.ASAKUSA_HOME, "J:\temp");
    m.put(
        Constants.THUNDER_GATE_HOME,
        ConfigurationLoader.getEnvProperty(Constants.THUNDER_GATE_HOME));
    ConfigurationLoader.setEnv(m);

    Properties p = System.getProperties();
    p.setProperty(Constants.ASAKUSA_HOME, "J:\temp");
    p.setProperty(Constants.THUNDER_GATE_HOME, "src/test");
    ConfigurationLoader.setSysProp(p);
    System.setProperties(p);

    try {
      ConfigurationLoader.checkEnv();
      fail();
    } catch (Exception e) {
      assertTrue(e instanceof Exception);
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
 /**
  * loadJDBCPropのテストケース 異常系:DBMSの接続情報を記述したプロパティファイルの読み込みに失敗するケース
  *
  * @throws Exception
  */
 @Test
 public void loadJDBCProp02() throws Exception {
   ConfigurationLoader.init(properties_db, true, false);
   //
   // LogInitializer.execute(ConfigurationLoader.getProperty(Constants.PROP_KEY_LOG_CONF_PATH));
   try {
     ConfigurationLoader.loadJDBCProp("targetErr");
     fail();
   } catch (BulkLoaderSystemException e) {
     LOG.info(e.getCause(), e.getMessageId(), e.getMessageArgs());
   }
 }
Ejemplo n.º 3
0
  private BlockingService processBlockingConfiguration(MpiConfigDocument configuration) {
    checkConfiguration(configuration);

    if (configuration.getMpiConfig().getBlockingConfigurationArray() == null) {
      return null;
    }

    int count = configuration.getMpiConfig().getBlockingConfigurationArray().length;
    BlockingService blockingService = null;
    for (int i = 0; i < count; i++) {
      BlockingConfigurationType obj = configuration.getMpiConfig().getBlockingConfigurationArray(i);
      if (obj == null) {
        log.warn("No blocking service configuration has been specified.");
        return null;
      }
      log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI());
      String namespaceUriStr = obj.getDomNode().getNamespaceURI();
      URI namespaceURI = getNamespaceURI(namespaceUriStr);

      String resourcePath = generateComponentResourcePath(namespaceURI);
      Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath);

      String configurationLoaderBean = getExtensionBeanNameFromComponent(component);

      ConfigurationLoader loader =
          (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean);
      loader.loadAndRegisterComponentConfiguration(this, obj);

      Component.Extension extension =
          component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION);
      if (extension == null) {
        log.error(
            "Encountered a custom blocking component with no implementation extension: "
                + component);
        throw new InitializationException(
            "Unable to locate an implementation component for custom blocking component "
                + component.getName());
      }
      log.debug(
          "Registering implementation of blocking component named "
              + extension.getName()
              + " and implementation key "
              + extension.getImplementationKey());
      blockingService =
          (BlockingService)
              Context.getApplicationContext().getBean(extension.getImplementationKey());

      String entity = loader.getComponentEntity();
      log.info("Registering blocking service " + blockingService + " for entity " + entity);
      Context.registerCustomBlockingService(entity, blockingService);
    }
    return blockingService;
  }
Ejemplo n.º 4
0
  /**
   * checkAndSetParamHCのテストケース 正常系:エクスポートファイルをTSVファイルに変換する際のファイル分割サイズが設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamHC05() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.tsv-max-size", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamHC();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals("16777216", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_LOAD_MAX_SIZE));
  }
Ejemplo n.º 5
0
  /**
   * checkAndSetParamDBのテストケース 正常系:Importファイルの圧縮時のバッファサイズ不正なケース
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB05() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("import.zip-comp-buf-size", "a");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
      fail();
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(e instanceof BulkLoaderSystemException);
    }
  }
Ejemplo n.º 6
0
  /**
   * checkAndSetParamDBのテストケース 正常系:Importerのリトライ回数が設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB06() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("import.retry-count", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals("3", ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_RETRY_COUNT));
  }
Ejemplo n.º 7
0
  /**
   * checkAndSetParamDBのテストケース 正常系:Exporterのリトライインターバルが設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB14() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.retry-interval", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals("10", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_RETRY_INTERVAL));
  }
Ejemplo n.º 8
0
  /**
   * checkAndSetParamDBのテストケース
   * 正常系:エクスポート処理でExport対象テーブルにデータをコピーする時の最大レコード数が設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB18() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.data-copy-max-count", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals("100000", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_COPY_MAX_RECORD));
  }
Ejemplo n.º 9
0
  /**
   * checkAndSetParamDBのテストケース 異常系:Importファイルを置くディレクトリのトップディレクトリが設定されていないケース
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB24() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("import.tsv-create-dir", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
      fail();
    } catch (Exception e) {
      assertTrue(e instanceof BulkLoaderSystemException);
      e.printStackTrace();
    }
  }
Ejemplo n.º 10
0
  /**
   * checkAndSetParamDBのテストケース 異常系:エクスポート正常終了時のTSVファイル削除有無が不正なケース
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB31() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.delete-tsv", "2");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
      fail();
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(e instanceof BulkLoaderSystemException);
    }
  }
Ejemplo n.º 11
0
  /**
   * checkAndSetParamHCのテストケース 正常系:エクスポートファイルをTSVファイルに変換する際のファイル分割サイズが不正なケース
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamHC06() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.tsv-max-size", "a");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamHC();
      fail();
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(e instanceof BulkLoaderSystemException);
    }
  }
Ejemplo n.º 12
0
  /**
   * checkAndSetParamHCのテストケース 異常系:HDFSのプロトコルとホスト名が設定されていないケース
   *
   * @throws Exception
   */
  @Ignore("hdfs-protocol-host is obsoleted")
  @Test
  public void checkAndSetParamHC04() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("hdfs-protocol-host", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamHC();
      fail();
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(e instanceof BulkLoaderSystemException);
    }
  }
Ejemplo n.º 13
0
  public Connection connect(String url, Properties info) throws SQLException {
    if (acceptsURL(url)) {
      String fileName = getFileNameFromUrl(url);
      try {
        Configuration configuration = configLoader.load(fileName);

        List<String> drivers = configuration.getDrivers();
        for (String classname : drivers) {
          Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName(classname);
          Driver driver = driverClass.newInstance();
          java.sql.DriverManager.registerDriver(driver);
          logger.debug("Registering driver " + classname);
        }

        List<ConnectionInfo> connections = configuration.getConnections();

        ConnectionsHolder connectionsHolder = new ConnectionsHolder();
        for (ConnectionInfo connectionInfo : connections) {
          Properties properties = new Properties(info);
          properties.setProperty("user", connectionInfo.getUser());
          properties.setProperty("password", connectionInfo.getPassword());

          Connection connection = DriverManager.getConnection(connectionInfo.getUrl(), properties);
          connectionsHolder.add(connectionInfo.getName(), connection);
        }
        return new ShardsConnection(connectionsHolder, configuration);
      } catch (Exception e) {
        throw new SQLException("Cannot load configuration file", e);
      }
    } else {
      return null;
    }
  }
Ejemplo n.º 14
0
  /**
   * checkAndSetParamDBのテストケース 異常系:Collectorのシェル名が設定されていないケース
   *
   * @throws Exception
   */
  @Ignore(Constants.PROP_KEY_COL_SHELL_NAME + " is obsoleted")
  @Test
  public void checkAndSetParamDB27() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty(Constants.PROP_KEY_COL_SHELL_NAME, "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
      fail();
    } catch (Exception e) {
      assertTrue(e instanceof BulkLoaderSystemException);
      e.printStackTrace();
    }
  }
Ejemplo n.º 15
0
  /**
   * checkAndSetParamDBのテストケース 正常系:Exportファイルの圧縮時のバッファサイズが設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB10() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.zip-comp-buf-size", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals(
        "32768", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_FILE_COMP_BUFSIZE));
  }
Ejemplo n.º 16
0
  /**
   * Actual entry point.
   *
   * @param args application parameters.
   */
  public static void go(String[] args) {
    FileHandler file = new LocalFileHandler();
    IRCConfiguration ircConfiguration;
    StartupConfiguration startupConfiguration;

    try {

      if ((args.length == 0) || ((args.length >= 2) && (args[0].equals("-f")))) {
        String f = "pjirc.cfg";
        if (args.length >= 2) f = args[1];
        StreamParameterProvider provider = new StreamParameterProvider(file.getInputStream(f));
        ConfigurationLoader loader =
            new ConfigurationLoader(
                provider, new NullURLHandler(), new AWTImageLoader(), new NullSoundHandler(), file);
        ircConfiguration = loader.loadIRCConfiguration();
        startupConfiguration = loader.loadStartupConfiguration();
      } else if ((args.length >= 5) && (args[0].equals("-p"))) {
        StreamParameterProvider provider = new StreamParameterProvider(null);
        ConfigurationLoader loader =
            new ConfigurationLoader(
                provider, new NullURLHandler(), new AWTImageLoader(), new NullSoundHandler(), file);
        ircConfiguration = loader.loadIRCConfiguration();
        ircConfiguration.set("gui", args[4]);
        startupConfiguration =
            new StartupConfiguration(
                args[1],
                "",
                args[2],
                new String[] {""},
                new String[] {args[3]},
                new int[] {6667},
                "",
                new String[] {},
                new String[] {},
                true); // last value "true" set smileys to true by default
      } else {
        usage();
        return;
      }

      IRCApplication application = new IRCApplication(ircConfiguration, startupConfiguration, null);
      EventDispatcher.dispatchEventAsyncAndWaitEx(application, "init", new Object[0]);
    } catch (Throwable ex) {
      System.out.println("Error : " + ex.getMessage());
      ex.printStackTrace();
    }
  }
Ejemplo n.º 17
0
  /**
   * checkAndSetParamHCのテストケース 正常系:ワーキングディレクトリベースが設定されていないケース
   *
   * @throws Exception
   */
  @Ignore("hadoop-cluster.workingdir.use is obsoleted")
  @Test
  public void checkAndSetParamHC03() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("hadoop-cluster.workingdir.use", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamHC();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }

    assertEquals("false", ConfigurationLoader.getProperty(Constants.PROP_KEY_WORKINGDIR_USE));
  }
Ejemplo n.º 18
0
  /**
   * checkAndSetParamDBのテストケース 正常系:Importファイルの圧縮有無が設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB02() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("import.zip-comp-type", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals(
        FileCompType.STORED,
        FileCompType.find(ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_FILE_COMP_TYPE)));
  }
Ejemplo n.º 19
0
  /**
   * checkAndSetParamHCのテストケース 正常系:出力ファイルの圧縮有無が設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamHC07() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("import.seq-comp-type", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamHC();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }

    assertEquals(
        "NONE", ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_SEQ_FILE_COMP_TYPE));
  }
Ejemplo n.º 20
0
  /**
   * checkAndSetParamDBのテストケース 正常系:エクスポート正常終了時のTSVファイル削除有無が設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParamDB30() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("export.delete-tsv", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParamDB();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }
    assertEquals(
        TsvDeleteType.find(Constants.PROP_DEFAULT_EXPORT_TSV_DELETE),
        TsvDeleteType.find(ConfigurationLoader.getProperty(Constants.PROP_KEY_EXPORT_TSV_DELETE)));
  }
Ejemplo n.º 21
0
 /**
  * initのテストケース(doHCPropCheck:true) 正常系:HudoopClusterの初期化が正常に終了するケース
  *
  * @throws Exception
  */
 @Test
 public void initTest02() throws Exception {
   try {
     ConfigurationLoader.init(properties_hc, false, true);
   } catch (Exception e) {
     fail();
     e.printStackTrace();
   }
 }
Ejemplo n.º 22
0
  /**
   * checkAndSetParamのテストケース 正常系:log4j.xmlのパスが設定されていないケース(デフォルト値が設定される)
   *
   * @throws Exception
   */
  @Test
  public void checkAndSetParam01() throws Exception {
    ConfigurationLoader.init(properties_hc, false, true);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("log.conf-path", "");
    ConfigurationLoader.setProperty(p);

    try {
      ConfigurationLoader.checkAndSetParam();
    } catch (Exception e) {
      fail();
      e.printStackTrace();
    }

    assertEquals(
        new File("bulkloader/conf/log4j.xml").getCanonicalPath(),
        ConfigurationLoader.getProperty(Constants.PROP_KEY_LOG_CONF_PATH));
  }
Ejemplo n.º 23
0
  /**
   * checkEnvのテストケース 異常系:"BULKLOADER_HOME"が設定されていないケース
   *
   * @throws Exception
   */
  @Test
  public void checkEnvTest01() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    Map<String, String> m = new HashMap<String, String>();
    m.put(Constants.ASAKUSA_HOME, ConfigurationLoader.getEnvProperty(Constants.ASAKUSA_HOME));
    m.put(Constants.THUNDER_GATE_HOME, null);
    ConfigurationLoader.setEnv(m);

    UnitTestUtil.tearDownEnv();

    try {
      ConfigurationLoader.checkEnv();
      fail();
    } catch (Exception e) {
      assertTrue(e instanceof Exception);
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
Ejemplo n.º 24
0
 /**
  * initのテストケース(doDBPropCheck:true) 異常系:プロパティファイルの読み込みに失敗するケース
  *
  * @throws Exception
  */
 @Test
 public void initTest03() throws Exception {
   try {
     ConfigurationLoader.init(
         Arrays.asList(new String[] {"io-conf-dummy.properties"}), true, false);
     fail();
   } catch (Exception e) {
     assertTrue(e instanceof IOException);
     e.printStackTrace();
   }
 }
Ejemplo n.º 25
0
  /**
   * getPropStartWithStringのテストケース
   *
   * @throws Exception
   */
  @Test
  public void getPropStartWithString01() throws Exception {
    ConfigurationLoader.init(properties_db, false, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("clean.hdfs-dir.0", "abc");
    p.setProperty("clean.hdfs-dir.1", "def");
    p.setProperty("clean.hdfs-dir.2", "ghi");
    p.setProperty("clean.hdfs-dir.3", "jkl");
    p.setProperty("clean.hdfs-dir1.0", "xxx");
    p.setProperty("clean.hdfs.0", "xxx");
    p.setProperty("clean.hdfs-dir", "xxx");
    ConfigurationLoader.setProperty(p);

    List<String> list = ConfigurationLoader.getPropStartWithString("clean.hdfs-dir.");
    assertEquals(4, list.size());
    assertEquals("clean.hdfs-dir.3", list.get(0));
    assertEquals("clean.hdfs-dir.2", list.get(1));
    assertEquals("clean.hdfs-dir.1", list.get(2));
    assertEquals("clean.hdfs-dir.0", list.get(3));
  }
Ejemplo n.º 26
0
  /**
   * loadJDBCPropのテストケース 異常系:DBMSのDB名が設定されていないケース
   *
   * @throws Exception
   */
  @Test
  public void loadJDBCProp07() throws Exception {
    //        ConfigurationLoader.init(propertys_db, true, false);
    //
    // LogInitializer.execute(ConfigurationLoader.getProperty(Constants.PROP_KEY_LOG_CONF_PATH));

    ConfigurationLoader.init(properties_db, false, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("jdbc.driver", "com.mysql.jdbc.Driver");
    p.setProperty("jdbc.url", "jdbc:mysql://localhost/asakusa");
    p.setProperty("jdbc.user", "asakusa");
    p.setProperty("jdbc.password", "asakusa");
    p.setProperty("db.parameter", PATH_DB_PARAMETER);
    ConfigurationLoader.setProperty(p);
    try {
      ConfigurationLoader.loadJDBCProp("target2");
    } catch (BulkLoaderSystemException e) {
      LOG.info(e.getCause(), e.getMessageId(), e.getMessageArgs());
    }
  }
Ejemplo n.º 27
0
  /**
   * getNoEmptyListのテストケース
   *
   * @throws Exception
   */
  @Test
  public void getNoEmptyList01() throws Exception {
    ConfigurationLoader.init(properties_db, false, false);
    Properties p = ConfigurationLoader.getProperty();
    p.setProperty("clean.hdfs-dir.0", "abc");
    p.setProperty("clean.hdfs-dir.1", "");
    p.setProperty("clean.hdfs-dir.3", "jkl");
    ConfigurationLoader.setProperty(p);

    List<String> list = new ArrayList<String>();
    list.add("clean.hdfs-dir.0");
    list.add("clean.hdfs-dir.1");
    list.add("clean.hdfs-dir.3");
    list.add("clean.hdfs-dir.4");
    List<String> resultList = ConfigurationLoader.getExistValueList(list);

    assertEquals(2, resultList.size());
    assertEquals("clean.hdfs-dir.0", resultList.get(0));
    assertEquals("clean.hdfs-dir.3", resultList.get(1));

    resultList = ConfigurationLoader.getExistValueList(null);
    assertEquals(0, resultList.size());

    resultList = ConfigurationLoader.getExistValueList(new ArrayList<String>());
    assertEquals(0, resultList.size());
  }
Ejemplo n.º 28
0
  private void processSingleBestRecordConfiguration(MpiConfigDocument configuration) {
    checkConfiguration(configuration);
    if (configuration.getMpiConfig().sizeOfSingleBestRecordArray() == 0) {
      log.warn("No single best record configuration has been specified.");
      return;
    }
    SingleBestRecordType obj = configuration.getMpiConfig().getSingleBestRecordArray(0);
    log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI());
    String namespaceUriStr = obj.getDomNode().getNamespaceURI();
    URI namespaceURI = getNamespaceURI(namespaceUriStr);

    String resourcePath = generateComponentResourcePath(namespaceURI);
    Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath);

    String configurationLoaderBean = getExtensionBeanNameFromComponent(component);

    ConfigurationLoader loader =
        (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean);
    loader.loadAndRegisterComponentConfiguration(this, obj);

    Component.Extension extension =
        component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION);
    if (extension == null) {
      log.error(
          "Encountered a custom single best record component with no implementation extension: "
              + component);
      throw new InitializationException(
          "Unable to locate an implementation component for custom single best record component "
              + component.getName());
    }
    log.debug(
        "Registering implementation of single best record component named "
            + extension.getName()
            + " and implementation key "
            + extension.getImplementationKey());
    SingleBestRecordService singleBestRecordService =
        (SingleBestRecordService)
            Context.getApplicationContext().getBean(extension.getImplementationKey());
    Context.registerCustomSingleBestRecordService(singleBestRecordService);
  }
Ejemplo n.º 29
0
  /**
   * loadJDBCPropのテストケース 正常系:DBMSの接続情報を記述したプロパティファイルを読み込むケース
   *
   * @throws Exception
   */
  @Test
  public void loadJDBCProp01() throws Exception {
    ConfigurationLoader.init(properties_db, true, false);
    try {
      ConfigurationLoader.loadJDBCProp("target3");
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }

    assertEquals("com.mysql.jdbc.Driver", ConfigurationLoader.getProperty("jdbc.driver"));
    assertEquals(
        "jdbc:mysql://localhost/__asakusa_utest_thundergate",
        ConfigurationLoader.getProperty("jdbc.url"));
    assertEquals("__asakusa_ut_tg", ConfigurationLoader.getProperty("jdbc.user"));
    assertEquals("__asakusa_ut_tg", ConfigurationLoader.getProperty("jdbc.password"));
    assertEquals(PATH_DB_PARAMETER, ConfigurationLoader.getProperty("db.parameter"));
  }
Ejemplo n.º 30
0
 @Before
 public void setUp() throws Exception {
   UnitTestUtil.setUpEnv();
   ConfigurationLoader.cleanProp();
 }