public void CreateDefaultContext() { var result = Mock.Of <IOperationContext>(); var session = this.CreateSessionMock(result); var context = OperationContextFactory.CreateDefaultContext(session.Object); session.VerifyThatAllDefaultValuesAreSet(); session.VerifyThatFilterContainsPath(); Assert.That(context, Is.EqualTo(result)); }
/// <summary> /// Connect this instance. /// </summary> /// <returns><c>true</c>, if connection was successful, otherwise <c>false</c></returns> protected bool Connect() { lock (this.repoInfoLock) { try { if (this.isForbiddenUntil > DateTime.UtcNow) { return(false); } // Create session. var session = this.SessionFactory.CreateSession(this.RepoInfo, authenticationProvider: this.AuthProvider); Logger.Debug(session.RepositoryInfo.ToLogString()); this.cancelToken.ThrowIfCancellationRequested(); session.DefaultContext = OperationContextFactory.CreateDefaultContext(session); this.cancelToken.ThrowIfCancellationRequested(); this.Queue.AddEvent(new SuccessfulLoginEvent(this.RepoInfo.Address, session)); this.lastSuccessfulLogin = DateTime.Now; return(true); } catch (DotCMIS.Exceptions.CmisPermissionDeniedException e) { Logger.Info(string.Format("Failed to connect to server {0}", this.RepoInfo.Address.ToString()), e); var permissionDeniedEvent = new PermissionDeniedEvent(e); this.Queue.AddEvent(permissionDeniedEvent); this.isForbiddenUntil = permissionDeniedEvent.IsBlockedUntil ?? DateTime.MaxValue; } catch (CmisRuntimeException e) { if (e.Message == "Proxy Authentication Required") { this.Queue.AddEvent(new ProxyAuthRequiredEvent(e)); Logger.Warn("Proxy Settings Problem", e); this.isForbiddenUntil = DateTime.MaxValue; } else { Logger.Error("Connection to repository failed: ", e); this.Queue.AddEvent(new ExceptionEvent(e)); } } catch (DotCMIS.Exceptions.CmisInvalidArgumentException e) { Logger.Warn(string.Format("Failed to connect to server {0}", this.RepoInfo.Address.ToString()), e); this.Queue.AddEvent(new ConfigurationNeededEvent(e)); this.isForbiddenUntil = DateTime.MaxValue; } catch (CmisObjectNotFoundException e) { Logger.Error("Failed to find cmis object: ", e); } catch (CmisConnectionException e) { Logger.Info(string.Format("Failed to create connection to \"{0}\". Will try again in {1} ms", this.RepoInfo.Address.ToString(), this.Interval)); Logger.Debug(string.Empty, e); } catch (CmisBaseException e) { Logger.Error("Failed to create session to remote " + this.RepoInfo.Address.ToString() + ": ", e); } return(false); } }
/// <summary> /// Connect this instance. /// </summary> protected bool Connect() { lock (this.repoInfoLock) { try { if (this.isForbidden) { return(false); } // Create session. var session = this.SessionFactory.CreateSession(this.GetCmisParameter(this.RepoInfo), null, this.AuthProvider, null); session.DefaultContext = OperationContextFactory.CreateDefaultContext(session); this.Queue.AddEvent(new SuccessfulLoginEvent(this.RepoInfo.Address, session)); return(true); } catch (DotCMIS.Exceptions.CmisPermissionDeniedException e) { Logger.Info(string.Format("Failed to connect to server {0}", this.RepoInfo.Address.ToString()), e); this.Queue.AddEvent(new PermissionDeniedEvent(e)); this.isForbidden = true; } catch (CmisRuntimeException e) { if (e.Message == "Proxy Authentication Required") { this.Queue.AddEvent(new ProxyAuthRequiredEvent(e)); Logger.Warn("Proxy Settings Problem", e); this.isForbidden = true; } else { Logger.Error("Connection to repository failed: ", e); this.Queue.AddEvent(new ExceptionEvent(e)); } } catch (CmisObjectNotFoundException e) { Logger.Error("Failed to find cmis object: ", e); } catch (CmisBaseException e) { Logger.Error("Failed to create session to remote " + this.RepoInfo.Address.ToString() + ": ", e); } return(false); } }