### Question:
ClientRuntime extends CayenneRuntime { public static ClientRuntimeBuilder builder() { return new ClientRuntimeBuilder(); } protected  ClientRuntime(Collection<Module> modules); static ClientRuntimeBuilder builder(); ClientConnection getConnection(); static final String CLIENT_SERVER_CHANNEL_KEY; }### Answer:
@Test public void testGetObjectContext() { Map<String, String> properties = new HashMap<>(); ClientModule extraModule = new ClientModule() { @Override public void configure(Binder binder) { super.configure(binder); binder.bind(ClientConnection.class).to(MockClientConnection.class); } }; ClientRuntime runtime = ClientRuntime.builder() .properties(properties) .addModule(extraModule) .build(); ObjectContext context = runtime.newContext(); assertNotNull(context); assertTrue(context instanceof CayenneContext); assertNotSame("ObjectContext must not be a singleton", context, runtime.newContext()); CayenneContext clientContext = (CayenneContext) context; assertNotNull(clientContext.getChannel()); assertSame(runtime.getChannel(), clientContext.getChannel()); }
@Test public void testGetDataChannel() { Map<String, String> properties = new HashMap<>(); Module extraModule = binder -> binder.bind(ClientConnection.class).to(MockClientConnection.class); ClientRuntime runtime = ClientRuntime.builder() .properties(properties) .addModule(extraModule) .build(); DataChannel channel = runtime.getChannel(); assertNotNull(channel); assertTrue(channel instanceof ClientChannel); }
@Test public void testShutdown() throws Exception { Map<String, String> properties = new HashMap<>(); ClientRuntime runtime = ClientRuntime.builder() .properties(properties) .addModule(binder -> ServerModule.contributeProperties(binder) .put(Constants.SERVER_CONTEXTS_SYNC_PROPERTY, String.valueOf(true))) .build(); EventManager em = runtime.getInjector().getInstance(EventManager.class); assertNotNull(em); assertTrue(em instanceof DefaultEventManager); assertFalse(((DefaultEventManager) em).isStopped()); runtime.getInjector().shutdown(); assertTrue(((DefaultEventManager) em).isStopped()); }