public virtual void Remove() { HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); bool actual = testSubject.Remove("foo"); Assert.Fail("TODO"); }
/// <summary> /// Converts the given <c>HsqlConnectionStringBuilder</c> /// to an instance descriptor. /// </summary> /// <param name="builder">The builder.</param> /// <returns> /// An instance descriptor representing the given /// <c>HsqlConnectionStringBuilder</c>. /// </returns> private InstanceDescriptor ConvertToInstanceDescriptor( HsqlConnectionStringBuilder builder) { return(new InstanceDescriptor( typeof(HsqlConnectionStringBuilder).GetConstructor(types), new object[] { builder.ConnectionString })); }
public virtual void ShouldSerialize() { HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); bool actual = testSubject.ShouldSerialize("foo"); Assert.Fail("TODO"); }
/// <summary> /// Contructs a new <c>HsqlConnection</c> /// with the default connection string. /// </summary> public HsqlConnection() : base() { m_id = idseq++; m_settings = new HsqlConnectionStringBuilder(); GC.SuppressFinalize(this); }
public virtual void Clear() { HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); testSubject.Clear(); Assert.Fail("TODO"); }
/// <summary> /// Returns the collection of currently valid initial schema names, /// given the specified context. /// </summary> /// <param name="context"> /// An <see cref="ITypeDescriptorContext"></see> whose <c>Instance</c> /// property supplies the <c>HsqlConnectionStringBuilder</c> use to /// connect to a data source to retrieve the currently valid initial /// schema names. /// </param> /// <returns> /// A <see cref="TypeConverter.StandardValuesCollection"/> that holds /// collection of currently valid initial schema names. /// </returns> public override TypeConverter.StandardValuesCollection GetStandardValues( ITypeDescriptorContext context) { if (!IsStandardValuesSupported(context)) { return(null); } List <string> values = new List <string>(); try { HsqlConnectionStringBuilder builder = (HsqlConnectionStringBuilder)context.Instance; // TODO: this is sub-optimal, but is currently the best (only?) // solution to the problem of how to avoid creating and/or // leaving open embedded database instances. if (IsEmbeddedProtocol(builder)) { builder = new HsqlConnectionStringBuilder( builder.ConnectionString); builder.AutoShutdown = true; builder.IfExists = true; } using (HsqlConnection connection = new HsqlConnection()) { connection.ConnectionString = builder.ConnectionString; using (HsqlCommand command = new HsqlCommand( connection, SchemaQuery)) { connection.Open(); using (HsqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { values.Add(reader.GetString(0)); } } } } } catch (Exception exception) { #if DEBUG Debug.WriteLine(exception); #endif } return(new TypeConverter.StandardValuesCollection(values)); }
public virtual void ContainsKey() { // Create Constructor Parameters HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); testSubject.ContainsKey("foo"); Assert.Fail("TODO"); }
public virtual void EquivalentTo() { HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); bool expected = true; bool actual = testSubject.EquivalentTo(testSubject); Assert.AreEqual(expected, actual); Assert.Fail("TODO"); }
static HsqlConnection NewConnection() { HsqlConnectionStringBuilder builder = new HsqlConnectionStringBuilder(); builder.Protocol = ConnectionProtocol.Mem; builder.Path = "test"; builder.UserId = "SA"; builder.Password = ""; HsqlConnection connection = new HsqlConnection(builder.ToString()); connection.Open(); return(connection); }
/// <summary> /// Gets an <c>HsqlSession</c> corresponding to the given connection /// string builder. /// </summary> /// <param name="builder">The builder.</param> /// <returns> /// An HsqlSession corresponding to the given connection string builder. /// </returns> internal static HsqlSession GetSession(HsqlConnectionStringBuilder builder) { string url = builder.JdbcUrl; org.hsqldb.persist.HsqlProperties properties = HsqlDriver.ParseURL(url); switch (builder.Protocol) { case ConnectionProtocol.File: case ConnectionProtocol.Mem: { return(HsqlSession.Factory.NewEmbeddedSession(properties)); } case ConnectionProtocol.Res: { return(HsqlSession.Factory.NewEmbeddedResSession(properties)); } case ConnectionProtocol.Hsql: { return(HsqlSession.Factory.NewHsqlClientSession(properties, /*tls*/ false)); } case ConnectionProtocol.Hsqls: { return(HsqlSession.Factory.NewHsqlClientSession(properties, /*tls*/ true)); } case ConnectionProtocol.Http: { return(HsqlSession.Factory.NewHttpClientSession(properties, /*tls*/ false)); } case ConnectionProtocol.Https: { return(HsqlSession.Factory.NewHttpClientSession(properties, /*tls*/ true)); } default: { throw new HsqlDataSourceException("Unknown Connection URL: " + url, org.hsqldb.Trace.GENERAL_ERROR, "S1000"); } } }
public virtual void TryGetValue() { HsqlConnectionStringBuilder testSubject = new HsqlConnectionStringBuilder(); object value; bool success = false; try { success = testSubject.TryGetValue("foo", out value); } catch (Exception) { } Assert.Fail("TODO"); }
/// <summary> /// Determines whether the given builder specifies an /// embedded connection protocol /// </summary> /// <param name="builder">The builder.</param> /// <returns> /// <c>true</c> if the builder specified an embedded connection protocol; /// otherwise, <c>false</c>. /// </returns> public static bool IsEmbeddedProtocol(HsqlConnectionStringBuilder builder) { switch (builder.Protocol) { case ConnectionProtocol.File: case ConnectionProtocol.Mem: case ConnectionProtocol.Res: { return(true); } default: { return(false); } } }
/// <summary> /// Gets an <c>HsqlSession</c> corresponding to the given connection /// string builder. /// </summary> /// <param name="builder">The builder.</param> /// <returns> /// An HsqlSession corresponding to the given connection string builder. /// </returns> internal static HsqlSession GetSession(HsqlConnectionStringBuilder builder) { string url = builder.JdbcUrl; org.hsqldb.persist.HsqlProperties properties = HsqlDriver.ParseURL(url); switch (builder.Protocol) { case ConnectionProtocol.File: case ConnectionProtocol.Mem: { return HsqlSession.Factory.NewEmbeddedSession(properties); } case ConnectionProtocol.Res: { return HsqlSession.Factory.NewEmbeddedResSession(properties); } case ConnectionProtocol.Hsql: { return HsqlSession.Factory.NewHsqlClientSession(properties, /*tls*/false); } case ConnectionProtocol.Hsqls: { return HsqlSession.Factory.NewHsqlClientSession(properties, /*tls*/true); } case ConnectionProtocol.Http: { return HsqlSession.Factory.NewHttpClientSession(properties, /*tls*/false); } case ConnectionProtocol.Https: { return HsqlSession.Factory.NewHttpClientSession(properties, /*tls*/true); } default: { throw new HsqlDataSourceException("Unknown Connection URL: " + url, org.hsqldb.Trace.GENERAL_ERROR, "S1000"); } } }
/// <summary> /// Converts the given value object to the specified type, using /// the specified context and culture information. /// </summary> /// <param name="context"> /// An <see cref="ITypeDescriptorContext"/> that provides a format context. /// </param> /// <param name="culture"> /// A <see cref="CultureInfo"/>. If null is passed, the current culture is assumed. /// </param> /// <param name="value"> /// The <see cref="Object"></see> to convert. /// </param> /// <param name="destinationType"> /// The <see cref="Type"></see> to which to convert the value parameter. /// </param> /// <returns> /// An object that represents the converted value. /// </returns> /// <exception cref="NotSupportedException"> /// When the conversion cannot be performed. /// </exception> /// <exception cref="ArgumentNullException"> /// When the <c>destinationType</c> parameter is <c>null</c>. /// </exception> public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (typeof(InstanceDescriptor) == destinationType) { HsqlConnectionStringBuilder builder = value as HsqlConnectionStringBuilder; if (builder != null) { return(ConvertToInstanceDescriptor(builder)); } } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Closes this connection. /// </summary> internal void CloseInternal() { ConnectionState state = m_connectionState; if (state == ConnectionState.Closed) { return; } HsqlSession session = m_session; if (m_session == null) { // Sanity-Check: Should never happen. throw new InvalidOperationException( "HsqlSession is null"); // NOI18N } // Handle dispose/close while enlisted in a system transaction. HsqlTransaction transaction = m_transaction; HsqlEnlistment enlistment = m_enlistment; bool enlisted = (enlistment != null); bool preserveEnlistment = (enlisted && !enlistment.m_disposeConnection); if (preserveEnlistment) { #if DEBUG // Without this, it is difficult to debug // because the m_enlistment's connection // ceases to be this one and this connection // loses its reference to the enlistment // (m_enlistment is set null below). m_enlistment_dbg = m_enlistment; #endif // ...then until it ceases to participate in a // System.Transactions.Transaction, the enlistment // needs a valid local transaction to commit or // rollback HsqlConnection connection = new HsqlConnection(this); connection.m_connectionState = ConnectionState.Open; connection.m_session = session; connection.m_enlistment = enlistment; connection.m_transaction = transaction; enlistment.m_dbConnection = connection; enlistment.m_disposeConnection = true; if (transaction != null) { transaction.m_connection = connection; } } SetStateInternal(ConnectionState.Closed); m_session = null; m_transaction = null; m_enlistment = null; m_dbMetaData = null; m_settings = null; if (!enlisted) { // No need to roll back here. This will happen automatically // a moment later on the back end in response to the // session.Close() call below. if (transaction != null) { transaction.DisposeInternal(/*rollback*/ false); } // release the back-end session and any associated resources, // such as network sockets, etc. session.Close(); } }
/// <summary> /// Returns the collection of standard values for /// the <see cref="HsqlConnectionStringBuilder.DataSource"/> /// property. /// </summary> /// <param name="context">Which may hold</param> /// <returns> /// The standard set of valid values. /// </returns> public override TypeConverter.StandardValuesCollection GetStandardValues( ITypeDescriptorContext context) { DataTable dataSources = DSEC.GetDataSources(); DataRowCollection rows = dataSources.Rows; int rowCount = rows.Count; string[] array; if (context != null && context.Instance != null) { // might be a connection string builder or wrapper for one. try { HsqlConnectionStringBuilder csb = new HsqlConnectionStringBuilder( Convert.ToString(context.Instance)); array = new string[rowCount + 1]; array[rowCount] = csb.DataSource; } catch (Exception) { array = new string[rowCount]; } } else { array = new string[rowCount]; } for (int i = 0; i < rowCount; i++) { DataRow row = rows[i]; string prefix = row[DSEC.ServerNameColumnOrdinal] as string; string suffix = row[DSEC.InstanceNameColumnOrdinal] as string; string version = row[DSEC.VersionColumnOrdinal] as string; if (string.IsNullOrEmpty(version) || version.StartsWith("1.8.0", StringComparison.Ordinal)) { array[i] = (string.IsNullOrEmpty(suffix)) ? prefix.Replace('\\', '/') : new StringBuilder(prefix) .Replace('\\', '/') .Append('/') .Append(suffix.Replace('\\', '/').TrimStart('/')) .ToString(); } else { array[i] = string.Empty; } } org.hsqldb.lib.HashSet set = new org.hsqldb.lib.HashSet(); set.addAll(array); set.remove(string.Empty); if (array.Length != set.size()) { array = new string[set.size()]; } set.toArray(array); Array.Sort <string>(array); return(new TypeConverter.StandardValuesCollection(array)); }
/// <summary> /// Constructs a new <c>HsqlConnectionSettings</c> instance /// with the given builder. /// </summary> /// <param name="builder">The builder.</param> internal HsqlConnectionSettings(HsqlConnectionStringBuilder builder) { m_builder = builder; Reset (); }
static HsqlConnection NewConnection() { HsqlConnectionStringBuilder builder = new HsqlConnectionStringBuilder(); builder.Protocol = ConnectionProtocol.Mem; builder.Path = "test"; builder.UserId = "SA"; builder.Password = ""; HsqlConnection connection = new HsqlConnection(builder.ToString()); connection.Open(); return connection; }