Example #1
0
  public void setUp() throws RegistryException {
    if (System.getProperty("carbon.home") == null) {
      File file = new File("src/test/resources/carbon-home");
      if (file.exists()) {
        System.setProperty("carbon.home", file.getAbsolutePath());
      }
    }

    // The line below is responsible for initializing the cache.
    CarbonContext.getCurrentContext();

    String carbonHome = System.getProperty("carbon.home");
    System.out.println("carbon home " + carbonHome);
    String carbonXMLPath =
        carbonHome
            + File.separator
            + "repository"
            + File.separator
            + "conf"
            + File.separator
            + "carbon.xml";
    RegistryConfiguration regConfig = new RegistryConfiguration(carbonXMLPath);
    RegistryCoreServiceComponent.setRegistryConfig(regConfig);

    RealmService realmService = new InMemoryRealmService();
    InputStream is;

    try {
      is = this.getClass().getClassLoader().getResourceAsStream("registry.xml");
    } catch (Exception e) {
      is = null;
    }
    ctx = RegistryContext.getBaseInstance(is, realmService);
    // RegistryConfigurationProcessor.populateRegistryConfig(is, ctx);
    ctx.setSetup(true);
    ctx.selectDBConfig("h2-db");
  }