List of usage examples for org.apache.commons.configuration MapConfiguration MapConfiguration
public MapConfiguration(Map map)
From source file:org.neo4j.desktop.runtime.DesktopConfigurator.java
public void refresh() { compositeConfig.clear();// www. j a v a 2 s . c o m compositeConfig.addConfiguration(new MapConfiguration(map)); // re-read server properties, then add to config propertyFileConfig = new PropertyFileConfigurator(installation.getServerConfigurationsFile()); compositeConfig.addConfiguration(propertyFileConfig.configuration()); }
From source file:org.neo4j.server.configuration.ConfiguratorWrappingConfigurationBuilderTest.java
@Test public void shouldGetNewPropertyValuesFromConfiguratorWrappingBuilder() throws Exception { // GIVEN/* w ww . j av a2 s . c o m*/ Configurator configurator = new Configurator.Adapter() { @Override public Configuration configuration() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(ServerSettings.http_logging_enabled.name(), new Boolean(true)); return new MapConfiguration(properties); } @Override public List<ThirdPartyJaxRsPackage> getThirdpartyJaxRsPackages() { List<ThirdPartyJaxRsPackage> list = new ArrayList(); list.add(new ThirdPartyJaxRsPackage("lala", "sasa")); return list; } }; // WHEN ConfiguratorWrappingConfigurationBuilder builder = new ConfiguratorWrappingConfigurationBuilder( configurator); // THEN assertTrue(builder.configuration().get(ServerSettings.http_logging_enabled)); assertEquals(1, builder.configuration().get(ServerSettings.third_party_packages).size()); }
From source file:org.neo4j.server.database.EphemeralDatabase.java
public EphemeralDatabase() { this(new MapConfiguration(new HashMap<String, String>())); }
From source file:org.neo4j.server.database.TestCommunityDatabase.java
@Before public void setup() throws Exception { databaseDirectory = createTempDir(); Configuration conf = new MapConfiguration(new HashMap<String, String>()); conf.addProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, databaseDirectory.getAbsolutePath()); theDatabase = new CommunityDatabase(conf); }
From source file:org.neo4j.server.database.TestCommunityDatabase.java
@Test(expected = IllegalStateException.class) public void shouldComplainIfDatabaseLocationIsAlreadyInUse() throws Throwable { deletionFailureOk = true;//from w w w . j a v a 2 s . c o m theDatabase.start(); Configuration conf = new MapConfiguration(new HashMap<String, String>()); conf.addProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, databaseDirectory.getAbsolutePath()); CommunityDatabase db = new CommunityDatabase(conf); db.start(); }
From source file:org.neo4j.server.database.TestCommunityDatabase.java
@Test public void shouldBeAbleToOverrideShellConfig() throws Throwable { int customPort = findFreeShellPortToUse(8881); File tempDir = createTempDir(); File tuningProperties = new File(tempDir, "neo4j.properties"); tuningProperties.createNewFile();// www. j a v a 2 s .co m ServerTestUtils.writePropertiesToFile(stringMap(ShellSettings.remote_shell_enabled.name(), GraphDatabaseSetting.TRUE, ShellSettings.remote_shell_port.name(), "" + customPort), tuningProperties); Configuration conf = new MapConfiguration(new HashMap<String, String>()); conf.addProperty(Configurator.DATABASE_LOCATION_PROPERTY_KEY, tempDir.getAbsolutePath()); conf.addProperty(Configurator.DB_TUNING_PROPERTY_FILE_KEY, tuningProperties.getAbsolutePath()); Database otherDb = new CommunityDatabase(conf); otherDb.start(); // Try to connect with a shell client to that custom port. // Throws exception if unable to connect ShellLobby.newClient(customPort).shutdown(); otherDb.stop(); FileUtils.forceDelete(tempDir); }
From source file:org.neo4j.server.enterprise.EnterpriseDatabaseIT.java
@Test public void shouldStartInSingleModeByDefault() throws Throwable { EnterpriseDatabase db = new EnterpriseDatabase(new Configurator.Adapter() { @Override/* ww w . j a v a 2 s .co m*/ public Configuration configuration() { return new MapConfiguration( stringMap(DATABASE_LOCATION_PROPERTY_KEY, testDirectory.directory().getPath())); } }); try { db.start(); assertThat(db.getGraph(), is(EmbeddedGraphDatabase.class)); } finally { db.stop(); } }
From source file:org.neo4j.server.enterprise.EnterpriseNeoServerTest.java
@Test public void shouldStartInSingleModeByDefault() throws Throwable { EnterpriseNeoServer db = new EnterpriseNeoServer(new Configurator.Adapter() { @Override//from ww w.j a v a 2 s. c o m public Configuration configuration() { return new MapConfiguration( stringMap(DATABASE_LOCATION_PROPERTY_KEY, testDirectory.directory().getPath())); } }); try { db.start(); assertThat(db.getDatabase().getGraph(), is(EmbeddedGraphDatabase.class)); } finally { db.stop(); } }
From source file:org.neo4j.server.enterprise.TestHaDatabaseWithRrd.java
@Test @Ignore//from w w w. j av a2 s .c o m public void startHaGraphDatabaseWithRrd() throws Exception { String dir = TargetDirectory.forTest(getClass()).directory("rrd", true).getAbsolutePath(); Map<String, String> config = stringMap(HaSettings.server_id.name(), "1", HaSettings.coordinators.name(), zoo.getConnectionString()); Database db = new Database(HA_GRAPH_DATABASE_FACTORY.createDatabase(dir, config)); Configuration dbConfig = new MapConfiguration( stringMap(Configurator.RRDB_LOCATION_PROPERTY_KEY, new File(dir, "rrd").getAbsolutePath())); RrdDb rrd = new RrdFactory(dbConfig).createRrdDbAndSampler(db, noScheduling()); db.setRrdDb(rrd); doTransaction(db); db.shutdown(); }
From source file:org.neo4j.server.modules.WebAdminModuleTest.java
@Test public void shouldRegisterASingleUri() throws Exception { WebServer webServer = mock(WebServer.class); NeoServerWithEmbeddedWebServer neoServer = mock(NeoServerWithEmbeddedWebServer.class); when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575")); when(neoServer.getWebServer()).thenReturn(webServer); Database db = mock(Database.class); db.graph = (mock(AbstractGraphDatabase.class)); Kernel mockKernel = mock(Kernel.class); ObjectName mockObjectName = mock(ObjectName.class); when(mockKernel.getMBeanQuery()).thenReturn(mockObjectName); when(db.graph.getManagementBeans(Kernel.class)).thenReturn(Collections.singleton(mockKernel)); when(neoServer.getDatabase()).thenReturn(db); when(neoServer.getConfiguration()).thenReturn(new MapConfiguration(new HashMap<Object, Object>())); Config config = mock(Config.class); when(db.graph.getConfig()).thenReturn(config); NodeManager nodeManager = mock(NodeManager.class); GraphDbModule graphDbModule = mock(GraphDbModule.class); when(config.getGraphDbModule()).thenReturn(graphDbModule); when(graphDbModule.getNodeManager()).thenReturn(nodeManager); CompositeDataSupport result = mock(CompositeDataSupport.class); when(result.get("used")).thenReturn(50L); when(result.get("max")).thenReturn(1000L); MBeanServer mbeanServer = mock(MBeanServer.class); when(mbeanServer.getAttribute(any(ObjectName.class), eq("HeapMemoryUsage"))).thenReturn(result); // when(mbeanServer.getAttribute(any(ObjectName.class), eq("Collector"))).thenReturn( new StatisticCollector() ); setStaticFinalField(JmxUtils.class.getDeclaredField("mbeanServer"), mbeanServer); WebAdminModule module = new WebAdminModule(); module.start(neoServer, null);/* ww w. jav a2 s . c o m*/ verify(db).setRrdDb(any(RrdDb.class)); }