public void Data3() { TcpConnection c = new TcpConnection(null, "tcp://127.0.0.1:" + port, null); MyDataHandler dh = new MyDataHandler(c); Assert.IsFalse(c.IsStarted()); c.Start(); Assert.IsTrue(c.IsStarted()); c.WaitUp(TIMEOUT); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); AssertWhat(What.UP, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); t.Shutdown(SocketShutdown.Send); AssertWhat(What.DOWN, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); t.Close(); c.Close(); }
public void Constructor9() { TcpConnection c = new TcpConnection(null, "tcp://localhost:" + port, null); SessionData dh = new MyDataHandler(c); Assert.AreEqual(dh, c.GetSession()); }
public void Start5() { IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port); Socket s = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); s.Connect(ipe); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); TcpConnection c = new TcpConnection(s, "tcp:", null); MyDataHandler dh = new MyDataHandler(c); Assert.IsFalse(c.IsStarted()); c.Start(); Assert.IsTrue(c.IsStarted()); c.WaitUp(TIMEOUT); AssertWhat(What.UP, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); Assert.IsTrue(c.IsStarted()); c.Close(true); c.WaitDown(TIMEOUT); AssertWhat(What.DOWN, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); t.Close(); }
public virtual void Index() { using (_writer = new IndexWriter(_index, this.Analyzer, IndexWriter.MaxFieldLength.UNLIMITED)) { MyDataHandler handler = new MyDataHandler(_writer); _digester.Digest(handler); _writer.Optimize(); } }
public virtual void Index() { IndexWriterConfig config = new IndexWriterConfig(LuceneVersion.LUCENE_48, Analyzer); using (m_writer = new IndexWriter(m_index, config)) { MyDataHandler handler = new MyDataHandler(m_writer); m_digester.Digest(handler); m_writer.ForceMerge(1); } }
public void Constructor3() { IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port); Socket s = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); s.Connect(ipe); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); TcpConnection c = new TcpConnection(s, "tcp:", null); SessionData dh = new MyDataHandler(c); Assert.AreEqual(dh, c.GetSession()); s.Close(); t.Close(); }
public void Index() { bool create = !BoboIndexReader.IndexExists(_index); _writer=null; try { _writer=new IndexWriter(_index, this.Analyzer, create, IndexWriter.MaxFieldLength.UNLIMITED); MyDataHandler handler = new MyDataHandler(_writer); _digester.Digest(handler); _writer.Optimize(); } finally { if (_writer != null) { _writer.Close(); } } }
public void Data2() { TcpConnection c = new TcpConnection(null, "tcp://127.0.0.1:" + port, null); MyDataHandler dh = new MyDataHandler(c); Assert.IsFalse(c.IsStarted()); c.Start(); Assert.IsTrue(c.IsStarted()); c.WaitUp(TIMEOUT); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); AssertWhat(What.UP, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); byte[] buf = { 21, 22, 23 }; t.Send(buf); // t.getOutputStream().flush(); AssertWhat(What.DATA, dh.what); Assert.IsNull(dh.xsender); Assert.IsNotNull(dh.xbuf); Assert.AreEqual(3, dh.xbuf.Length); Assert.AreEqual(( byte )21, dh.xbuf[0]); Assert.AreEqual(( byte )22, dh.xbuf[1]); Assert.AreEqual(( byte )23, dh.xbuf[2]); Assert.IsTrue(c.IsStarted()); c.Stop(); Assert.IsFalse(c.IsStarted()); AssertWhat(What.DOWN, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); t.Close(); }
public void Data4() { TcpConnection c = new TcpConnection(null, "tcp://127.0.0.1:" + port, null); MyDataHandler dh = new MyDataHandler(c); c.Start(); c.WaitUp(TIMEOUT); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); AssertWhat(What.UP, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); byte[] sendBuf = new byte[] { 21, 22, 23 }; // c.Data( null, new FlexBuffer( sendBuf ) ); c.TransportData(null, new FlexBuffer(sendBuf)); // c.flush(); byte[] receiveBuf = new byte[3]; t.Receive(receiveBuf); Assert.AreEqual(sendBuf, receiveBuf); c.ShutdownOutput(); // Assert.AreEqual( -1, is.read() ); c.Close(); AssertWhat(What.DOWN, dh.what); Assert.IsNull(dh.xsender); Assert.IsNull(dh.xbuf); t.Close(); }
public void restart2() { TcpConnection c = new TcpConnection(null, "tcp://127.0.0.1:" + port + "?TcpTransport.reconnectDelay=200", null); MyDataHandler dh = new MyDataHandler(c); c.Start(); c.WaitUp(TIMEOUT); int n = 10; int i = 0; while (++i <= n) { // Log.report( "--- waitAccepted" ); Socket t = lh.accepted.WaitUntilNotEqAndSet(null, TIMEOUT, null); Console.WriteLine(String.Format("accepted i {0} t.local {1} t.remote {2}", i, t.LocalEndPoint, t.RemoteEndPoint)); AssertWhat(What.UP, dh.what); // Log.report( "up", "c.local", c.localAddress(), "c.remote", c.remoteAddress() ); Assert.AreEqual(t.LocalEndPoint, c.RemoteAddress()); Assert.AreEqual(t.RemoteEndPoint, c.LocalAddress()); byte[] data = new byte[] { Convert.ToByte(i) }; t.Send(data); AssertWhat(What.DATA, dh.what); Assert.IsNull(dh.xsender); Assert.IsNotNull(dh.xbuf); Assert.AreEqual(1, dh.xbuf.Length); Assert.AreEqual((byte)i, dh.xbuf[0]); // Log.report( "c.shutingDownOutput" ); c.ShutdownOutput(); // Log.report( "c.shutdownOutput" ); // Log.report( "t.reading" ); Assert.AreEqual(0, t.Receive(data)); // Log.report( "t.eof" ); t.Shutdown(SocketShutdown.Send); t.Close(); t = null; AssertWhat(What.DOWN, dh.what); // Log.report( "down" ); } Thread t1 = new Thread(new ThreadStart(RunMonitorSocketThread)); t1.Start(); Thread t2 = new Thread(new ThreadStart(delegate() { try { Object t; Monitor <What> mon = dh.what; while ((t = mon.WaitUntilNotEqAndSet(default(What), TIMEOUT, default(What))) != null) { } // Log.report( "harvested", "mon", mon, "t", t ); } catch (Exception) { // ignore } })); t2.Start(); Console.WriteLine("stopping"); c.Stop(); c.WaitDown(TIMEOUT); Console.WriteLine("stopped"); t1.Join(); t2.Join(); }
public void SetUp() { dh = new MyDataHandler(); p = new Packetizer(dh, "tcp:", null); mph = new MyPacketHandler(p); }