List of usage examples for org.apache.commons.configuration Configuration setProperty
void setProperty(String key, Object value);
From source file:org.lrodero.blueprintstests.TestLocal.java
protected static Graph createLocalTitanGraph(File storageDir) { logger.info("Creating local Titan database configuration"); Configuration conf = new BaseConfiguration(); conf.setProperty("storage.directory", storageDir.getAbsolutePath()); conf.setProperty("storage.backend", "berkeleyje"); logger.info("Creating local Titan database instance"); return TitanFactory.open(conf); }
From source file:org.lrodero.blueprintstests.TestLocal.java
protected static Graph createLocalNeo4jGraph(File storageDir) { logger.info("Creating local Neo4J database configuration"); Configuration conf = new BaseConfiguration(); conf.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph"); conf.setProperty("blueprints.neo4j.directory", storageDir.getAbsolutePath()); logger.info("Creating local Neo4J database instance"); return GraphFactory.open(conf); }
From source file:org.lrodero.blueprintstests.TestLocal.java
protected static Graph createLocalOrientDBGraph(File storageDir) { logger.info("Creating local OrientDB database configuration"); Configuration conf = new BaseConfiguration(); conf.setProperty("blueprints.graph", "com.tinkerpop.blueprints.impls.orient.OrientGraph"); conf.setProperty("blueprints.orientdb.url", "local:" + storageDir.getAbsolutePath()); logger.info("Creating local OrientDB database instance"); return GraphFactory.open(conf); }
From source file:org.mobicents.servlet.restcomm.http.EndpointMockedTest.java
private Configuration getConfiguration(String path, String homeDirectory, String rootUri) throws ConfigurationException { Configuration xml = null; XMLConfiguration xmlConfiguration = new XMLConfiguration(); xmlConfiguration.setDelimiterParsingDisabled(true); xmlConfiguration.setAttributeSplittingDisabled(true); xmlConfiguration.load(path);/*from w w w . j ava 2s . com*/ xml = xmlConfiguration; xml.setProperty("runtime-settings.home-directory", homeDirectory); xml.setProperty("runtime-settings.root-uri", rootUri); return xml; }
From source file:org.mobicents.servlet.sip.restcomm.Bootstrapper.java
public static void bootstrap(final ServletConfig config) throws BootstrapException { final ServletContext context = config.getServletContext(); final String path = context.getRealPath("WEB-INF/conf/vnxivr.xml"); LOGGER.info("loading configuration file located at " + path); // Initialize the configuration interpolator. final ConfigurationStringLookup strings = new ConfigurationStringLookup(); strings.addProperty("home", getRestCommPath(config)); strings.addProperty("uri", getRestCommUri(config)); ConfigurationInterpolator.registerGlobalLookup("vnxivr", strings); // Load the vnxivr configuration. XMLConfiguration configuration = null; try {/* ww w . j av a 2 s. c o m*/ configuration = new XMLConfiguration(path); } catch (final ConfigurationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } // Register the services with the service locator. final ServiceLocator services = ServiceLocator.getInstance(); try { final Configuration runtimeConfiguration = configuration.subset("runtime-settings"); runtimeConfiguration.setProperty("home-directory", getRestCommPath(config)); runtimeConfiguration.setProperty("root-uri", getRestCommUri(config)); services.set(Configuration.class, runtimeConfiguration); final MgcpServerManager serverManager = getMgcpServerManager(configuration); services.set(MgcpServerManager.class, serverManager); final CallManager callManager = (CallManager) context .getAttribute("org.mobicents.servlet.sip.restcomm.callmanager.CallManager"); services.set(CallManager.class, callManager); services.set(ConferenceCenter.class, getConferenceCenter(serverManager)); services.set(SmsAggregator.class, getSmsAggregator(configuration)); } catch (final ObjectInstantiationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } }
From source file:org.neo4j.server.advanced.BootstrapperTest.java
@Test public void shouldBeAbleToRestartServer() throws Exception { TargetDirectory target = TargetDirectory.forTest(getClass()); String dbDir1 = target.cleanDirectory("db1").getAbsolutePath(); Configurator config = new PropertyFileConfigurator(Validator.NO_VALIDATION, AdvancedServerBuilder.server().usingDatabaseDir(dbDir1).createPropertiesFiles(), ConsoleLogger.DEV_NULL);//from w w w .j a va 2 s. c o m // TODO: This needs to be here because of a startuphealthcheck // that requires this system property. Look into moving // config file check into bootstrapper to avoid this. File irrelevant = target.file("irrelevant"); irrelevant.createNewFile(); config.configuration().setProperty("org.neo4j.server.properties", irrelevant.getAbsolutePath()); AdvancedNeoServer server = new AdvancedNeoServer(config, GraphDatabaseDependencies.newDependencies().logging(new SingleLoggingService(StringLogger.SYSTEM))); server.start(); assertNotNull(server.getDatabase().getGraph()); // Change the database location String dbDir2 = target.cleanDirectory("db2").getAbsolutePath(); Configuration conf = config.configuration(); conf.setProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, dbDir2); ServerManagement bean = new ServerManagement(server); bean.restartServer(); }
From source file:org.neo4j.server.extension.httplog.TestLogLine.java
@Test public void expectLogLine() throws IOException { File logFile = new File("target/logs/http.log"); logFile.delete();/* w w w .j a v a 2 s . c o m*/ ImpermanentGraphDatabase db = new ImpermanentGraphDatabase(); EmbeddedServerConfigurator configurator = new EmbeddedServerConfigurator(db); Configuration config = configurator.configuration(); config.setProperty("http.log.dir", logFile.getParent()); config.setProperty("http.log.cfg", "conf/neo4j-server-test-logback.xml"); configurator.getThirdpartyJaxRsClasses() .add(new ThirdPartyJaxRsPackage("org.neo4j.server.extension.httplog", "/authlog")); WrappingNeoServerBootstrapper testBootstrapper = new WrappingNeoServerBootstrapper(db, configurator); testBootstrapper.start(); Client client = Client.create(); client.resource("http://localhost:7474/db/data").get(String.class); testBootstrapper.stop(); Scanner file = new Scanner(logFile); String line = file.nextLine(); assertTrue(line.contains("/db/data")); }
From source file:org.neo4j.server.preflight.TestPerformRecoveryIfNecessary.java
private Configuration buildProperties() throws IOException { FileUtils.deleteRecursively(new File(homeDirectory)); new File(homeDirectory + "/conf").mkdirs(); Properties databaseProperties = new Properties(); String databasePropertiesFileName = homeDirectory + "/conf/neo4j.properties"; databaseProperties.store(new FileWriter(databasePropertiesFileName), null); Configuration serverProperties = new MapBasedConfiguration(); serverProperties.setProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, storeDirectory); serverProperties.setProperty(Configurator.DB_TUNING_PROPERTY_FILE_KEY, databasePropertiesFileName); return serverProperties; }
From source file:org.neo4j.server.preflight.TestPerformUpgradeIfNecessary.java
private Configuration buildProperties(boolean allowStoreUpgrade) throws IOException { FileUtils.deleteRecursively(HOME_DIRECTORY); assertTrue(CONF_DIRECTORY.mkdirs()); Properties databaseProperties = new Properties(); if (allowStoreUpgrade) { databaseProperties.setProperty(GraphDatabaseSettings.allow_store_upgrade.name(), "true"); }/*from w w w . ja v a 2 s . c om*/ databaseProperties.store(new FileWriter(NEO4J_PROPERTIES.getAbsolutePath()), null); Configuration serverProperties = new MapBasedConfiguration(); serverProperties.setProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, STORE_DIRECTORY.getPath()); serverProperties.setProperty(Configurator.DB_TUNING_PROPERTY_FILE_KEY, NEO4J_PROPERTIES.getAbsolutePath()); return serverProperties; }
From source file:org.neo4j.server.web.logging.HTTPLoggingFunctionalTest.java
@Test public void givenConfigurationWithUnwritableLogDirectoryShouldFailToStartServer() throws Exception { // given/*from w ww. j av a 2s .c o m*/ final File confDir = TargetDirectory.forTest(this.getClass()).directory("confdir"); FileUtils.forceMkdir(confDir); final File unwritableLogDir = createUnwritableDirectory(); final File configFile = HTTPLoggingPreparednessRuleTest.createConfigFile( HTTPLoggingPreparednessRuleTest.createLogbackConfigXml(unwritableLogDir), confDir); Configuration config = new MapBasedConfiguration(); config.setProperty(Configurator.HTTP_LOGGING, "true"); config.setProperty(Configurator.HTTP_LOG_CONFIG_LOCATION, configFile.getPath()); server = ServerBuilder.server().withDefaultDatabaseTuning() .withPreflightTasks(new EnsurePreparedForHttpLogging(config)) .withProperty(Configurator.HTTP_LOGGING, "true") .withProperty(Configurator.HTTP_LOG_CONFIG_LOCATION, configFile.getPath()).build(); // when try { server.start(); fail("should have thrown exception"); } catch (PreflightFailedException e) { // then assertThat(e.getMessage(), containsString(String.format("HTTP log file [%s] does not exist", unwritableLogDir.getAbsolutePath() + File.separator + "http.log"))); } }