List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:org.bhave.sweeper.IntegerSequenceSweepTest.java
@Test public void test() { IntegerSequenceSweep seq = new IntegerSequenceSweep("p1", -10, 10, 1); System.out.println(seq);//from ww w . j a va 2 s.c om List<Integer> values = seq.getValues(); System.out.println(values); Iterator<Integer> valuesIt = values.iterator(); for (Configuration config : seq) { assertEquals(valuesIt.next().intValue(), config.getInt("p1")); } assertEquals(20, seq.size()); IntegerSequenceSweep seq2 = new IntegerSequenceSweep("p1", 0, 1, 1); assertEquals(2, seq2.size()); }
From source file:org.bhave.sweeper.ValueListSweepTest.java
@Test public void testListSweep() { List<Integer> values = new ArrayList<>(); values.add(1);//w ww . j a va 2s . c om values.add(5); values.add(10); ListSweep<Integer> sweep = new ListSweep<>("p1", values); SingleValueSweep<Integer> sweep2 = new SingleValueSweep<Integer>("p2", 1); assertEquals(values.size(), sweep.size()); ParameterSweep sweep3 = ParameterSweepUtil.<Integer>createSweep("p3", values); List<ParameterSweep> params = new ArrayList<>(); params.add(sweep); params.add(sweep2); params.add(sweep3); DefaultCombinedParameterSweep space = new DefaultCombinedParameterSweep(params, 3); for (Configuration config : space) { System.out.println( "[" + config.getInt("p1") + "," + config.getInt("p2") + "," + config.getInt("p3") + "]"); } }
From source file:org.chenillekit.core.tests.TestConfigurationService.java
@Test public void test1() { Resource configResource = new ClasspathResource("test.properties"); Configuration testConfiguration = service.getConfiguration(configResource); assertNotNull(testConfiguration);//from w ww . ja v a2s .c o m assertEquals(testConfiguration.getString("test.value1"), "test1"); assertEquals(testConfiguration.getInt("test.value2"), 3); assertEquals(testConfiguration.getStringArray("test.value3"), new String[] { "test1", "test2", "test3", "test4" }); assertEquals(testConfiguration.getString("test.value4"), System.getProperty("java.vendor")); }
From source file:org.chenillekit.core.tests.TestConfigurationService.java
@Test public void test2() { Resource configResource = new ClasspathResource("test.xml"); Configuration testConfiguration = service.getConfiguration(configResource); String backColor = testConfiguration.getString("colors.background"); String textColor = testConfiguration.getString("colors.text"); String linkNormal = testConfiguration.getString("colors.link[@normal]"); String defColor = testConfiguration.getString("colors.default"); int rowsPerPage = testConfiguration.getInt("rowsPerPage"); List buttons = testConfiguration.getList("buttons.name"); assertNotNull(testConfiguration);/*from w w w . ja v a2 s.co m*/ assertEquals(backColor, "#808080"); assertEquals(textColor, "#000000"); assertEquals(linkNormal, "#000080"); assertEquals(defColor, "#008000"); assertEquals(rowsPerPage, 15); assertEquals(buttons.size(), 3); }
From source file:org.chenillekit.core.tests.TestConfigurationService.java
@Test(expectedExceptions = { RuntimeException.class }, enabled = false) public void test4() { Resource configResource = new ClasspathResource("test.ini"); Configuration configuration = service.getConfiguration(configResource); Configuration subConfiguration = configuration.subset("Mail"); assertEquals(subConfiguration.getInt("MAPI"), 1); }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrLogIndexer.java
/** * Pull solr query field parameters from a Properties file and use them to issue a solr query. * * The solr query results are transformed into a Log object and returned. * * The following fields are currently supported and passed through to the solr log index as a query * * fromDate (Types.DateTime) Records with time stamp greater than or equal to (>=) this value will be returned. * Transmitted as a URL query parameter, and so must be escaped accordingly. toDate (Types.DateTime) Records with * a time stamp less than this value will be returned. If not specified, then defaults to now. Transmitted as a URL * query parameter, and so must be escaped accordingly. event (Types.Event) Return only log records for the * specified type of event. Default is all. Transmitted as a URL query parameter, and so must be escaped * accordingly. pidFilter (string) Return only log records for identifiers that start with the supplied identifier * string. Support for this parameter is optional and MAY be ignored by the Member Node implementation with no * warning. Transmitted as a URL query parameter, and so must be escaped accordingly. start=0 (integer) Optional * zero based offset from the first record in the set of matching log records. Used to assist with paging the * response. Transmitted as a URL query parameter, and so must be escaped accordingly. count=1000 (integer) The * maximum number of log records that should be returned in the response. The Member Node may return fewer and the * caller should check the total in the response to determine if further pages may be retrieved. Transmitted as a * URL query parameter, and so must be escaped accordingly. * * * * * @param query/*from www .ja v a 2s .com*/ * @return Log * @throws org.apache.commons.configuration.ConfigurationException * @throws java.io.IOException * @throws org.apache.solr.client.solrj.SolrServerException */ @Override public Log search(Properties query) throws ConfigurationException, IOException, SolrServerException { // since this is the implementation assume the input to be a properties file. Configuration apacheConfiguration = getApacheConfiguration(query); List<LogEntrySolrItem> outputList = new ArrayList(); // may not have to initialize Log log = new Log(); SolrQuery queryParams = new SolrQuery(); queryParams.setQuery(queryStringBuilder(apacheConfiguration)); queryParams.setSortField("dateAggregated", SolrQuery.ORDER.desc); if (apacheConfiguration.containsKey("start")) { queryParams.setStart(apacheConfiguration.getInt("start")); } else { queryParams.setStart(0); } if (apacheConfiguration.containsKey("count")) { queryParams.setRows(apacheConfiguration.getInt("count")); } else { queryParams.setRows(defaultCount); } QueryResponse queryResponse = solrServer.query(queryParams); queryResponse.getResults(); List<LogEntrySolrItem> logEntryList = queryResponse.getBeans(LogEntrySolrItem.class); for (LogEntrySolrItem lesi : logEntryList) { log.addLogEntry(lesi.getLogEntry()); } log.setTotal(Long.valueOf(queryResponse.getResults().getNumFound()).intValue()); log.setStart(Long.valueOf(queryResponse.getResults().getStart()).intValue()); log.setCount(logEntryList.size()); return log; }
From source file:org.dataone.proto.trove.mn.dao.v1.SolrQueryIndexer.java
@Override public ObjectList search(Properties query) throws Exception { // since this is the implementation assume the input to be a properties file. Configuration apacheConfiguration = getApacheConfiguration(query); ObjectList objectList = new ObjectList(); SolrQuery queryParams = new SolrQuery(); queryParams.setQuery(queryStringBuilder(apacheConfiguration)); queryParams.setSortField("id", SolrQuery.ORDER.desc); if (apacheConfiguration.containsKey("start")) { queryParams.setStart(apacheConfiguration.getInt("start")); } else {// ww w. j a v a 2s. c o m queryParams.setStart(0); } if (apacheConfiguration.containsKey("count")) { queryParams.setRows(apacheConfiguration.getInt("count")); } else { queryParams.setRows(defaultCount); } QueryResponse queryResponse = solrServer.query(queryParams); queryResponse.getResults(); List<ObjectInfoSolrItem> objectInfoList = queryResponse.getBeans(ObjectInfoSolrItem.class); for (ObjectInfoSolrItem lesi : objectInfoList) { objectList.addObjectInfo(lesi.getObjectInfo()); } objectList.setTotal(Long.valueOf(queryResponse.getResults().getNumFound()).intValue()); objectList.setStart(Long.valueOf(queryResponse.getResults().getStart()).intValue()); objectList.setCount(objectInfoList.size()); return objectList; }
From source file:org.janusgraph.olap.ShortestDistanceVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { maxDepth = configuration.getInt(MAX_DEPTH); seed = configuration.getLong(SEED);/*from w w w .j a va 2s. c o m*/ weightProperty = configuration.getString(WEIGHT_PROPERTY, "distance"); incidentMessageScope = MessageScope.Local.of(__::inE, (msg, edge) -> msg + edge.<Integer>value(weightProperty)); log.debug("Loaded maxDepth={}", maxDepth); }
From source file:org.jgrades.logging.dao.LoggingConfigurationDaoFileImpl.java
private static LoggingConfiguration extractConfigurationProperties(Configuration externalConfig) { String strategyName = externalConfig.getString(STRATEGY_PROPERTY_NAME); String levelName = externalConfig.getString(LEVEL_PROPERTY_NAME); String maxSizeValue = externalConfig.getString(MAX_FILE_SIZE_PROPERTY_NAME); int maxDaysValue = externalConfig.getInt(MAX_DAYS_PROPERTY_NAME); return new LoggingConfiguration(LoggingStrategy.valueOf(strategyName), JgLogLevel.valueOf(levelName), maxSizeValue, maxDaysValue); }
From source file:org.lable.oss.dynamicconfig.core.commonsconfiguration.ConcurrentConfigurationTest.java
@Test public void testMethodWrappers() { CombinedConfiguration mockConfiguration = mock(CombinedConfiguration.class); Configuration concurrentConfiguration = new ConcurrentConfiguration(mockConfiguration, null); concurrentConfiguration.subset("subset"); concurrentConfiguration.isEmpty();// www . j a v a 2 s. c o m concurrentConfiguration.containsKey("key"); concurrentConfiguration.getProperty("getprop"); concurrentConfiguration.getKeys("getkeys"); concurrentConfiguration.getKeys(); concurrentConfiguration.getProperties("getprops"); concurrentConfiguration.getBoolean("getboolean1"); concurrentConfiguration.getBoolean("getboolean2", true); concurrentConfiguration.getBoolean("getboolean3", Boolean.FALSE); concurrentConfiguration.getByte("getbyte1"); concurrentConfiguration.getByte("getbyte2", (byte) 0); concurrentConfiguration.getByte("getbyte3", Byte.valueOf((byte) 0)); concurrentConfiguration.getDouble("getdouble1"); concurrentConfiguration.getDouble("getdouble2", 0.2); concurrentConfiguration.getDouble("getdouble3", Double.valueOf(0.2)); concurrentConfiguration.getFloat("getfloat1"); concurrentConfiguration.getFloat("getfloat2", 0f); concurrentConfiguration.getFloat("getfloat3", Float.valueOf(0f)); concurrentConfiguration.getInt("getint1"); concurrentConfiguration.getInt("getint2", 0); concurrentConfiguration.getInteger("getint3", 0); concurrentConfiguration.getLong("getlong1"); concurrentConfiguration.getLong("getlong2", 0L); concurrentConfiguration.getLong("getlong3", Long.valueOf(0L)); concurrentConfiguration.getShort("getshort1"); concurrentConfiguration.getShort("getshort2", (short) 0); concurrentConfiguration.getShort("getshort3", Short.valueOf((short) 0)); concurrentConfiguration.getBigDecimal("getbigd1"); concurrentConfiguration.getBigDecimal("getbigd2", BigDecimal.valueOf(0.4)); concurrentConfiguration.getBigInteger("getbigi1"); concurrentConfiguration.getBigInteger("getbigi2", BigInteger.valueOf(2L)); concurrentConfiguration.getString("getstring1"); concurrentConfiguration.getString("getstring2", "def"); concurrentConfiguration.getStringArray("stringarray"); concurrentConfiguration.getList("getlist1"); concurrentConfiguration.getList("getlist2", Arrays.asList("a", "b")); verify(mockConfiguration, times(1)).subset("subset"); verify(mockConfiguration, times(1)).isEmpty(); verify(mockConfiguration, times(1)).containsKey("key"); verify(mockConfiguration, times(1)).getProperty("getprop"); verify(mockConfiguration, times(1)).getKeys("getkeys"); verify(mockConfiguration, times(1)).getKeys(); verify(mockConfiguration, times(1)).getProperties("getprops"); verify(mockConfiguration, times(1)).getBoolean("getboolean1"); verify(mockConfiguration, times(1)).getBoolean("getboolean2", true); verify(mockConfiguration, times(1)).getBoolean("getboolean3", Boolean.FALSE); verify(mockConfiguration, times(1)).getByte("getbyte1"); verify(mockConfiguration, times(1)).getByte("getbyte2", (byte) 0); verify(mockConfiguration, times(1)).getByte("getbyte3", Byte.valueOf((byte) 0)); verify(mockConfiguration, times(1)).getDouble("getdouble1"); verify(mockConfiguration, times(1)).getDouble("getdouble2", 0.2); verify(mockConfiguration, times(1)).getDouble("getdouble3", Double.valueOf(0.2)); verify(mockConfiguration, times(1)).getFloat("getfloat1"); verify(mockConfiguration, times(1)).getFloat("getfloat2", 0f); verify(mockConfiguration, times(1)).getFloat("getfloat3", Float.valueOf(0f)); verify(mockConfiguration, times(1)).getInt("getint1"); verify(mockConfiguration, times(1)).getInt("getint2", 0); verify(mockConfiguration, times(1)).getInteger("getint3", Integer.valueOf(0)); verify(mockConfiguration, times(1)).getLong("getlong1"); verify(mockConfiguration, times(1)).getLong("getlong2", 0L); verify(mockConfiguration, times(1)).getLong("getlong3", Long.valueOf(0L)); verify(mockConfiguration, times(1)).getShort("getshort1"); verify(mockConfiguration, times(1)).getShort("getshort2", (short) 0); verify(mockConfiguration, times(1)).getShort("getshort3", Short.valueOf((short) 0)); verify(mockConfiguration, times(1)).getBigDecimal("getbigd1"); verify(mockConfiguration, times(1)).getBigDecimal("getbigd2", BigDecimal.valueOf(0.4)); verify(mockConfiguration, times(1)).getBigInteger("getbigi1"); verify(mockConfiguration, times(1)).getBigInteger("getbigi2", BigInteger.valueOf(2L)); verify(mockConfiguration, times(1)).getString("getstring1"); verify(mockConfiguration, times(1)).getString("getstring2", "def"); verify(mockConfiguration, times(1)).getStringArray("stringarray"); verify(mockConfiguration, times(1)).getList("getlist1"); verify(mockConfiguration, times(1)).getList("getlist2", Arrays.asList("a", "b")); }