AbstractQueryChangesTest: Open TestRepository in try-with-resource
Since [1], included in JGit 5.3.0, TestRepository is AutoCloseable and should be managed by try-with-resource. [1] https://git.eclipse.org/r/#/c/134912 Change-Id: I77b0b5b8f49972f289d9e3cf0a7289e4904d5018
This commit is contained in:
@@ -1958,8 +1958,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
assertQuery("draftby:" + userId, change);
|
assertQuery("draftby:" + userId, change);
|
||||||
assertQuery("commentby:" + userId);
|
assertQuery("commentby:" + userId);
|
||||||
|
|
||||||
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
|
try (TestRepository<Repo> allUsers =
|
||||||
|
new TestRepository<>(repoManager.openRepository(allUsersName))) {
|
||||||
Ref draftsRef = allUsers.getRepository().exactRef(RefNames.refsDraftComments(id, userId));
|
Ref draftsRef = allUsers.getRepository().exactRef(RefNames.refsDraftComments(id, userId));
|
||||||
assertThat(draftsRef).isNotNull();
|
assertThat(draftsRef).isNotNull();
|
||||||
|
|
||||||
@@ -1974,6 +1974,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
// Re-add drafts ref and ensure it gets filtered out during indexing.
|
// Re-add drafts ref and ensure it gets filtered out during indexing.
|
||||||
allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
|
allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
|
||||||
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
|
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
indexer.index(project, id);
|
indexer.index(project, id);
|
||||||
assertQuery("draftby:" + userId);
|
assertQuery("draftby:" + userId);
|
||||||
@@ -3028,7 +3029,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
String destination4 = "refs/heads/master\trepo3";
|
String destination4 = "refs/heads/master\trepo3";
|
||||||
String destination5 = "refs/heads/other\trepo1";
|
String destination5 = "refs/heads/other\trepo1";
|
||||||
|
|
||||||
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
|
try (TestRepository<Repo> allUsers =
|
||||||
|
new TestRepository<>(repoManager.openRepository(allUsersName))) {
|
||||||
String refsUsers = RefNames.refsUsers(userId);
|
String refsUsers = RefNames.refsUsers(userId);
|
||||||
allUsers.branch(refsUsers).commit().add("destinations/destination1", destination1).create();
|
allUsers.branch(refsUsers).commit().add("destinations/destination1", destination1).create();
|
||||||
allUsers.branch(refsUsers).commit().add("destinations/destination2", destination2).create();
|
allUsers.branch(refsUsers).commit().add("destinations/destination2", destination2).create();
|
||||||
@@ -3038,6 +3040,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
|
|
||||||
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
||||||
assertThat(userRef).isNotNull();
|
assertThat(userRef).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
assertQuery("destination:destination1", change1);
|
assertQuery("destination:destination1", change1);
|
||||||
assertQuery("destination:destination2", change2);
|
assertQuery("destination:destination2", change2);
|
||||||
@@ -3058,12 +3061,14 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
+ "query3\tproject:repo branch:stable\n"
|
+ "query3\tproject:repo branch:stable\n"
|
||||||
+ "query4\tproject:repo branch:other";
|
+ "query4\tproject:repo branch:other";
|
||||||
|
|
||||||
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
|
try (TestRepository<Repo> allUsers =
|
||||||
|
new TestRepository<>(repoManager.openRepository(allUsersName))) {
|
||||||
String refsUsers = RefNames.refsUsers(userId);
|
String refsUsers = RefNames.refsUsers(userId);
|
||||||
allUsers.branch(refsUsers).commit().add("queries", queries).create();
|
allUsers.branch(refsUsers).commit().add("queries", queries).create();
|
||||||
|
|
||||||
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
||||||
assertThat(userRef).isNotNull();
|
assertThat(userRef).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
assertThatQueryException("query:foo").hasMessageThat().isEqualTo("Unknown named query: foo");
|
assertThatQueryException("query:foo").hasMessageThat().isEqualTo("Unknown named query: foo");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user