当前位置: 首页>>代码示例>>Java>>正文


Java MapConfiguration类代码示例

本文整理汇总了Java中org.apache.commons.configuration.MapConfiguration的典型用法代码示例。如果您正苦于以下问题:Java MapConfiguration类的具体用法?Java MapConfiguration怎么用?Java MapConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapConfiguration类属于org.apache.commons.configuration包,在下文中一共展示了MapConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderWithPrettyUrls

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
public void renderWithPrettyUrls() throws Exception {
    Map<String, Object> testProperties = new HashMap<String, Object>();
    testProperties.put(Keys.URI_NO_EXTENSION, true);
    testProperties.put(Keys.URI_NO_EXTENSION_PREFIX, "/blog");

    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new MapConfiguration(testProperties));
    config.addConfiguration(ConfigUtil.load(new File(this.getClass().getResource("/").getFile())));

    Crawler crawler = new Crawler(db, sourceFolder, config);
    crawler.crawl(new File(sourceFolder.getPath() + File.separator + config.getString(Keys.CONTENT_FOLDER)));

    Assert.assertEquals(4, db.getDocumentCount("post"));
    Assert.assertEquals(3, db.getDocumentCount("page"));

    DocumentList documents = db.getPublishedPosts();

    for (Map<String, Object> model : documents) {
        String noExtensionUri = "blog/\\d{4}/" + FilenameUtils.getBaseName((String) model.get("file")) + "/";

        Assert.assertThat(model.get("noExtensionUri"), RegexMatcher.matches(noExtensionUri));
        Assert.assertThat(model.get("uri"), RegexMatcher.matches(noExtensionUri + "index\\.html"));
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:26,代码来源:CrawlerTest.java

示例2: shouldReturnDetachedElements

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
public void shouldReturnDetachedElements() {
    final Graph graph = TinkerFactory.createModern();
    final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put(HaltedTraverserStrategy.HALTED_TRAVERSER_FACTORY, DetachedFactory.class.getCanonicalName());
    }})));
    g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
    g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
    g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
    g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
    g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
    g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
    g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
    // should handle nested collections
    g.V().out().fold().next().forEach(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:20,代码来源:HaltedTraverserStrategyTest.java

示例3: createConfiguration

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
protected CompositeConfiguration createConfiguration() throws ConfigurationException {
    final CompositeConfiguration config = new CompositeConfiguration();

    if (properties != null) {
        config.addConfiguration(new MapConfiguration(properties));
    }
    config.addConfiguration(new MapConfiguration(project.getProperties()));
    config.addConfiguration(ConfigUtil.load(inputDirectory));
    
    if (getLog().isDebugEnabled()) {
        getLog().debug("Configuration:");

        Iterator<String> iter = config.getKeys();
        while (iter.hasNext()) {
            String key = iter.next();
            getLog().debug(key + ": " + config.getString(key));
        }
    }

    return config;
}
 
开发者ID:Blazebit,项目名称:jbake-maven-plugin,代码行数:22,代码来源:BuildMojo.java

示例4: setUp

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Before
public void setUp() throws IOException, ServletException {
	req = context.mock(HttpServletRequest.class);
	res = context.mock(HttpServletResponse.class);
	chain = context.mock(FilterChain.class);
	context.checking(new Expectations() {{
		allowing(req).getServletPath(); will(returnValue("/servlet"));
	}});
	
	filter = new AuthzFilter();

	props.put(SAMLUtil.OIOSAML_HOME, System.getProperty("java.io.tmpdir"));
	SAMLConfiguration.setSystemConfiguration(new MapConfiguration(props));
	
	configFile = generateConfigFile();
	
	props.put(Constants.PROP_PROTECTION_CONFIG_FILE, configFile);
	filter.init(null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:20,代码来源:AuthzFilterTest.java

示例5: onSetUp

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Before
public final void onSetUp() throws Exception {
	req = mock(HttpServletRequest.class);
	res = mock(HttpServletResponse.class);
	when(res.getOutputStream()).thenReturn(new ServletOutputStream() {
		public void write(int b) throws IOException {}
	});
	
	session = mock(HttpSession.class);
	when(req.getSession()).thenReturn(session);
	when(session.getId()).thenReturn(UUID.randomUUID().toString());
	
	EntityDescriptor desc = (EntityDescriptor) SAMLUtil.unmarshallElement(getClass().getResourceAsStream("SPMetadata.xml"));
	
	sh = mock(SessionHandler.class);
	
	CredentialRepository rep = new CredentialRepository();
	BasicX509Credential credential = rep.getCredential("test/test.pkcs12", "Test1234");
	
	cfg = new MapConfiguration(new HashMap<String, Object>() {{
		put("oiosaml-sp.assertion.validator", Validator.class.getName());
		put(Constants.PROP_HOME, "/home");
	}});
	IdpMetadata idp = new IdpMetadata("http://schemas.xmlsoap.org/ws/2006/12/federation", (EntityDescriptor)SAMLUtil.unmarshallElement(getClass().getResourceAsStream("IdPMetadata.xml")));
	rc = new RequestContext(req, res, idp, new SPMetadata(desc, "http://schemas.xmlsoap.org/ws/2006/12/federation"), credential, cfg, sh, null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:27,代码来源:AbstractTests.java

示例6: testMetricsHelperRegistration

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
public void testMetricsHelperRegistration() {
  listenerOneOkay = false;
  listenerTwoOkay = false;

  Map<String, String> configKeys = new HashMap<String, String>();
  configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners",
      ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
  Configuration configuration = new MapConfiguration(configKeys);

  MetricsRegistry registry = new MetricsRegistry();

  // Initialize the MetricsHelper and create a new timer
  MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
  MetricsHelper.registerMetricsRegistry(registry);
  MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);

  // Check that the two listeners fired
  assertTrue(listenerOneOkay);
  assertTrue(listenerTwoOkay);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:22,代码来源:MetricsHelperTest.java

示例7: getConfiguration

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Override
public Configuration getConfiguration() {
    final Map<String, Object> map = new HashMap<>();
    map.put(GRAPH_COMPUTER, this.computer.getGraphComputerClass().getCanonicalName());
    if (-1 != this.computer.getWorkers())
        map.put(WORKERS, this.computer.getWorkers());
    if (null != this.computer.getPersist())
        map.put(PERSIST, this.computer.getPersist().name());
    if (null != this.computer.getResultGraph())
        map.put(RESULT, this.computer.getResultGraph().name());
    if (null != this.computer.getVertices())
        map.put(VERTICES, this.computer.getVertices());
    if (null != this.computer.getEdges())
        map.put(EDGES, this.computer.getEdges());
    map.putAll(this.computer.getConfiguration());
    return new MapConfiguration(map);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:VertexProgramStrategy.java

示例8: shouldSupportMapBasedStrategies

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
public void shouldSupportMapBasedStrategies() throws Exception {
    GraphTraversalSource g = EmptyGraph.instance().traversal();
    assertFalse(g.getStrategies().getStrategy(SubgraphStrategy.class).isPresent());
    g = g.withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
        put("vertices", __.hasLabel("person"));
        put("vertexProperties", __.limit(0));
        put("edges", __.hasLabel("knows"));
    }})));
    assertTrue(g.getStrategies().getStrategy(SubgraphStrategy.class).isPresent());
    g = g.withoutStrategies(SubgraphStrategy.class);
    assertFalse(g.getStrategies().getStrategy(SubgraphStrategy.class).isPresent());
    //
    assertFalse(g.getStrategies().getStrategy(ReadOnlyStrategy.class).isPresent());
    g = g.withStrategies(ReadOnlyStrategy.instance());
    assertTrue(g.getStrategies().getStrategy(ReadOnlyStrategy.class).isPresent());
    g = g.withoutStrategies(ReadOnlyStrategy.class);
    assertFalse(g.getStrategies().getStrategy(ReadOnlyStrategy.class).isPresent());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:GraphTraversalSourceTest.java

示例9: parseModelConfig

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
private void parseModelConfig() throws FOSException {
    configuration = new MapConfiguration((Map) modelConfig.getProperties());
    classIndex = this.modelConfig.getIntProperty(CLASS_INDEX, -1);
    if (classIndex < 0) {
        classIndex = this.modelConfig.getAttributes().size() - 1;
    }

    String modelFile = configuration.getString(MODEL_FILE);
    if (modelFile != null) {
        this.model = new File(modelFile);
    }

    String formatValue = configuration.getString(CLASSIFIER_FORMAT);
    if (formatValue != null) {
        ModelDescriptor.Format format = ModelDescriptor.Format.valueOf(formatValue);
        this.modelDescriptor = new ModelDescriptor(format, modelFile);
    }

    classifierThreadSafe = configuration.getBoolean(IS_CLASSIFIER_THREAD_SAFE, false /* defaults to Pool implementation*/);

    String uuid = configuration.getString(ID);
    if (uuid != null) {
        this.id = UUID.fromString(uuid);
    }
}
 
开发者ID:feedzai,项目名称:fos-weka,代码行数:26,代码来源:WekaModelConfig.java

示例10: testApplyReplicationTokenChanges

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
/**
 * Test of applyReplicationTokenChanges method, of class Install.
 */
@Test
public void testApplyReplicationTokenChanges() throws Exception {
        System.out.println("applyReplicationTokenChanges");
        InputStream fis = getClass().getClassLoader().getResourceAsStream("juddi_install_data/root_replicationConfiguration.xml");
        
        ReplicationConfiguration replicationCfg = (ReplicationConfiguration) XmlUtils.unmarshal(fis, ReplicationConfiguration.class);
        Properties props = new Properties();
        props.put(Property.JUDDI_NODE_ID, "uddi:a_custom_node");
        props.put(Property.JUDDI_BASE_URL, "http://juddi.apache.org");
        props.put(Property.JUDDI_BASE_URL_SECURE, "https://juddi.apache.org");
        
        Configuration config = new MapConfiguration(props);
        String thisnode = "uddi:a_custom_node";
        
        ReplicationConfiguration result = Install.applyReplicationTokenChanges(replicationCfg, config, thisnode);
        StringWriter sw = new StringWriter();
        JAXB.marshal(result, sw);
        Assert.assertFalse(sw.toString().contains("${juddi.nodeId}"));
        Assert.assertFalse(sw.toString().contains("${juddi.server.baseurlsecure}"));
        Assert.assertFalse(sw.toString().contains("${juddi.server.baseurl}"));
        
}
 
开发者ID:apache,项目名称:juddi,代码行数:26,代码来源:InstallTest.java

示例11: basePathExists_noOverwrite

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
 public void basePathExists_noOverwrite() throws Exception {
     Assert.assertNull(curatorFramework.checkExists().forPath(base));

     try (CuratorFramework zkCurator = createCuratorFramework()) {
      ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, false);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
		
      Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
      Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
	
      try {
          writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
          Assert.fail();
      } catch (BootstrapException e) {
          //expected
      }
     }
 }
 
开发者ID:Kixeye,项目名称:chassis,代码行数:20,代码来源:ZookeeperConfigurationWriterTest.java

示例12: beforeClass

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Before
public void beforeClass() throws Exception {
    zookeeper = new TestingServer(SocketUtils.findAvailableTcpPort());
    curatorFramework = CuratorFrameworkFactory.newClient(zookeeper.getConnectString(), new RetryOneTime(1000));
    curatorFramework.start();

    curatorFramework.create().forPath(CONFIG_BASE_PATH);

    Map<String, Object> defaults = new HashMap<>();
    defaults.put(DEF_KEY1, DEF_VAL1);
    defaults.put(DEF_KEY2, DEF_VAL2);

    defaultConfiguration = new MapConfiguration(defaults);

    node = UUID.randomUUID().toString();
    config = new ConcurrentCompositeConfiguration();
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:18,代码来源:DynamicZookeeperConfigurationSourceTest.java

示例13: setUp

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    org.apache.log4j.BasicConfigurator.configure();
    LogManager.getRootLogger().setLevel(Level.INFO);
    HttpConfiguration httpConfiguration = new HttpConfiguration(new MapConfiguration(ImmutableMap.<String, Object>of(
            HttpConfiguration.LISTEN_ADDRESS_PROP, HOST,
            HttpConfiguration.LISTEN_PORT_PROP, Integer.toString(PORT)
    )));
    SQLiteWebPushStore sqLiteWebPushStore = SQLiteWebPushStoreFactory.create(new WebPushStoreConfiguration(new BaseConfiguration()));
    sqLiteWebPushStore.createWebPushUserTable();
    WebPushUserIdAuth webPushUserIdAuth = new WebPushUserIdAuth(sqLiteWebPushStore,httpConfiguration);
    PackageSigner packageSigner = new PackageSigner() {
        @Override
        public byte[] sign(byte[] data) throws Exception {
            return new byte[0];
        }
    };
    HashMap<String, String> hashProps = Maps.newHashMap();
    hashProps.put(PackageZipConfiguration.PUSH_PACKAGE_FILES, "pushpackage.raw");
    PackageZipBuilder packageZipBuilder = new PackageZipBuilder(new PackageZipConfiguration(new MapConfiguration(hashProps)), packageSigner);
    PackageZipCreator packageZipCreator = new PackageZipCreator(packageZipBuilder);
    Server server = HttpServiceFactory.create(sqLiteWebPushStore, webPushUserIdAuth, packageZipCreator, mock(ApnsPushManager.class), httpConfiguration);
    server.start();
    client = HttpClients.createDefault();
}
 
开发者ID:chriskearney,项目名称:stickypunch,代码行数:26,代码来源:ModuleFunctionalTest.java

示例14: buildToolkitConfig

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
/**
 * Builds the configuration object for our toolkit config.
 *
 * @return A Configuration object.
 */
private Configuration buildToolkitConfig() {

    // The toolkit configuration file.
    try {
        File configFile = ResourceUtil
                .getFileForResource("jersey2-toolkit.properties");
        return new PropertiesConfiguration(configFile);
    } catch (ConfigurationException ce) {
        logger.error("jersey2-toolkit.properties not readable,"
                + " some features may be misconfigured.");

        // Return a new, empty map configuration so we don't error out.
        return new MapConfiguration(new HashMap<String, String>());
    }
}
 
开发者ID:krotscheck,项目名称:jersey2-toolkit,代码行数:21,代码来源:Jersey2ToolkitConfig.java

示例15: testList

import org.apache.commons.configuration.MapConfiguration; //导入依赖的package包/类
@Test
public void testList() {
    Properties props = new Properties();
    props.setProperty("a", "${b.1},${d}");
    props.setProperty("b.1", "4,5,6,${c}");
    props.setProperty("c", "1,2,3");
    props.setProperty("d", "7,8,9");

    MapConfiguration mapConfig = new MapConfiguration(props);
    mapConfig.setDelimiterParsingDisabled(true);

    ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
    config.addConfiguration(mapConfig);
    config.addConfiguration(new MapConfiguration(new Properties()));

    assertEquals("4,5,6,1,2,3,7,8,9", config.getString("a"));

    ConfigurationBackedDynamicPropertySupportImpl impl = new ConfigurationBackedDynamicPropertySupportImpl(config);

    assertEquals("4,5,6,1,2,3,7,8,9", impl.getString("a"));
}
 
开发者ID:rancher,项目名称:cattle,代码行数:22,代码来源:NamedPropertiesConfigurationTest.java


注:本文中的org.apache.commons.configuration.MapConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。