infos = (Set) connectionManagerMap.get(key1);
assertEquals("Expected no connection set for key1", null, infos);
}
public void testNestedComponentContextLifecyle() throws Exception {
DefaultComponentContext componentContext1 = new DefaultComponentContext();
TrackedConnectionAssociator.ConnectorContextInfo oldConnectorContext1 = connectionTrackingCoordinator.enter(componentContext1, unshareableResources);
assertNull("Expected old component context to be null", oldConnectorContext1.getInstanceContext());
//give the context a ConnectionInfo
ManagedConnectionInfo managedConnectionInfo1 = new ManagedConnectionInfo(null, null);
ConnectionInfo connectionInfo1 = new ConnectionInfo(managedConnectionInfo1);
connectionTrackingCoordinator.handleObtained(key1, connectionInfo1);
//Simulate calling another component
DefaultComponentContext componentContext2 = new DefaultComponentContext();
TrackedConnectionAssociator.ConnectorContextInfo oldConnectorContext2 = connectionTrackingCoordinator.enter(componentContext2, unshareableResources);
assertTrue("Expected returned component context to be componentContext1", oldConnectorContext2.getInstanceContext() == componentContext1);
//give the context a ConnectionInfo
ManagedConnectionInfo managedConnectionInfo2 = new ManagedConnectionInfo(null, null);
ConnectionInfo connectionInfo2 = new ConnectionInfo(managedConnectionInfo2);
connectionTrackingCoordinator.handleObtained(key2, connectionInfo2);
connectionTrackingCoordinator.exit(oldConnectorContext2);
Map connectionManagerMap2 = componentContext2.getConnectionManagerMap();
Set infos2 = (Set) connectionManagerMap2.get(key2);
assertEquals("Expected one connection for key2", 1, infos2.size());
assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo2 == infos2.iterator().next());
assertEquals("Expected no connection for key1", null, connectionManagerMap2.get(key1));