}
@Test
public void testLifecycleListenerProvider() {
final JerseyClientBuilder builder = new JerseyClientBuilder();
final JerseyClient client = builder.build();
final BarListener filter = new BarListener();
final BarListener filter2 = new BarListener2();
// ClientRuntime initializes lazily, so it is forced by invoking a (dummy) request
client.register(filter2); // instance registered into client
client.target(getBaseUri()).register(filter).request().get(String.class); // instance registration into target
assertTrue("Filter was expected to be already initialized.", filter.isInitialized());
assertTrue("Filter2 was expected to be already initialized.", filter2.isInitialized());
client.target(getBaseUri()).register(FooListener.class).request().get(String.class); // class registration into target
assertTrue("Class-registered filter was expected to be already initialized", FooListener.isInitialized());
assertFalse("Class-registered filter was expected to be still open.", FooListener.isClosed());
assertFalse("Filter was expected to be still open.", filter.isClosed());
assertFalse("Filter2 was expected to be still open.", filter2.isClosed());
client.close();
assertTrue("Class-registered filter was expected to be closed.", FooListener.isClosed());
assertTrue("Filter was expected to be closed.", filter.isClosed());
assertTrue("Filter2 was expected to be closed.", filter2.isClosed());
}