public void close() { using (JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII)) { testSubject.close(); } }
public void availableWithIOException() { using (JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(new BaseStreamAdapter())) { int available = testSubject.available(); } }
public void closeAfterDispose() { JavaInputStreamAdapter testSubject = NewClosedTestSubject("asdf", Encoding.ASCII); testSubject.close(); testSubject.close(); }
public void readByte() { using (JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII)) { int b = testSubject.read(); Assert.AreEqual((int)'a', b); b = testSubject.read(); Assert.AreEqual((int)'s', b); b = testSubject.read(); Assert.AreEqual((int)'d', b); b = testSubject.read(); Assert.AreEqual((int)'f', b); b = testSubject.read(); Assert.That(b == -1); b = testSubject.read(); Assert.That(b == -1); } }
public void readIntoBufferWithOffsetAfterDispose() { JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII); testSubject.Dispose(); byte[] buff = new byte[2]; try { testSubject.read(buff, 1, 2); } catch (Exception ex) { java.io.IOException ioe = ex as java.io.IOException; if (ioe != null) { System.Exception cause = ioe.getCause(); Assert.IsNotNull(cause); Assert.IsInstanceOfType(typeof(System.ObjectDisposedException), cause); } throw; } }
public void availableWithIOException() { using (JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(new BaseStreamAdapter())) { int available = testSubject.available(); } }
public void resetAfterDispose() { JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII); testSubject.Dispose(); testSubject.reset(); }
public void available() { using (JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII)) { int available = testSubject.available(); Assert.GreaterOrEqual(available, 0); } }
public void availableAfterDispose() { JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII); testSubject.Dispose(); int available = testSubject.available(); Assert.AreEqual(0, available); }
/// <summary> /// Opens the connection. /// </summary> /// <param name="host">The host.</param> /// <param name="port">The port.</param> /// <param name="tls"> /// if set to <c>true</c>, use transport layer security. /// </param> /// <exception cref="HsqlException"> /// </exception> protected virtual void OpenConnection( string host, int port, bool tls) { if (m_tcpClient != null) { throw new System.InvalidOperationException( "The connection is already open."); } HsqlDiagnostics.Debug("..."); try { HsqlDiagnostics.Debug("Entered with arguments ({0},{1},{2})", host, port, tls); m_tcpClient = new TcpClient(host, port); HsqlDiagnostics.Debug("Created TcpClient({0},{1})", host, port); Stream stream = m_tcpClient.GetStream(); HsqlDiagnostics.Debug("Got client stream from TcpClient"); if (m_tls) { HsqlDiagnostics.Debug("Initializing Client TLS..."); SslStream sslStream = new SslStream( stream, false, ValidateRemoteCertificate, null); HsqlDiagnostics.Debug("Invoking sslStream.AuthenticateAsClient({0})", host); sslStream.AuthenticateAsClient(host); stream = sslStream; } JavaInputStreamAdapter input = new JavaInputStreamAdapter(stream); JavaOutputStreamAdapter output = new JavaOutputStreamAdapter(stream); m_dataInput = new DataInputStream(new BufferedInputStream(input)); m_dataOutput = new BufferedOutputStream(output); } catch (System.Exception e) { throw Trace.error(Trace.SOCKET_ERROR, e); } }
public void readIntoBufferWithOffset() { byte[] buffer = new byte[4]; using (JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII)) { int rval = testSubject.read(buffer, 1, 2); Assert.AreEqual(2, rval); Assert.AreEqual((int)'a', buffer[1]); Assert.AreEqual((int)'s', buffer[2]); rval = testSubject.read(buffer, 0, 2); Assert.AreEqual(2, rval); rval = testSubject.read(buffer); Assert.AreEqual(-1, rval); } }
public void readIntoBuffer() { byte[] buffer = new byte[4]; using (JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII)) { int rval = testSubject.read(buffer); Assert.That(rval == 4); Assert.AreEqual((int)'a', buffer[0]); Assert.AreEqual((int)'s', buffer[1]); Assert.AreEqual((int)'d', buffer[2]); Assert.AreEqual((int)'f', buffer[3]); rval = testSubject.read(buffer); Assert.That(rval == -1); rval = testSubject.read(buffer); Assert.That(rval == -1); } }
public void skipAfterDispose() { JavaInputStreamAdapter testSubject = NewTestSubject("asdf", Encoding.ASCII); testSubject.Dispose(); try { testSubject.skip(1); } catch (Exception ex) { java.io.IOException ioe = ex as java.io.IOException; if (ioe != null) { System.Exception cause = ioe.getCause(); Assert.IsNotNull(cause); Assert.IsInstanceOfType(typeof(System.ObjectDisposedException), cause); } throw; } }
public void ctorWithNullStream() { using (JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(null)) { } }
public void closeWithIOException() { JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(new BaseNonClosableStream()); testSubject.close(); }
public void closeWithIOException() { JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(new BaseNonClosableStream()); testSubject.close(); }
public void ctorWithNullStream() { using (JavaInputStreamAdapter testSubject = new JavaInputStreamAdapter(null)) { } }