예제 #1
0
        public void testRegisterSIF20()
        {
            Adk.SifVersion = (SifVersion.SIF20);
            String          iconURL = "http://acme.foo.bar/ico";
            AgentProperties props   = Agent.Properties;

            props.AgentIconUrl = iconURL;

            Agent.Name         = "acmeAgent";
            props.AgentVendor  = "acmeVendor";
            props.AgentVersion = "2.6.5.8";

            props.ApplicationName    = "acmeApp";
            props.ApplicationVendor  = "acme<>AppVendor";
            props.ApplicationVersion = "10.2";

            Zone.Connect(ProvisioningFlags.Register);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            SIF_Register sr = (SIF_Register)handler.readMsg();

            Assert.AreEqual(Agent.Id, sr.SourceId, "SourceID");
            Assert.AreEqual("acmeAgent", sr.SIF_Name, "Name");
            Assert.AreEqual("acmeVendor", sr.SIF_NodeVendor, "Agent Vendor");
            Assert.AreEqual("2.6.5.8", sr.SIF_NodeVersion, "Agent Version");
            SIF_Application appInfo = sr.SIF_Application;

            Assert.IsNotNull(appInfo);
            Assert.AreEqual("acmeApp", appInfo.SIF_Product, "App Name");
            Assert.AreEqual("acme<>AppVendor", appInfo.SIF_Vendor, "App Vendor");
            Assert.AreEqual("10.2", appInfo.SIF_Version, "App Version");
            Assert.AreEqual(iconURL, sr.SIF_Icon, "Icon");
        }
예제 #2
0
        public void testAsynchronousGetZoneStatus()
        {
            Adk.SifVersion = (SifVersion.LATEST);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            Zone.Properties.UseZoneStatusSystemControl = false;
            Zone.Properties.ZisVersion = SifVersion.SIF15r1.ToString();
            handler.clear();

            try
            {
                // We expect a SIF XML Error exception in this case because
                // our handler doesn't return a valid response back to a pull message
                Zone.GetZoneStatus();
            }
            catch (SifException sifEx)
            {
                Assert.AreEqual(SifErrorCategoryCode.Xml, sifEx.ErrorCategory);
            }

            SIF_Request sr = (SIF_Request)handler.readMsg();

            Assert.AreEqual(SifVersion.SIF15r1, sr.SifVersion, "SifVersion");
            Assert.AreEqual(SifVersion.SIF15r1.Xmlns, sr.GetXmlns(), "SifVersion->Xmlns");
        }
예제 #3
0
        public void testSIFPingDifferentVersions()
        {
            Adk.SifVersion = (SifVersion.LATEST);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            handler.clear();
            Zone.SifPing();
            SIF_SystemControl ssc = (SIF_SystemControl)handler.readMsg();

            Assert.AreEqual(SifVersion.LATEST, ssc.SifVersion, "SifVersion");
            Assert.AreEqual(SifVersion.LATEST.Xmlns, ssc.GetXmlns(), "SifVersion->Xmlns");

            foreach (SifVersion version in Adk.SupportedSIFVersions)
            {
                // This may seem strange, but the ADK sometimes has a SIF version in the list of
                // supported versions that is not fully supported yet (e.g. preparing the ADK for
                // the next version. Because of that, only test SIF_Ping with versions if they
                // are equal to or less than SifVersion.LATEST
                if (version.CompareTo(SifVersion.LATEST) <= 0)
                {
                    testSIFPingWithZISVersion(handler, version);
                }
            }
        }
        public void testSifResponseSenderMultiplePackets()
        {
            MessageDispatcher testDispatcher = new MessageDispatcher(Zone);

            Zone.Properties.OneObjectPerResponse = true;
            Zone.SetDispatcher(testDispatcher);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            testProto.clear();

            // Send a single SIF_Response with a small Authentication object

            String     SifRequestMsgId = Adk.MakeGuid();
            String     sourceId        = "TEST_SOURCEID";
            SifVersion testVersion     = SifVersion.LATEST;
            int        maxBufferSize   = int.MaxValue;

            IElementDef[] testRestrictions = new IElementDef[] { InfrastructureDTD.AUTHENTICATION_REFID };

            SifResponseSender srs = new SifResponseSender();

            srs.Open(Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, testRestrictions);
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Close();


            for (int x = 0; x < 5; x++)
            {
                // Retrieve the SIF_Response message off the protocol handler and asssert the results
                SIF_Response response = (SIF_Response)testProto.readMsg();

                Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId);
                Assert.AreEqual(x + 1, response.SIF_PacketNumber.Value);
                if (x == 4)
                {
                    Assert.AreEqual("No", response.SIF_MorePackets);
                }
                else
                {
                    Assert.AreEqual("Yes", response.SIF_MorePackets);
                }

                SIF_Header header = response.SIF_Header;
                Assert.AreEqual(sourceId, header.SIF_DestinationId);

                SifElement responseObject = response.SIF_ObjectData.GetChildList()[0];
                Assert.IsNotNull(responseObject);
            }
        }
        public void testSetPacketNumberAndMorePackets()
        {
            MessageDispatcher testDispatcher = new MessageDispatcher(this.Zone);

            this.Zone.SetDispatcher(testDispatcher);
            this.Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)this.Zone.ProtocolHandler;

            testProto.clear();

            // Send a single SIF_Response with a small Authentication object

            String     SifRequestMsgId  = Adk.MakeGuid();
            String     sourceId         = "TEST_SOURCEID";
            SifVersion testVersion      = SifVersion.LATEST;
            int        maxBufferSize    = int.MaxValue;
            int        packetNumber     = 999;
            YesNo      morePacketsValue = YesNo.YES;

            IElementDef[] testRestrictions = new IElementDef[] { InfrastructureDTD.AUTHENTICATION_REFID };

            SifResponseSender srs = new SifResponseSender();

            srs.Open(this.Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, testRestrictions);

            srs.SIF_PacketNumber = packetNumber;
            srs.SIF_MorePackets  = morePacketsValue;

            // Assert the values of the properties set before writing
            Assert.AreEqual(packetNumber, srs.SIF_PacketNumber);
            Assert.AreEqual(morePacketsValue, srs.SIF_MorePackets);

            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Close();

            // Assert the values of the properties set after writing
            Assert.AreEqual(packetNumber, srs.SIF_PacketNumber);
            Assert.AreEqual(morePacketsValue, srs.SIF_MorePackets);

            // Retrieve the SIF_Response message off the protocol handler and asssert the results
            SIF_Response response = (SIF_Response)testProto.readMsg();

            Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId);
            Assert.AreEqual(packetNumber, response.SIF_PacketNumber.Value);
            Assert.AreEqual(morePacketsValue.ToString(), response.SIF_MorePackets);

            SIF_Header header = response.SIF_Header;

            Assert.AreEqual(sourceId, header.SIF_DestinationId);

            SifElement responseObject = response.SIF_ObjectData.GetChildList()[0];

            Assert.IsNotNull(responseObject);
        }
예제 #6
0
        private void testSIFPingWithZISVersion(InMemoryProtocolHandler handler, SifVersion testVersion)
        {
            SIF_SystemControl ssc;

            Zone.Properties.ZisVersion = testVersion.ToString();
            Zone.SifPing();
            ssc = (SIF_SystemControl)handler.readMsg();

            Assert.AreEqual(testVersion, ssc.SifVersion, "SifVersion");
            Assert.AreEqual(testVersion.Xmlns, ssc.GetXmlns(), "SifVersion->Xmlns");
        }
예제 #7
0
        private void assertMessagesInVersion(SifVersion version, String[] expectedMessages)
        {
            Zone.Connect(ProvisioningFlags.Register);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            for (int a = 0; a < expectedMessages.Length; a++)
            {
                SifMessagePayload smp = (SifMessagePayload)handler.readMsg();
                Assert.AreEqual(expectedMessages[a], smp.Tag, "Should be a " + expectedMessages[a]);
                Assert.AreEqual(version, smp.SifVersion, "Version should be " + version);
            }

            Assert.IsNull(handler.readMsg(), " Should have no more messages ");
        }
예제 #8
0
        public void testSIFRegisterZISVersion15r1()
        {
            Adk.SifVersion = (SifVersion.LATEST);
            String          iconURL = "http://acme.foo.bar/ico";
            AgentProperties props   = Agent.Properties;

            // Set the ZIS Version to 1.5r1
            props.ZisVersion = SifVersion.SIF15r1.ToString();

            props.AgentIconUrl = iconURL;

            Agent.Name               = "acmeAgent";
            props.AgentVendor        = "acmeVendor";
            props.AgentVersion       = "2.6.5.8";
            props.ApplicationName    = "acmeApp";
            props.ApplicationVendor  = "acme<>AppVendor";
            props.ApplicationVersion = "10.2";


            Zone.Connect(ProvisioningFlags.Register);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            SIF_Register sr = (SIF_Register)handler.readMsg();

            Assert.AreEqual(SifVersion.SIF15r1, sr.SifVersion, "SifVersion");
            Assert.AreEqual(SifVersion.SIF15r1.Xmlns, sr.GetXmlns(), "SifVersion->Xmlns");

            Assert.AreEqual(Agent.Id, sr.SourceId, "SourceID");
            Assert.AreEqual("acmeAgent", sr.SIF_Name, "Name");
            Assert.IsNull(sr.SIF_NodeVendor, "Agent Vendor");
            Assert.IsNull(sr.SIF_NodeVersion, "Agent Version");
            SIF_Application appInfo = sr.SIF_Application;

            Assert.IsNull(appInfo);
            Assert.IsNull(sr.SIF_Icon, "Icon");


            // Assert the versions in the message. If the ADK is initialized to
            // SIF 1.5r1, it should not be sending any versions that start with a
            // "2"
            SifVersion messageVersion = sr.SifVersion;

            Assert.AreEqual(SifVersion.SIF15r1, messageVersion, "Should be version 1.5r1");
            foreach (SIF_Version version in sr.GetSIF_Versions())
            {
                String versionString = version.TextValue;
                Assert.IsTrue(versionString.StartsWith("1"), "Should start with 1 but was " + versionString);
            }
        }
예제 #9
0
        public void testRegisterOverrideZISVersion()
        {
            Adk.SifVersion = (SifVersion.SIF20);
            AgentProperties props = Agent.Properties;

            props.OverrideSifVersions = "1.1, 2.5";

            Zone.Connect(ProvisioningFlags.Register);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            SIF_Register sr = (SIF_Register)handler.readMsg();

            SIF_Version[] versions = sr.GetSIF_Versions();
            Assert.IsNotNull(versions);
            Assert.AreEqual(2, versions.Length);
            Assert.AreEqual("1.1", versions[0].Value);
            Assert.AreEqual("2.5", versions[1].Value);
        }
예제 #10
0
        public void testSynchronousGetZoneStatus()
        {
            Adk.SifVersion = (SifVersion.LATEST);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler handler = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            Zone.Properties.UseZoneStatusSystemControl = true;
            Zone.Properties.ZisVersion = SifVersion.SIF15r1.ToString();
            handler.clear();

            SIF_ZoneStatus szs = Zone.GetZoneStatus();

            SIF_SystemControl ssc = (SIF_SystemControl)handler.readMsg();

            Assert.AreEqual(SifVersion.SIF15r1, ssc.SifVersion, "SifVersion");
            Assert.AreEqual(SifVersion.SIF15r1.Xmlns, ssc.GetXmlns(), "SifVersion->Xmlns");
            SifElement element = ssc.SIF_SystemControlData.GetChildList()[0];

            Assert.IsNotNull(element, "SIF_SystemControlData\\Child");
            Assert.IsTrue(element is SIF_GetZoneStatus, "is instanceof SIF_GetZoneStatus");
        }
        public void testSifResponseSender010()
        {
            string queryStr =
                @"<SIF_Query>
                                         <SIF_QueryObject ObjectName='SectionInfo'>
                                            <SIF_Element>@RefId</SIF_Element>
                                            <SIF_Element>@SchoolCourseInfoRefId</SIF_Element>
                                            <SIF_Element>@SchoolYear</SIF_Element>
                                            <SIF_Element>LocalId</SIF_Element>
                                            <SIF_Element>ScheduleInfoList/ScheduleInfo/@TermInfoRefId</SIF_Element>
                                            <SIF_Element>Description</SIF_Element>
                                            <SIF_Element>LanguageOfInstruction</SIF_Element>
                                            <SIF_Element>LanguageOfInstruction/Code</SIF_Element>
                                         </SIF_QueryObject>
                                      </SIF_Query>";

            string sectionInfoStr =
                @"<SectionInfo RefId='D9C9889878144863B190C7D3428D7953' SchoolCourseInfoRefId='587F89D23EDD4761A59C04BA0D39E8D9' SchoolYear='2008'>
                                                  <LocalId>1</LocalId>
                                                  <Description>section 19</Description>
                                                  <ScheduleInfoList>
                                                    <ScheduleInfo TermInfoRefId='0D8165B1ADB34780BD1DFF9E38A7B935'>
                                                      <TeacherList>
                                                        <StaffPersonalRefId>F9D3916707634682B84C530BCF96B5CA</StaffPersonalRefId>
                                                      </TeacherList>
                                                      <SectionRoomList>
                                                        <RoomInfoRefId>EED167D761CD493EA94A875F56ABB0CB</RoomInfoRefId>
                                                      </SectionRoomList>
                                                      <MeetingTimeList>
                                                        <MeetingTime>
                                                          <TimetableDay>R</TimetableDay>
                                                          <TimetablePeriod>6</TimetablePeriod>
                                                        </MeetingTime>
                                                        <MeetingTime>
                                                          <TimetableDay>F</TimetableDay>
                                                          <TimetablePeriod>6</TimetablePeriod>
                                                        </MeetingTime>
                                                        <MeetingTime>
                                                          <TimetableDay>W</TimetableDay>
                                                          <TimetablePeriod>6</TimetablePeriod>
                                                        </MeetingTime>
                                                        <MeetingTime>
                                                          <TimetableDay>M</TimetableDay>
                                                          <TimetablePeriod>6</TimetablePeriod>
                                                        </MeetingTime>
                                                        <MeetingTime>
                                                          <TimetableDay>T</TimetableDay>
                                                          <TimetablePeriod>6</TimetablePeriod>
                                                        </MeetingTime>
                                                      </MeetingTimeList>
                                                    </ScheduleInfo>
                                                  </ScheduleInfoList>
                                                  <MediumOfInstruction><Code>0605</Code></MediumOfInstruction>
                                                  <LanguageOfInstruction><Code>eng</Code></LanguageOfInstruction>
                                                  <SummerSchool>No</SummerSchool>
                                                </SectionInfo>";


            SifParser   parser   = SifParser.NewInstance();
            SIF_Query   sifquery = (SIF_Query)parser.Parse(queryStr);
            SectionInfo section  = (SectionInfo)parser.Parse(sectionInfoStr);
            Query       query    = new Query(sifquery);

            String     SifRequestMsgId = Adk.MakeGuid();
            String     sourceId        = "TEST_SOURCEID";
            SifVersion testVersion     = SifVersion.LATEST;
            int        maxBufferSize   = int.MaxValue;

            MessageDispatcher testDispatcher = new MessageDispatcher(Zone);

            Zone.SetDispatcher(testDispatcher);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            testProto.clear();

            SifResponseSender srs = new SifResponseSender();

            srs.Open(Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, query);
            srs.Write(section);
            srs.Close();

            // Retrieve the SIF_Response message off the protocol handler and asssert the results
            SIF_Response response = (SIF_Response)testProto.readMsg();

            Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId);
            Assert.AreEqual(1, response.SIF_PacketNumber.Value);
            Assert.AreEqual("No", response.SIF_MorePackets);

            SIF_Header header = response.SIF_Header;

            Assert.AreEqual(sourceId, header.SIF_DestinationId);

            SifDataObject responseObject = (SifDataObject)response.SIF_ObjectData.GetChildList()[0];

            Assert.IsNotNull(responseObject);

            Console.Out.WriteLine(responseObject.ToXml());

            SifXPathContext context = SifXPathContext.NewSIFContext(responseObject);

            foreach (ElementRef reference in query.FieldRestrictionRefs)
            {
                Element found = context.GetElementOrAttribute(reference.XPath);
                Assert.IsNotNull(found, reference.XPath);
            }


            Element sectionInfoList =
                responseObject.GetElementOrAttribute("ScheduleInfoList/ScheduleInfo/SectionInfoList");

            Assert.IsNull(sectionInfoList);
        }
        public void testSifResponseSenderError()
        {
            MessageDispatcher testDispatcher = new MessageDispatcher(Zone);

            Zone.SetDispatcher(testDispatcher);
            Zone.Connect(ProvisioningFlags.None);
            InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)Zone.ProtocolHandler;

            testProto.clear();

            // Send a single SIF_Response with a small Authentication object

            String     SifRequestMsgId = Adk.MakeGuid();
            String     sourceId        = "TEST_SOURCEID";
            SifVersion testVersion     = SifVersion.LATEST;
            int        maxBufferSize   = int.MaxValue;
            SIF_Error  error           =
                new SIF_Error(SifErrorCategoryCode.Generic, SifErrorCodes.GENERIC_GENERIC_ERROR_1, "ERROR", "EXT_ERROR");

            IElementDef[] testRestrictions = new IElementDef[] { InfrastructureDTD.AUTHENTICATION_REFID };

            SifResponseSender srs = new SifResponseSender();

            srs.Open(Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, testRestrictions);
            srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL));
            srs.Write(error);
            srs.Close();

            // Retrieve the SIF_Response message off the protocol handler and asssert the results
            SIF_Response response = (SIF_Response)testProto.readMsg();

            Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId);
            Assert.AreEqual(1, response.SIF_PacketNumber.Value);
            Assert.AreEqual("Yes", response.SIF_MorePackets);

            SIF_Header header = response.SIF_Header;

            Assert.AreEqual(sourceId, header.SIF_DestinationId);

            SifElement responseObject = response.SIF_ObjectData.GetChildList()[0];

            Assert.IsNotNull(responseObject);

            // now test the error packet
            response = (SIF_Response)testProto.readMsg();

            Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId);
            Assert.AreEqual(2, response.SIF_PacketNumber.Value);
            Assert.AreEqual("No", response.SIF_MorePackets);

            header = response.SIF_Header;
            Assert.AreEqual(sourceId, header.SIF_DestinationId);

            Assert.IsNull(response.SIF_ObjectData);
            SIF_Error respError = response.SIF_Error;

            Assert.IsNotNull(respError);
            Assert.AreEqual(12, respError.SIF_Category.Value);
            Assert.AreEqual(1, respError.SIF_Code.Value);
            Assert.AreEqual("ERROR", respError.SIF_Desc);
            Assert.AreEqual("EXT_ERROR", respError.SIF_ExtendedDesc);
        }