List of usage examples for java.lang AssertionError AssertionError
public AssertionError(double detailMessage)
double
, which is converted to a string as defined in section 15.18.1.1 of The Java™ Language Specification. From source file:Main.java
public static Throwable getExceptionFromNewThread(String threadName, Runnable target) { try {//from ww w . j a va 2 s . c o m runInNewThread(threadName, target); } catch (Throwable throwable) { return throwable; } throw new AssertionError("Expected to throw an exception but did not throw anything"); }
From source file:Main.java
/** * Will throw AssertionError, if expression is not true * * @param expression result of your asserted condition * @param failedMessage message to be included in error log * @throws java.lang.AssertionError/* w w w .jav a 2 s . c o m*/ */ public static void asserts(final boolean expression, final String failedMessage) { if (!expression) { throw new AssertionError(failedMessage); } }
From source file:Main.java
public static void check(boolean b, @NonNull String message) { if (b)//from w w w . j ava2s .co m throw new AssertionError(message); }
From source file:Main.java
public static <T> T waitOnFuture(Future<T> future) { try {//from w ww.j a v a 2 s . co m return future.get(); } catch (ExecutionException ee) { throw new RuntimeException(ee); } catch (InterruptedException ie) { throw new AssertionError(ie); } }
From source file:Main.java
public static String createUri(final String path) { if (path.contains(":/")) { return path; }// w w w . ja va 2 s . c om try { return DUMMY_PREFIX + URLEncoder.encode(path, "UTF-8"); } catch (final UnsupportedEncodingException e) { throw new AssertionError(e); } }
From source file:Main.java
/** Helper method which throws an exception when an assertion has failed. */ public static void assertIsTrue(boolean condition) { if (!condition) { throw new AssertionError("Expected condition to be true"); }//from ww w .j av a 2 s . c o m }
From source file:Main.java
public static void fail(String message, Object... args) { throw new AssertionError(args.length == 0 ? message : String.format(message, args)); }
From source file:Main.java
public static void asserts(final boolean expression, final String failedMessage) { if (!expression) { throw new AssertionError(failedMessage); }//from w w w . j av a 2s .c om }
From source file:Main.java
public static void assertMainThread() { if (!isMainThread()) { throw new AssertionError("Main-thread assertion failed."); }/*from w ww .ja va 2 s . co m*/ }
From source file:Main.java
/** * Retrieves the PackageInfo object for this application. * * @param context Any context.//from w w w . j a va 2 s .co m * @return The PackageInfo object for this application. */ public static PackageInfo getOwnPackageInfo(Context context) { PackageManager manager = context.getPackageManager(); try { String packageName = context.getApplicationContext().getPackageName(); return manager.getPackageInfo(packageName, 0); } catch (NameNotFoundException e) { // Should never happen. throw new AssertionError("Failed to retrieve own package info"); } }