Java 类org.apache.commons.configuration2.MapConfiguration 实例源码

项目:grpc-mate    文件:ProductDaoTest.java   
@BeforeClass
public static void setUpClass() throws Exception {
  faker = new Faker();
  String ip = esContainer.getContainerIpAddress();
  Integer transportPort = esContainer.getMappedPort(9300);
  MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
  memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
  injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule())
          .with(binder -> {
            binder.bind(Configuration.class).toProvider(() -> memoryParams);
          })
  );
  productDao = injector.getInstance(ProductDao.class);
  esClient = injector.getInstance(TransportClient.class);
}
项目:grpc-mate    文件:TransportClientProviderTest.java   
@Before
public void setUp() throws Exception {
  String ip = esContainer.getContainerIpAddress();
  Integer transportPort = esContainer.getMappedPort(9300);
  MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
  memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
  Injector injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule()).with(
          binder -> {
            binder.bind(Configuration.class).toInstance(memoryParams);
          }
      )
  );
  transportClientProvider = injector.getInstance(TransportClientProvider.class);
}
项目:bitflyer4j    文件:KeyTypeTest.java   
@Test
public void test() throws ConfigurationException {

    // Null input.  (= Default value.)
    assertEquals(VERSION.fetch(null), VERSION.getDefaultValue());

    // Not found. (= Default value.)
    Configuration conf = new MapConfiguration(new HashMap<>());
    assertEquals(VERSION.fetch(conf), VERSION.getDefaultValue());

    // Retrieved from properties. (Empty)
    conf.setProperty(VERSION.getKey(), "");
    assertNull(VERSION.fetch(conf));

    // Retrieved from properties. (Configured)
    conf.setProperty(VERSION.getKey(), "test");
    assertEquals(VERSION.fetch(conf), "test");

}
项目:yajsw    文件:WrapperExe.java   
/**
 * Do reconnect.
 */
private static void doReconnect()
{
    prepareProperties();
    Configuration localConf = new MapConfiguration(_properties);
    YajswConfiguration conf = new YajswConfigurationImpl(localConf, true);
    WrappedProcess w = WrappedProcessFactory.createProcess(conf);

    System.out.println("************* RECONNECTING WRAPPER TO PID  " + pid
            + " ***********************");
    System.out.println();

    if (w.reconnect(pid))
        System.out.println("Connected to PID " + pid);
    else
        System.out.println("NOT connected to PID " + pid);
    _exitOnTerminate = false;

}
项目:yajsw    文件:WrapperExe.java   
private static WrappedService getService()
{
    if (_service != null)
        return _service;
    prepareProperties();
    _service = new WrappedService();
    if (confFileList != null && confFileList.size() > 1)
        _service.setConfFilesList(confFileList);
    _service.setLocalConfiguration(new MapConfiguration(_properties));
    _service.init();
    return _service;
}
项目:yajsw    文件:WrappedProcessFactory.java   
public static WrappedProcess createProcess(Map map,
        boolean useSystemProperties)
{
    Configuration localConf = new MapConfiguration(map);
    YajswConfiguration conf = new YajswConfigurationImpl(localConf, true);
    WrappedProcess process = createProcess(conf);
    process.setLocalConfiguration(localConf);
    process.setUseSystemProperties(useSystemProperties);
    process.init();
    return process;
}
项目:yajsw    文件:WrappedServiceFactory.java   
public static Object createService(Map map)
{
    Configuration localConf = new MapConfiguration(map);
    WrappedService service = new WrappedService();
    service.setLocalConfiguration(localConf);
    service.init();
    return service;
}
项目:yajsw    文件:WrappedServiceFactory.java   
public static Object createServiceList(Map map, List<String> confFiles)
{
    Configuration localConf = new MapConfiguration(map);
    WrappedService service = new WrappedService();
    service.setLocalConfiguration(localConf);
    service.setConfFilesList(confFiles);
    service.init();
    return service;
}
项目:cryptotrader    文件:UnivariateEstimatorTest.java   
@BeforeMethod
public void setUp() throws Exception {

    configuration = new HashMap<>();

    context = mock(Context.class);

    target = spy(new UnivariateEstimator());

    target.setConfiguration(new MapConfiguration(configuration));

    prices = new TreeMap<>();
    prices.put(parseDate("2017-05-31"), new BigDecimal("19650.57"));
    prices.put(parseDate("2017-05-30"), new BigDecimal("19677.85"));
    prices.put(parseDate("2017-05-29"), new BigDecimal("19682.57"));
    prices.put(parseDate("2017-05-26"), new BigDecimal("19686.84"));
    prices.put(parseDate("2017-05-25"), new BigDecimal("19813.13"));
    prices.put(parseDate("2017-05-24"), new BigDecimal("19742.98"));
    prices.put(parseDate("2017-05-23"), new BigDecimal("19613.28"));
    prices.put(parseDate("2017-05-22"), new BigDecimal("19678.28"));
    prices.put(parseDate("2017-05-19"), new BigDecimal("19590.76"));
    prices.put(parseDate("2017-05-18"), new BigDecimal("19553.86"));
    prices.put(parseDate("2017-05-17"), new BigDecimal("19814.88"));
    prices.put(parseDate("2017-05-16"), new BigDecimal("19919.82"));
    prices.put(parseDate("2017-05-15"), new BigDecimal("19869.85"));
    prices.put(parseDate("2017-05-12"), new BigDecimal("19883.90"));
    prices.put(parseDate("2017-05-11"), new BigDecimal("19961.55"));
    prices.put(parseDate("2017-05-10"), new BigDecimal("19900.09"));
    prices.put(parseDate("2017-05-09"), new BigDecimal("19843.00"));
    prices.put(parseDate("2017-05-08"), new BigDecimal("19895.70"));
    prices.put(parseDate("2017-05-02"), new BigDecimal("19445.70"));
    prices.put(parseDate("2017-05-01"), new BigDecimal("19310.52"));
    prices.put(parseDate("2017-04-28"), new BigDecimal("19196.74"));
    prices.put(parseDate("2017-04-27"), new BigDecimal("19251.87"));
    prices.put(parseDate("2017-04-26"), new BigDecimal("19289.43"));
    prices.put(parseDate("2017-04-25"), new BigDecimal("19079.33"));
    prices.put(parseDate("2017-04-24"), new BigDecimal("18875.88"));
    prices.put(parseDate("2017-04-21"), new BigDecimal("18620.75"));
    prices.put(parseDate("2017-04-20"), new BigDecimal("18430.49"));
    prices.put(parseDate("2017-04-19"), new BigDecimal("18432.20"));
    prices.put(parseDate("2017-04-18"), new BigDecimal("18418.59"));
    prices.put(parseDate("2017-04-17"), new BigDecimal("18355.26"));
    prices.put(parseDate("2017-04-14"), new BigDecimal("18335.63"));
    prices.put(parseDate("2017-04-13"), new BigDecimal("18426.84"));
    prices.put(parseDate("2017-04-12"), new BigDecimal("18552.61"));
    prices.put(parseDate("2017-04-11"), new BigDecimal("18747.87"));
    prices.put(parseDate("2017-04-10"), new BigDecimal("18797.88"));
    prices.put(parseDate("2017-04-07"), new BigDecimal("18664.63"));
    prices.put(parseDate("2017-04-06"), new BigDecimal("18597.06"));
    prices.put(parseDate("2017-04-05"), new BigDecimal("18861.27"));
    prices.put(parseDate("2017-04-04"), new BigDecimal("18810.25"));
    prices.put(parseDate("2017-04-03"), new BigDecimal("18983.23"));

}
项目:cryptotrader    文件:TemplateAdviserTest.java   
@BeforeMethod
public void setUp() throws Exception {

    context = mock(Context.class);

    BiFunction<InvocationOnMock, BigDecimal, BigDecimal> f = (i, unit) -> {

        BigDecimal value = i.getArgumentAt(1, BigDecimal.class);

        RoundingMode mode = i.getArgumentAt(2, RoundingMode.class);

        if (value == null || mode == null) {
            return null;
        }

        BigDecimal units = value.divide(unit, INTEGER_ZERO, mode);

        return units.multiply(unit);

    };
    when(context.roundTickSize(any(), any(), any())).thenAnswer(i -> f.apply(i, new BigDecimal("0.0025")));
    when(context.roundLotSize(any(), any(), any())).thenAnswer(i -> f.apply(i, new BigDecimal("0.25")));

    rBuilder = Request.builder().site("s").instrument("i").targetTime(now());

    eBuilder = Estimation.builder().price(new BigDecimal("12345.6789")).confidence(new BigDecimal("0.5"));

    configuration = spy(new MapConfiguration(new HashMap<>()));

    target = spy(new TemplateAdviser("test"));

    target.setConfiguration(configuration);

}
项目:cryptotrader    文件:AbstractServiceTest.java   
@Test
public void testConfiguration() {

    Map<String, Object> map = new HashMap<>();
    target.setConfiguration(new MapConfiguration(map));

    // String
    assertEquals(target.getStringProperty("string", "b"), "b");
    map.put(target.getClass().getName() + ".string", "a");
    assertEquals(target.getStringProperty("string", "b"), "a");
    map.put(target.getClass().getName() + ".string", new Object() {
        @Override
        public String toString() {
            throw new RuntimeException("test");
        }
    }); // Exception
    assertEquals(target.getStringProperty("string", "b"), "b");

    // Int
    assertEquals(target.getIntProperty("int", -123), -123);
    map.put(target.getClass().getName() + ".int", -999);
    assertEquals(target.getIntProperty("int", -123), -999);
    map.put(target.getClass().getName() + ".int", "a"); // Exception
    assertEquals(target.getIntProperty("int", -123), -123);

    // Long
    assertEquals(target.getLongProperty("int", -123), -123);
    map.put(target.getClass().getName() + ".int", -999);
    assertEquals(target.getLongProperty("int", -123), -999);
    map.put(target.getClass().getName() + ".int", "a"); // Exception
    assertEquals(target.getLongProperty("int", -123), -123);

    // Decimal
    assertEquals(target.getDecimalProperty("decimal", TEN), TEN);
    map.put(target.getClass().getName() + ".decimal", "1");
    assertEquals(target.getDecimalProperty("decimal", TEN), ONE);
    map.put(target.getClass().getName() + ".decimal", "a"); // Exception
    assertEquals(target.getDecimalProperty("decimal", TEN), TEN);


}
项目:swagger2markup    文件:Swagger2MarkupProperties.java   
public Swagger2MarkupProperties(Map<String, String> map) {
    this(new MapConfiguration(map));
}
项目:bitflyer4j    文件:KeyTypeTest.java   
@Test
public void testFetch_Unconfigured() throws ConfigurationException {

    Configuration c = new MapConfiguration(new HashMap<>());

    for (KeyType type : KeyType.values()) {

        type.fetch(null);

        type.fetch(c);

    }

}
项目:bitflyer4j    文件:EnvironmentImplTest.java   
@BeforeMethod
public void setUp() throws Exception {

    conf = new MapConfiguration(new HashMap<>());

    target = new EnvironmentImpl(conf, conf);

}
项目:cryptotrader    文件:ResteasyContextListenerTest.java   
@Test
public void testEndpointImpl_getConfiguration() {

    Map<String, String> map = new LinkedHashMap<>();
    map.put("foo", "FOO");
    map.put("bar", "BAR");

    when(provider.get()).thenReturn(new MapConfiguration(map));

    assertNotNull(endpoint.getConfiguration());

}
项目:cryptotrader    文件:BitflyerAdviserTest.java   
@BeforeMethod
public void setUp() throws Exception {

    configurations = new HashMap<>();

    module = new TestModule();

    context = module.getMock(Context.class);

    target = spy(new BitflyerAdviser());

    target.setConfiguration(new MapConfiguration(configurations));

    when(context.roundLotSize(any(), any(), any())).thenAnswer(i -> {

        BigDecimal value = i.getArgumentAt(1, BigDecimal.class);

        RoundingMode mode = i.getArgumentAt(2, RoundingMode.class);

        if (value == null || mode == null) {
            return null;
        }

        BigDecimal unit = new BigDecimal("0.5");

        BigDecimal units = value.divide(unit, INTEGER_ZERO, mode);

        return units.multiply(unit);

    });

}
项目:cryptotrader    文件:TemplateInstructorTest.java   
@BeforeMethod
public void setUp() throws Exception {

    context = mock(Context.class);

    BiFunction<InvocationOnMock, BigDecimal, BigDecimal> f = (i, unit) -> {

        RoundingMode mode = i.getArgumentAt(2, RoundingMode.class);

        BigDecimal value = i.getArgumentAt(1, BigDecimal.class);

        if (value == null || mode == null) {
            return null;
        }

        BigDecimal units = value.divide(unit, INTEGER_ZERO, mode);

        return units.multiply(unit);

    };
    when(context.roundTickSize(any(), any(), any())).thenAnswer(i -> f.apply(i, new BigDecimal("0.003")));
    when(context.roundLotSize(any(), any(), any())).thenAnswer(i -> f.apply(i, new BigDecimal("0.3")));

    configuration = spy(new MapConfiguration(new HashMap<>()));

    builder = Request.builder().site("s").instrument("i")
            .currentTime(ofEpochMilli(123L)).targetTime(ofEpochMilli(456L))
            .tradingExposure(ZERO).tradingSplit(5).tradingSpread(ZERO).tradingInstruction("IOC");

    target = spy(new TemplateInstructor("test"));

    target.setConfiguration(configuration);

}
项目:cryptotrader    文件:CoincheckContextTest.java   
@BeforeMethod
public void setUp() throws Exception {

    conf = new MapConfiguration(new HashMap<>());

    target = spy(new CoincheckContext());
    target.setConfiguration(conf);

    doReturn(null).when(target).request(any(), any(), any(), any());
    doNothing().when(target).scheduleSocket(any(), any());

}