diff options
author | Ivan Frade <ifrade@google.com> | 2019-09-18 14:38:37 -0700 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2019-09-18 14:43:28 -0700 |
commit | 83a6145f2fd08e6e256c4342799476c90d7de2e0 (patch) | |
tree | f0a9782d03d84d495aab8c2b0156aeba440097bd | |
parent | 208ddab5ab1722269245e643430f0d56cd04233d (diff) | |
download | jgit-83a6145f2fd08e6e256c4342799476c90d7de2e0.tar.gz jgit-83a6145f2fd08e6e256c4342799476c90d7de2e0.zip |
UploadPackReachabilityTest: Use assertThrows instead of thrown
In https://git.eclipse.org/r/c/144009/ UploadPack tests moved from
thrown to assertThrows, but newly introduced tests are still using
the thrown.
Update test so all of them use assertThrows.
Change-Id: I0ff19a6f8ba9e978d8ffc7a912c0572d9f00c7fa
Signed-off-by: Ivan Frade <ifrade@google.com>
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java index 1a855d1d9b..7122082d81 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java @@ -63,7 +63,6 @@ import org.eclipse.jgit.transport.UploadPack.RequestPolicy; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.UploadPackFactory; -import org.hamcrest.Matchers; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -189,11 +188,11 @@ public class UploadPackReachabilityTest { assertFalse(client.getObjectDatabase().has(blob.toObjectId())); try (Transport tn = testProtocol.open(uri, client, "server")) { - thrown.expect(TransportException.class); - thrown.expectMessage(Matchers - .containsString("want " + blob.name() + " not valid")); + TransportException e = assertThrows(TransportException.class, () -> tn.fetch(NullProgressMonitor.INSTANCE, - Collections.singletonList(new RefSpec(blob.name()))); + Collections.singletonList(new RefSpec(blob.name())))); + assertThat(e.getMessage(), + containsString("want " + blob.name() + " not valid")); } } @@ -266,11 +265,11 @@ public class UploadPackReachabilityTest { assertFalse(client.getObjectDatabase().has(commit.toObjectId())); try (Transport tn = testProtocol.open(uri, client, "server")) { - thrown.expect(TransportException.class); - thrown.expectMessage(Matchers - .containsString("want " + commit.name() + " not valid")); - tn.fetch(NullProgressMonitor.INSTANCE, - Collections.singletonList(new RefSpec(commit.name()))); + TransportException e = assertThrows(TransportException.class, + () -> tn.fetch(NullProgressMonitor.INSTANCE, + Collections.singletonList(new RefSpec(commit.name())))); + assertThat(e.getMessage(), + containsString("want " + commit.name() + " not valid")); } } @@ -285,11 +284,11 @@ public class UploadPackReachabilityTest { assertFalse(client.getObjectDatabase().has(commit.toObjectId())); try (Transport tn = testProtocol.open(uri, client, "server")) { - thrown.expect(TransportException.class); - thrown.expectMessage(Matchers - .containsString("want " + commit.name() + " not valid")); - tn.fetch(NullProgressMonitor.INSTANCE, - Collections.singletonList(new RefSpec(commit.name()))); + TransportException e = assertThrows(TransportException.class, + () -> tn.fetch(NullProgressMonitor.INSTANCE, Collections + .singletonList(new RefSpec(commit.name())))); + assertThat(e.getMessage(), + containsString("want " + commit.name() + " not valid")); } } |