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());
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToUseCementedValueOnceHardened()
        public virtual void ShouldBeAbleToUseCementedValueOnceHardened()
        {
            // GIVEN
            DelegateInvocationHandler <Value> handler = NewDelegateInvocationHandler();
            Value cementedValue = handler.Cement();

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

            // THEN
            assertEquals(10, cementedValue.Get());
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwsWhenDelegateIsNotSet()
        public virtual void ThrowsWhenDelegateIsNotSet()
        {
            DelegateInvocationHandler <Value> handler = NewDelegateInvocationHandler();

            try
            {
                handler.Invoke(new object(), typeof(Value).getDeclaredMethod("get"), new object[0]);
                fail("Exception expected");
            }
            catch (Exception t)
            {
                assertThat(t, instanceOf(typeof(TransactionFailureException)));
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBeAbleToUseValueBeforeHardened()
        public virtual void ShouldNotBeAbleToUseValueBeforeHardened()
        {
            // GIVEN
            DelegateInvocationHandler <Value> handler = NewDelegateInvocationHandler();
            Value value = handler.Cement();

            // WHEN
            try
            {
                value.Get();
                fail("Should fail");
            }
            catch (Exception e)
            {
                // THEN
                assertThat(e, instanceOf(typeof(TransientDatabaseFailureException)));
            }
        }
Example #5
0
 public LazySingleReferenceAnonymousInnerClass(DelegateInvocationHandler <T> outerInstance, Type interfaceClass)
 {
     this.outerInstance   = outerInstance;
     this._interfaceClass = interfaceClass;
 }