aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-12-09 14:11:46 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-12-09 14:29:33 +0400
commit68e146c9723b58ae0f58fa627cefc390d63547fc (patch)
tree05ba040a1a7fe17f4018ef75c0832bb12d9adbd5 /sonar-plugin-api/src/test
parent926a2012da92c2cde3f58e205d6ce2452d113848 (diff)
downloadsonarqube-68e146c9723b58ae0f58fa627cefc390d63547fc.tar.gz
sonarqube-68e146c9723b58ae0f58fa627cefc390d63547fc.zip
SONAR-3070 DateUtils should not parse badly formatted strings
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java
index 8b41e61ba9a..2a42e9d1047 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java
@@ -20,14 +20,10 @@
package org.sonar.api.utils;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import org.junit.Test;
-import java.text.ParseException;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.OrderingComparisons.greaterThan;
@@ -48,6 +44,11 @@ public class DateUtilsTest {
DateUtils.parseDate("2010/05/18");
}
+ @Test(expected = SonarException.class)
+ public void shouldNotParseDate2() {
+ DateUtils.parseDate("1986-12-04foo");
+ }
+
@Test
public void shouldParseDateTime() {
Date date = DateUtils.parseDateTime("2010-05-18T15:50:45+0100");
@@ -59,6 +60,11 @@ public class DateUtilsTest {
DateUtils.parseDate("2010/05/18 10:55");
}
+ @Test(expected = SonarException.class)
+ public void shouldNotParseDateTime2() {
+ DateUtils.parseDateTime("1986-12-04T01:02:03+0300foo");
+ }
+
@Test
public void shouldFormatDate() {
assertThat(DateUtils.formatDate(new Date()), startsWith("20"));