Convert ssh acceptance tests to use Google Truth

Change-Id: I6b087f877ae0004ca4e591c602df84b6bf1f6eb2
This commit is contained in:
David Pursehouse
2014-11-10 16:40:05 +09:00
parent c03cd517c3
commit 4ea945eb5e
3 changed files with 22 additions and 19 deletions

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.acceptance.ssh;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static com.google.gerrit.acceptance.GitUtil.add;
import static com.google.gerrit.acceptance.GitUtil.createCommit;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GitUtil.Commit;
@@ -40,11 +40,12 @@ public class BanCommitIT extends AbstractDaemonTest {
String response =
sshSession.exec("gerrit ban-commit " + project.get() + " "
+ c.getCommit().getName());
assertFalse(sshSession.getError(), sshSession.hasError());
assertFalse(response, response.toLowerCase(Locale.US).contains("error"));
assert_().withFailureMessage(sshSession.getError())
.that(sshSession.hasError()).isFalse();
assertThat(response.toLowerCase(Locale.US)).doesNotContain("error");
PushResult pushResult = pushHead(git, "refs/heads/master", false);
assertTrue(pushResult.getRemoteUpdate("refs/heads/master").getMessage()
.startsWith("contains banned commit"));
assertThat(pushResult.getRemoteUpdate("refs/heads/master").getMessage())
.startsWith("contains banned commit");
}
}

View File

@@ -14,10 +14,9 @@
package com.google.gerrit.acceptance.ssh;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GcAssert;
@@ -66,7 +65,8 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
String response =
sshSession.exec("gerrit gc \"" + project.get() + "\" \""
+ project2.get() + "\"");
assertFalse(sshSession.getError(), sshSession.hasError());
assert_().withFailureMessage(sshSession.getError())
.that(sshSession.hasError()).isFalse();
assertNoError(response);
gcAssert.assertHasPackFile(project, project2);
gcAssert.assertHasNoPackFile(allProjects, project3);
@@ -76,7 +76,8 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
@UseLocalDisk
public void testGcAll() throws Exception {
String response = sshSession.exec("gerrit gc --all");
assertFalse(sshSession.getError(), sshSession.hasError());
assert_().withFailureMessage(sshSession.getError())
.that(sshSession.hasError()).isFalse();
assertNoError(response);
gcAssert.assertHasPackFile(allProjects, project, project2, project3);
}
@@ -95,18 +96,19 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
gcQueue.addAll(Arrays.asList(project));
GarbageCollectionResult result = garbageCollectionFactory.create().run(
Arrays.asList(allProjects, project, project2, project3));
assertTrue(result.hasErrors());
assertEquals(1, result.getErrors().size());
assertThat(result.hasErrors()).isTrue();
assertThat(result.getErrors().size()).isEqualTo(1);
GarbageCollectionResult.Error error = result.getErrors().get(0);
assertEquals(GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED, error.getType());
assertEquals(project, error.getProjectName());
assertThat(error.getType()).isEqualTo(
GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED);
assertThat(error.getProjectName()).isEqualTo(project);
}
private void assertError(String expectedError, String response) {
assertTrue(response, response.contains(expectedError));
assertThat(response).contains(expectedError);
}
private void assertNoError(String response) {
assertFalse(response, response.toLowerCase(Locale.US).contains("error"));
assertThat(response.toLowerCase(Locale.US)).doesNotContain("error");
}
}

View File

@@ -14,13 +14,13 @@
package com.google.gerrit.acceptance.ssh;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.createProject;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -62,6 +62,6 @@ public class JschVerifyFalseBugIT extends AbstractDaemonTest {
for (Future<Void> future : futures) {
future.get();
}
Assert.assertEquals(threads, futures.size());
assertThat(futures.size()).isEqualTo(threads);
}
}