Migrate to JUnit 4.8.1
This is the latest release available on the maven repo. Maven surefire plugin for JUnit4 does not like when a class that contains Test in its name has no @Test annotated methods. To fix this issue I renamed the class TestDatabase -> InMemoryDatabase. See http://jira.codehaus.org/browse/SUREFIRE-482 for more information. Change-Id: I9ee452cc0b73a48e68448200cf7b41660b2d8680
This commit is contained in:
committed by
Shawn O. Pearce
parent
8cb68dcc70
commit
e530b5bf22
@@ -23,7 +23,7 @@ import com.google.gerrit.reviewdb.ReviewDb;
|
|||||||
import com.google.gerrit.reviewdb.SystemConfig;
|
import com.google.gerrit.reviewdb.SystemConfig;
|
||||||
import com.google.gerrit.server.workflow.NoOpFunction;
|
import com.google.gerrit.server.workflow.NoOpFunction;
|
||||||
import com.google.gerrit.server.workflow.SubmitFunction;
|
import com.google.gerrit.server.workflow.SubmitFunction;
|
||||||
import com.google.gerrit.testutil.TestDatabase;
|
import com.google.gerrit.testutil.InMemoryDatabase;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.gwtorm.jdbc.JdbcSchema;
|
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||||
|
|
||||||
@@ -36,17 +36,17 @@ import java.util.HashSet;
|
|||||||
|
|
||||||
public class SchemaCreatorTest extends TestCase {
|
public class SchemaCreatorTest extends TestCase {
|
||||||
private ApprovalCategory.Id codeReview = new ApprovalCategory.Id("CRVW");
|
private ApprovalCategory.Id codeReview = new ApprovalCategory.Id("CRVW");
|
||||||
private TestDatabase db;
|
private InMemoryDatabase db;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
db = new TestDatabase();
|
db = new InMemoryDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
TestDatabase.drop(db);
|
InMemoryDatabase.drop(db);
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package com.google.gerrit.server.schema;
|
|||||||
import com.google.gerrit.reviewdb.ReviewDb;
|
import com.google.gerrit.reviewdb.ReviewDb;
|
||||||
import com.google.gerrit.reviewdb.SystemConfig;
|
import com.google.gerrit.reviewdb.SystemConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.testutil.TestDatabase;
|
import com.google.gerrit.testutil.InMemoryDatabase;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.gwtorm.client.SchemaFactory;
|
import com.google.gwtorm.client.SchemaFactory;
|
||||||
import com.google.gwtorm.client.StatementExecutor;
|
import com.google.gwtorm.client.StatementExecutor;
|
||||||
@@ -33,17 +33,17 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SchemaUpdaterTest extends TestCase {
|
public class SchemaUpdaterTest extends TestCase {
|
||||||
private TestDatabase db;
|
private InMemoryDatabase db;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
db = new TestDatabase();
|
db = new InMemoryDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
TestDatabase.drop(db);
|
InMemoryDatabase.drop(db);
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.util;
|
package com.google.gerrit.server.util;
|
||||||
|
|
||||||
import static com.google.gerrit.server.util.SocketUtil.format;
|
|
||||||
import static com.google.gerrit.server.util.SocketUtil.hostname;
|
import static com.google.gerrit.server.util.SocketUtil.hostname;
|
||||||
import static com.google.gerrit.server.util.SocketUtil.isIPv6;
|
import static com.google.gerrit.server.util.SocketUtil.isIPv6;
|
||||||
import static com.google.gerrit.server.util.SocketUtil.parse;
|
import static com.google.gerrit.server.util.SocketUtil.parse;
|
||||||
@@ -48,21 +47,21 @@ public class SocketUtilTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFormat() throws UnknownHostException {
|
public void testFormat() throws UnknownHostException {
|
||||||
assertEquals("*:1234", format(new InetSocketAddress(1234), 80));
|
assertEquals("*:1234", SocketUtil.format(new InetSocketAddress(1234), 80));
|
||||||
assertEquals("*", format(new InetSocketAddress(80), 80));
|
assertEquals("*", SocketUtil.format(new InetSocketAddress(80), 80));
|
||||||
|
|
||||||
assertEquals("foo:1234", format(createUnresolved("foo", 1234), 80));
|
assertEquals("foo:1234", SocketUtil.format(createUnresolved("foo", 1234), 80));
|
||||||
assertEquals("foo", format(createUnresolved("foo", 80), 80));
|
assertEquals("foo", SocketUtil.format(createUnresolved("foo", 80), 80));
|
||||||
|
|
||||||
assertEquals("[1:2:3:4:5:6:7:8]:1234",//
|
assertEquals("[1:2:3:4:5:6:7:8]:1234",//
|
||||||
format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 1234), 80));
|
SocketUtil.format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 1234), 80));
|
||||||
assertEquals("[1:2:3:4:5:6:7:8]",//
|
assertEquals("[1:2:3:4:5:6:7:8]",//
|
||||||
format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 80), 80));
|
SocketUtil.format(new InetSocketAddress(getByName("1:2:3:4:5:6:7:8"), 80), 80));
|
||||||
|
|
||||||
assertEquals("localhost:1234",//
|
assertEquals("localhost:1234",//
|
||||||
format(new InetSocketAddress("localhost", 1234), 80));
|
SocketUtil.format(new InetSocketAddress("localhost", 1234), 80));
|
||||||
assertEquals("localhost",//
|
assertEquals("localhost",//
|
||||||
format(new InetSocketAddress("localhost", 80), 80));
|
SocketUtil. format(new InetSocketAddress("localhost", 80), 80));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParse() {
|
public void testParse() {
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ import javax.sql.DataSource;
|
|||||||
* <p>
|
* <p>
|
||||||
* Test classes should create one instance of this class for each unique test
|
* Test classes should create one instance of this class for each unique test
|
||||||
* database they want to use. When the tests needing this instance are complete,
|
* database they want to use. When the tests needing this instance are complete,
|
||||||
* ensure that {@link #drop(TestDatabase)} is called to free the resources so
|
* ensure that {@link #drop(InMemoryDatabase)} is called to free the resources so
|
||||||
* the JVM running the unit tests doesn't run out of heap space.
|
* the JVM running the unit tests doesn't run out of heap space.
|
||||||
*/
|
*/
|
||||||
public class TestDatabase implements SchemaFactory<ReviewDb> {
|
public class InMemoryDatabase implements SchemaFactory<ReviewDb> {
|
||||||
private static int dbCnt;
|
private static int dbCnt;
|
||||||
|
|
||||||
private static synchronized DataSource newDataSource() throws SQLException {
|
private static synchronized DataSource newDataSource() throws SQLException {
|
||||||
@@ -58,7 +58,7 @@ public class TestDatabase implements SchemaFactory<ReviewDb> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Drop the database from memory; does nothing if the instance was null. */
|
/** Drop the database from memory; does nothing if the instance was null. */
|
||||||
public static void drop(final TestDatabase db) {
|
public static void drop(final InMemoryDatabase db) {
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.drop();
|
db.drop();
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class TestDatabase implements SchemaFactory<ReviewDb> {
|
|||||||
private boolean created;
|
private boolean created;
|
||||||
private SchemaVersion schemaVersion;
|
private SchemaVersion schemaVersion;
|
||||||
|
|
||||||
public TestDatabase() throws OrmException {
|
public InMemoryDatabase() throws OrmException {
|
||||||
try {
|
try {
|
||||||
final DataSource dataSource = newDataSource();
|
final DataSource dataSource = newDataSource();
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ public class TestDatabase implements SchemaFactory<ReviewDb> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Ensure the database schema has been created and initialized. */
|
/** Ensure the database schema has been created and initialized. */
|
||||||
public TestDatabase create() throws OrmException {
|
public InMemoryDatabase create() throws OrmException {
|
||||||
if (!created) {
|
if (!created) {
|
||||||
created = true;
|
created = true;
|
||||||
final ReviewDb c = open();
|
final ReviewDb c = open();
|
||||||
2
pom.xml
2
pom.xml
@@ -655,7 +655,7 @@ limitations under the License.
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>3.8.2</version>
|
<version>4.8.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
Reference in New Issue
Block a user