[Test] // Bug fix
        public void NotInfiniteLoopRemovingAnApplicationWithAManagerThatThrowsExceptionWhenStopped()
        {
            factoryMock.ExpectAndReturn("CreateApplicationWatcherMonitor", watcher);
            watcherMock.Expect("StartWatching");
            watcherMock.ExpectAndThrow("StopWatching", new Exception());
            AddApplication();
            ForwardingDeployEventDispatcher dispatcher = new ForwardingDeployEventDispatcher();

            dispatcher.DeployEvent += new DeployEventHandler(dispatcher_DeployEvent);
            location = new FileSystemDeployLocation(dispatcher, factory, deployPath, true);
            Directory.Delete(sampleDir, true);
            forwardDispatcherSync.Acquire();
            Assert.IsTrue(deployEventDispatched, "removal not dispatched in case of error on application watcher");
        }
 public void Go()
 {
     latch.Release();
     sync.Acquire();
     gone = true;
     sync.Release();
 }
 public void DoesNotLockTheServiceableWhenQueryingForStatus()
 {
     new Thread(new ThreadStart(serviceable.Dispose)).Start();
     sync1.Acquire();
     Assert.IsFalse(serviceSupport.StopRequested);
     sync2.Release();
 }
 public void Dispose()
 {
     lock (this)
     {
         _sync1.Release();
         _sync2.Acquire();
     }
 }
 public void SetUp()
 {
     MockApplication.ResetCount();
     started = new Latch();
     new Thread(new ThreadStart(Go)).Start();
     started.Acquire();
     boxTester     = new MyListBoxTester("applicationList", form);
     appStatus     = new LabelTester("applicationStatus", form);
     serviceStatus = new LabelTester("serviceStatus", form);
 }
Esempio n. 6
0
        public void CanBeUsedWithTheUsingCSharpIdiomToAcquireAnIsync()
        {
            sync.Acquire();
            sync.Release();
            mocks.ReplayAll();

            using (new SyncHolder(sync))
            {
                throw new ThreadStateException();
            }
        }
Esempio n. 7
0
 public void Work()
 {
     // very slow worker initialization ...
     // ... attach to messaging system
     // ... connect to database
     startPermit.Acquire();
     // ... use resources initialized in Mush
     // ... do real work
     worked = true;
     // ... we are finished
     workedSync.Release();
 }
 /// <summary> Execute the given command directly in the current thread,
 /// within the supplied lock.
 /// </summary>
 public virtual void  Execute(IRunnable command)
 {
     mutex_.Acquire();
     try
     {
         command.Run();
     }
     finally
     {
         mutex_.Release();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Invokes <c>outer_.Acquire</c> followed by <c>inner_.Acquire</c>,
 /// but backing out of outer (via <c>outer_.Release</c>) upon an
 /// exception in <c>inner_.Acquire</c>.
 /// </summary>
 public virtual void  Acquire()
 {
     outer_.Acquire();
     try
     {
         inner_.Acquire();
     }
     catch (System.Threading.ThreadInterruptedException ex)
     {
         outer_.Release();
         throw ex;
     }
 }
Esempio n. 10
0
        public void CanBeUsedWithTheUsingCSharpIdiomToAcquireAnIsync()
        {
            sync.Acquire();
            sync.Release();

            Assert.Throws <ThreadStateException>(() =>
            {
                using (new SyncHolder(sync))
                {
                    throw new ThreadStateException();
                }
            });
        }
            public void Run()
            {
                SimplePool pool = new SimplePool(new Pooled(creationTime, executionTime), poolSize);

                for (int i = 0; i < clientSize; i++)
                {
                    Client client = new Client(i, run, pool, repeat);
                    Thread thread = new Thread(new ThreadStart(client.Run));
                    thread.Start();
                    clients.Add(client);
                }
                run.Acquire();

                foreach (Client client in clients)
                {
                    Assert.IsTrue(client.runned, "\nclient " + clients.IndexOf(client) + " not runned");
                }
            }
Esempio n. 12
0
 public void Execute(IRunnable runnable)
 {
     if (runnable == serviceSupport.StartedCommand)
     {
         ServiceSupportTest.Log("waiting to start ...");
         starting.Acquire();
         ServiceSupportTest.Log("starting ...");
         runnable.Run();
         wasStarted = true;
         ServiceSupportTest.Log("releasing started sync ...");
         started.Release();
         ServiceSupportTest.Log("started ...");
     }
     else
     {
         ServiceSupportTest.Log("unexpected runnable: " + runnable);
         runnable.Run();
     }
 }
 public void RecreatesTheWatcherWhenItsDefinitonChanges()
 {
     Assert.IsTrue(manager.Watcher is NullApplicationWatcher);
     File.Copy("Data/Xml/watcher-0.xml", application.WatcherXmlFullPath, true);
     reconfigured.Acquire();
     Assert.IsTrue(manager.Watcher is NullApplicationWatcher);
     TestUtils.SafeCopyFile("Data/Xml/watcher-1.xml", application.WatcherXmlFullPath, true);
     reconfigured.Acquire();
     Assert.IsTrue(manager.Watcher is FileSystemApplicationWatcher);
     TestUtils.SafeDeleteFile(application.WatcherXmlFullPath);
     reconfigured.Acquire();
     Assert.IsTrue(manager.Watcher is NullApplicationWatcher);
     Assert.AreEqual(3, nReconfigured);
 }
 public void Wait()
 {
     wait.Acquire();
 }
Esempio n. 15
0
 /// <summary>
 /// initializes and acquire access to the <see cref="ISync"/>
 /// </summary>
 /// <param name="sync"></param>
 private void Init(ISync sync)
 {
     this._sync = sync;
     _sync.Acquire();
 }
Esempio n. 16
0
 /// <summary>
 /// initializes and acquire access to the <see cref="ISync"/>
 /// </summary>
 /// <param name="sync"></param>
 private void Init (ISync sync)
 {
     this._sync = sync;
     _sync.Acquire();
 }
 public void SetUp ()
 {
     MockApplication.ResetCount();
     started = new Latch();
     new Thread(new ThreadStart(Go)).Start();
     started.Acquire();
     boxTester = new MyListBoxTester("applicationList", form);
     appStatus = new LabelTester("applicationStatus", form);
     serviceStatus = new LabelTester("serviceStatus", form);
 }