Java 类org.apache.commons.configuration.HierarchicalConfiguration 实例源码

项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * 
 * @param config Preferred configuration
 * @param altConfig Alternative configuration
 * @param inPath XML path
 * @param defaultList List of default values to return if none found in config
 * @return
 */
private static List<String> getLocalList(HierarchicalConfiguration config, HierarchicalConfiguration altConfig, String inPath,
        List<String> defaultList) {
    if (config == null) {
        throw new IllegalArgumentException("config may not be null");
    }
    List<Object> objects = config.getList(inPath, altConfig == null ? null : altConfig.getList(inPath, defaultList));
    if (objects != null && !objects.isEmpty()) {
        List<String> ret = new ArrayList<>(objects.size());
        for (Object obj : objects) {
            ret.add((String) obj);
        }
        return ret;
    }

    return new ArrayList<>(0);
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * Returns mappings for the ESE "type" element.
 * 
 * @return
 * @should return all values
 */
@SuppressWarnings("rawtypes")
public Map<String, String> getEseTypes() {
    Map<String, String> ret = new HashMap<>();

    List<HierarchicalConfiguration> types = getLocalConfigurationsAt("ese.types.docstruct");
    if (types != null) {
        for (Iterator it = types.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
            ret.put(sub.getString("[@name]"), sub.getString("[@type]"));
            // logger.debug("loaded type: " + sub.getString("[@name]") + ": " + sub.getString("[@type]"));
        }
    }

    return ret;
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * Returns a list of additional docstruct types "type" element.
 * 
 * @return
 * @should return all values
 */
@SuppressWarnings("rawtypes")
public List<String> getAdditionalDocstructTypes() {
    List<String> ret = new ArrayList<>();

    List<HierarchicalConfiguration> docstructs = getLocalConfigurationsAt("epicur.additionalDocstructTypes.docstruct");
    if (docstructs != null) {
        for (Iterator it = docstructs.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
            ret.add(sub.getString("."));
            logger.trace("loaded additional docstruct type: {}", sub.getString("."));
        }
    }

    return ret;
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * 
 * @return
 * @should return all values
 */
public List<Set> getAllValuesSets() {
    List<HierarchicalConfiguration> types = getLocalConfigurationsAt("sets.allValuesSet");
    if (types != null) {
        List<Set> ret = new ArrayList<>(types.size());
        for (Iterator<HierarchicalConfiguration> it = types.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = it.next();
            Set set = new Set(sub.getString("."), null, null);
            set.setTranslate(sub.getBoolean("[@translate]", false));
            ret.add(set);
            // logger.debug("loaded type: " + sub.getString("[@name]") + ": " + sub.getString("[@type]"));
        }
        return ret;
    }
    return new ArrayList<>(0);
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * Returns collection names to be omitted from search results, listings etc. from config_viewer.xml
 * 
 * @return
 * @should return all key-value pairs
 */
public List<String> getCollectionBlacklist() {
    List<String> ret = new ArrayList<>();
    if (viewerConfig == null) {
        logger.error("Viewer config not loaded, cannot read collection blacklist.");
        return ret;
    }
    List<HierarchicalConfiguration> templates = viewerConfig.configurationsAt("collections.collection");
    if (templates != null && !templates.isEmpty()) {
        for (Iterator<HierarchicalConfiguration> it = templates.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = it.next();
            String field = sub.getString("[@field]");
            List<Object> collections = sub.getList("blacklist.collection");
            for (Object o : collections) {
                ret.add(field + ":" + (String) o);
            }
        }
    }
    return ret;
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * @return
 * @should return all values
 */
public List<LicenseType> getRestrictedAccessConditions() {
    List<HierarchicalConfiguration> elements = getLocalConfigurationsAt("solr.restrictions.restriction");
    if (elements != null) {
        List<LicenseType> ret = new ArrayList<>(elements.size());
        for (Iterator<HierarchicalConfiguration> it = elements.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = it.next();
            Map<String, String> fieldConfig = new HashMap<>();
            String value = sub.getString(".");
            String field = sub.getString("[@field]", null);
            String condition = sub.getString("[@conditions]", null);
            ret.add(new LicenseType(field, value, condition));
        }
        return ret;
    }

    return new ArrayList<>(0);
}
项目:athena    文件:PortDiscoveryCienaWaveserverImpl.java   
public static PortDescription parseWaveServerCienaOchPorts(long portNumber, long oduPortSpeed,
                                                           HierarchicalConfiguration config,
                                                           SparseAnnotations annotations) {
    final List<String> tunableType = Lists.newArrayList("Performance-Optimized", "Accelerated");
    final String transmitterPath = "ptp-config.transmitter-state";
    final String tunablePath = "ptp-config.adv-config.tx-tuning-mode";
    final String gridTypePath = "ptp-config.adv-config.wl-spacing";
    final String frequencyPath = "ptp-config.adv-config.frequency";

    boolean isEnabled = config.getString(transmitterPath).equals("enabled");
    boolean isTunable = tunableType.contains(config.getString(tunablePath));

    //FIXME change when all optical types have two way information methods, see jira tickets
    final int speed100GbpsinMbps = 100000;
    OduSignalType oduSignalType = oduPortSpeed == speed100GbpsinMbps ? OduSignalType.ODU4 : null;
    GridType gridType = config.getString(gridTypePath).equals("FlexGrid") ? GridType.FLEX : null;
    ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null;

    //Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier
    final int baseFrequency = 193100;
    int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) -
            baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ?

    return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable,
                                  new OchSignal(gridType, chSpacing, spacingMult, 1), annotations);
}
项目:athena    文件:PortGetterFujitsuImpl.java   
/**
 * Parses a configuration and returns a set of ports for the fujitsu T100.
 * @param cfg a hierarchical configuration
 * @return a list of port descriptions
 */
private static List<PortDescription> parseFujitsuT100Ports(HierarchicalConfiguration cfg) {
    AtomicInteger counter = new AtomicInteger(1);
    List<PortDescription> portDescriptions = Lists.newArrayList();
    List<HierarchicalConfiguration> subtrees =
            cfg.configurationsAt("data.interfaces.interface");
    for (HierarchicalConfiguration portConfig : subtrees) {
        if (!portConfig.getString("name").contains("LCN") &&
                !portConfig.getString("name").contains("LMP") &&
                portConfig.getString("type").equals("ianaift:ethernetCsmacd")) {
            portDescriptions.add(parseT100OduPort(portConfig, counter.getAndIncrement()));
        } else if (portConfig.getString("type").equals("ianaift:otnOtu")) {
            portDescriptions.add(parseT100OchPort(portConfig, counter.getAndIncrement()));
        }
    }
    return portDescriptions;
}
项目:athena    文件:XmlParserCisco.java   
/**
 * Parses device configuration and returns the descriptions of the device
 * interfaces.
 *
 * @param cfg an hierarchical configuration
 * @return list of interface descriptions for the device
 */

public static List<DeviceInterfaceDescription> getInterfacesFromConfig(
        HierarchicalConfiguration cfg) {
    List<DeviceInterfaceDescription> intfs = Lists.newArrayList();
    List<HierarchicalConfiguration> subtrees =
            cfg.configurationsAt("data.xml-config-data.Device-Configuration.interface");
    for (HierarchicalConfiguration intfConfig :subtrees) {
        String intfName = getInterfaceName(intfConfig);
        DeviceInterfaceDescription.Mode intfMode = getInterfaceMode(intfConfig);
        List<VlanId> intfVlans = getInterfaceVlans(intfConfig, intfMode);
        short intfLimit = getInterfaceLimit(intfConfig);
        boolean intfLimited = (intfLimit == NO_LIMIT ?  false : true);
        DeviceInterfaceDescription intf =
                new DefaultDeviceInterfaceDescription(intfName,
                                                      intfMode,
                                                      intfVlans,
                                                      intfLimited,
                                                      intfLimit);
        intfs.add(intf);
    }
    return intfs;
}
项目:athena    文件:YangXmlUtils.java   
private String findPath(HierarchicalConfiguration cfg, String element) {
    Iterator<String> it = cfg.getKeys();
    while (it.hasNext()) {
        String key = it.next();
        String[] arr = key.split("\\.");
        for (int i = 0; i < arr.length; i++) {
            if (element.equals(arr[i])) {
                String completeKey = "";
                for (int j = 0; j <= i; j++) {
                    completeKey = completeKey + "." + arr[j];
                }
                return completeKey.substring(1);
            }
        }
    }
    return null;
}
项目:athena    文件:XmlDriverLoader.java   
/**
 * Loads a driver from the supplied hierarchical configuration.
 *
 * @param driverCfg hierarchical configuration containing the driver definition
 * @param resolver  driver resolver
 * @return driver
 */
public DefaultDriver loadDriver(HierarchicalConfiguration driverCfg,
                                DriverResolver resolver) {
    String name = driverCfg.getString(NAME);
    String parentsString = driverCfg.getString(EXTENDS, "");
    List<Driver> parents = Lists.newArrayList();
    if (!parentsString.equals("")) {
        List<String> parentsNames;
        if (parentsString.contains(",")) {
            parentsNames = Arrays.asList(parentsString.replace(" ", "").split(","));
        } else {
            parentsNames = Lists.newArrayList(parentsString);
        }
        parents = parentsNames.stream().map(parent -> (parent != null) ?
                resolve(parent, resolver) : null).collect(Collectors.toList());
    }
    String manufacturer = driverCfg.getString(MFG, "");
    String hwVersion = driverCfg.getString(HW, "");
    String swVersion = driverCfg.getString(SW, "");
    return new DefaultDriver(name, parents, manufacturer, hwVersion, swVersion,
                             parseBehaviours(driverCfg),
                             parseProperties(driverCfg));
}
项目:CacheStore    文件:BuildRemoteConfig.java   
public RemoteConfig build() {
    int port = config.getInt("port", 7210);
    String className = config.getString("className");
    int maxQueue = config.getInt("maxQueue", Runtime.getRuntime().availableProcessors() * 100);
    int maxThread = config.getInt("maxThread", Runtime.getRuntime().availableProcessors());
    int replicaPort = config.getInt("replicaPort", 7310);
    freq = config.getInt("freq", 10);
    boolean useNio = config.getBoolean("useNio", true);
    List<HierarchicalConfiguration> list = (List<HierarchicalConfiguration>) config.configurationsAt(STORE);
    if (list == null || list.size() == 0 ) throw new RuntimeException("list is null or freq ==0 for node "+STORE);
    List<StoreConfig> toReturn = new CopyOnWriteArrayList<StoreConfig>();
    for( HierarchicalConfiguration each : list) {
        toReturn.add( buildStoreConfig( each));
    }
    RemoteConfig remoteConfig = new RemoteConfig(maxQueue, maxThread, port, className, toReturn, replicaPort, freq);
    remoteConfig.setUseNio( useNio);
    return remoteConfig;

}
项目:CacheStore    文件:BuildClusterNodes.java   
public List<ClusterNodes> build() {
    List<HierarchicalConfiguration> list = (List<HierarchicalConfiguration>) config.configurationsAt(CLUSTERS);
    if (list == null || list.size() == 0 ) throw new RuntimeException("list is null or freq ==0 for node "+CLUSTERS);
    List<ClusterNodes> toReturn = new CopyOnWriteArrayList<ClusterNodes>();
    StringBuilder stringBuilder = new StringBuilder();
    HashSet<Short> sets = new HashSet<Short>();
    int error = 0;
    for (HierarchicalConfiguration each : list) {
        ClusterNodes clusterNode = buildClusterNodes(each);
        if (sets.contains( clusterNode.getId())) {
            error++;
            stringBuilder.append(" cluster no "+ clusterNode.getId());
        }
        else
            sets.add( clusterNode.getId() );
        toReturn.add( clusterNode);
    }
    if ( error > 0 ) {
        throw new RuntimeException(error+" duplicate clusters , "+stringBuilder.toString()+" in clusters.xml" );
    }
    else
        return toReturn;
}
项目:atf-toolbox-java    文件:ConfigurationManager.java   
private void loadConfiguration() {
    Properties sysProps = System.getProperties();
    String configFileName = sysProps.getProperty("test.config.filename");

    if (StringUtils.isEmpty(configFileName)) {
        configFileName = defaultConfigurationFileName;
    }

    try {
        AllConfiguration = new DefaultConfigurationBuilder(configFileName).getConfiguration();
        ((HierarchicalConfiguration) AllConfiguration).setExpressionEngine(new XPathExpressionEngine());
    } catch (Exception e) {
        Fail.fail("failed to read config file", e);
        log.error("Failed to read config file", e);
    }
}
项目:java-cme-mdp3-handler    文件:Configuration.java   
/**
 * Loads and parse CME MDP Configuration.
 *
 * @param uri URI to CME MDP Configuration (config.xml, usually available on CME FTP)
 * @throws ConfigurationException if failed to parse configuration file
 * @throws MalformedURLException  if URI to Configuration is malformed
 */
private void load(final URI uri) throws ConfigurationException, MalformedURLException {
    // todo: if to implement the same via standard JAXB then dep to apache commons configuration will be not required
    final XMLConfiguration configuration = new XMLConfiguration();
    configuration.setDelimiterParsingDisabled(true);
    configuration.load(uri.toURL());
    for (final HierarchicalConfiguration channelCfg : configuration.configurationsAt("channel")) {
        final ChannelCfg channel = new ChannelCfg(channelCfg.getString("[@id]"), channelCfg.getString("[@label]"));

        for (final HierarchicalConfiguration connCfg : channelCfg.configurationsAt("connections.connection")) {
            final String id = connCfg.getString("[@id]");
            final FeedType type = FeedType.valueOf(connCfg.getString("type[@feed-type]"));
            final TransportProtocol protocol = TransportProtocol.valueOf(connCfg.getString("protocol").substring(0, 3));
            final Feed feed = Feed.valueOf(connCfg.getString("feed"));
            final String ip = connCfg.getString("ip");
            final int port = connCfg.getInt("port");
            final List<String> hostIPs = Arrays.asList(connCfg.getStringArray("host-ip"));

            final ConnectionCfg connection = new ConnectionCfg(feed, id, type, protocol, ip, hostIPs, port);
            channel.addConnection(connection);
            connCfgs.put(connection.getId(), connection);
        }
        channelCfgs.put(channel.getId(), channel);
    }
}
项目:Tank    文件:AgentConfigCpTest.java   
/**
 * Run the AgentConfig(HierarchicalConfiguration) constructor test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testAgentConfig_1()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();

    AgentConfig result = new AgentConfig(config);

    assertNotNull(result);
    assertEquals(new Long(40000L), result.getConnectionTimeout());
    assertEquals(false, result.getLogVariables());
    assertEquals(false, result.getLogPostResponse());
    assertEquals(8090, result.getAgentPort());
    assertEquals(false, result.getLogPostRequest());
    assertEquals(90000L, result.getSSLTimeout());
    assertEquals(5000L, result.getMaxAgentResponseTime());
    assertEquals(180000L, result.getMaxAgentWaitTime());
    assertEquals("/tmp", result.getAgentDataFileStorageDir());
    assertEquals(15, result.getTPSPeriod());
    assertEquals(7200000L, result.getOverSimulationMaxTime());
    assertEquals(5000, result.getMaxBodyReportSize());
    assertEquals(null, result.getDefaultResultProvider());
}
项目:development    文件:LPlatformBase.java   
public List<Network> getNetworks() {
    List<Network> result = new LinkedList<Network>();
    if (configuration != null) {
        List<HierarchicalConfiguration> networks = configuration
                .configurationsAt("networks.network");
        for (HierarchicalConfiguration networkEntry : networks) {
            int maxVm = 0;
            try {
                maxVm = Integer.parseInt(networkEntry
                        .getString("numOfMaxVm"));
            } catch (NumberFormatException e) {
                maxVm = Integer.MAX_VALUE;
            }
            Network network = new Network(networkEntry.getString("name"),
                    networkEntry.getString("networkCategory"),
                    networkEntry.getString("networkId"), maxVm);
            result.add(network);
        }
    }
    return result;
}
项目:development    文件:LServerConfiguration.java   
@Override
public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append("============ Server Configuration =========\n");
    sb.append("ServerId:\t" + getServerId() + "\n");
    sb.append("ServerName:\t" + getServerName() + "\n");
    sb.append("ServerType:\t" + getServerType() + "\n");
    sb.append("DiskImgId:\t" + getDiskImageId() + "\n");
    sb.append("VMHostPool:\t" + getPool() + "\n");
    sb.append("StoragePool:\t" + getStoragePool() + "\n");
    sb.append("NetworkID:\t" + getNetworkId() + " [");
    List<HierarchicalConfiguration> nics = configuration
            .configurationsAt("nics.nic");
    for (HierarchicalConfiguration nic : nics) {
        sb.append("networkID=" + nic.getString("networkId") + ", ");
        sb.append("nicNo=" + nic.getString("nicNo") + ", ");
        sb.append("management=" + nic.getString("management") + "]\n");
    }
    sb.append("===========================================\n");
    return sb.toString();
}
项目:Tank    文件:AgentConfigCpTest.java   
/**
 * Run the AgentConfig(HierarchicalConfiguration) constructor test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testAgentConfig_9()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();

    AgentConfig result = new AgentConfig(config);

    assertNotNull(result);
    assertEquals(new Long(40000L), result.getConnectionTimeout());
    assertEquals(false, result.getLogVariables());
    assertEquals(false, result.getLogPostResponse());
    assertEquals(8090, result.getAgentPort());
    assertEquals(false, result.getLogPostRequest());
    assertEquals(90000L, result.getSSLTimeout());
    assertEquals(5000L, result.getMaxAgentResponseTime());
    assertEquals(180000L, result.getMaxAgentWaitTime());
    assertEquals("/tmp", result.getAgentDataFileStorageDir());
    assertEquals(15, result.getTPSPeriod());
    assertEquals(7200000L, result.getOverSimulationMaxTime());
    assertEquals(5000, result.getMaxBodyReportSize());
    assertEquals(null, result.getDefaultResultProvider());
}
项目:development    文件:RORClient.java   
/**
 * Retrieves a list of disk images available for the tenant.
 * 
 * @return the list
 * @throws RORException
 */
public List<DiskImage> listDiskImages() throws IaasException {
    HashMap<String, String> request = getBasicParameters();
    request.put(LParameter.ACTION, LOperation.LIST_DISKIMAGE);
    XMLConfiguration result = execute(request);

    List<DiskImage> resultList = new LinkedList<DiskImage>();
    if (result != null) {
        List<HierarchicalConfiguration> images = result
                .configurationsAt("diskimages.diskimage");
        for (HierarchicalConfiguration image : images) {
            resultList.add(new RORDiskImage(image));
        }
    }
    return resultList;
}
项目:yamj-v2    文件:Library.java   
private static void fillCategoryMap(String xmlCategoryFilename) {
    File xmlFile = new File(xmlCategoryFilename);
    if (xmlFile.exists() && xmlFile.isFile() && xmlCategoryFilename.toUpperCase().endsWith("XML")) {

        try {
            XMLConfiguration c = new XMLConfiguration(xmlFile);

            List<HierarchicalConfiguration> categories = c.configurationsAt("category");
            for (HierarchicalConfiguration category : categories) {
                boolean enabled = Boolean.parseBoolean(category.getString("enable", TRUE));

                if (enabled) {
                    String origName = category.getString(LIT_NAME);
                    String newName = category.getString("rename", origName);
                    CATEGORIES_MAP.put(origName, newName);
                    //logger.debug("Added category '" + origName + "' with name '" + newName + "'");
                }
            }
        } catch (ConfigurationException error) {
            LOG.error("Failed parsing moviejukebox category input file: {}", xmlFile.getName());
            LOG.error(SystemTools.getStackTrace(error));
        }
    } else {
        LOG.error("The moviejukebox category input file you specified is invalid: {}", xmlFile.getName());
    }
}
项目:java-dynamicconfig    文件:ZookeepersAsConfigSourceIT.java   
@Test
public void viaInitializerTest() throws Exception {
    setData(zookeeper, "test", "\n");

    System.setProperty(LIBRARY_PREFIX + ".type", "zookeeper");
    System.setProperty(LIBRARY_PREFIX + ".zookeeper.znode", "/config");
    System.setProperty(LIBRARY_PREFIX + ".zookeeper.quorum", zookeeperHost);
    System.setProperty(LIBRARY_PREFIX + "." + APPNAME_PROPERTY, "test");
    HierarchicalConfiguration defaults = new HierarchicalConfiguration();
    defaults.setProperty("key", "DEFAULT");

    Configuration configuration = ConfigurationManager.configureFromProperties(
            defaults, new YamlDeserializer()
    );

    assertThat(configuration.getString("key"), is("DEFAULT"));

    setData(zookeeper, "test", "key: AAA");
    TimeUnit.MILLISECONDS.sleep(300);

    assertThat(configuration.getString("key"), is("AAA"));
}
项目:Tank    文件:AgentConfigCpTest.java   
/**
 * Run the AgentConfig(HierarchicalConfiguration) constructor test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testAgentConfig_5()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();

    AgentConfig result = new AgentConfig(config);

    assertNotNull(result);
    assertEquals(new Long(40000L), result.getConnectionTimeout());
    assertEquals(false, result.getLogVariables());
    assertEquals(false, result.getLogPostResponse());
    assertEquals(8090, result.getAgentPort());
    assertEquals(false, result.getLogPostRequest());
    assertEquals(90000L, result.getSSLTimeout());
    assertEquals(5000L, result.getMaxAgentResponseTime());
    assertEquals(180000L, result.getMaxAgentWaitTime());
    assertEquals("/tmp", result.getAgentDataFileStorageDir());
    assertEquals(15, result.getTPSPeriod());
    assertEquals(7200000L, result.getOverSimulationMaxTime());
    assertEquals(5000, result.getMaxBodyReportSize());
    assertEquals(null, result.getDefaultResultProvider());
}
项目:java-dynamicconfig    文件:JsonSerializer.java   
/**
     * {@inheritDoc}
     */
    @Override
    public void serialize(HierarchicalConfiguration configuration, OutputStream output, boolean humanReadable)
            throws ConfigurationException {
        StringWriter writer = new StringWriter();
        if (humanReadable) {
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
        } else {
            mapper.disable(SerializationFeature.INDENT_OUTPUT);
        }

//        mapper.enable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);
//        mapper.disable(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED);

        try {
            mapper.writeValue(writer, traverseTreeAndEmit(configuration.getRootNode()));
            output.write(writer.toString().getBytes());
        } catch (IOException e) {
            throw new ConfigurationException("IOException caught.", e);
        }
    }
项目:development    文件:LPlatformDescriptorConfigurationTest.java   
@Test
public void getVSystemTemplateId() {
    // given
    HierarchicalConfiguration configuration = mock(HierarchicalConfiguration.class);
    List<HierarchicalConfiguration> servers = new ArrayList<HierarchicalConfiguration>();
    servers.add(configuration);
    when(configuration.getString(eq(LSERVERTYPE))).thenReturn(LSERVERTYPE);
    when(configuration.configurationsAt(eq("lservers.lserver")))
            .thenReturn(servers);

    // when
    lPlatformDescriptorConfiguration = new LPlatformDescriptorConfiguration(
            configuration);
    List<LServerConfiguration> result = lPlatformDescriptorConfiguration
            .getVServers();

    // then
    assertEquals(1, result.size());
    assertEquals(LSERVERTYPE, result.get(0).getLServerType());
}
项目:Tank    文件:BaseCommonsXmlConfigCpTest.java   
/**
 * Run the HierarchicalConfiguration getChildConfigurationAt(HierarchicalConfiguration,String) method test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testGetChildConfigurationAt_2()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();
    String key = "";

    HierarchicalConfiguration result = BaseCommonsXmlConfig.getChildConfigurationAt(config, key);

    assertNotNull(result);
    assertEquals(true, result.isEmpty());
    assertEquals(false, result.isDelimiterParsingDisabled());
    assertEquals(',', result.getListDelimiter());
    assertEquals(false, result.isThrowExceptionOnMissing());
    assertEquals(false, result.isDetailEvents());
}
项目:Tank    文件:AgentConfigCpTest.java   
/**
 * Run the AgentConfig(HierarchicalConfiguration) constructor test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testAgentConfig_6()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();

    AgentConfig result = new AgentConfig(config);

    assertNotNull(result);
    assertEquals(new Long(40000L), result.getConnectionTimeout());
    assertEquals(false, result.getLogVariables());
    assertEquals(false, result.getLogPostResponse());
    assertEquals(8090, result.getAgentPort());
    assertEquals(false, result.getLogPostRequest());
    assertEquals(90000L, result.getSSLTimeout());
    assertEquals(5000L, result.getMaxAgentResponseTime());
    assertEquals(180000L, result.getMaxAgentWaitTime());
    assertEquals("/tmp", result.getAgentDataFileStorageDir());
    assertEquals(15, result.getTPSPeriod());
    assertEquals(7200000L, result.getOverSimulationMaxTime());
    assertEquals(5000, result.getMaxBodyReportSize());
    assertEquals(null, result.getDefaultResultProvider());
}
项目:Tank    文件:AgentConfigCpTest.java   
/**
 * Run the AgentConfig(HierarchicalConfiguration) constructor test.
 * 
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testAgentConfig_7()
        throws Exception {
    HierarchicalConfiguration config = new HierarchicalConfiguration();

    AgentConfig result = new AgentConfig(config);

    assertNotNull(result);
    assertEquals(new Long(40000L), result.getConnectionTimeout());
    assertEquals(false, result.getLogVariables());
    assertEquals(false, result.getLogPostResponse());
    assertEquals(8090, result.getAgentPort());
    assertEquals(false, result.getLogPostRequest());
    assertEquals(90000L, result.getSSLTimeout());
    assertEquals(5000L, result.getMaxAgentResponseTime());
    assertEquals(180000L, result.getMaxAgentWaitTime());
    assertEquals("/tmp", result.getAgentDataFileStorageDir());
    assertEquals(15, result.getTPSPeriod());
    assertEquals(7200000L, result.getOverSimulationMaxTime());
    assertEquals(5000, result.getMaxBodyReportSize());
    assertEquals(null, result.getDefaultResultProvider());
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * 
 * @param inPath
 * @return
 */
private List<HierarchicalConfiguration> getLocalConfigurationsAt(String inPath) {
    List<HierarchicalConfiguration> ret = configLocal.configurationsAt(inPath);
    if (ret == null || ret.isEmpty()) {
        ret = configDefault.configurationsAt(inPath);
    }

    return ret;
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * 
 * @param metadataFormat
 * @return
 * @should return all values
 */
public List<FieldConfiguration> getFieldForMetadataFormat(String metadataFormat) {
    if (metadataFormat == null) {
        throw new IllegalArgumentException("metadataFormat may not be null");
    }

    List<HierarchicalConfiguration> elements = getLocalConfigurationsAt(metadataFormat + ".fields.field");
    if (elements != null) {
        List<FieldConfiguration> ret = new ArrayList<>(elements.size());
        for (Iterator<HierarchicalConfiguration> it = elements.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = it.next();
            Map<String, String> fieldConfig = new HashMap<>();
            String name = sub.getString("[@name]", null);
            String valueSource = sub.getString("[@valueSource]", null);
            boolean translate = sub.getBoolean("[@translate]", false);
            boolean multivalued = sub.getBoolean("[@multivalued]", false);
            boolean useTopstructValueIfNoneFound = sub.getBoolean("[@useTopstructValueIfNoneFound]", false);
            String defaultValue = sub.getString("[@defaultValue]", null);
            String prefix = sub.getString("[@prefix]", null);
            if (prefix != null) {
                prefix = prefix.replace("_SPACE_", " ");
            }
            String suffix = sub.getString("[@suffix]", null);
            if (suffix != null) {
                suffix = suffix.replace("_SPACE_", " ");
            }
            ret.add(new FieldConfiguration(name, valueSource, translate, multivalued, useTopstructValueIfNoneFound, defaultValue, prefix,
                    suffix));
        }
        return ret;
    }

    return null;
}
项目:goobi-viewer-connector    文件:Configuration.java   
/**
 * 
 * @return
 * @should return all values
 */
public List<Set> getAdditionalSets() {
    List<HierarchicalConfiguration> types = getLocalConfigurationsAt("sets.set");
    if (types != null) {
        List<Set> ret = new ArrayList<>(types.size());
        for (Iterator<HierarchicalConfiguration> it = types.iterator(); it.hasNext();) {
            HierarchicalConfiguration sub = it.next();
            Set set = new Set(sub.getString("[@setName]"), sub.getString("[@setSpec]"), sub.getString("[@setQuery]"));
            ret.add(set);
            // logger.debug("loaded type: " + sub.getString("[@name]") + ": " + sub.getString("[@type]"));
        }
        return ret;
    }
    return new ArrayList<>(0);
}
项目:obevo    文件:DbEnvironmentXmlEnricher.java   
private static Function<HierarchicalConfiguration, Group> convertCfgToGroup(final Tokenizer tokenizer) {
    return new Function<HierarchicalConfiguration, Group>() {
        @Override
        public Group valueOf(HierarchicalConfiguration cfg) {
            return new Group(tokenizer.tokenizeString(cfg.getString("[@name]")));
        }
    };
}
项目:obevo    文件:DbEnvironmentXmlEnricher.java   
private static Function<HierarchicalConfiguration, User> convertCfgToUser(final Tokenizer tokenizer) {
    return new Function<HierarchicalConfiguration, User>() {
        @Override
        public User valueOf(HierarchicalConfiguration cfg) {
            return new User(tokenizer.tokenizeString(cfg.getString("[@name]")), cfg.getString("[@password]"),
                    cfg.getBoolean("[@admin]", false));
        }
    };
}
项目:obevo    文件:DbEnvironmentXmlEnricher.java   
private static Function<HierarchicalConfiguration, Permission> convertCfgToPermission(final Tokenizer tokenizer) {
    return new Function<HierarchicalConfiguration, Permission>() {
        @Override
        public Permission valueOf(HierarchicalConfiguration cfg) {
            return new Permission(cfg.getString("[@scheme]"),
                    iterConfig(cfg, "grant").collect(convertCfgToGrant(tokenizer)));
        }
    };
}
项目:obevo    文件:DbEnvironmentXmlEnricher.java   
private static Function<HierarchicalConfiguration, Grant> convertCfgToGrant(final Tokenizer tokenizer) {
    return new Function<HierarchicalConfiguration, Grant>() {
        @Override
        public Grant valueOf(HierarchicalConfiguration cfg) {
            MutableListMultimap<GrantTargetType, String> grantTargetMap = Multimaps.mutable.list.empty();
            grantTargetMap.putAll(GrantTargetType.GROUP, iterString(cfg, "[@groups]").collect(tokenizer.tokenizeString()));
            grantTargetMap.putAll(GrantTargetType.USER, iterString(cfg, "[@users]").collect(tokenizer.tokenizeString()));
            return new Grant(
                    iterString(cfg, "[@privileges]").toImmutable(),
                    grantTargetMap.toImmutable()
            );
        }
    };
}
项目:obevo    文件:DbEnvironmentXmlEnricher.java   
/**
 * Returns the desired property from the config, giving preference to the environment but defaulting to the system if it exists.
 * The calls above should look to adopt this method.
 */
private String getProperty(HierarchicalConfiguration sysCfg, HierarchicalConfiguration envCfg, String property) {
    String envVal = envCfg.getString(property);
    if (envVal != null) {
        return envVal;
    }

    String sysVal = sysCfg.getString(property);
    if (sysVal != null) {
        return sysVal;
    }

    return null;
}
项目:athena    文件:PortGetterFujitsuImpl.java   
private static PortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration otuConfig = cfg.configurationAt("otu");
    boolean enabled = otuConfig.getString("administrative-state").equals("up");
    OduSignalType signalType = otuConfig.getString("rate").equals("OTU4") ? OduSignalType.ODU4 : null;
    //Unsure how to retreive, outside knowledge it is tunable.
    boolean isTunable = true;
    OchSignal lambda = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
    DefaultAnnotations annotations = DefaultAnnotations.builder().
            set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
            build();
    return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations);
}
项目:athena    文件:PortGetterFujitsuImpl.java   
private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
    boolean enabled = ethernetConfig.getString("administrative-state").equals("up");
    //Rate is in kbps
    CltSignalType signalType = ethernetConfig.getString("rate").equals("100000000") ?
            CltSignalType.CLT_100GBE : null;
    DefaultAnnotations annotations = DefaultAnnotations.builder().
            set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
            build();
    return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
项目:athena    文件:XmlParserCisco.java   
private static DeviceInterfaceDescription.Mode
getInterfaceMode(HierarchicalConfiguration intfConfig) {
    if (intfConfig.containsKey(TRUNK_MODE_KEY)) {
        return DeviceInterfaceDescription.Mode.TRUNK;
    } else if (intfConfig.containsKey(ACCESS_KEY)) {
        return DeviceInterfaceDescription.Mode.ACCESS;
    } else {
        return DeviceInterfaceDescription.Mode.NORMAL;
    }
}
项目:athena    文件:XmlParserCisco.java   
private static List<VlanId> getInterfaceVlans(
        HierarchicalConfiguration intfConfig,
        DeviceInterfaceDescription.Mode mode) {
    List<VlanId> vlans = Lists.newArrayList();
    if (mode == DeviceInterfaceDescription.Mode.ACCESS) {
        vlans.add(getVlanForAccess(intfConfig));
    } else if (mode == DeviceInterfaceDescription.Mode.TRUNK) {
        vlans.addAll(getVlansForTrunk(intfConfig));
    }
    return vlans;
}