Package org.ngrinder.common.util

Examples of org.ngrinder.common.util.PropertiesWrapper


  @Test
  public void testClusterConfig() {
    Config config = new Config() {
      @Override
      public PropertiesWrapper getClusterProperties() {
        PropertiesWrapper mock = mock(PropertiesWrapper.class);
        when(mock.getProperty(PROP_CLUSTER_MEMBERS)).thenReturn("10.10.10.10;10.10.10.20,10.10.10.30");
        return mock;
      }
    };
    final String[] clusterURIs = config.getClusterURIs();
    assertThat(clusterURIs[0]).isEqualTo("10.10.10.10");
View Full Code Here


    assertThat(port, not(0));
  }

  @Test
  public void testTestMode() {
    PropertiesWrapper wrapper = mock(PropertiesWrapper.class);
    config.setControllerProperties(wrapper);
    // When dev_mode false and pluginsupport is true, it should be true
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(false);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_PLUGIN_SUPPORT)).thenReturn(false);
    assertThat(config.isPluginSupported(), is(false));

    // When dev_mode true and pluginsupport is false, it should be false
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(true);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_PLUGIN_SUPPORT)).thenReturn(false);
    assertThat(config.isPluginSupported(), is(false));

    // When dev_mode false and pluginsupport is false, it should be false
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(false);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_PLUGIN_SUPPORT)).thenReturn(false);
    assertThat(config.isPluginSupported(), is(false));

    // When dev_mode true and pluginsupport is true, it should be false
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(true);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_PLUGIN_SUPPORT)).thenReturn(true);
    assertThat(config.isPluginSupported(), is(true));

    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(true);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_SECURITY)).thenReturn(true);
    assertThat(config.isSecurityEnabled(), is(false));

    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(false);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_SECURITY)).thenReturn(true);
    assertThat(config.isSecurityEnabled(), is(true));

    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_DEV_MODE)).thenReturn(false);
    when(wrapper.getPropertyBoolean(PROP_CONTROLLER_SECURITY)).thenReturn(false);
    assertThat(config.isSecurityEnabled(), is(false));
  }
View Full Code Here

  protected void loadProperties() {
    checkNotNull(home);
    Properties properties = home.getProperties("agent.conf");
    properties.put("NGRINDER_AGENT_HOME", home.getDirectory().getAbsolutePath());
    properties.putAll(System.getProperties());
    agentProperties = new PropertiesWrapper(properties, agentPropertyMapper);
    monitorProperties = new PropertiesWrapper(properties, monitorPropertyMapper);
    commonProperties = new PropertiesWrapper(properties, commonPropertyMapper);
  }
View Full Code Here

    InputStream inputStream = null;
    Properties properties = new Properties();
    try {
      inputStream = AgentConfig.class.getResourceAsStream("/internal.properties");
      properties.load(inputStream);
      internalProperties = new PropertiesWrapper(properties, internalPropertyMapper);
    } catch (IOException e) {
      LOGGER.error("Error while load internal.properties", e);
      internalProperties = new PropertiesWrapper(properties, internalPropertyMapper);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }
  }
View Full Code Here

  public boolean isServerMode() {
    return getAgentProperties().getPropertyBoolean(PROP_AGENT_SERVER_MODE);
  }

  public boolean isSilentMode() {
    final PropertiesWrapper properties = getCommonProperties();
    if (properties == null) {
      return Boolean.getBoolean(System.getProperty(PROP_COMMON_SILENT_MODE, "false"));
    } else {
      return properties.getPropertyBoolean(PROP_COMMON_SILENT_MODE);
    }
  }
View Full Code Here

  protected void initDevModeProperties() {
    if (!isDevMode()) {
      initLogger(false);
    } else {
      final PropertiesWrapper controllerProperties = getControllerProperties();
      controllerProperties.addProperty(PROP_CONTROLLER_AGENT_FORCE_UPDATE, "true");
      controllerProperties.addProperty(PROP_CONTROLLER_ENABLE_AGENT_AUTO_APPROVAL, "true");
      controllerProperties.addProperty(PROP_CONTROLLER_ENABLE_SCRIPT_CONSOLE, "true");
    }
  }
View Full Code Here

    InputStream inputStream = null;
    Properties properties = new Properties();
    try {
      inputStream = new ClassPathResource("/internal.properties").getInputStream();
      properties.load(inputStream);
      internalProperties = new PropertiesWrapper(properties, internalPropertiesKeyMapper);
    } catch (IOException e) {
      CoreLogger.LOGGER.error("Error while load internal.properties", e);
      internalProperties = new PropertiesWrapper(properties, internalPropertiesKeyMapper);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }
  }
View Full Code Here

  protected void loadDatabaseProperties() {
    checkNotNull(home);
    Properties properties = home.getProperties("database.conf");
    properties.put("NGRINDER_HOME", home.getDirectory().getAbsolutePath());
    properties.putAll(System.getProperties());
    databaseProperties = new PropertiesWrapper(properties, databasePropertiesKeyMapper);
  }
View Full Code Here

      }
      properties.putAll(exProperties);
    }
    properties.putAll(System.getProperties());
    // Override if exists
    controllerProperties = new PropertiesWrapper(properties, controllerPropertiesKeyMapper);
    clusterProperties = new PropertiesWrapper(properties, clusterPropertiesKeyMapper);
  }
View Full Code Here

   * @return dataSource
   */
  @Bean(name = "dataSource", destroyMethod = "close")
  public BasicDataSource dataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    PropertiesWrapper databaseProperties = config.getDatabaseProperties();
    Database database = Database.getDatabase(databaseProperties.getProperty(PROP_DATABASE_TYPE));
    database.setup(dataSource, databaseProperties);
    return dataSource;
  }
View Full Code Here

TOP

Related Classes of org.ngrinder.common.util.PropertiesWrapper

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.