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"); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); }
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)); }
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); }
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(); }