Browse Source
Since version 4.13 JUnit has an assertThrows method. Remove the implementation in MoreAsserts and use the one from JUnit. CQ: 21439 Change-Id: I086baa94aa3069cebe87c4cbf91ed1534523c6cb Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>stable-5.8
David Pursehouse
5 years ago
committed by
Matthias Sohn
34 changed files with 83 additions and 129 deletions
@ -1,7 +1,7 @@ |
|||||||
target "jgit-4.6" with source configurePhase |
target "jgit-4.6" with source configurePhase |
||||||
|
|
||||||
include "projects/jetty-9.4.x.tpd" |
include "projects/jetty-9.4.x.tpd" |
||||||
include "orbit/I20200115225246.tpd" |
include "orbit/I20200120214610.tpd" |
||||||
|
|
||||||
location "http://download.eclipse.org/releases/neon/" { |
location "http://download.eclipse.org/releases/neon/" { |
||||||
org.eclipse.osgi lazy |
org.eclipse.osgi lazy |
||||||
|
@ -1,7 +1,7 @@ |
|||||||
target "jgit-4.9" with source configurePhase |
target "jgit-4.9" with source configurePhase |
||||||
|
|
||||||
include "projects/jetty-9.4.x.tpd" |
include "projects/jetty-9.4.x.tpd" |
||||||
include "orbit/I20200115225246.tpd" |
include "orbit/I20200120214610.tpd" |
||||||
|
|
||||||
location "http://download.eclipse.org/releases/2018-09/" { |
location "http://download.eclipse.org/releases/2018-09/" { |
||||||
org.eclipse.osgi lazy |
org.eclipse.osgi lazy |
||||||
|
@ -1,46 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright (C) 2019, Google LLC and others |
|
||||||
* |
|
||||||
* This program and the accompanying materials are made available under the |
|
||||||
* terms of the Eclipse Distribution License v. 1.0 which is available at |
|
||||||
* https://www.eclipse.org/org/documents/edl-v10.php.
|
|
||||||
* |
|
||||||
* SPDX-License-Identifier: BSD-3-Clause |
|
||||||
*/ |
|
||||||
package org.eclipse.jgit.lib; |
|
||||||
|
|
||||||
/** Assertion methods. */ |
|
||||||
public class MoreAsserts { |
|
||||||
/** |
|
||||||
* Simple version of assertThrows that will be introduced in JUnit 4.13. |
|
||||||
* |
|
||||||
* @param expected |
|
||||||
* Expected throwable class
|
|
||||||
* @param r |
|
||||||
* Runnable that is expected to throw an exception. |
|
||||||
* @return The thrown exception. |
|
||||||
*/ |
|
||||||
public static <T extends Throwable> T assertThrows(Class<T> expected, |
|
||||||
ThrowingRunnable r) { |
|
||||||
try { |
|
||||||
r.run(); |
|
||||||
} catch (Throwable actual) { |
|
||||||
if (expected.isAssignableFrom(actual.getClass())) { |
|
||||||
@SuppressWarnings("unchecked") |
|
||||||
T toReturn = (T) actual; |
|
||||||
return toReturn; |
|
||||||
} |
|
||||||
throw new AssertionError("Expected " + expected.getSimpleName() |
|
||||||
+ ", but got " + actual.getClass().getSimpleName(), actual); |
|
||||||
} |
|
||||||
throw new AssertionError( |
|
||||||
"Expected " + expected.getSimpleName() + " to be thrown"); |
|
||||||
} |
|
||||||
|
|
||||||
public interface ThrowingRunnable { |
|
||||||
void run() throws Throwable; |
|
||||||
} |
|
||||||
|
|
||||||
private MoreAsserts() { |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue