### Question:
ManagedConnectionFactoryImpl extends AbstractManagedConnectionFactoryImpl implements CXFManagedConnectionFactory { public Bus getBus() { return (jcaBusFactory != null) ? jcaBusFactory.getBus() : null; } ManagedConnectionFactoryImpl();  ManagedConnectionFactoryImpl(Properties props); void setLogLevel(String logLevel); void setEJBServicePropertiesURL(String name); void setMonitorEJBServiceProperties(Boolean monitor); void setEJBServicePropertiesPollInterval(Integer pollInterval); String getLogLevel(); String getEJBServicePropertiesURL(); Boolean getMonitorEJBServiceProperties(); Integer getEJBServicePropertiesPollInterval(); URL getEJBServicePropertiesURLInstance(); String getEJBServantBaseURL(); void setEJBServantBaseURL(String url); Object createConnectionFactory(); Object createConnectionFactory(ConnectionManager connMgr); ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connReqInfo); void close(); Bus getBus();  }### Answer:
@Test public void testMatchManagedConnectionsWithBoundConnections() throws Exception { Subject subj = new Subject(); BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); BusFactory.setDefaultBus(bus); ManagedConnectionFactoryImpl factory = EasyMock.createMock(ManagedConnectionFactoryImpl.class); factory.getBus(); EasyMock.expectLastCall().andReturn(bus).times(4); EasyMock.replay(factory); ManagedConnectionImpl mc1 = new ManagedConnectionImpl(factory, cri, subj); Object connection = mc1.getConnection(subj, cri); assertNotNull("connection must not be null.", connection); Set<ManagedConnection> mcSet = new HashSet<>(); mcSet.add(mc1); assertSame("MC1 must be selected.", mci.matchManagedConnections(mcSet, subj, cri), mc1); bus.shutdown(true); }
@Test public void testMatchManagedConnectionsWithBoundConnections() throws Exception { Subject subj = new Subject(); BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); BusFactory.setDefaultBus(bus); ManagedConnectionFactoryImpl factory = EasyMock.createMock(ManagedConnectionFactoryImpl.class); factory.getBus(); EasyMock.expectLastCall().andReturn(bus).times(4); EasyMock.replay(factory); ManagedConnectionImpl mc1 = new ManagedConnectionImpl(factory, cri, subj); Object connection = mc1.getConnection(subj, cri); assertNotNull("connection must not be null.", connection); Set<ManagedConnection> mcSet = new HashSet<ManagedConnection>(); mcSet.add(mc1); assertSame("MC1 must be selected.", mci.matchManagedConnections(mcSet, subj, cri), mc1); bus.shutdown(true); }