Package org.ngrinder.common.model

Examples of org.ngrinder.common.model.Home


    config.init();
  }

  @Test
  public void testDefaultHome() {
    Home home = config.getHome();
    File oracle = new File(System.getProperty("user.home"), ".ngrinder");
    assertThat(home.getDirectory(), is(oracle));
    assertThat(home.getPluginsDirectory(), is(new File(oracle, "plugins")));
  }
View Full Code Here


    config.cluster = true;
    Properties wrapper = new Properties();
    wrapper.put(PROP_CLUSTER_REGION, "TestNewRegion");
    config.doRealOnRegion = true;
    // set mock exHome and test
    Home mockExHome = mock(Home.class);
    when(mockExHome.getProperties("system-ex.conf")).thenReturn(wrapper);
    when(mockExHome.exists()).thenReturn(true);
    ReflectionTestUtils.setField(config, "exHome", mockExHome);
    config.loadProperties();
    assertThat(config.getRegion(), is("TestNewRegion"));
  }
View Full Code Here

  public void testGetReportDataWithExistingData() throws IOException {
    long testId = 123456L; // there is sample monitor data in test resources.

    // Given
    File testHomeDir = new ClassPathResource("world.py").getFile().getParentFile();
    Home mockHome = new Home(testHomeDir);
    LOG.debug("mock home dir is:{}", mockHome.getDirectory());
    Config mockConfig = spy(config);
    when(mockConfig.getHome()).thenReturn(mockHome);
    PerfTestService mockService = spy(testService);
    mockService.setConfig(mockConfig);
View Full Code Here

  @Test
  public void testGetMonitorDataWithExistingData() throws IOException {
    // Given
    long testId = 123456L; // there is sample monitor data in test resources.
    File testHomeDir = new ClassPathResource("world.py").getFile().getParentFile();
    Home mockHome = new Home(testHomeDir);
    LOG.debug("mock home dir is:{}", mockHome.getDirectory());
    Config mockConfig = spy(config);
    when(mockConfig.getHome()).thenReturn(mockHome);
    PerfTestService mockService = spy(testService);
    mockService.setConfig(mockConfig);
View Full Code Here

      try {
        FileUtils.forceDeleteOnExit(tmpHome);
      } catch (IOException e) {
        LOG.error("Error while setting forceDeleteOnExit on {}", tmpHome);
      }
      return new Home(tmpHome);
    }
    String userHomeFromEnv = System.getenv("NGRINDER_HOME");
    String userHomeFromProperty = System.getProperty("ngrinder.home");
    if (!StringUtils.equals(userHomeFromEnv, userHomeFromProperty)) {
      CoreLogger.LOGGER.warn("The path to ngrinder-home is ambiguous:");
      CoreLogger.LOGGER.warn("    System Environment:  NGRINDER_HOME=" + userHomeFromEnv);
      CoreLogger.LOGGER.warn("    Java System Property:  ngrinder.home=" + userHomeFromProperty);
      CoreLogger.LOGGER.warn("    '" + userHomeFromProperty + "' is accepted.");
    }
    String userHome = StringUtils.defaultIfEmpty(userHomeFromProperty, userHomeFromEnv);
    if (StringUtils.isEmpty(userHome)) {
      userHome = System.getProperty("user.home") + File.separator + NGRINDER_DEFAULT_FOLDER;
    } else if (StringUtils.startsWith(userHome, "~" + File.separator)) {
      userHome = System.getProperty("user.home") + File.separator + userHome.substring(2);
    } else if (StringUtils.startsWith(userHome, "." + File.separator)) {
      userHome = System.getProperty("user.dir") + File.separator + userHome.substring(2);
    }

    userHome = FilenameUtils.normalize(userHome);
    File homeDirectory = new File(userHome);
    CoreLogger.LOGGER.info("nGrinder home directory:{}.", homeDirectory.getPath());

    return new Home(homeDirectory);
  }
View Full Code Here

      exHomeDirectory.mkdirs();
    } catch (Exception e) {
      // If it's not possible.. do it... without real directory.
      noOp();
    }
    return new Home(exHomeDirectory, false);
  }
View Full Code Here

   * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context
   * .ApplicationEvent)
   */
  @Override
  public void onApplicationEvent(ContextRefreshedEvent event) {
    Home exHome = config.getExHome();
    if (exHome.exists()) {
      FileUtils.deleteQuietly(exHome.getSubFile("shutdown.lock"));
      FileUtils.deleteQuietly(exHome.getSubFile("no_more_test.lock"));
    }
  }
View Full Code Here

        reg.register(IConfig.class).forInstance(config);
        reg.register(CacheManager.class).forInstance(cacheManager);
        reg.register(IScheduledTaskService.class).forInstance(scheduledTaskService);
      }
    };
    Home home = config.getHome();
    final String region = config.getRegion();

    // Construct the configuration
    final File pluginsDirectory = home.getPluginsDirectory();
    File pluginCache = getPluginCacheFolder(region, home.getPluginsCacheDirectory());
    PluginsConfiguration config = new PluginsConfigurationBuilder().pluginDirectory(pluginsDirectory)
        .packageScannerConfiguration(scannerConfig)
        .hotDeployPollingFrequency(PLUGIN_UPDATE_FREQUENCY, TimeUnit.SECONDS)
        .hostComponentProvider(host).moduleDescriptorFactory(modules).osgiPersistentCache(pluginCache).build();
View Full Code Here

TOP

Related Classes of org.ngrinder.common.model.Home

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.