@@ -71,7 +71,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.plugins.core.sensors; | |||
import org.hamcrest.Matchers; | |||
import org.junit.Before; | |||
import org.junit.Ignore; | |||
import org.junit.Test; | |||
@@ -31,7 +32,6 @@ import org.sonar.api.resources.Project; | |||
import java.util.Arrays; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.Matchers.closeTo; | |||
import static org.mockito.Matchers.doubleThat; | |||
import static org.mockito.Matchers.eq; | |||
import static org.mockito.Mockito.atLeastOnce; | |||
@@ -82,7 +82,7 @@ public class UnitTestDecoratorTest { | |||
verify(context).saveMeasure(eq(CoreMetrics.TEST_FAILURES), eq(2.0)); | |||
verify(context).saveMeasure(eq(CoreMetrics.SKIPPED_TESTS), eq(2.0)); | |||
verify(context).saveMeasure(eq(CoreMetrics.TEST_EXECUTION_TIME), eq(2.0)); | |||
verify(context).saveMeasure(eq(CoreMetrics.TEST_SUCCESS_DENSITY), doubleThat(closeTo(33.3, 0.1))); | |||
verify(context).saveMeasure(eq(CoreMetrics.TEST_SUCCESS_DENSITY), doubleThat(Matchers.closeTo(33.3, 0.1))); | |||
} | |||
private void mockChildrenMeasures(Metric metric, double value) { |
@@ -36,7 +36,7 @@ import java.text.SimpleDateFormat; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.mockito.Matchers.anyList; | |||
import static org.mockito.Mockito.mock; |
@@ -43,9 +43,15 @@ | |||
<artifactId>sonar-testing-harness</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> |
@@ -27,8 +27,8 @@ import org.sonar.api.resources.File; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.test.IsMeasure; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.argThat; |
@@ -47,6 +47,11 @@ | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<!-- TODO http://jira.codehaus.org/browse/SONAR-2011 | |||
We need following dependency, otherwise we will receive | |||
@@ -60,7 +65,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> |
@@ -29,7 +29,7 @@ import java.util.List; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.internal.matchers.IsCollectionContaining.hasItem; | |||
import static org.hamcrest.Matchers.hasItem; | |||
public class DeleteAllFilterTest { | |||
@@ -19,8 +19,8 @@ | |||
*/ | |||
package org.sonar.plugins.dbcleaner.period; | |||
import org.hamcrest.core.IsCollectionContaining; | |||
import org.junit.Test; | |||
import org.junit.internal.matchers.IsCollectionContaining; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.core.purge.PurgeableSnapshotDto; | |||
import org.sonar.plugins.dbcleaner.DbCleanerTestUtils; | |||
@@ -46,7 +46,7 @@ public class KeepOneFilterTest { | |||
createSnapshotWithDate(4L, "2011-05-19"), // may -> to be deleted | |||
createSnapshotWithDate(5L, "2011-06-01"), // june -> keep | |||
createSnapshotWithDate(6L, "2012-01-01") // out of scope -> keep | |||
)); | |||
)); | |||
assertThat(toDelete.size(), is(2)); | |||
assertThat(toDelete, IsCollectionContaining.hasItem(new DbCleanerTestUtils.SnapshotMatcher(3L))); | |||
@@ -62,7 +62,7 @@ public class KeepOneFilterTest { | |||
createSnapshotWithDate(2L, "2011-05-02").setLast(true), | |||
createSnapshotWithDate(3L, "2011-05-19").setHasEvents(true).setLast(false), | |||
createSnapshotWithDate(4L, "2011-05-23") // to be deleted | |||
)); | |||
)); | |||
assertThat(toDelete.size(), is(2)); | |||
assertThat(toDelete, IsCollectionContaining.hasItem(new DbCleanerTestUtils.SnapshotMatcher(1L))); |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.plugins.design; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; | |||
@@ -36,7 +36,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -51,7 +51,11 @@ | |||
<artifactId>fest-assert</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
<build> |
@@ -907,19 +907,20 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<version>1.9.5</version> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-core</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.easytesting</groupId> | |||
<artifactId>fest-assert</artifactId> | |||
<version>1.4</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<version>1.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.thoughtworks.xstream</groupId> | |||
<artifactId>xstream</artifactId> | |||
@@ -1048,10 +1049,21 @@ | |||
<artifactId>jsonassert</artifactId> | |||
<version>1.2.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<version>1.3</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
<version>4.10</version> | |||
<version>4.11</version> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-core</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>xmlunit</groupId> |
@@ -192,6 +192,11 @@ | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.easytesting</groupId> | |||
<artifactId>fest-assert</artifactId> | |||
@@ -199,7 +204,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -25,7 +25,7 @@ import org.junit.Test; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class ConfigurationUtilsTest { |
@@ -22,7 +22,7 @@ package org.sonar.application; | |||
import org.junit.Test; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class EncryptionTest { |
@@ -33,6 +33,7 @@ import org.mockito.Mockito; | |||
import org.slf4j.Logger; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import static org.mockito.Matchers.argThat; | |||
@@ -47,7 +48,7 @@ public class LoggingTest { | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
@Before | |||
public void setHome() { | |||
public void setHome() throws IOException { | |||
File homeDir = temp.newFolder("home"); | |||
System.setProperty("SONAR_HOME", homeDir.getAbsolutePath()); | |||
} |
@@ -27,7 +27,6 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.fest.assertions.Fail.fail; |
@@ -27,6 +27,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
@@ -44,7 +45,7 @@ public class WebappTest { | |||
private Env env; | |||
@Before | |||
public void initEnv() { | |||
public void initEnv() throws IOException { | |||
env = mock(Env.class); | |||
File sonarHome = temp.newFolder("home"); | |||
when(env.rootDir()).thenReturn(sonarHome); |
@@ -116,18 +116,13 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-testing-harness</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-testing-harness</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -33,7 +33,7 @@ import java.util.Collection; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.internal.matchers.IsCollectionContaining.hasItem; | |||
import static org.hamcrest.Matchers.hasItem; | |||
import static org.mockito.Mockito.mock; | |||
public class BatchExtensionDictionnaryTest { |
@@ -27,10 +27,10 @@ import org.sonar.jpa.test.AbstractDbUnitTestCase; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.internal.matchers.IsCollectionContaining.hasItems; | |||
import static org.hamcrest.Matchers.hasItems; | |||
public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase { | |||
@@ -27,7 +27,7 @@ import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class PastSnapshotFinderByDateTest extends AbstractDbUnitTestCase { |
@@ -31,7 +31,7 @@ import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
@@ -23,7 +23,7 @@ import org.junit.Test; | |||
import org.sonar.api.database.model.Snapshot; | |||
import org.sonar.jpa.test.AbstractDbUnitTestCase; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.core.IsNull.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
@@ -24,12 +24,12 @@ import org.sonar.api.measures.Metric; | |||
import org.sonar.api.resources.Directory; | |||
import org.sonar.api.resources.File; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.core.IsNot.not; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.internal.matchers.IsCollectionContaining.hasItem; | |||
import static org.hamcrest.Matchers.hasItem; | |||
public class BucketTest { | |||
@@ -36,7 +36,7 @@ import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.hamcrest.Matchers.notNullValue; | |||
import static org.mockito.Mockito.mock; |
@@ -28,7 +28,7 @@ import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import java.io.File; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.anyList; |
@@ -21,7 +21,7 @@ package org.sonar.batch.scan.filesystem; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.io.FilenameUtils; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
@@ -36,8 +36,8 @@ import static org.mockito.Mockito.mock; | |||
public class ModuleFileSystemInitializerTest { | |||
@ClassRule | |||
public static TemporaryFolder temp = new TemporaryFolder(); | |||
@Rule | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
PathResolver pathResolver = new PathResolver(); | |||
@@ -31,8 +31,10 @@ | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<version>1.3</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.easytesting</groupId> | |||
<artifactId>fest-assert</artifactId> |
@@ -135,7 +135,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
@@ -153,6 +153,19 @@ | |||
<artifactId>fest-assert</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.google.code.bean-matchers</groupId> | |||
<artifactId>bean-matchers</artifactId> | |||
<version>0.9</version> | |||
<scope>test</scope> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-core</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<!-- | |||
JDBC drivers for MyBatis integration tests. |
@@ -1,42 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.jpa.dao; | |||
import org.sonar.api.database.DatabaseSession; | |||
/** | |||
* @deprecated stop using Hibernate | |||
*/ | |||
@Deprecated | |||
public class BaseDao { | |||
private final DatabaseSession session; | |||
public BaseDao(DatabaseSession session) { | |||
super(); | |||
this.session = session; | |||
} | |||
public DatabaseSession getSession() { | |||
return session; | |||
} | |||
} |
@@ -31,12 +31,13 @@ import java.util.Map; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
public class MeasuresDao extends BaseDao { | |||
public class MeasuresDao { | |||
private final DatabaseSession session; | |||
private final Map<String, Metric> metricsByName = new HashMap<String, Metric>(); | |||
public MeasuresDao(DatabaseSession session) { | |||
super(session); | |||
this.session = session; | |||
} | |||
public Metric getMetric(Metric metric) { | |||
@@ -77,8 +78,8 @@ public class MeasuresDao extends BaseDao { | |||
} | |||
public void disableAutomaticMetrics() { | |||
getSession().createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate(); | |||
getSession().commit(); | |||
session.createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate(); | |||
session.commit(); | |||
metricsByName.clear(); | |||
} | |||
@@ -88,7 +89,7 @@ public class MeasuresDao extends BaseDao { | |||
metric.setEnabled(Boolean.TRUE); | |||
persistMetricWithoutClear(metric); | |||
} | |||
getSession().commit(); | |||
session.commit(); | |||
} | |||
metricsByName.clear(); | |||
} | |||
@@ -97,10 +98,10 @@ public class MeasuresDao extends BaseDao { | |||
Metric dbMetric = getMetric(metric); | |||
if (dbMetric != null) { | |||
dbMetric.merge(metric); | |||
getSession().getEntityManager().merge(dbMetric); | |||
session.getEntityManager().merge(dbMetric); | |||
} else { | |||
getSession().getEntityManager().persist(new Metric().merge(metric)); | |||
session.getEntityManager().persist(new Metric().merge(metric)); | |||
} | |||
} | |||
@@ -112,14 +113,14 @@ public class MeasuresDao extends BaseDao { | |||
public void disabledMetrics(Collection<Metric> metrics) { | |||
for (Metric metric : metrics) { | |||
metric.setEnabled(Boolean.FALSE); | |||
getSession().getEntityManager().persist(metric); | |||
session.getEntityManager().persist(metric); | |||
metricsByName.put(metric.getName(), metric); | |||
} | |||
} | |||
private Map<String, Metric> getMetricsByName() { | |||
if (metricsByName.isEmpty()) { | |||
List<Metric> metrics = getSession().getResults(Metric.class); | |||
List<Metric> metrics = session.getResults(Metric.class); | |||
for (Metric metric : metrics) { | |||
metricsByName.put(metric.getKey(), metric); | |||
} |
@@ -25,8 +25,8 @@ import org.sonar.core.persistence.AbstractDaoTestCase; | |||
import java.util.Date; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertThat; | |||
@@ -27,9 +27,9 @@ import org.junit.Test; | |||
import java.util.Locale; | |||
import java.util.ResourceBundle; | |||
import static org.hamcrest.CoreMatchers.not; | |||
import static org.hamcrest.Matchers.not; | |||
import static org.hamcrest.Matchers.containsString; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.internal.matchers.StringContains.containsString; | |||
import static org.junit.matchers.JUnitMatchers.hasItems; | |||
import static org.mockito.Mockito.mock; | |||
@@ -24,7 +24,7 @@ import org.junit.Test; | |||
import java.util.Locale; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Mockito.*; |
@@ -33,7 +33,7 @@ import java.util.List; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.internal.matchers.IsCollectionContaining.hasItem; | |||
import static org.hamcrest.Matchers.hasItem; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@@ -22,7 +22,7 @@ package org.sonar.core.purge; | |||
import org.junit.Test; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.junit.Assert.assertThat; | |||
public class PurgeableSnapshotDtoTest { |
@@ -29,7 +29,7 @@ import java.sql.Connection; | |||
import java.sql.ResultSet; | |||
import java.sql.SQLException; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.junit.Assert.assertThat; | |||
public class ResourceIndexerDaoTest extends AbstractDaoTestCase { |
@@ -25,7 +25,7 @@ import org.sonar.api.rules.RuleFinder; | |||
import org.sonar.core.rule.CacheRuleFinder; | |||
import org.sonar.jpa.test.AbstractDbUnitTestCase; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.hamcrest.core.IsNull.notNullValue; | |||
import static org.junit.Assert.assertThat; |
@@ -20,9 +20,9 @@ | |||
package org.sonar.jpa.session; | |||
import org.hamcrest.Matchers; | |||
import org.hamcrest.core.IsCollectionContaining; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.internal.matchers.IsCollectionContaining; | |||
import org.sonar.api.database.model.MeasureModel; | |||
import org.sonar.api.database.model.ResourceModel; | |||
import org.sonar.api.database.model.Snapshot; |
@@ -30,6 +30,11 @@ | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>sonar-plugin-api</artifactId> | |||
@@ -40,7 +45,7 @@ | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -21,7 +21,7 @@ package org.sonar.api.resources; | |||
import org.junit.Test; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class MethodTest { |
@@ -35,7 +35,7 @@ import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver; | |||
import java.io.File; | |||
import java.net.URISyntaxException; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.anyDouble; | |||
import static org.mockito.Matchers.argThat; |
@@ -65,7 +65,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -26,7 +26,7 @@ import org.sonar.duplications.statement.Statement; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.*; | |||
import static org.hamcrest.Matchers.*; | |||
import static org.junit.Assert.assertThat; | |||
/** |
@@ -19,17 +19,17 @@ | |||
*/ | |||
package org.sonar.duplications.detector; | |||
import org.hamcrest.CoreMatchers; | |||
import org.hamcrest.Description; | |||
import org.hamcrest.Matcher; | |||
import org.hamcrest.Matchers; | |||
import org.hamcrest.TypeSafeMatcher; | |||
import org.sonar.duplications.index.CloneGroup; | |||
import org.sonar.duplications.index.ClonePart; | |||
public class CloneGroupMatcher extends TypeSafeMatcher<CloneGroup> { | |||
public static Matcher<Iterable<CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { | |||
return Matchers.hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); | |||
public static Matcher<Iterable<? super CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { | |||
return CoreMatchers.hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); | |||
} | |||
private final int expectedLen; |
@@ -34,8 +34,8 @@ import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.sameInstance; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.sameInstance; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.matchers.JUnitMatchers.hasItem; |
@@ -22,7 +22,7 @@ package org.sonar.duplications.detector.original; | |||
import org.junit.Test; | |||
import org.sonar.duplications.block.Block; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class BlocksGroupTest { |
@@ -19,24 +19,22 @@ | |||
*/ | |||
package org.sonar.duplications.detector.suffixtree; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.lessThan; | |||
import static org.junit.Assert.assertThat; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.junit.runners.Parameterized; | |||
import org.junit.runners.Parameterized.Parameters; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
@RunWith(Parameterized.class) | |||
public class SuffixTreeTest { | |||
@Parameters | |||
public static Collection<Object[]> generateData() { | |||
return Arrays.asList(new Object[][] { { "banana" }, { "mississippi" }, { "book" }, { "bookke" }, { "cacao" }, { "googol" }, { "abababc" }, { "aaaaa" } }); | |||
return Arrays.asList(new Object[][] { {"banana"}, {"mississippi"}, {"book"}, {"bookke"}, {"cacao"}, {"googol"}, {"abababc"}, {"aaaaa"}}); | |||
} | |||
private final String data; | |||
@@ -50,14 +48,14 @@ public class SuffixTreeTest { | |||
String text = this.data + "$"; | |||
StringSuffixTree tree = StringSuffixTree.create(text); | |||
assertThat("number of leaves", tree.getNumberOfLeafs(), is(text.length())); | |||
assertThat("number of inner nodes", tree.getNumberOfInnerNodes(), lessThan(text.length() - 1)); | |||
assertThat("number of edges", tree.getNumberOfEdges(), is(tree.getNumberOfInnerNodes() + tree.getNumberOfLeafs())); | |||
assertThat(tree.getNumberOfLeafs()).as("number of leaves").isEqualTo(text.length()); | |||
assertThat(tree.getNumberOfInnerNodes()).as("number of inner nodes").isLessThan(text.length() - 1); | |||
assertThat(tree.getNumberOfEdges()).as("number of edges").isEqualTo(tree.getNumberOfInnerNodes() + tree.getNumberOfLeafs()); | |||
for (int beginIndex = 0; beginIndex < text.length(); beginIndex++) { | |||
for (int endIndex = beginIndex + 1; endIndex < text.length() + 1; endIndex++) { | |||
String substring = text.substring(beginIndex, endIndex); | |||
assertThat("index of " + substring + " in " + text, tree.indexOf(substring), is(text.indexOf(substring))); | |||
assertThat(tree.indexOf(substring)).as("index of " + substring + " in " + text).isEqualTo(text.indexOf(substring)); | |||
} | |||
} | |||
} |
@@ -29,7 +29,7 @@ import org.junit.Test; | |||
import java.io.IOException; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class TokenizerBridgeTest { |
@@ -35,7 +35,7 @@ import org.sonar.duplications.token.TokenChunker; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
/** |
@@ -23,6 +23,7 @@ import com.google.common.base.Charsets; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.io.IOUtils; | |||
import org.hamcrest.Matcher; | |||
import org.hamcrest.Matchers; | |||
import org.junit.Test; | |||
import org.sonar.duplications.DuplicationsTestUtil; | |||
import org.sonar.duplications.token.Token; | |||
@@ -37,7 +38,6 @@ import java.io.Reader; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -303,10 +303,10 @@ public class JavaTokenProducerTest { | |||
@Test | |||
public void realExamples() { | |||
File testFile = DuplicationsTestUtil.findFile("/java/MessageResources.java"); | |||
assertThat(chunk(testFile).size(), greaterThan(0)); | |||
assertThat(chunk(testFile).size(), Matchers.greaterThan(0)); | |||
testFile = DuplicationsTestUtil.findFile("/java/RequestUtils.java"); | |||
assertThat(chunk(testFile).size(), greaterThan(0)); | |||
assertThat(chunk(testFile).size(), Matchers.greaterThan(0)); | |||
} | |||
private TokenQueue chunk(File file) { |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.duplications.statement; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.spy; |
@@ -38,6 +38,11 @@ | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.easytesting</groupId> | |||
<artifactId>fest-assert</artifactId> | |||
@@ -51,7 +56,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -23,7 +23,7 @@ import org.junit.Test; | |||
import org.sonar.api.resources.Java; | |||
import org.sonar.api.resources.Language; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class JavaClassTest { |
@@ -21,7 +21,7 @@ package org.sonar.java.api; | |||
import org.junit.Test; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class JavaMethodTest { |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.java.api; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import org.apache.commons.configuration.BaseConfiguration; |
@@ -41,6 +41,11 @@ | |||
<artifactId>fest-assert</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -41,9 +41,14 @@ | |||
<artifactId>junit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -157,7 +157,7 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.batch.bootstrap; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -27,7 +27,7 @@ import org.sonar.api.test.MavenTestUtils; | |||
import java.nio.charset.Charset; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertThat; | |||
@@ -34,7 +34,9 @@ import java.security.InvalidKeyException; | |||
import java.security.Key; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.hamcrest.Matchers.instanceOf; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.hamcrest.core.Is.isA; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.fail; | |||
@@ -94,7 +96,7 @@ public class AesCipherTest { | |||
fail(); | |||
} catch (RuntimeException e) { | |||
assertThat(e.getCause(), is(InvalidKeyException.class)); | |||
assertThat(e.getCause(), instanceOf(InvalidKeyException.class)); | |||
} | |||
} | |||
@@ -109,7 +111,7 @@ public class AesCipherTest { | |||
fail(); | |||
} catch (RuntimeException e) { | |||
assertThat(e.getCause(), is(BadPaddingException.class)); | |||
assertThat(e.getCause(), instanceOf(BadPaddingException.class)); | |||
} | |||
} | |||
@@ -21,7 +21,7 @@ package org.sonar.api.config; | |||
import org.junit.Test; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class EncryptionTest { |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.measures; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; | |||
import static org.mockito.Mockito.mock; |
@@ -25,7 +25,7 @@ import org.junit.Test; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.measures; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertNull; | |||
import static org.junit.Assert.assertThat; |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.measures; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; | |||
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.measures; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; |
@@ -30,8 +30,8 @@ import java.util.Collections; | |||
import java.util.List; | |||
import static junit.framework.Assert.assertNull; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; |
@@ -25,8 +25,8 @@ import org.junit.rules.TemporaryFolder; | |||
import java.io.IOException; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; |
@@ -26,8 +26,8 @@ import org.junit.rules.TemporaryFolder; | |||
import java.io.IOException; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; |
@@ -21,7 +21,7 @@ package org.sonar.api.resources; | |||
import org.junit.Test; | |||
import static org.hamcrest.collection.IsCollectionContaining.hasItems; | |||
import static org.hamcrest.Matchers.hasItems; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.sonar.api.resources.ResourceTypesTest.qualifiers; |
@@ -28,9 +28,9 @@ import java.util.Date; | |||
import java.util.List; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo; | |||
import static org.hamcrest.text.StringStartsWith.startsWith; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.hamcrest.Matchers.greaterThanOrEqualTo; | |||
import static org.hamcrest.Matchers.startsWith; | |||
import static org.junit.Assert.*; | |||
public class DateUtilsTest { |
@@ -29,7 +29,7 @@ import java.util.Map; | |||
import java.util.TreeMap; | |||
import static junit.framework.Assert.assertEquals; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
public class DeprecatedKeyValueFormatTest { |
@@ -30,8 +30,8 @@ import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import java.util.Map; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
public class KeyValueFormatTest { |
@@ -30,7 +30,7 @@ import java.util.List; | |||
import java.util.Locale; | |||
import java.util.MissingResourceException; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.matchers.JUnitMatchers.hasItems; | |||
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.utils; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; | |||
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.utils; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.assertTrue; |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.api.web; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertThat; | |||
import org.junit.Test; |
@@ -177,7 +177,12 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
@@ -195,11 +200,6 @@ | |||
<artifactId>jsonassert</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>xmlunit</groupId> | |||
<artifactId>xmlunit</artifactId> |
@@ -34,6 +34,7 @@ import org.junit.rules.TemporaryFolder; | |||
import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import java.net.URLClassLoader; | |||
import java.util.Collection; | |||
@@ -96,7 +97,7 @@ public class ClassLoaderUtilsTest { | |||
} | |||
@Test | |||
public void copyRubyRailsApp() { | |||
public void copyRubyRailsApp() throws IOException { | |||
File toDir = temp.newFolder("dest"); | |||
ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, Functions.<String>identity()); | |||
@@ -106,7 +107,7 @@ public class ClassLoaderUtilsTest { | |||
} | |||
@Test | |||
public void copyRubyRailsApp_relocate_files() { | |||
public void copyRubyRailsApp_relocate_files() throws IOException { | |||
File toDir = temp.newFolder("dest"); | |||
ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, new Function<String, String>() { | |||
public String apply(@Nullable String path) { |
@@ -32,7 +32,7 @@ import java.net.URL; | |||
import java.net.URLClassLoader; | |||
import java.util.Collections; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.assertTrue; |
@@ -28,7 +28,7 @@ import java.net.InetAddress; | |||
import java.net.UnknownHostException; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.text.StringStartsWith.startsWith; | |||
import static org.hamcrest.Matchers.startsWith; | |||
import static org.junit.Assert.assertThat; | |||
public class ServerIdGeneratorTest { |
@@ -38,9 +38,9 @@ import java.util.List; | |||
import static com.google.common.collect.Iterables.getOnlyElement; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.lessThan; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.junit.Assert.assertArrayEquals; | |||
import static org.junit.Assert.assertThat; | |||
@@ -16,10 +16,6 @@ | |||
<groupId>org.easytesting</groupId> | |||
<artifactId>fest-assert</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.skyscreamer</groupId> | |||
<artifactId>jsonassert</artifactId> | |||
@@ -32,6 +28,10 @@ | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
</dependency> | |||
<dependency> | |||
<!-- used only for org.sonar.test.channel classes --> | |||
<groupId>org.codehaus.sonar</groupId> |
@@ -31,20 +31,16 @@ import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.SortedMap; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.hamcrest.Matchers.containsString; | |||
import static org.hamcrest.Matchers.hasItem; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.assertTrue; | |||
import static junit.framework.TestCase.fail; | |||
import static org.hamcrest.Matchers.*; | |||
import static org.junit.Assert.*; | |||
public class BundleSynchronizedMatcherTest { | |||
@Rule | |||
public ExpectedException thrown = ExpectedException.none(); | |||
private BundleSynchronizedMatcher matcher; | |||
BundleSynchronizedMatcher matcher; | |||
@Before | |||
public void init() { | |||
@@ -76,26 +72,31 @@ public class BundleSynchronizedMatcherTest { | |||
@Test | |||
public void shouldNotMatchIfNotString() { | |||
assertThat(matcher.matches(3)).isFalse(); | |||
assertThat(matcher.matches(3), is(false)); | |||
} | |||
@Test | |||
public void testGetBundleFileFromClasspath() { | |||
// OK | |||
assertThat(BundleSynchronizedMatcher.getBundleFileInputStream("myPlugin_fr.properties")) | |||
.isNotNull(); | |||
assertThat(BundleSynchronizedMatcher.getBundleFileInputStream("myPlugin_fr.properties"), notNullValue()); | |||
// KO | |||
thrown.expect(AssertionError.class); | |||
thrown.expectMessage("File 'unexistingBundle.properties' does not exist in '/org/sonar/l10n/'."); | |||
BundleSynchronizedMatcher.getBundleFileInputStream("unexistingBundle.properties"); | |||
try { | |||
BundleSynchronizedMatcher.getBundleFileInputStream("unexistingBundle.properties"); | |||
fail(); | |||
} catch (AssertionError e) { | |||
assertThat(e.getMessage(), startsWith("File 'unexistingBundle.properties' does not exist in '/org/sonar/l10n/'.")); | |||
} | |||
} | |||
@Test | |||
public void testGetDefaultBundleFileFromClasspath() { | |||
thrown.expect(AssertionError.class); | |||
thrown.expectMessage("Default bundle 'unexistingBundle.properties' could not be found: add a dependency to the corresponding plugin in your POM."); | |||
BundleSynchronizedMatcher.getDefaultBundleFileInputStream("unexistingBundle_fr.properties"); | |||
try { | |||
BundleSynchronizedMatcher.getDefaultBundleFileInputStream("unexistingBundle_fr.properties"); | |||
fail(); | |||
} catch (AssertionError e) { | |||
assertThat(e.getMessage(), startsWith("Default bundle 'unexistingBundle.properties' could not be found: add a dependency to the corresponding plugin in your POM.")); | |||
} | |||
} | |||
@Test | |||
@@ -105,9 +106,13 @@ public class BundleSynchronizedMatcherTest { | |||
assertThat(BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin_fr_QB.properties"), is("myPlugin.properties")); | |||
// KO | |||
thrown.expect(AssertionError.class); | |||
thrown.expectMessage("The bundle 'myPlugin.properties' is a default bundle (without locale), so it can't be compared."); | |||
BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin.properties"); | |||
try { | |||
BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin.properties"); | |||
fail(); | |||
} catch (AssertionError e) { | |||
assertThat(e.getMessage(), startsWith("The bundle 'myPlugin.properties' is a default bundle (without locale), so it can't be compared.")); | |||
} | |||
} | |||
@Test |
@@ -51,18 +51,18 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>javax.servlet-api</artifactId> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.hamcrest</groupId> | |||
<artifactId>hamcrest-all</artifactId> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>javax.servlet-api</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<artifactId>mockito-core</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> |
@@ -20,6 +20,7 @@ | |||
package org.sonar.wsclient; | |||
import org.eclipse.jetty.testing.ServletTester; | |||
import org.hamcrest.Matchers; | |||
import org.junit.AfterClass; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
@@ -32,17 +33,11 @@ import org.sonar.wsclient.services.MetricQuery; | |||
import org.sonar.wsclient.services.Query; | |||
import org.sonar.wsclient.services.Server; | |||
import org.sonar.wsclient.services.ServerQuery; | |||
import org.sonar.wsclient.unmarshallers.UnmarshalException; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.number.OrderingComparisons.greaterThan; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.fail; | |||
import static org.junit.internal.matchers.StringContains.containsString; | |||
@RunWith(value = Parameterized.class) | |||
public class SonarTest { | |||
@@ -86,20 +81,20 @@ public class SonarTest { | |||
@Test | |||
public void findAll() { | |||
Collection<Metric> metrics = sonar.findAll(MetricQuery.all()); | |||
assertThat(metrics.size(), greaterThan(1)); | |||
assertThat(metrics.size(), Matchers.greaterThan(1)); | |||
} | |||
@Test | |||
public void findEmptyResults() { | |||
Query<Metric> query = new EmptyQuery(); | |||
Collection<Metric> metrics = sonar.findAll(query); | |||
assertThat(metrics.size(), is(0)); | |||
assertThat(metrics.size(), Matchers.is(0)); | |||
} | |||
@Test | |||
public void returnNullWhenSingleResultNotFound() { | |||
Query<Metric> query = new EmptyQuery(); | |||
assertThat(sonar.find(query), nullValue()); | |||
assertThat(sonar.find(query), Matchers.nullValue()); | |||
} | |||
@Test(expected = ConnectionException.class) | |||
@@ -111,8 +106,8 @@ public class SonarTest { | |||
@Test | |||
public void getVersion() { | |||
Server server = sonar.find(new ServerQuery()); | |||
assertThat(server.getId(), is("123456789")); | |||
assertThat(server.getVersion(), is("2.0")); | |||
assertThat(server.getId(), Matchers.is("123456789")); | |||
assertThat(server.getVersion(), Matchers.is("2.0")); | |||
} | |||
static class EmptyQuery extends Query<Metric> { |
@@ -21,8 +21,8 @@ package org.sonar.wsclient.services; | |||
import org.junit.Test; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
public class ResourceTest { |
@@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Dependency; | |||
import java.util.Collection; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -26,8 +26,8 @@ import org.junit.Test; | |||
import java.util.Date; | |||
import java.util.TimeZone; | |||
import static org.hamcrest.CoreMatchers.is; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.junit.Assert.assertThat; | |||
public class JsonUtilsTest extends UnmarshallerTestCase { |
@@ -24,7 +24,7 @@ import org.sonar.wsclient.services.ManualMeasure; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Metric; | |||
import java.util.Collection; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
import static org.junit.Assert.assertTrue; |
@@ -23,7 +23,7 @@ import org.hamcrest.CoreMatchers; | |||
import org.junit.Test; | |||
import org.sonar.wsclient.services.Profile; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Property; | |||
import java.util.Collection; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -23,7 +23,7 @@ import org.junit.Test; | |||
import org.sonar.wsclient.services.ResourceSearchResult; | |||
import org.sonar.wsclient.services.Server; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -24,8 +24,8 @@ import org.sonar.wsclient.services.Resource; | |||
import java.util.List; | |||
import static org.hamcrest.CoreMatchers.not; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.not; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||
@@ -22,7 +22,7 @@ package org.sonar.wsclient.unmarshallers; | |||
import org.junit.Test; | |||
import org.sonar.wsclient.services.ServerSetup; | |||
import static org.hamcrest.CoreMatchers.nullValue; | |||
import static org.hamcrest.Matchers.nullValue; | |||
import static org.hamcrest.core.Is.is; | |||
import static org.junit.Assert.assertThat; | |||