[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");
        }
Ejemplo n.º 2
0
 public void Go()
 {
     latch.Release();
     sync.Acquire();
     gone = true;
     sync.Release();
 }
Ejemplo n.º 3
0
 public void DoesNotLockTheServiceableWhenQueryingForStatus()
 {
     new Thread(new ThreadStart(serviceable.Dispose)).Start();
     sync1.Acquire();
     Assert.IsFalse(serviceSupport.StopRequested);
     sync2.Release();
 }
Ejemplo n.º 4
0
 public void Dispose()
 {
     lock (this)
     {
         _sync1.Release();
         _sync2.Acquire();
     }
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
        public void CanBeUsedWithTheUsingCSharpIdiomToAcquireAnIsync()
        {
            sync.Acquire();
            sync.Release();
            mocks.ReplayAll();

            using (new SyncHolder(sync))
            {
                throw new ThreadStateException();
            }
        }
Ejemplo 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();
     }
 }
Ejemplo 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;
     }
 }
Ejemplo n.º 10
0
        public void CanBeUsedWithTheUsingCSharpIdiomToAcquireAnIsync()
        {
            sync.Acquire();
            sync.Release();

            Assert.Throws <ThreadStateException>(() =>
            {
                using (new SyncHolder(sync))
                {
                    throw new ThreadStateException();
                }
            });
        }
Ejemplo n.º 11
0
            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");
                }
            }
Ejemplo 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();
 }
Ejemplo 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();
 }
Ejemplo 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();
 }
Ejemplo n.º 17
0
 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);
 }