aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-02-08 01:05:56 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-02-08 01:05:56 +0100
commit54a6901006ec1ec7f498cbb968c47a05e4075937 (patch)
treef5fc9c2ab36f3ccef9445559df9671e06a73b745
parent5c22f66a216bff2ee2dac2c325cfb87f456a1570 (diff)
downloadsonarqube-54a6901006ec1ec7f498cbb968c47a05e4075937.tar.gz
sonarqube-54a6901006ec1ec7f498cbb968c47a05e4075937.zip
SONAR-726 Add a unit test
-rw-r--r--sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java21
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/backup-with-multiline-property.xml19
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportMultilineProperties.xml6
3 files changed, 46 insertions, 0 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java
index 7b6f191a815..2a49a5058c0 100644
--- a/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/configuration/PropertiesBackupTest.java
@@ -20,14 +20,20 @@
package org.sonar.server.configuration;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.CharEncoding;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.database.configuration.Property;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
+import org.sonar.test.TestUtils;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.startsWith;
import static org.hamcrest.collection.IsCollectionContaining.hasItem;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -87,4 +93,19 @@ public class PropertiesBackupTest extends AbstractDbUnitTestCase {
checkTables("shouldImportProperties", "properties");
}
+ @Test
+ public void shouldImportMultilineProperties() throws Exception {
+ setupData("shouldImportMultilineProperties");
+
+ new Backup(getSession()).doImportXml(
+ FileUtils.readFileToString(
+ TestUtils.getResource(getClass(), "backup-with-multiline-property.xml"), CharEncoding.UTF_8));
+
+ getSession().commit();
+
+ Property property = getSession().getSingleResult(Property.class, "key", "sonar.multiline.secured");
+ assertThat(property.getValue(), startsWith("ONQwdcwcwwdadalkdmaiQGMqMVnhtAbhxwjjoVkHbWgx"));
+ assertThat(property.getValue(), endsWith("mmmm"));
+
+ }
}
diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/backup-with-multiline-property.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/backup-with-multiline-property.xml
new file mode 100644
index 00000000000..3d577e3f4ab
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/backup-with-multiline-property.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sonar-config>
+ <version><![CDATA[180]]></version>
+ <date><![CDATA[2011-02-08]]></date>
+ <metrics/>
+ <properties>
+ <property>
+ <key><![CDATA[sonar.multiline.secured]]></key>
+ <value><![CDATA[ONQwdcwcwwdadalkdmaiQGMqMVnhtAbhxwjjoVkHbWgx
+ mi2KrURzVJmEZQD1l0T>JBJk2Ke7ZrTZvmO00u366sv9IY
+ rqqMuWRPpRNNRompPqrtwqnoPpMoqqprMrVVvVXXVtVppQ
+ RrnmqmUUnorrvrtommmmmUCasdaswommmmmUUJlkXoUUn
+ mmmm]]></value>
+ </property>
+ </properties>
+ <profiles>
+ </profiles>
+ <rules/>
+</sonar-config> \ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportMultilineProperties.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportMultilineProperties.xml
new file mode 100644
index 00000000000..7c6403b5e4a
--- /dev/null
+++ b/sonar-server/src/test/resources/org/sonar/server/configuration/PropertiesBackupTest/shouldImportMultilineProperties.xml
@@ -0,0 +1,6 @@
+<dataset>
+ <!-- global properties -->
+ <properties id="1" prop_key="key1" text_value="oldvalue" resource_id="[null]" user_id="[null]"/>
+
+
+</dataset> \ No newline at end of file