Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setDelegateShouldBeAbleToOverridePreviousHarden()
        public virtual void SetDelegateShouldBeAbleToOverridePreviousHarden()
        {
            /* This test case stems from a race condition where a thread switching role to slave and
             * HaKernelPanicHandler thread were competing to harden the master delegate handler.
             * While all components were switching to their slave versions a kernel panic event came
             * in and made its switch, ending with hardening the master delegate handler. All components
             * would take that as a sign about the master delegate being ready to use. When the slave switching
             * was done, that thread would set the master delegate to the actual one, but all components would
             * have already gotten a concrete reference to the master such that the latter setDelegate call would
             * not affect them. */

            // GIVEN
            DelegateInvocationHandler <Value> handler = NewDelegateInvocationHandler();

            handler.Delegate = Value(10);
            Value cementedValue = handler.Cement();

            handler.Harden();

            // WHEN setting the delegate (implies hardening it)
            handler.Delegate = Value(20);

            // THEN
            assertEquals(20, cementedValue.Get());
        }