]> source.dussan.org Git - sonarqube.git/commitdiff
Add unit test
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Tue, 19 Feb 2013 11:39:53 +0000 (12:39 +0100)
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Tue, 19 Feb 2013 14:28:11 +0000 (15:28 +0100)
sonar-plugin-api/src/test/java/org/sonar/api/config/LicenseTest.java

index 37e880e21fd9927f35f4fd9ec44900ac70c8a775..1bc5bb7f7d9aa09d6713ea1862ec1f4cd23d4e1f 100644 (file)
@@ -101,6 +101,21 @@ public class LicenseTest {
     assertThat(license.getType(), Is.is("EVALUATION"));
   }
 
+  @Test
+  public void trimBeforeReadingBase64() {
+    String encodedKeyWithTrailingWhiteSpaces = "Rm9vOiBiYXIKT3JnYW5pc2F0aW9uOiBBQkMgClNlcnZlcjogMTIzND  \n" +
+      "UgICAKUHJvZHVjdDogU1FBTEUKICBFeHBpcmF0aW9uOiAyMDEyLTA1    \n" +
+      "LTE4ICAKVHlwZTogIEVWQUxVQVRJT04gICAKT3RoZXI6IGZpZWxkCg==\n";
+
+    License license = License.readBase64(new String(encodedKeyWithTrailingWhiteSpaces.getBytes()));
+
+    assertThat(license.getOrganization(), Is.is("ABC"));
+    assertThat(license.getServer(), Is.is("12345"));
+    assertThat(license.getProduct(), Is.is("SQALE"));
+    assertThat(license.getExpirationDateAsString(), Is.is("2012-05-18"));
+    assertThat(license.getType(), Is.is("EVALUATION"));
+  }
+
   @Test
   public void readBase64_not_base64() {
     License license = License.readBase64("çé '123$@");