java.util.FormatterClosedException Java Examples

The following examples show how to use java.util.FormatterClosedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonPoolTest.java    From reactor-pool with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("allPools")
void disposingPoolClosesCloseable(Function<PoolBuilder<Formatter, ?>, AbstractPool<Formatter>> configAdjuster) {
	Formatter uniqueElement = new Formatter();

	PoolBuilder<Formatter, ?> builder = PoolBuilder
			.from(Mono.just(uniqueElement))
			.sizeBetween(1, 1)
			.evictionPredicate((poolable, metadata) -> true);
	AbstractPool<Formatter> pool = configAdjuster.apply(builder);
	pool.warmup().block();

	pool.dispose();

	assertThatExceptionOfType(FormatterClosedException.class)
			.isThrownBy(uniqueElement::flush);
}
 
Example #2
Source File: FormatterTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.util.Formatter#toString()
 */
public void test_toString() {
    Formatter f = new Formatter();
    assertNotNull(f.toString());
    assertEquals(f.out().toString(), f.toString());
    f.close();
    try {
        f.toString();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
 
Example #3
Source File: Log.java    From couchbase-lite-java with Apache License 2.0 4 votes vote down vote up
private static String formatMessage(String msg, Object... args) {
    try { return String.format(Locale.ENGLISH, msg, args); }
    catch (IllegalFormatException | FormatterClosedException ignore) { }
    return msg;
}