@@ -22,7 +22,7 @@ package org.sonar.server.batch; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.api.platform.Server; | |||
@@ -51,13 +51,14 @@ public class IssuesActionTest { | |||
IssuesAction issuesAction; | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
private DbSession session; | |||
@Before | |||
public void before() throws Exception { | |||
db.truncateTables(); | |||
this.session = db.myBatis().openSession(false); | |||
DbClient dbClient = new DbClient(db.database(), db.myBatis(), new IssueDao(db.myBatis()), new ComponentDao()); |
@@ -22,7 +22,7 @@ package org.sonar.server.component.db; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbSession; | |||
@@ -34,8 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
@Category(DbTests.class) | |||
public class ComponentIndexDaoTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
DbSession session; | |||
@@ -43,6 +43,7 @@ public class ComponentIndexDaoTest { | |||
@Before | |||
public void createDao() throws Exception { | |||
dbTester.truncateTables(); | |||
session = dbTester.myBatis().openSession(false); | |||
dao = new ComponentIndexDao(); | |||
} |
@@ -21,8 +21,9 @@ | |||
package org.sonar.server.component.ws; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.api.web.UserRole; | |||
import org.sonar.core.persistence.DbTester; | |||
import org.sonar.core.user.AuthorizationDao; | |||
@@ -31,20 +32,23 @@ import org.sonar.server.component.db.ComponentIndexDao; | |||
import org.sonar.server.db.DbClient; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import org.sonar.test.DbTests; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Fail.failBecauseExceptionWasNotThrown; | |||
import static org.mockito.Mockito.mock; | |||
public class SearchActionMediumTest { | |||
@Category(DbTests.class) | |||
public class SearchActionTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
WsTester tester; | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
DbClient dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), | |||
new ComponentDao(), new AuthorizationDao(dbTester.myBatis()), new ComponentIndexDao() | |||
); |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.server.computation; | |||
import org.junit.Rule; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.core.activity.Activity; | |||
@@ -41,8 +42,8 @@ import static org.mockito.Mockito.*; | |||
public class ComputationServiceTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
ComputationStep projectStep1 = mockStep(Qualifiers.PROJECT); | |||
ComputationStep projectStep2 = mockStep(Qualifiers.PROJECT); | |||
@@ -50,6 +51,11 @@ public class ComputationServiceTest { | |||
ComputationSteps steps = mock(ComputationSteps.class); | |||
ActivityService activityService = mock(ActivityService.class); | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
} | |||
@Test | |||
public void process_project() throws Exception { | |||
// db contains project with key "PROJECT_KEY" |
@@ -21,10 +21,7 @@ | |||
package org.sonar.server.computation.db; | |||
import org.apache.commons.io.IOUtils; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.*; | |||
import org.junit.experimental.categories.Category; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.utils.System2; | |||
@@ -51,8 +48,8 @@ public class AnalysisReportDaoTest { | |||
private static final String DEFAULT_PROJECT_KEY = "123456789-987654321"; | |||
private static final long DEFAULT_SNAPSHOT_ID = 123L; | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
@Rule | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
@@ -63,6 +60,7 @@ public class AnalysisReportDaoTest { | |||
@Before | |||
public void before() { | |||
db.truncateTables(); | |||
this.session = db.myBatis().openSession(false); | |||
this.system2 = mock(System2.class); | |||
this.sut = new AnalysisReportDao(system2); |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.server.computation.issue; | |||
import org.junit.Rule; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.core.persistence.DbTester; | |||
@@ -33,8 +34,13 @@ import static org.junit.Assert.fail; | |||
public class RuleCacheLoaderTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
} | |||
@Test | |||
public void load_by_key() throws Exception { |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.server.computation.issue; | |||
import org.junit.Rule; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbTester; | |||
@@ -36,8 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
@Category(DbTests.class) | |||
public class SourceLinesCacheTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
} | |||
@Test | |||
public void line_author() throws Exception { |
@@ -19,6 +19,8 @@ | |||
*/ | |||
package org.sonar.server.computation.step; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
@@ -50,8 +52,13 @@ public class ParseReportStepTest { | |||
@Rule | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
} | |||
@Test | |||
public void extract_report_from_db_and_browse_components() throws Exception { |
@@ -21,7 +21,7 @@ | |||
package org.sonar.server.computation.step; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.api.utils.DateUtils; | |||
@@ -42,13 +42,14 @@ import static org.mockito.Mockito.when; | |||
@Category(DbTests.class) | |||
public class SwitchSnapshotStepTest { | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
SwitchSnapshotStep sut; | |||
@Before | |||
public void before() { | |||
db.truncateTables(); | |||
System2 system2 = mock(System2.class); | |||
when(system2.now()).thenReturn(DateUtils.parseDate("2011-09-29").getTime()); | |||
this.sut = new SwitchSnapshotStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao(system2))); |
@@ -24,8 +24,8 @@ import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.persistence.DbTester; | |||
import org.sonar.core.persistence.MyBatis; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDao; | |||
import org.sonar.server.qualityprofile.db.ActiveRuleDao; | |||
import org.sonar.server.rule.db.RuleDao; |
@@ -24,7 +24,7 @@ import com.google.common.collect.Iterables; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbTester; | |||
@@ -39,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
@Category(DbTests.class) | |||
public class IssueAuthorizationDaoTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
IssueAuthorizationDao dao = new IssueAuthorizationDao(); | |||
DbClient client; | |||
@@ -48,6 +48,7 @@ public class IssueAuthorizationDaoTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
client = new DbClient(dbTester.database(), dbTester.myBatis()); | |||
connection = dbTester.openConnection(); | |||
} |
@@ -24,7 +24,7 @@ import com.google.common.collect.Maps; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbTester; | |||
@@ -39,14 +39,15 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
@Category(DbTests.class) | |||
public class IssueResultSetIteratorTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
DbClient client; | |||
Connection connection; | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
client = new DbClient(dbTester.database(), dbTester.myBatis()); | |||
connection = dbTester.openConnection(); | |||
} |
@@ -21,8 +21,9 @@ package org.sonar.server.source.ws; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.api.web.UserRole; | |||
@@ -35,19 +36,21 @@ import org.sonar.server.exceptions.ForbiddenException; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.user.MockUserSession; | |||
import org.sonar.server.ws.WsTester; | |||
import org.sonar.test.DbTests; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.fail; | |||
import static org.mockito.Mockito.mock; | |||
@RunWith(MockitoJUnitRunner.class) | |||
@Category(DbTests.class) | |||
public class HashActionTest { | |||
final static String COMPONENT_KEY = "Action.java"; | |||
final static String PROJECT_KEY = "struts"; | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
DbSession session; | |||
@@ -55,6 +58,7 @@ public class HashActionTest { | |||
@Before | |||
public void before() throws Exception { | |||
db.truncateTables(); | |||
this.session = db.myBatis().openSession(false); | |||
DbClient dbClient = new DbClient(db.database(), db.myBatis(), new FileSourceDao(db.myBatis()), new ComponentDao()); |
@@ -23,7 +23,7 @@ package org.sonar.server.user; | |||
import com.google.common.base.Strings; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.junit.runner.RunWith; | |||
@@ -60,8 +60,8 @@ import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class UserUpdaterTest { | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
@Mock | |||
System2 system2; | |||
@@ -82,6 +82,7 @@ public class UserUpdaterTest { | |||
@Before | |||
public void setUp() throws Exception { | |||
db.truncateTables(); | |||
settings = new Settings(); | |||
session = db.myBatis().openSession(false); | |||
userDao = new UserDao(db.myBatis(), system2); |
@@ -22,13 +22,15 @@ package org.sonar.server.user.db; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.DbTester; | |||
import org.sonar.core.user.UserDto; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.test.DbTests; | |||
import java.util.List; | |||
@@ -36,16 +38,19 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.fail; | |||
import static org.mockito.Mockito.mock; | |||
@Category(DbTests.class) | |||
public class UserDaoTest { | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
private UserDao dao; | |||
private DbSession session; | |||
@Before | |||
public void before() throws Exception { | |||
db.truncateTables(); | |||
this.session = db.myBatis().openSession(false); | |||
System2 system2 = mock(System2.class); | |||
this.dao = new UserDao(db.myBatis(), system2); |
@@ -22,22 +22,26 @@ package org.sonar.server.user.db; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.persistence.DbTester; | |||
import org.sonar.core.user.UserGroupDto; | |||
import org.sonar.test.DbTests; | |||
@Category(DbTests.class) | |||
public class UserGroupDaoTest { | |||
@Rule | |||
public DbTester db = new DbTester(); | |||
@ClassRule | |||
public static DbTester db = new DbTester(); | |||
private UserGroupDao dao; | |||
private DbSession session; | |||
@Before | |||
public void before() throws Exception { | |||
db.truncateTables(); | |||
this.session = db.myBatis().openSession(false); | |||
this.dao = new UserGroupDao(); | |||
} |
@@ -24,7 +24,7 @@ import com.google.common.collect.Maps; | |||
import org.apache.commons.dbutils.DbUtils; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.junit.experimental.categories.Category; | |||
import org.sonar.core.persistence.DbTester; | |||
@@ -39,14 +39,15 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
@Category(DbTests.class) | |||
public class UserResultSetIteratorTest { | |||
@Rule | |||
public DbTester dbTester = new DbTester(); | |||
@ClassRule | |||
public static DbTester dbTester = new DbTester(); | |||
DbClient client; | |||
Connection connection; | |||
@Before | |||
public void setUp() throws Exception { | |||
dbTester.truncateTables(); | |||
client = new DbClient(dbTester.database(), dbTester.myBatis()); | |||
connection = dbTester.openConnection(); | |||
} |