本文整理汇总了Java中org.apache.commons.configuration.CompositeConfiguration.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeConfiguration.setProperty方法的具体用法?Java CompositeConfiguration.setProperty怎么用?Java CompositeConfiguration.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.CompositeConfiguration
的用法示例。
在下文中一共展示了CompositeConfiguration.setProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: propagatesRenderingException
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
@Test(expected = RenderingException.class)
public void propagatesRenderingException() throws Exception {
IndexRenderer renderer = new IndexRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
compositeConfiguration.setProperty(PAGINATE_INDEX, false);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
doThrow(new Exception()).when(mockRenderer).renderIndex(anyString());
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
verify(mockRenderer, never()).renderIndex("random string");
}
示例2: load
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
public static CompositeConfiguration load(File source, boolean isRunServer) throws ConfigurationException {
CompositeConfiguration config = new CompositeConfiguration();
config.setListDelimiter(',');
File customConfigFile = new File(source, LEGACY_CONFIG_FILE);
if (customConfigFile.exists()) {
LEGACY_CONFIG_FILE_EXISTS = true;
config.addConfiguration(new PropertiesConfiguration(customConfigFile));
}
customConfigFile = new File(source, CONFIG_FILE);
if (customConfigFile.exists()) {
config.addConfiguration(new PropertiesConfiguration(customConfigFile));
}
config.addConfiguration(new PropertiesConfiguration(DEFAULT_CONFIG_FILE));
config.addConfiguration(new SystemConfiguration());
if (isRunServer) {
String port = config.getString(Keys.SERVER_PORT);
config.setProperty(Keys.SITE_HOST, "http://localhost:"+port);
}
return config;
}
示例3: readFilterIntoProperties
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
/**
* Filter io contain the properties we wish to substitute in templates.
*
* Uses Apache Commons Configuration to load filters.
*/
private Properties readFilterIntoProperties(final FileInfo filter) throws ConfigurationException, IOException {
final CompositeConfiguration composite = new CompositeConfiguration();
final List<File> files = filter.getFiles();
for (final File file : files) {
final PropertiesConfiguration config = new PropertiesConfiguration(file);
config.setEncoding(configGeneratorParameters.getEncoding());
composite.addConfiguration(config);
}
if (StringUtils.isNotBlank(configGeneratorParameters.getFilterSourcePropertyName())) {
composite.setProperty(configGeneratorParameters.getFilterSourcePropertyName(), filter.getAllSources());
}
return ConfigurationConverter.getProperties(composite);
}
示例4: shouldGenerateTagsHome
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
@Test
public void shouldGenerateTagsHome() throws Exception {
TagsRenderer renderer = new TagsRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
compositeConfiguration.setProperty(Keys.TAG_PATH, "tags");
compositeConfiguration.setProperty(Keys.OUTPUT_EXTENSION, ".html");
compositeConfiguration.setProperty(Keys.RENDER_ENCODING, "UTF-8");
ContentStore contentStore = mock(ContentStore.class);
File destination = folder.newFolder();
//Let it create the files in temporary folder
Renderer rendere = new Renderer(contentStore, destination, new File("."), compositeConfiguration);
Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2"));
when(contentStore.getAllTags()).thenReturn(tags);
int renderResponse = renderer.render(rendere, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
assertThat(renderResponse).isEqualTo(3);
//Verify that index.html is created as tags home.
assertThat(new File(destination, "tags/index.html").exists()).isEqualTo(true);
}
示例5: loadBaseConfig
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
private void loadBaseConfig() {
loadedConfig = new CompositeConfiguration();
loadedConfig.setProperty("name", "name");
loadedConfig.setProperty("owner", "owner");
loadedConfig.setProperty("token", "changeMe");
}
示例6: startup
import org.apache.commons.configuration.CompositeConfiguration; //导入方法依赖的package包/类
public synchronized void startup() throws Exception
{
LOG.info("Starting up cluster...");
config = new CompositeConfiguration();
if (System.getProperty("whirr.config") != null)
{
config.addConfiguration(
new PropertiesConfiguration(System.getProperty("whirr.config")));
}
config.addConfiguration(new PropertiesConfiguration("whirr-default.properties"));
clusterSpec = new ClusterSpec(config);
if (clusterSpec.getPrivateKey() == null)
{
Map<String, String> pair = KeyPair.generate();
clusterSpec.setPublicKey(pair.get("public"));
clusterSpec.setPrivateKey(pair.get("private"));
}
// if a local tarball is available deploy it to the blobstore where it will be available to cassandra
if (System.getProperty("whirr.cassandra_tarball") != null)
{
Pair<BlobMetadata,URI> blob = BlobUtils.storeBlob(config, clusterSpec, System.getProperty("whirr.cassandra_tarball"));
tarball = blob.left;
config.setProperty(CassandraClusterActionHandler.BIN_TARBALL, blob.right.toURL().toString());
// TODO: parse the CassandraVersion property file instead
config.setProperty(CassandraClusterActionHandler.MAJOR_VERSION, "0.8");
}
service = new ServiceFactory().create(clusterSpec.getServiceName());
cluster = service.launchCluster(clusterSpec);
computeService = ComputeServiceContextBuilder.build(clusterSpec).getComputeService();
hosts = new ArrayList<InetAddress>();
for (Instance instance : cluster.getInstances())
{
hosts.add(instance.getPublicAddress());
}
ShutdownHook shutdownHook = new ShutdownHook(this);
Runtime.getRuntime().addShutdownHook(shutdownHook);
waitForClusterInitialization();
running = true;
}