Exemple #1
0
        /// <summary>Test that a java interruption can stop the watcher thread</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestInterruption()
        {
            DomainSocketWatcher watcher = NewDomainSocketWatcher(10);

            watcher.watcherThread.Interrupt();
            Uninterruptibles.JoinUninterruptibly(watcher.watcherThread);
            watcher.Close();
        }
Exemple #2
0
        /// <summary>Test that domain sockets are closed when the watcher is closed.</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestCloseSocketOnWatcherClose()
        {
            DomainSocketWatcher watcher = NewDomainSocketWatcher(10000000);

            DomainSocket[] pair = DomainSocket.Socketpair();
            watcher.Add(pair[1], new _Handler_103());
            watcher.Close();
            Uninterruptibles.JoinUninterruptibly(watcher.watcherThread);
            NUnit.Framework.Assert.IsFalse(pair[1].IsOpen());
        }
Exemple #3
0
        /// <summary>Test that we can get notifications out a DomainSocketWatcher.</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestDeliverNotifications()
        {
            DomainSocketWatcher watcher = NewDomainSocketWatcher(10000000);

            DomainSocket[] pair  = DomainSocket.Socketpair();
            CountDownLatch latch = new CountDownLatch(1);

            watcher.Add(pair[1], new _Handler_73(latch));
            pair[0].Close();
            latch.Await();
            watcher.Close();
        }
Exemple #4
0
        /// <exception cref="System.Exception"/>
        public virtual void TestStress()
        {
            int                    SocketNum   = 250;
            ReentrantLock          Lock        = new ReentrantLock();
            DomainSocketWatcher    watcher     = NewDomainSocketWatcher(10000000);
            AList <DomainSocket[]> pairs       = new AList <DomainSocket[]>();
            AtomicInteger          handled     = new AtomicInteger(0);
            Thread                 adderThread = new Thread(new _Runnable_122(SocketNum, watcher
                                                                              , Lock, pairs, handled));
            Thread removerThread = new Thread(new _Runnable_149(handled, SocketNum
                                                                , Lock, pairs, watcher));

            adderThread.Start();
            removerThread.Start();
            Uninterruptibles.JoinUninterruptibly(adderThread);
            Uninterruptibles.JoinUninterruptibly(removerThread);
            watcher.Close();
        }
Exemple #5
0
        /// <summary>Test that we can create a DomainSocketWatcher and then shut it down.</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestCreateShutdown()
        {
            DomainSocketWatcher watcher = NewDomainSocketWatcher(10000000);

            watcher.Close();
        }