List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key);
From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java
@Test public void isIgnored() throws IOException { final File tempFile = temporaryFolder.newFile("issue.txt"); final PrintWriter writer = new PrintWriter(tempFile); writer.println("**/*;pmd:AbstractClassWithoutAnyMethod;*"); writer.println("**/*;*;*");//from w ww .j a v a 2 s.c o m writer.close(); final Configuration configuration = Mockito.mock(Configuration.class); Mockito.when(configuration.getString(IgnoreIssueFilter.CONFIG_FILE)).thenReturn(tempFile.getAbsolutePath()); final IgnoreIssueFilter filter = new IgnoreIssueFilter(configuration); Assert.assertFalse("mating ignore", filter.accept(DEFAULT_ISSUE, DEFAULT_CHAIN)); }
From source file:com.microrisc.simply.init.SimpleInitObjectsFactory.java
/** * Creates and returns mapper of device interfaces to theirs implementing classes. * @param configuration source configuration * @return mapper of device interfaces to theirs implementing classes. * @throws java.lang.Exception if an error has occured during creating of * mapper// ww w . j av a 2 s . com */ protected ImplClassesMapper createImplClassesMapper(Configuration configuration) throws Exception { String mappingFile = configuration.getString("implClassesMapping.configFile"); XMLConfiguration mapperConfig = new XMLConfiguration(mappingFile); // get all "interfaceMappings" nodes List<HierarchicalConfiguration> implMappings = mapperConfig.configurationsAt("implMapping"); // if no implementation class mapping exists, throw Exception if (implMappings.isEmpty()) { throw new SimplyException("Implementation mapping: No implementation class mapping exist"); } // mapping Map<Class, Class> ifaceToImpl = new HashMap<>(); // read in all impl mappings for (HierarchicalConfiguration implMapping : implMappings) { String ifaceStr = implMapping.getString("interface"); String implStr = implMapping.getString("implClass"); Class ifaceClass = Class.forName(ifaceStr); Class implClass = Class.forName(implStr); ifaceToImpl.put(ifaceClass, implClass); } return new SimpleImplClassesMapper(ifaceToImpl); }
From source file:com.impetus.kundera.ycsb.runner.YCSBRunner.java
public YCSBRunner(final String propertyFile, final Configuration config) { this.propertyFile = propertyFile; ycsbJarLocation = config.getString("ycsbjar.location"); clientjarlocation = config.getString("clientjar.location"); host = config.getString("hosts"); schema = config.getString("schema"); columnFamilyOrTable = config.getString("columnfamilyOrTable"); releaseNo = config.getDouble("release.no"); runType = config.getString("run.type", "load"); port = config.getInt("port"); password = config.getString("password"); clients = config.getStringArray("clients"); isUpdate = config.containsKey("update"); crudUtils = new HibernateCRUDUtils(); }
From source file:com.appeligo.channelfeed.SendCaptions.java
@Override protected void openSources(Configuration provider) { int tunerCount = provider.getList("tuners.tuner[@deviceNumber]").size(); for (int j = 0; j < tunerCount; j++) { String deviceNumber = provider.getString("tuners.tuner(" + j + ")[@deviceNumber]"); String channel = provider.getString("tuners.tuner(" + j + ")[@channel]"); String callsign = provider.getString("tuners.tuner(" + j + ")[@callsign]"); boolean capturetv = provider.getBoolean("tuners.tuner(" + j + ")[@capturetv]", false); String framesize = provider.getString("tuners.tuner(" + j + ")[@framesize]"); int framerate = provider.getInt("tuners.tuner(" + j + ")[@framerate]", -1); boolean nocaptions = provider.getBoolean("tuners.tuner(" + j + ")[@nocaptions]", false); boolean xds = provider.getBoolean("tuners.tuner(" + j + ")[@xds]", false); boolean itv = provider.getBoolean("tuners.tuner(" + j + ")[@itv]", false); log.info("deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign + ", capturetv=" + capturetv + ", framesize=" + framesize + ", framerate=" + framerate + ", nocaptions=" + nocaptions + ", xds=" + xds + ", itv=" + itv); if (deviceNumber == null || channel == null || callsign == null) { log.error("Invalid configuration in: " + identifyMe()); log.error(" deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign); continue; }/*from w w w . j a v a 2 s .c o m*/ try { VideoDevice videoDevice = new VideoDevice(Integer.parseInt(deviceNumber), getFrequencyStandard()); videoDevice.setChannel(channel); if (capturetv) { TVThread tvThread = new TVThread( "Video record " + getLineupID() + ", channel " + channel + ", callsign " + callsign); tvThread.setEpgService(getEpgService()); tvThread.setLineupID(getLineupID()); tvThread.setCallsign(callsign); tvThread.setCcDocumentRoot(getCaptionDocumentRoot()); if (framesize != null && (framesize.trim().length() > 0)) { tvThread.setFrameSize(framesize); } if (framerate >= 0) { tvThread.setFrameRate(framerate); } tvThread.setVideoDevice(videoDevice); tvThread.start(); } if (!nocaptions) { VideoDeviceReaderThread captionThread = new VideoDeviceReaderThread( "Captions " + getLineupID() + ", channel " + channel + ", callsign " + callsign); Destinations destinations = setupDestinations(); destinations.setCallsign(callsign); destinations.setSendXDS(xds); destinations.setSendITV(itv); captionThread.setDestinations(destinations); captionThread.setVideoDevice(videoDevice); // important to set destination and it's callsign before video device...sorry captionThread.setEpgService(getEpgService()); destinations.connect(); captionThread.start(); } } catch (MalformedURLException e1) { log.error("Exception on a channel", e1); } catch (NumberFormatException e1) { log.error("Exception on a channel", e1); } catch (IOException e1) { log.error("Exception on a channel", e1); } catch (BadChannelException e1) { log.error("Exception on a channel", e1); } catch (Throwable e1) { log.error("Unexpected exception", e1); } } }
From source file:io.mindmaps.graql.internal.analytics.DegreeVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { this.selectedTypes = new HashSet<>(); configuration.getKeys(TYPE).forEachRemaining(key -> selectedTypes.add(configuration.getString(key))); }
From source file:TestExtractor.java
@Test public void testValue() { try {//from ww w . j a v a 2 s. c o m Configuration conf = new PropertiesConfiguration( System.getProperty("user.dir") + "/src/test/resources/xwiki.cfg"); String tmpldap_server = conf .getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_server"); //String tmpldap_base_DN = conf.getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_base_DN"); String tmpBinDN = conf.getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_bind_DN"); String tmpldap_bind_pass = conf .getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_bind_pass"); String[] ldap_server = StringUtils.split(tmpldap_server, "|"); //String[] ldap_base_DN = StringUtils.split(tmpldap_base_DN,"|"); String[] BinDN = StringUtils.split(tmpBinDN, "|"); String[] ldap_bind_pass = StringUtils.split(tmpldap_bind_pass, "|"); int i = 0; String userDomain = StringUtils.split(ldap_server[i], "=")[0]; String userDomainLDAPServer = StringUtils.split(ldap_server[i], "=")[1]; // never used String userDomainLDAPBaseDN = ldap_base_DN[i].split("=")[1]; String userDomainBinDN = StringUtils.split(BinDN[i], "=")[1]; String userDomainldap_bind_pass = StringUtils.split(ldap_bind_pass[i], "=")[1]; assertEquals(userDomain, "ZOZO.AD"); assertEquals(userDomainLDAPServer, "10.0.0.1"); assertEquals(userDomainBinDN, "connecuserssosw@ZOZO.AD"); assertEquals(userDomainldap_bind_pass, "secret001"); i = 3; userDomain = ldap_server[i].split("=")[0]; userDomainLDAPServer = ldap_server[i].split("=")[1]; // never used String userDomainLDAPBaseDN = ldap_base_DN[i].split("=")[1]; userDomainBinDN = BinDN[i].split("=")[1]; userDomainldap_bind_pass = ldap_bind_pass[i].split("=")[1]; assertEquals(userDomain, "SOMEWHERE.INTERNAL"); assertEquals(userDomainLDAPServer, "10.0.0.4"); assertEquals(userDomainBinDN, "connecuserssoau@SOMEWHERE.INTERNAL"); assertEquals(userDomainldap_bind_pass, "secret004"); } catch (ConfigurationException ex) { Logger.getLogger(TestExtractor.class.getName()).log(Level.SEVERE, null, ex); fail(ex.getLocalizedMessage()); } }
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
void configureTickFrequency(Configuration boltConf, BoltDeclarer boltDeclarer) { String tickFrequency = boltConf.getString(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS.replaceAll("\\.", "..")); if (StringUtils.isNotBlank(tickFrequency)) { boltDeclarer.addConfiguration(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, tickFrequency); }/*from ww w . jav a 2 s . c o m*/ }
From source file:es.udc.gii.common.eaf.algorithm.evaluate.SerialEvaluationStrategy.java
@Override public void configure(Configuration conf) { try {/* w w w . ja v a 2s . c o m*/ if (conf.containsKey("ConstraintMethod.Class")) { this.contraintMethod = ((ConstraintMethod) Class.forName(conf.getString("ConstraintMethod.Class")) .newInstance()); this.contraintMethod.configure(conf.subset("ConstraintMethod")); } else { ConfWarning w = new ConfWarning("ConstraintMethod.Class", this.contraintMethod.getClass().getName()); w.warn(); } } catch (Exception ex) { throw new ConfigurationException(this.getClass(), ex); } }
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
/** * Gets a topology builder and a storm spout configuration. Initializes the spout and sets it with the topology * builder.// www. ja v a 2 s . c o m * * @param builder * @param spout * @return * @throws ConfigurationException */ String configureSpout(TopologyBuilder builder, Configuration spout) throws ConfigurationException { String spoutType = spout.getString(TYPE); Configuration spoutConf = spout.subset(CONF); StormParallelismConfig parallelismConfig = getStormParallelismConfig(spoutConf); IRichSpout spoutComponent = (IRichSpout) buildComponent(spoutType, spoutConf); builder.setSpout(spoutType, spoutComponent, parallelismConfig.getParallelismHint()) .setNumTasks(parallelismConfig.getNumTasks()); return spoutType; }
From source file:com.cisco.oss.foundation.message.RabbitMQMessageConsumer.java
RabbitMQMessageConsumer(String consumerName) { try {/*from ww w . j a v a2s. c om*/ this.consumerName = consumerName; Configuration subset = configuration.subset(consumerName); queueName = subset.getString("queue.name"); String filter = subset.getString("queue.filter", ""); boolean isDurable = subset.getBoolean("queue.isDurable", true); boolean isSubscription = subset.getBoolean("queue.isSubscription", false); long expiration = subset.getLong("queue.expiration", 1800000); long maxLength = subset.getLong("queue.maxLength", -1); boolean deadLetterIsEnabled = subset.getBoolean("queue.deadLetterIsEnabled", true); String deadLetterExchangeName = subset.getString("queue.deadLetterExchangeName", DLQ); String subscribedTo = isSubscription ? subset.getString("queue.subscribedTo", "") : queueName; String exchangeType = isSubscription ? "topic" : "direct"; try { RabbitMQMessagingFactory.INIT_LATCH.await(); } catch (InterruptedException e) { LOGGER.error("error waiting for init to finish: " + e); } Channel channel = RabbitMQMessagingFactory.getChannel(); channel.exchangeDeclare(subscribedTo, exchangeType, isDurable, false, false, null); Map<String, Object> args = new HashMap<String, Object>(); if (maxLength > 0) { args.put("x-max-length", maxLength); } if (expiration > 0) { args.put("x-message-ttl", expiration); } if (deadLetterIsEnabled) { channel.exchangeDeclare(deadLetterExchangeName, exchangeType, true, false, false, null); args.put("x-dead-letter-exchange", deadLetterExchangeName); } String queue = channel.queueDeclare(queueName, isDurable, false, false, args).getQueue(); Map<String, String> filters = ConfigUtil.parseSimpleArrayAsMap(consumerName + ".queue.filters"); if (filters != null && !filters.isEmpty()) { for (String routingKey : filters.values()) { channel.queueBind(queue, subscribedTo, routingKey); } } else { channel.queueBind(queue, subscribedTo, "#"); } consumer = new QueueingConsumer(channel); // channel.basicConsume(queueName, true, consumer); LOGGER.info("created rabbitmq consumer: {} on exchange: {}, queue-name: {}", consumerName, subscribedTo, queueName); } catch (IOException e) { throw new QueueException("Can't create consumer: " + e, e); } }