Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JUnit 4.13.2 Source Code Files
JUnit Source Code Files are provided in the source package file, junit-4.13.2-sources.jar.
You can browse JUnit Source Code files below:
✍: FYIcenter.com
⏎ junit/framework/Assert.java
package junit.framework; /** * A set of assert methods. Messages are only displayed when an assert fails. * * @deprecated Please use {@link org.junit.Assert} instead. */ @Deprecated public class Assert { /** * Protect constructor since it is a static only class */ protected Assert() { } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ public static void assertTrue(String message, boolean condition) { if (!condition) { fail(message); } } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ public static void assertTrue(boolean condition) { assertTrue(null, condition); } /** * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError with the given message. */ public static void assertFalse(String message, boolean condition) { assertTrue(message, !condition); } /** * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError. */ public static void assertFalse(boolean condition) { assertFalse(null, condition); } /** * Fails a test with the given message. */ public static void fail(String message) { if (message == null) { throw new AssertionFailedError(); } throw new AssertionFailedError(message); } /** * Fails a test with no message. */ public static void fail() { fail(null); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) { return; } if (expected != null && expected.equals(actual)) { return; } failNotEquals(message, expected, actual); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ public static void assertEquals(Object expected, Object actual) { assertEquals(null, expected, actual); } /** * Asserts that two Strings are equal. */ public static void assertEquals(String message, String expected, String actual) { if (expected == null && actual == null) { return; } if (expected != null && expected.equals(actual)) { return; } String cleanMessage = message == null ? "" : message; throw new ComparisonFailure(cleanMessage, expected, actual); } /** * Asserts that two Strings are equal. */ public static void assertEquals(String expected, String actual) { assertEquals(null, expected, actual); } /** * Asserts that two doubles are equal concerning a delta. If they are not * an AssertionFailedError is thrown with the given message. If the expected * value is infinity then the delta value is ignored. */ public static void assertEquals(String message, double expected, double actual, double delta) { if (Double.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { failNotEquals(message, Double.valueOf(expected), Double.valueOf(actual)); } } /** * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ public static void assertEquals(double expected, double actual, double delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two floats are equal concerning a positive delta. If they * are not an AssertionFailedError is thrown with the given message. If the * expected value is infinity then the delta value is ignored. */ public static void assertEquals(String message, float expected, float actual, float delta) { if (Float.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { failNotEquals(message, Float.valueOf(expected), Float.valueOf(actual)); } } /** * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ public static void assertEquals(float expected, float actual, float delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two longs are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, long expected, long actual) { assertEquals(message, Long.valueOf(expected), Long.valueOf(actual)); } /** * Asserts that two longs are equal. */ public static void assertEquals(long expected, long actual) { assertEquals(null, expected, actual); } /** * Asserts that two booleans are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, boolean expected, boolean actual) { assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual)); } /** * Asserts that two booleans are equal. */ public static void assertEquals(boolean expected, boolean actual) { assertEquals(null, expected, actual); } /** * Asserts that two bytes are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, byte expected, byte actual) { assertEquals(message, Byte.valueOf(expected), Byte.valueOf(actual)); } /** * Asserts that two bytes are equal. */ public static void assertEquals(byte expected, byte actual) { assertEquals(null, expected, actual); } /** * Asserts that two chars are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, char expected, char actual) { assertEquals(message, Character.valueOf(expected), Character.valueOf(actual)); } /** * Asserts that two chars are equal. */ public static void assertEquals(char expected, char actual) { assertEquals(null, expected, actual); } /** * Asserts that two shorts are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, short expected, short actual) { assertEquals(message, Short.valueOf(expected), Short.valueOf(actual)); } /** * Asserts that two shorts are equal. */ public static void assertEquals(short expected, short actual) { assertEquals(null, expected, actual); } /** * Asserts that two ints are equal. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertEquals(String message, int expected, int actual) { assertEquals(message, Integer.valueOf(expected), Integer.valueOf(actual)); } /** * Asserts that two ints are equal. */ public static void assertEquals(int expected, int actual) { assertEquals(null, expected, actual); } /** * Asserts that an object isn't null. */ public static void assertNotNull(Object object) { assertNotNull(null, object); } /** * Asserts that an object isn't null. If it is * an AssertionFailedError is thrown with the given message. */ public static void assertNotNull(String message, Object object) { assertTrue(message, object != null); } /** * Asserts that an object is null. If it isn't an {@link AssertionError} is * thrown. * Message contains: Expected: <null> but was: object * * @param object Object to check or <code>null</code> */ public static void assertNull(Object object) { if (object != null) { assertNull("Expected: <null> but was: " + object.toString(), object); } } /** * Asserts that an object is null. If it is not * an AssertionFailedError is thrown with the given message. */ public static void assertNull(String message, Object object) { assertTrue(message, object == null); } /** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertSame(String message, Object expected, Object actual) { if (expected == actual) { return; } failNotSame(message, expected, actual); } /** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ public static void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); } /** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown with the * given message. */ public static void assertNotSame(String message, Object expected, Object actual) { if (expected == actual) { failSame(message); } } /** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ public static void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); } public static void failSame(String message) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected not same"); } public static void failNotSame(String message, Object expected, Object actual) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); } public static void failNotEquals(String message, Object expected, Object actual) { fail(format(message, expected, actual)); } public static String format(String message, Object expected, Object actual) { String formatted = ""; if (message != null && message.length() > 0) { formatted = message + " "; } return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; } }
⏎ junit/framework/Assert.java
Or download all of them as a single archive file:
File name: junit-4.13.2-sources.jar File size: 234540 bytes Release date: 2021-02-13 Download
⇒ Download and Install junit-4.12.jar
⇐ Download and Install junit-4.13.2.jar
2016-03-28, 19084👍, 0💬
Popular Posts:
Apache BCEL Source Code Files are inside the Apache BCEL source package file like bcel-6.5.0-src.zip...
Jetty provides an HTTP server, HTTP client, and javax.servlet container. These components are open s...
How to compare performances of various XML parsers with the jaxp\SourceValidator.jav aprovided in th...
JavaMail Source Code Files are provided in the source package file, httpcomponents-client-5. 2-src.zi...
Apache Log4j API provides the interface that applications should code to and provides the adapter co...