List of usage examples for org.apache.commons.configuration PropertiesConfiguration setProperty
public void setProperty(String key, Object value)
From source file:org.xwiki.test.ui.AllTests.java
@XWikiExecutorSuite.PreStart public void preStart(List<XWikiExecutor> executors) throws Exception { XWikiExecutor executor = executors.get(0); LOGGER.info("Put back the old WYSIWYG editor in xwiki.properties"); PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration(); properties.setProperty("edit.defaultEditor.org.xwiki.rendering.syntax.SyntaxContent#wysiwyg", "gwt"); executor.saveXWikiProperties(properties); }
From source file:org.xwiki.wikistream.confluence.xml.internal.ConfluenceXMLPackage.java
private int readObjectProperties(XMLStreamReader xmlReader, PropertiesConfiguration properties) throws XMLStreamException, WikiStreamException, ConfigurationException, IOException { int id = -1;/*from w w w. j av a2 s .c o m*/ for (xmlReader.nextTag(); xmlReader.isStartElement(); xmlReader.nextTag()) { String elementName = xmlReader.getLocalName(); if (elementName.equals("id")) { id = Integer.valueOf(xmlReader.getElementText()); properties.setProperty("id", id); } else if (elementName.equals("property")) { String propertyName = xmlReader.getAttributeValue(null, "name"); properties.setProperty(propertyName, readProperty(xmlReader)); } else if (elementName.equals("collection")) { String propertyName = xmlReader.getAttributeValue(null, "name"); properties.setProperty(propertyName, readProperty(xmlReader)); } else { StAXUtils.skipElement(xmlReader); } } return id; }
From source file:org.xwiki.wikistream.confluence.xml.internal.ConfluenceXMLPackage.java
private void readSpaceDescriptionObject(XMLStreamReader xmlReader) throws XMLStreamException, WikiStreamException, ConfigurationException, IOException { PropertiesConfiguration properties = newProperties(); int descriptionId = readObjectProperties(xmlReader, properties); properties.setProperty(KEY_PAGE_HOMEPAGE, true); // Save page/*from w ww . ja v a2s . c om*/ savePageProperties(properties, descriptionId); }
From source file:org.xwiki.wikistream.confluence.xml.internal.ConfluenceXMLPackage.java
private void readMembershipObject(XMLStreamReader xmlReader) throws ConfigurationException, XMLStreamException, WikiStreamException, IOException { PropertiesConfiguration properties = newProperties(); readObjectProperties(xmlReader, properties); Integer parentGroup = properties.getInteger("parentGroup", null); if (parentGroup != null) { PropertiesConfiguration groupProperties = getGroupProperties(parentGroup); Integer userMember = properties.getInteger("userMember", null); if (userMember != null) { List<Integer> users = new ArrayList<Integer>( getIntegertList(groupProperties, KEY_GROUP_MEMBERUSERS, Collections.<Integer>emptyList())); users.add(userMember);/*www. jav a2s . c o m*/ groupProperties.setProperty(KEY_GROUP_MEMBERUSERS, users); } Integer groupMember = properties.getInteger("groupMember", null); if (groupMember != null) { List<Integer> groups = new ArrayList<Integer>( getIntegertList(groupProperties, KEY_GROUP_MEMBERGROUPS, Collections.<Integer>emptyList())); groups.add(groupMember); groupProperties.setProperty(KEY_GROUP_MEMBERGROUPS, groups); } saveGroupProperties(groupProperties, parentGroup); } }
From source file:test.db_memory.QualitativeTest.java
private static void setCacheForDb(TestDescription test) { String confFileName = String.format("%s/conf.properties", test.getInputDb()); try {/*from w ww .ja va 2 s.c o m*/ PropertiesConfiguration config = new PropertiesConfiguration(new File(confFileName)); config.setProperty("storage.batch-loading", "false"); config.setProperty("cache.db-cache", "true"); config.setProperty("cache.db-cache-size", "250000000"); config.setProperty("cache.db-cache-time", "0"); config.setProperty("query.batch", "true"); config.setProperty("query.fast-property", "true"); config.setProperty("storage.transactions", "false"); config.setProperty("storage.read-only", "false"); config.save(); } catch (ConfigurationException ex) { java.util.logging.Logger.getLogger(QualitativeTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ubic.basecode.util.ConfigUtilsTest.java
@Test public void testLoadConfigFileNew() throws Exception { PropertiesConfiguration config = ConfigUtils.loadConfig(new File(tmpPath)); assertNotNull(config);//from ww w . j av a 2 s .co m config.setProperty("foo", "bar"); assertEquals("bar", config.getProperty("foo")); }
From source file:ubic.basecode.util.ConfigUtilsTest.java
@Test public void testLoadConfigStringNew() throws Exception { PropertiesConfiguration config = ConfigUtils.loadConfig(tmpPath); assertNotNull(config);/* ww w .j a va 2s . c om*/ config.setProperty("foo", "bar"); assertEquals("bar", config.getProperty("foo")); }
From source file:ubic.basecode.util.ConfigUtilsTest.java
@Test public void testLoadConfigStringNewName() throws Exception { PropertiesConfiguration config = ConfigUtils.loadConfig("testtemp.properties"); assertNotNull(config);/*w w w . j a v a2 s . co m*/ config.setProperty("foo", "bar"); assertEquals("bar", config.getProperty("foo")); new File(FileUtils.getUserDirectory(), "testtemp.properties").delete(); }
From source file:ubic.basecode.util.ConfigUtilsTest.java
@Test public void testLoadConfigURLNew() throws Exception { PropertiesConfiguration config = ConfigUtils.loadConfig(new File(tmpPath).toURI().toURL()); assertNotNull(config);/*from w w w.j av a 2s . c o m*/ config.setProperty("foo", "bar"); assertEquals("bar", config.getProperty("foo")); }
From source file:uk.ac.soton.simulation.jsit.core.TestModelVersioningAssistantSVN.java
private void validJSIT_CommitShared(String repoModelURI, boolean isLegacy) throws IOException { final String rootPath = tempFolder.getRoot().getAbsolutePath() + File.separator + WORKING_COPY_DIR; final File rootPathFile = new File(rootPath); final String codePath = rootPath + File.separator + "Code"; // Assistant needs in-VCS model code directory path ModelVersioningAssistant assistant = ModelVersioningAssistantSVN.createAssistantInternal(codePath); /*/*from ww w. ja v a2 s . c o m*/ * First try without any working copy changes. Should work because no * previous JSIT commits */ logger.info("JSIT commit without WC changes (first JSIT commit)"); boolean committedStuff = assistant.commitModelMaterial(rootPathFile); Assert.assertTrue(committedStuff); File prevChangesFile = new File(rootPath + File.separator + ModelVersioningAssistant.PREV_CHANGES_FILE); Assert.assertTrue(prevChangesFile.exists()); // We check content later // Re-instantiate to read hopefully altered version details assistant = ModelVersioningAssistantSVN.createAssistantInternal(codePath); Assert.assertEquals("r2", assistant.getLastCommitID()); Assert.assertEquals(repoModelURI + "/Code", assistant.getModelCommittedURL()); if (isLegacy) { Assert.assertEquals("SVN Legacy", assistant.getModelVCS()); } else { Assert.assertEquals("SVN", assistant.getModelVCS()); } Assert.assertEquals("DummyModel", assistant.getUserModelName()); Assert.assertEquals("0.1", assistant.getUserModelVersion()); logger.debug("Hash code after commit: " + assistant.getCommitTimeSourceDirsHash()); /* * Now check further commit doesn't commit anything */ logger.info("JSIT commit without WC changes (already JSIT committed)"); committedStuff = assistant.commitModelMaterial(rootPathFile); Assert.assertFalse(committedStuff); /* * Now make a change (to the version file, using assistant code to write * the props for us) and check the commit fails because of missing * working changes file */ logger.info("JSIT commit changed code without working changes file"); PropertiesConfiguration verProps = assistant.getVersionProperties(); String revisedVer = "0.1FINAL"; verProps.setProperty(ModelVersioningAssistant.MODEL_VER_PROPERTY, revisedVer); assistant.saveProperties(); // Re-instantiate to read hopefully altered version details assistant = ModelVersioningAssistantSVN.createAssistantInternal(codePath); try { committedStuff = assistant.commitModelMaterial(rootPathFile); Assert.fail("Expected VersionControlException"); } catch (VersionControlException e) { Assert.assertTrue(e.getMessage().startsWith("Code changes need specifying")); } /* * Create the changes file and check commit works OK, and that prev changes * file has appended the details */ logger.info("JSIT commit changed code with working changes file"); File changesFile = new File(rootPath + File.separator + ModelVersioningAssistant.WORKING_CHANGES_FILE); PrintWriter writer = new PrintWriter(new FileWriter(changesFile)); String changeText = "Changed model version number"; writer.println(changeText); writer.close(); // Re-instantiate just to ensure correctness of test assistant = ModelVersioningAssistantSVN.createAssistantInternal(codePath); committedStuff = assistant.commitModelMaterial(rootPathFile); Assert.assertTrue(committedStuff); // Temp file should have been deleted Assert.assertFalse(new File(assistant.getModelVersionFileBackupPath()).exists()); // Prev changes file should exist and have appended content Assert.assertTrue(prevChangesFile.exists()); BufferedReader prevReader = new BufferedReader(new FileReader(prevChangesFile)); String prevDesc = "prev chgs file"; String commitLinePattern = ">>> Commit \\d{4}-\\d{2}-\\d{2} \\d{9},.+"; Assert.assertTrue(readAndShowLine(prevDesc, prevReader).matches(commitLinePattern)); Assert.assertTrue(readAndShowLine(prevDesc, prevReader).equals("Initial JSIT commit")); Assert.assertTrue(readAndShowLine(prevDesc, prevReader).equals("")); // Blank 3rd line Assert.assertTrue(readAndShowLine(prevDesc, prevReader).matches(commitLinePattern)); Assert.assertTrue(readAndShowLine(prevDesc, prevReader).equals(changeText)); prevReader.close(); // Working changes file should be empty Assert.assertEquals(0, changesFile.length()); // Re-instantiate for fresh property values assistant = ModelVersioningAssistantSVN.createAssistantInternal(codePath); Assert.assertEquals("r3", assistant.getLastCommitID()); Assert.assertEquals(repoModelURI + "/Code", assistant.getModelCommittedURL()); if (isLegacy) { Assert.assertEquals("SVN Legacy", assistant.getModelVCS()); } else { Assert.assertEquals("SVN", assistant.getModelVCS()); } Assert.assertEquals("DummyModel", assistant.getUserModelName()); Assert.assertEquals(revisedVer, assistant.getUserModelVersion()); }