コード例 #1
0
        private void assertNormalHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
        {
            MessageDispatcher testDispatcher = new MessageDispatcher(zone);
            int result = testDispatcher.dispatch(payload);

            Assert.IsTrue(handler.wasCalled(), "Handler was not called");
            Assert.AreEqual(1, result, "Result code should always be 1 because this version does not support SMB");
        }
コード例 #2
0
        public void testSIFRetryPublish()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler =
                new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowSIFRetryException);

            fZone.SetPublisher(handler, objType, null);
            fZone.Connect(ProvisioningFlags.Register);
            AssertRetryHandling(handler, createSIF_Request(objType), fZone);
        }
コード例 #3
0
        public void testSIFRetryEvent()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowADKRetryException);

            fZone.SetSubscriber(handler, objType, null);
            SIF_Event evnt = createSIF_Event(objType);

            fZone.Connect(ProvisioningFlags.Register);
            AssertRetryHandling(handler, evnt, fZone);
        }
コード例 #4
0
        public void testQueryResultsNoCache()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.Normal);

            fZone.SetQueryResults(handler, objType, null);
            fZone.Connect(ProvisioningFlags.Register);
            SIF_Response r = createSIF_Response(objType, false, null);

            assertNormalHandling(handler, r, fZone);
            assertRequestCacheCleared(r);
        }
コード例 #5
0
        public void testUndeliverableRetryEvent()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler =
                new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowSIFRetryException);

            fAgent.ErrorHandler = handler;
            SIF_Event evnt = createSIF_Event(objType);

            fZone.Connect(ProvisioningFlags.Register);
            AssertRetryHandling(handler, evnt, fZone);
        }
コード例 #6
0
        public void testADKRetryEvent()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowADKRetryException);

            // SifContext ctxt = SifContext.Create("SIF_SUBSCRIBE");
            // SubscriptionOptions options = new SubscriptionOptions(ctxt);

            fZone.SetSubscriber(handler, objType, null);
            SIF_Event evnt = createSIF_Event(objType);

            fZone.Connect(ProvisioningFlags.Register);
            AssertRetryHandling(handler, evnt, fZone);
        }
コード例 #7
0
        public void testNormalEvent()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.Normal);

            SubscriptionOptions options = new SubscriptionOptions();

            fZone.SetSubscriber(handler, objType, options);
            fZone.Connect(ProvisioningFlags.Register);
            //fZone.SetSubscriber(handler, objType, null);
            SIF_Event evnt = createSIF_Event(objType);

            assertNormalHandling(handler, evnt, fZone);
        }
コード例 #8
0
 private void AssertRetryHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
 {
     try
     {
         assertNormalHandling(handler, payload, zone);
     }
     catch (SifException ex)
     {
         Assert.IsTrue(handler.wasCalled(), "Handler was not called");
         Assert.AreEqual(SifErrorCategoryCode.Transport, ex.ErrorCategory,
                         "SIF Error category should be 10: " + ex.Message);
     }
     Assert.IsTrue(handler.wasCalled(), "Handler was not called");
     AssertThreadIsOK();
 }
コード例 #9
0
        public void testEventThrowsException()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowException);

            SubscriptionOptions options = new SubscriptionOptions();

            fZone.SetSubscriber(handler, objType, options);
            fZone.Connect(ProvisioningFlags.Register);
            //

            // fZone.SetSubscriber(handler, objType, null);
            SIF_Event evnt = createSIF_Event(objType);

            AssertExceptionHandling(handler, evnt, fZone, typeof(AdkException));
        }
コード例 #10
0
        public void testSIFRetryQueryResultsNoCache()
        {
            IElementDef         objType = StudentDTD.STUDENTCONTACT;
            ErrorMessageHandler handler =
                new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowSIFRetryException);

            fZone.SetQueryResults(handler, objType, null);
            fZone.Connect(ProvisioningFlags.Register);
            SIF_Response r = createSIF_Response(objType, false, null);

            AssertRetryHandling(handler, r, fZone);

            // Now, dispatch a second time. This time the dispatching should work correctly, including
            // custom state
            handler.Behavior = ErrorMessageHandler.HandlerBehavior.Normal;
            assertNormalHandling(handler, r, fZone);
            assertRequestCacheCleared(r);
        }
コード例 #11
0
        private void AssertExceptionHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone,
                                             Type expectedExceptionType)
        {
            Exception exc = null;

            try
            {
                assertNormalHandling(handler, payload, zone);
            }
            catch (Exception ex)
            {
                exc = ex;
                Assert.IsTrue(handler.wasCalled(), "Handler was not called");

                AdkMessagingException adkme = ex as AdkMessagingException;
                Assert.IsNotNull(adkme,
                                 "Expected an ADKMessagingException, but was " + ex.GetType().Name + ":" + ex.ToString());

                Exception source  = adkme;
                Exception innerEx = null;
                while (source.InnerException != null)
                {
                    innerEx = source.InnerException;
                    source  = innerEx;
                }
                Assert.IsNotNull(innerEx, "AdkMessaginException was thrown but inner exception was not set");

                if (innerEx.GetType() != expectedExceptionType)
                {
                    Assert.Fail("Exception thrown was not a " + expectedExceptionType.Name + ", but was " +
                                innerEx.GetType().Name + ":" + innerEx.ToString());
                }
            }

            Assert.IsNotNull(exc, "An exception was not thrown by the handler");
            AssertThreadIsOK();
        }