ConnectorInstanceContextImpl componentContext = new ConnectorInstanceContextImpl(unshareableResources, applicationManagedSecurityResources);
ConnectorInstanceContext oldConnectorInstanceContext1 = connectionTrackingCoordinator.enter(componentContext);
assertNull("Expected old component context to be null", oldConnectorInstanceContext1);
// simulate create connection
ConnectionInfo connectionInfo = createConnectionInfo();
connectionTrackingCoordinator.handleObtained(key1, connectionInfo, false);
// connection should be in component instance context
Map connectionManagerMap = componentContext.getConnectionManagerMap();
Set infos = (Set) connectionManagerMap.get(key1);
assertNotNull("Expected one connections for key1", infos);
assertEquals("Expected one connection for key1", 1, infos.size());
assertTrue("Expected to get supplied ConnectionInfo from infos", connectionInfo == infos.iterator().next());
// verify handle
Object handle = connectionInfo.getConnectionHandle();
assertNotNull("Expected a handle from ConnectionInfo", handle);
assertTrue("Expected handle to be an instance of ConnectionImpl", handle instanceof ConnectionImpl);
ConnectionImpl connection = (ConnectionImpl) handle;
assertEquals("connection.getString()", "ConnectionString", connection.getString());
// verify proxy
Object proxy = connectionInfo.getConnectionProxy();
assertNotNull("Expected a proxy from ConnectionInfo", proxy);
assertTrue("Expected proxy to be an instance of Connection", proxy instanceof Connection);
Connection connectionProxy = (Connection) proxy;
assertEquals("connection.getString()", "ConnectionString", connectionProxy.getString());
assertSame("Expected connection.getUnmanaged() to be connectionImpl", connection, connectionProxy.getUnmanaged());