Exemple #1
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult  result;
            Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass;
            string expResult = "type is registered.";

            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqosHolder = null;
            mod.tstTypeSupport           typesupport;
            DDS.ReturnCode returnCode;
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }
            typesupport = new mod.tstTypeSupport();
            if (typesupport == null)
            {
                result = new Test.Framework.TestResult(expResult, "TypeSupport is not constructed."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }
            returnCode = typesupport.RegisterType(participant, "mod::tst");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "TypeSupport is not registered."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }
            returnCode = factory.DeleteParticipant(participant);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed."
                                                       , expVerdict, Test.Framework.TestVerdict.Fail);
                return(result);
            }
            result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict
                                                   );
            return(result);
        }
Exemple #2
0
        public virtual Test.Framework.TestResult Init()
        {
            DDS.ReturnCode rc;
            string         name;
            string         typeName;

            Test.Framework.TestResult result = new Test.Framework.TestResult("Initialization success"
                                                                             , string.Empty, TestVerdict.Pass, TestVerdict.Fail
                                                                             );
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return(result);
            }
            name     = "my_topic";
            typeName = "my_type";
            rc       = typeSupport.RegisterType(participant, typeName);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return(result);
            }
            topic = participant.CreateTopic(name, typeName, topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return(result);
            }
            result.Result  = "Initialization success.";
            result.Verdict = TestVerdict.Pass;
            return(null);
        }
Exemple #3
0
        public virtual Test.Framework.TestResult Init()
        {
            DDS.ReturnCode rc;
            string name;
            string typeName;
            Test.Framework.TestResult result = new Test.Framework.TestResult("Initialization success"
                , string.Empty, TestVerdict.Pass, TestVerdict.Fail
                );
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return result;
            }
            name = "my_topic";
            typeName = "my_type";
            rc = typeSupport.RegisterType(participant, typeName);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return result;
            }
            topic = participant.CreateTopic(name, typeName, topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return result;
            }
            result.Result = "Initialization success.";
            result.Verdict = TestVerdict.Pass;
            return null;
        }
Exemple #4
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass;
            string expResult = "type is registered.";
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
            DDS.DomainParticipantQos pqosHolder = null;
            mod.tstTypeSupport typesupport;
            DDS.ReturnCode returnCode;
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }
            typesupport = new mod.tstTypeSupport();
            if (typesupport == null)
            {
                result = new Test.Framework.TestResult(expResult, "TypeSupport is not constructed."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }
            returnCode = typesupport.RegisterType(participant, "mod::tst");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "TypeSupport is not registered."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }
            returnCode = factory.DeleteParticipant(participant);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed."
                    , expVerdict, Test.Framework.TestVerdict.Fail);
                return result;
            }
            result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict
                );
            return result;
        }
Exemple #5
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.IDomainParticipant    participant;
            DDS.TopicQos              topQosHolder = null;
            DDS.ITopic                topic;
            mod.tstTypeSupport        typeSupport = null;
            Test.Framework.TestResult result;
            DDS.ReturnCode            rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                                                   Test.Framework.TestVerdict.Fail);
            participant = (DDS.IDomainParticipant)testCase.ResolveObject("participant");
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return(result);
            }
            topic = participant.CreateTopic("my_topic", "my_type", topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return(result);
            }
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", topQosHolder);
            testCase.RegisterObject("typeSupport", typeSupport);
            result.Result  = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.IDomainParticipant participant;
            mod.tstTypeSupport typeSupport;
			DDS.TopicQos topQosHolder = null;
            DDS.ITopic topic;
            DDS.ReturnCode rc;
            Test.Framework.TestResult result;
            participant = (DDS.IDomainParticipant)testCase.ResolveObject("participant");
            typeSupport = new mod.tstTypeSupport();
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return result;
            }
            topic = participant.CreateTopic("my_topic", "my_type", topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return result;
            }
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", topQosHolder);
            testCase.RegisterObject("typeSupport", typeSupport);
            result.Result = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
        public override Test.Framework.TestResult Run()
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqosHolder     = null;
            DDS.TopicQos                   topQosHolder = null;
            DDS.ITopic                     topic;
            mod.tstTypeSupport             typeSupport = null;
            mod.tstDataReader              datareader;
            test.sacs.MyDataReaderListener listener;
            DDS.ISubscriber                subscriber;
            DDS.SubscriberQos              sqosHolder = null;
            DDS.DataReaderQos              dqosHolder = null;
            DDS.IPublisher                 publisher;
            DDS.PublisherQos               pubQosHolder = null;
            mod.tstDataWriter              datawriter;
            DDS.DataWriterQos              wqosHolder = null;
            Test.Framework.TestResult      result;
            DDS.ReturnCode                 rc;
            string expResult = "DataReaderListener test succeeded.";

            semaphores = new Dictionary <DDS.StatusKind, Semaphore>();
            semaphores.Add(DDS.StatusKind.DataAvailable, new Semaphore(0, 1));

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            topic = participant.CreateTopic("my_topic", "my_type", topQosHolder);//, null,
            //0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder);//, null, 0);
            if (datareader == null)
            {
                result.Result = "DataReader could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            publisher = participant.CreatePublisher(pubQosHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0);
            if (datawriter == null)
            {
                result.Result = "DataWriter could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }
            listener = new test.sacs.MyDataReaderListener(semaphores);
            rc       = datareader.SetListener(listener, DDS.StatusKind.LivelinessChanged | DDS.StatusKind.DataAvailable);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Set listener failed.";
                return(result);
            }
            mod.tst t = new mod.tst();
            t.long_1 = 1;
            t.long_2 = 2;
            t.long_3 = 3;

            rc = datawriter.Write(t, DDS.InstanceHandle.Nil);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Data could not be written.";
                this.Cleanup(factory, participant);
                return(result);
            }
            if (semaphores[DDS.StatusKind.DataAvailable].WaitOne(10000))
            {
                if (!listener.onDataAvailableCalled)
                {
                    result.Result = "on_data_available does not work properly.";
                    this.Cleanup(factory, participant);
                    return(result);
                }
            }
            else
            {
                result.Result = "on_data_available did not trigger";
                this.Cleanup(factory, participant);
                return(result);
            }
            listener.Reset();
            rc = publisher.DeleteDataWriter(datawriter);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "DataWriter could not be deleted.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = participant.DeleteContainedEntities();
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete contained entities failed.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete DomainParticipant failed.";
                this.Cleanup(factory, participant);
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqosHolder = null;
            DDS.TopicQos              topQosHolder  = null;
            DDS.ITopic                topic;
            mod.tstTypeSupport        typeSupport = null;
            Test.Framework.TestResult result;
            string name;
            string typeName;

            DDS.ReturnCode rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return(result);
            }
            name     = "my_topic";
            typeName = "my_type";
            rc       = typeSupport.RegisterType(participant, typeName);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return(result);
            }
            topic = participant.CreateTopic(name, typeName, topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return(result);
            }
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqosHolder);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", topQosHolder);
            testCase.RegisterObject("typeSupport", typeSupport);
            testCase.RegisterObject("topicName", name);
            testCase.RegisterObject("topicTypeName", typeName);
            result.Result  = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #9
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "register_typesupport tests pass";

            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos     participantQosHolder = null;
            DDS.IDomainParticipant       participant;
            mod.tstTypeSupport           typeSupport;
            DDS.ReturnCode            rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory (1)";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos (2)";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (2)";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            rc          = typeSupport.RegisterType(null, null);
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant and with a null name (3)";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, null);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with a null name (4)";
                return(result);
            }

            rc = typeSupport.RegisterType(participant, string.Empty);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with an empty name (5)";
                return(result);
            }

            rc = typeSupport.RegisterType(null, "type_name6");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant (6)";
                return(result);
            }

            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a participant (7)";
                return(result);
            }
            rc = typeSupport.RegisterType(null, "type_name8");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant (8)";
                return(result);
            }


            rc = typeSupport.RegisterType(participant, "type_name9");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a deleted participant (9)";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (10)";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "    ");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with all spaces (11)";
                return(result);
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "participant could not be deleted (12)";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #10
0
        public override Test.Framework.TestResult Run()
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqosHolder     = null;
            DDS.TopicQos                   topQosHolder = null;
            DDS.ITopic                     topic;
            mod.tstTypeSupport             typeSupport = null;
            mod.tstDataReader              datareader;
            test.sacs.MyDataReaderListener listener;
            DDS.ISubscriber                subscriber;
            DDS.SubscriberQos              sqosHolder = null;
            DDS.DataReaderQos              dqosHolder = null;
            DDS.IPublisher                 publisher;
            DDS.PublisherQos               pubQosHolder = null;
            mod.tstDataWriter              datawriter;
            DDS.DataWriterQos              wqosHolder = null;
            Test.Framework.TestResult      result;
            DDS.ReturnCode                 rc;
            string expResult = "DataReaderListener test succeeded.";

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            topQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topic = participant.CreateTopic("my_topic_t", "my_type", topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            publisher = participant.CreatePublisher(pubQosHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            wqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0);
            if (datawriter == null)
            {
                result.Result = "DataWriter could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }
            mod.tst t = new mod.tst();
            t.long_1 = 1;
            t.long_2 = 2;
            t.long_3 = 3;

            rc = datawriter.Write(t, DDS.InstanceHandle.Nil);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Data could not be written.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                this.Cleanup(factory, participant);
                return(result);
            }
            dqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            listener   = new test.sacs.MyDataReaderListener();
            datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder, listener, DDS.StatusKind.Any);
            if (datareader == null)
            {
                result.Result = "DataReader could not be created.";
                this.Cleanup(factory, participant);
                return(result);
            }
            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e);
            }
            if (!listener.onLivelinessChangedCalled)
            {
                result.Result = "on_liveliness_changed does not work properly.";
                this.Cleanup(factory, participant);
                return(result);
            }

            if (!listener.onDataAvailableCalled)
            {
                result.Result = "on_data_available does not work properly.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = participant.DeleteContainedEntities();
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete contained entities failed.";
                this.Cleanup(factory, participant);
                return(result);
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete DomainParticipant failed.";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #11
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "get_type_name returns the correct name";

            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos     participantQosHolder = null;
            DDS.IDomainParticipant       participant;
            mod.tstTypeSupport           typeSupport;
            DDS.ReturnCode            rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            string typeName = typeSupport.TypeName;

            if (typeName == null)
            {
                result.Result = "get_type_name returned null (1)";
                return(result);
            }
            if (!typeName.Equals("mod::tst"))
            {
                result.Result = "get_type_name returned incorrect typename (1)";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type";
                return(result);
            }
            typeName = typeSupport.TypeName;
            if (typeName == null)
            {
                result.Result = "get_type_name returned null (2)";
                return(result);
            }
            if (!typeName.Equals("mod::tst"))
            {
                result.Result = "get_type_name returned incorrect typename (2)";
                return(result);
            }
            mod.otherTypeTypeSupport typeSupport2 = new mod.otherTypeTypeSupport();
            typeName = typeSupport2.TypeName;
            if (typeName == null)
            {
                result.Result = "get_type_name returned null (3)";
                return(result);
            }
            if (!typeName.Equals("mod::otherType"))
            {
                result.Result = "get_type_name returned incorrect typename (3)";
                return(result);
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "participant could not be deleted (12)";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #12
0
        public override Test.Framework.TestResult Run()
        {
            DDS.IDomainParticipant participant;
            DDS.IPublisher         publisher;
            DDS.IPublisher         publisher2;
            DDS.PublisherQos       qos = null;
            DDS.IDataWriter        writer;
            DDS.IDataWriter        writer2;
            DDS.DataWriterQos      dataWriterQosHolder = null;
            DDS.DataWriterQos      dataWriterQos       = null;
            DDS.ITopic             topic;
            DDS.ITopic             topic2;
            DDS.TopicQos           defaultTopicQos = null;
            mod.tstTypeSupport     typeSupport;
            string expResult = "Successful creation and deletion of DataWriters";

            Test.Framework.TestResult result;
            DDS.ReturnCode            rc;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                                                   Test.Framework.TestVerdict.Fail);
            participant     = (DDS.IDomainParticipant) this.ResolveObject("participant");
            publisher       = (DDS.IPublisher) this.ResolveObject("publisher");
            qos             = (DDS.PublisherQos) this.ResolveObject("publisherQos");
            topic           = (DDS.ITopic) this.ResolveObject("topic");
            defaultTopicQos = (DDS.TopicQos) this.ResolveObject("topicQos");
            publisher.GetDefaultDataWriterQos(ref dataWriterQosHolder);
            writer = publisher.CreateDataWriter(topic, dataWriterQosHolder);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer (1).";
                return(result);
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (2).";
                return(result);
            }
            try
            {
                writer = publisher.CreateDataWriter(null, dataWriterQosHolder);//, null, 0);
            }
            catch (System.NullReferenceException)
            {
                writer = null;
            }
            if (writer != null)
            {
                result.Result = "could create a writer with invalid topic (3).";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "my_other_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }
            publisher2 = participant.CreatePublisher(qos);//, null, 0);
            if (publisher2 == null)
            {
                result.Result = "creation of a second publisher failed.";
                return(result);
            }
            topic2 = participant.CreateTopic("my_other_topic", "my_other_type", defaultTopicQos);//, null, 0);
            if (topic2 == null)
            {
                result.Result = "Topic2 could not be created.";
                return(result);
            }
            writer = publisher.CreateDataWriter(topic2, dataWriterQosHolder);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with another topic (4).";
                return(result);
            }
            writer2 = publisher.LookupDataWriter("my_other_topic");
            if (writer2 == null)
            {
                result.Result = "could not lookup writer (5).";
                return(result);
            }
            if (writer2 != writer)
            {
                result.Result = "looked-up writer != initial writer (6).";
                return(result);
            }
            writer2 = null;
            writer2 = publisher.LookupDataWriter("unknown_topic_name");
            if (writer2 != null)
            {
                result.Result = "could lookup writer with unknown topic name (7).";
                return(result);
            }
            rc = publisher2.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.PreconditionNotMet)
            {
                result.Result = "Expected returncode PRECONDITION_NOT_MET instead of " + rc + " after deleting a writer on wrong publisher (8).";
                return(result);
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (9).";
                return(result);
            }
            rc = participant.DeleteTopic(topic2);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a topic (10).";
                return(result);
            }
            writer = publisher.CreateDataWriter(topic2, dataWriterQosHolder);//, null, 0);
            if (writer != null)
            {
                result.Result = "could create a writer with an already deleted topic (11).";
                return(result);
            }
            dataWriterQos = dataWriterQosHolder;
            dataWriterQos.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            dataWriterQos.History.Kind    = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            writer = publisher.CreateDataWriter(topic, dataWriterQos);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with TRANSIENT durabilityQosPolicy (12).";
                return(result);
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (13).";
                return(result);
            }
            dataWriterQos.Durability.Kind = DDS.DurabilityQosPolicyKind.PersistentDurabilityQos;
            writer = publisher.CreateDataWriter(topic, dataWriterQos);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with PERSISTENT durabilityQosPolicy (14).";
                return(result);
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (15).";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #13
0
        public override Test.Framework.TestResult Run()
        {
            DDS.IDomainParticipant participant;
            DDS.IPublisher publisher;
            DDS.IPublisher publisher2;
			DDS.PublisherQos qos = null;
            DDS.IDataWriter writer;
            DDS.IDataWriter writer2;
			DDS.DataWriterQos dataWriterQosHolder = null;
			DDS.DataWriterQos dataWriterQos = null;
            DDS.ITopic topic;
            DDS.ITopic topic2;
			DDS.TopicQos defaultTopicQos = null;
            mod.tstTypeSupport typeSupport;
            string expResult = "Successful creation and deletion of DataWriters";
            Test.Framework.TestResult result;
            DDS.ReturnCode rc;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            participant = (DDS.IDomainParticipant)this.ResolveObject("participant");
            publisher = (DDS.IPublisher)this.ResolveObject("publisher");
            qos = (DDS.PublisherQos)this.ResolveObject("publisherQos");
            topic = (DDS.ITopic)this.ResolveObject("topic");
            defaultTopicQos = (DDS.TopicQos)this.ResolveObject("topicQos");
            publisher.GetDefaultDataWriterQos(ref dataWriterQosHolder);
            writer = publisher.CreateDataWriter(topic, dataWriterQosHolder);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer (1).";
                return result;
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (2).";
                return result;
            }
            try
            {
                writer = publisher.CreateDataWriter(null, dataWriterQosHolder);//, null, 0);
            }
            catch (System.NullReferenceException)
            {
                writer = null;
            }
            if (writer != null)
            {
                result.Result = "could create a writer with invalid topic (3).";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "my_other_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }
            publisher2 = participant.CreatePublisher(qos);//, null, 0);
            if (publisher2 == null)
            {
                result.Result = "creation of a second publisher failed.";
                return result;
            }
            topic2 = participant.CreateTopic("my_other_topic", "my_other_type", defaultTopicQos);//, null, 0);
            if (topic2 == null)
            {
                result.Result = "Topic2 could not be created.";
                return result;
            }
            writer = publisher.CreateDataWriter(topic2, dataWriterQosHolder);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with another topic (4).";
                return result;
            }
            writer2 = publisher.LookupDataWriter("my_other_topic");
            if (writer2 == null)
            {
                result.Result = "could not lookup writer (5).";
                return result;
            }
            if (writer2 != writer)
            {
                result.Result = "looked-up writer != initial writer (6).";
                return result;
            }
            writer2 = null;
            writer2 = publisher.LookupDataWriter("unknown_topic_name");
            if (writer2 != null)
            {
                result.Result = "could lookup writer with unknown topic name (7).";
                return result;
            }
            rc = publisher2.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.PreconditionNotMet)
            {
                result.Result = "Expected returncode PRECONDITION_NOT_MET instead of " + rc + " after deleting a writer on wrong publisher (8).";
                return result;
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (9).";
                return result;
            }
            rc = participant.DeleteTopic(topic2);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a topic (10).";
                return result;
            }
            writer = publisher.CreateDataWriter(topic2, dataWriterQosHolder);//, null, 0);
            if (writer != null)
            {
                result.Result = "could create a writer with an already deleted topic (11).";
                return result;
            }
            dataWriterQos = dataWriterQosHolder;
            dataWriterQos.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            dataWriterQos.History.Kind = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            writer = publisher.CreateDataWriter(topic, dataWriterQos);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with TRANSIENT durabilityQosPolicy (12).";
                return result;
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (13).";
                return result;
            }
            dataWriterQos.Durability.Kind = DDS.DurabilityQosPolicyKind.PersistentDurabilityQos;
            writer = publisher.CreateDataWriter(topic, dataWriterQos);//, null, 0);
            if (writer == null)
            {
                result.Result = "could not create a writer with PERSISTENT durabilityQosPolicy (14).";
                return result;
            }
            rc = publisher.DeleteDataWriter(writer);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a writer (15).";
                return result;
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #14
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
            mod.tstTypeSupport typeSupport;
            DDS.TopicQos topicQos = null;
            DDS.ITopic topic;
            DDS.DomainParticipantQos pqos = null;
            DDS.ReturnCode rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, pqos);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "register_type failed.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref topicQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "participant.get_default_topic_qos failed.";
                return result;
            }
            topic = participant.CreateTopic("my_topic", "my_type", topicQos);//, null, 0);
            if (topic == null)
            {
                result.Result = "participant.create_topic failed.";
                return result;
            }
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqos);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            result.Result = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #15
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "register_typesupport tests pass";

            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos     participantQosHolder = null;
            DDS.IDomainParticipant       participant;
            mod.tstTypeSupport           typeSupport;
            mod.otherTypeTypeSupport     otherTypeTypeSupport;
            DDS.ReturnCode            rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory (1)";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos (2)";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (2)";
                return(result);
            }
            typeSupport          = new mod.tstTypeSupport();
            otherTypeTypeSupport = new mod.otherTypeTypeSupport();

            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type (3)";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register the same type a second time (4)";
                return(result);
            }
            rc = otherTypeTypeSupport.RegisterType(participant, "type2");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could register a different type (5)";
                return(result);
            }
            rc = otherTypeTypeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.PreconditionNotMet)
            {
                result.Result = "Expected RETCODE_PRECONDITION_NOT_MET but recieved " + rc + " after calling register_type using an already used name for a different type (6)";
                return(result);
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a participant (7)";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #16
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "register_typesupport tests pass";
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos participantQosHolder = null;
            DDS.IDomainParticipant participant;
            mod.tstTypeSupport typeSupport;
            DDS.ReturnCode rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory (1)";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos (2)";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (2)";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            rc = typeSupport.RegisterType(null, null);
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant and with a null name (3)";
                return result;
            }
            rc = typeSupport.RegisterType(participant, null);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with a null name (4)";
                return result;
            }

            rc = typeSupport.RegisterType(participant, string.Empty);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with an empty name (5)";
                return result;
            }

            rc = typeSupport.RegisterType(null, "type_name6");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant (6)";
                return result;
            }

            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a participant (7)";
                return result;
            }
            rc = typeSupport.RegisterType(null, "type_name8");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a null participant (8)";
                return result;
            }

            rc = typeSupport.RegisterType(participant, "type_name9");
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "could register a type on a deleted participant (9)";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (10)";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "    ");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type with all spaces (11)";
                return result;
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "participant could not be deleted (12)";
                return result;
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #17
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "get_type_name returns the correct name";
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos participantQosHolder = null;
            DDS.IDomainParticipant participant;
            mod.tstTypeSupport typeSupport;
            DDS.ReturnCode rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            string typeName = typeSupport.TypeName;
            if (typeName == null)
            {
                result.Result = "get_type_name returned null (1)";
                return result;
            }
            if (!typeName.Equals("mod::tst"))
            {
                result.Result = "get_type_name returned incorrect typename (1)";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type";
                return result;
            }
            typeName = typeSupport.TypeName;
            if (typeName == null)
            {
                result.Result = "get_type_name returned null (2)";
                return result;
            }
            if (!typeName.Equals("mod::tst"))
            {
                result.Result = "get_type_name returned incorrect typename (2)";
                return result;
            }
            mod.otherTypeTypeSupport typeSupport2 = new mod.otherTypeTypeSupport();
            typeName = typeSupport2.TypeName;
            if (typeName == null)
            {
                result.Result = "get_type_name returned null (3)";
                return result;
            }
            if (!typeName.Equals("mod::otherType"))
            {
                result.Result = "get_type_name returned incorrect typename (3)";
                return result;
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "participant could not be deleted (12)";
                return result;
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #18
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqosHolder   = null;
            DDS.SubscriberQos            subQosHolder = null;
            DDS.DataReaderQos            drQosHolder  = null;
            DDS.ISubscriber           subscriber;
            DDS.PublisherQos          pubQosHolder = null;
            DDS.IPublisher            publisher;
            mod.tstTypeSupport        typeSupport;
            DDS.TopicQos              tQosHolder = null;
            DDS.ITopic                topic;
            DDS.DataWriterQos         dwQosHolder = null;
            mod.tstDataWriter         datawriter;
            Test.Framework.TestResult result;
            DDS.ReturnCode            rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                                                   Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }

            if (participant.GetDefaultSubscriberQos(ref subQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                return(result);
            }
            subQosHolder.Partition.Name    = new string[1];
            subQosHolder.Partition.Name[0] = "testPartition";
            subscriber = participant.CreateSubscriber(subQosHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            rc          = typeSupport.RegisterType(participant, "tstType");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Typesupport could not be registered.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return(result);
            }
            tQosHolder.Durability.Kind  = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            tQosHolder.Reliability.Kind = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topic = participant.CreateTopic("tst", "tstType", tQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return(result);
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                return(result);
            }
            pubQosHolder.Partition.Name    = new string[1];
            pubQosHolder.Partition.Name[0] = "testPartition";
            publisher = participant.CreatePublisher(pubQosHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                return(result);
            }

            if (publisher.CopyFromTopicQos(ref dwQosHolder, tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                return(result);
            }
            dwQosHolder.WriterDataLifecycle.AutodisposeUnregisteredInstances = true;
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, dwQosHolder);//, null, 0);
            if (datawriter == null)
            {
                result.Result = "DataWriter could not be created.";
                return(result);
            }

            if (subscriber.CopyFromTopicQos(ref drQosHolder, tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                return(result);
            }
            drQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.VolatileDurabilityQos;
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqosHolder);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", tQosHolder);
            testCase.RegisterObject("subscriber", subscriber);
            testCase.RegisterObject("subscriberQos", subQosHolder);
            testCase.RegisterObject("datareaderQos", drQosHolder);
            testCase.RegisterObject("publisher", publisher);
            testCase.RegisterObject("publisherQos", pubQosHolder);
            testCase.RegisterObject("datawriter", datawriter);
            testCase.RegisterObject("datawriterQos", dwQosHolder);
            result.Result  = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            string expResult = "contains_entity returns the correct result";
            DDS.IDomainParticipant participant;
            DDS.DomainParticipantFactory factory;
            DDS.TopicQos tHolder = new DDS.TopicQos();
            DDS.PublisherQos pHolder = new DDS.PublisherQos();
            DDS.SubscriberQos sHolder = new DDS.SubscriberQos();
            DDS.DataWriterQos wHolder = new DDS.DataWriterQos();
            DDS.DataReaderQos rHolder = new DDS.DataReaderQos();
            DDS.ITopic topic;
            DDS.IPublisher publisher;
            DDS.ISubscriber subscriber;
            mod.tstDataWriter writer;
            mod.tstDataReader reader;
            long handle;
            DDS.ReturnCode rc;
            participant = (DDS.IDomainParticipant)this.ResolveObject("participant");
            factory = (DDS.DomainParticipantFactory)this.ResolveObject("factory");
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            if (participant.ContainsEntity(0))
            {
                result.Result = "contains_entity with nil handle incorrect";
                return result;
            }
            if (participant.ContainsEntity(100))
            {
                result.Result = "contains_entity with incorrect handle incorrect";
                return result;
            }
            
            handle = participant.InstanceHandle;
            if (handle == DDS.InstanceHandle.Nil)
            {
                result.Result = "get_instance_handle returned 0";
                return result;
            }
            if (participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with own handle incorrect";
                return result;
            }
            mod.tstTypeSupport typeSupport = new mod.tstTypeSupport();
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }
            participant.GetDefaultTopicQos(ref tHolder);
            topic = participant.CreateTopic("TestTopic", "type1", tHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Create Topic failed.";
                return result;
            }
            participant.GetDefaultPublisherQos(ref pHolder);
            publisher = participant.CreatePublisher(pHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Create Publisher failed.";
                return result;
            }
            participant.GetDefaultSubscriberQos(ref sHolder);
            subscriber = participant.CreateSubscriber(sHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Create Subscriber failed.";
                return result;
            }
            publisher.GetDefaultDataWriterQos(ref wHolder);
            writer = publisher.CreateDataWriter(topic, wHolder) as mod.tstDataWriter;
            if (writer == null)
            {
                result.Result = "Create Writer failed.";
                return result;
            }

            subscriber.GetDefaultDataReaderQos(ref rHolder);
            reader = subscriber.CreateDataReader(topic, rHolder) as mod.tstDataReader;
            if (reader == null)
            {
                result.Result = "Create Reader failed.";
                return result;
            }
            handle = topic.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (topic) returned 0";
                return result;
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with topic handle incorrect";
                return result;
            }
            handle = publisher.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (publisher) returned != 0";
                return result;
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with publisher handle incorrect";
                return result;
            }
            handle = subscriber.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (subscriber) returned != 0";
                return result;
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with subscriber handle incorrect";
                return result;
            }
            handle = writer.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (writer) returned 0";
                return result;
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with writer handle incorrect";
                return result;
            }
            handle = reader.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (reader) returned 0";
                return result;
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with reader handle incorrect";
                return result;
            }
            rc = participant.DeleteContainedEntities();
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_contained_entities failed.";
                return result;
            }
            if (participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity of deleted reader incorrect";
                return result;
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result = expResult;
            return result;
        }
Exemple #20
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult    result;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos     qos;
            string expResult = "Default topicQos is used when TOPIC_QOS_DEFAULT is specified.";

            DDS.TopicQos       topQosHolder1;
            DDS.TopicQos       topQosHolder2;
            mod.tstTypeSupport typeSupport;
            DDS.ITopic         topic;
            DDS.ReturnCode     returnCode;
            factory     = (DDS.DomainParticipantFactory) this.ResolveObject("factory");
            qos         = (DDS.DomainParticipantQos) this.ResolveObject("participantQos");
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");
            result      = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                                                        Test.Framework.TestVerdict.Fail);
            typeSupport   = new mod.tstTypeSupport();
            topQosHolder1 = new DDS.TopicQos();
            topQosHolder2 = new DDS.TopicQos();
            typeSupport.RegisterType(participant, "My_Type");

            if (participant.GetDefaultTopicQos(ref topQosHolder1) != DDS.ReturnCode.Ok)
            {
                result.Result = "Get default TopicQos failed (1).";
                return(result);
            }

            topQosHolder1.Durability.Kind       = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topQosHolder1.Liveliness.Kind       = DDS.LivelinessQosPolicyKind.AutomaticLivelinessQos;
            topQosHolder1.Reliability.Kind      = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topQosHolder1.DestinationOrder.Kind = DDS.DestinationOrderQosPolicyKind.ByReceptionTimestampDestinationorderQos;
            topQosHolder1.History.Kind          = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            topQosHolder1.Ownership.Kind        = DDS.OwnershipQosPolicyKind.SharedOwnershipQos;
            participant.SetDefaultTopicQos(topQosHolder1);
            typeSupport = new mod.tstTypeSupport();
            returnCode  = typeSupport.RegisterType(participant, "myTopicType");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }
            topic = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic == null)
            {
                result.Result = "Create topic failed.";
                return(result);
            }
            topic.GetQos(ref topQosHolder2);
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, topQosHolder2))
            {
                result.Result = "Default topicQos is not used when TOPIC_QOS_DEFAULT is specified.";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed.";
                return(result);
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result  = expResult;
            return(result);
        }
Exemple #21
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
            DDS.DomainParticipantQos pqosHolder = null;
            DDS.SubscriberQos subQosHolder = null;
            DDS.ISubscriber subscriber;
            DDS.PublisherQos pubQosHolder = null;
            DDS.IPublisher publisher;
            mod.tstTypeSupport typeSupport;
            DDS.TopicQos tQosHolder = null;
            DDS.ITopic topic;
            DDS.DataReaderQos drQosHolder = null;
            mod.tstDataReader datareader;
            DDS.DataWriterQos dwQosHolder = null;
            mod.tstDataWriter datawriter;
            Test.Framework.TestResult result;
            DDS.ReturnCode rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, pqosHolder, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }

            if (participant.GetDefaultSubscriberQos(ref subQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                return result;
            }
            subscriber = participant.CreateSubscriber(subQosHolder, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            rc = typeSupport.RegisterType(participant, "tstType");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Typesupport could not be registered.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return result;
            }
            topic = participant.CreateTopic("tst", "tstType", tQosHolder, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return result;
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                return result;
            }
            publisher = participant.CreatePublisher(pubQosHolder, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                return result;
            }

            if (publisher.GetDefaultDataWriterQos(ref dwQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                return result;
            }
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, dwQosHolder, null, 0);
            if (subscriber.GetDefaultDataReaderQos(ref drQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                return result;
            }
            datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQosHolder, null, 0);
            if (datareader == null)
            {
                result.Result = "DataReader could not be created.";
                return result;
            }
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqosHolder);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", tQosHolder);
            testCase.RegisterObject("subscriber", subscriber);
            testCase.RegisterObject("subscriberQos", subQosHolder);
            testCase.RegisterObject("datareader", datareader);
            testCase.RegisterObject("datareaderQos", drQosHolder);
            testCase.RegisterObject("publisher", publisher);
            testCase.RegisterObject("publisherQos", pubQosHolder);
            testCase.RegisterObject("datawriter", datawriter);
            testCase.RegisterObject("datawriterQos", dwQosHolder);
            result.Result = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
			DDS.DomainParticipantQos pqosHolder = null;
			DDS.SubscriberQos subQosHolder = null;
			DDS.DataReaderQos drQosHolder = null;
            DDS.ISubscriber subscriber;
			DDS.PublisherQos pubQosHolder = null;
            DDS.IPublisher publisher;
            mod.tstTypeSupport typeSupport;
			DDS.TopicQos tQosHolder = null;
            DDS.ITopic topic;
			DDS.DataWriterQos dwQosHolder = null;
            mod.tstDataWriter datawriter;
            Test.Framework.TestResult result;
            DDS.ReturnCode rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }

            if (participant.GetDefaultSubscriberQos(ref subQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                return result;
            }
            subQosHolder.Partition.Name = new string[1];
            subQosHolder.Partition.Name[0] = "testPartition";
            subscriber = participant.CreateSubscriber(subQosHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            rc = typeSupport.RegisterType(participant, "tstType");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Typesupport could not be registered.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return result;
            }
            tQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            tQosHolder.Reliability.Kind = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topic = participant.CreateTopic("tst", "tstType", tQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return result;
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                return result;
            }
            pubQosHolder.Partition.Name = new string[1];
            pubQosHolder.Partition.Name[0] = "testPartition";
            publisher = participant.CreatePublisher(pubQosHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                return result;
            }

            if (publisher.CopyFromTopicQos(ref dwQosHolder, tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                return result;
            }
            dwQosHolder.WriterDataLifecycle.AutodisposeUnregisteredInstances = true;
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, dwQosHolder);//, null, 0);
            if (datawriter == null)
            {
                result.Result = "DataWriter could not be created.";
                return result;
            }

            if (subscriber.CopyFromTopicQos(ref drQosHolder, tQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                return result;
            }
            drQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.VolatileDurabilityQos;
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqosHolder);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", tQosHolder);
            testCase.RegisterObject("subscriber", subscriber);
            testCase.RegisterObject("subscriberQos", subQosHolder);
            testCase.RegisterObject("datareaderQos", drQosHolder);
            testCase.RegisterObject("publisher", publisher);
            testCase.RegisterObject("publisherQos", pubQosHolder);
            testCase.RegisterObject("datawriter", datawriter);
            testCase.RegisterObject("datawriterQos", dwQosHolder);
            result.Result = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult    result;
            DDS.IDomainParticipant       participant;
            DDS.IDomainParticipant       participant2;
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos     qos = null;
            string expResult = "Topic test succeeded.";

            DDS.TopicQos          topQosHolder1 = null;
            DDS.TopicQos          topQosHolder2 = null;
            mod.tstTypeSupport    typeSupport;
            DDS.ITopic            topic;
            DDS.ITopic            topic2;
            DDS.ITopic            topic3;
            DDS.ITopic            topic4;
            DDS.ITopicDescription description;
            DDS.ReturnCode        returnCode;
            factory     = (DDS.DomainParticipantFactory) this.ResolveObject("factory");
            qos         = (DDS.DomainParticipantQos) this.ResolveObject("participantQos");
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");
            result      = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                                                        Test.Framework.TestVerdict.Fail);
            typeSupport = new mod.tstTypeSupport();
            typeSupport.RegisterType(participant, "My_Type");

            if (participant.GetDefaultTopicQos(ref topQosHolder1) != DDS.ReturnCode.Ok)
            {
                result.Result = "Get default TopicQos failed (1).";
                return(result);
            }
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, test.sacs.QosComparer.defaultTopicQos))
            {
                result.Result = "Get default TopicQos did not return the default qos (1).";
                return(result);
            }
            topQosHolder1.Durability.Kind       = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topQosHolder1.Liveliness.Kind       = DDS.LivelinessQosPolicyKind.AutomaticLivelinessQos;
            topQosHolder1.Reliability.Kind      = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topQosHolder1.DestinationOrder.Kind = DDS.DestinationOrderQosPolicyKind.ByReceptionTimestampDestinationorderQos;
            topQosHolder1.History.Kind          = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            topQosHolder1.Ownership.Kind        = DDS.OwnershipQosPolicyKind.SharedOwnershipQos;
            typeSupport = new mod.tstTypeSupport();
            returnCode  = typeSupport.RegisterType(participant, "myTopicType");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }
            topic = participant.CreateTopic("MyDCPSTopic", "myTopicType", topQosHolder1);//, null, 0);
            if (topic == null)
            {
                result.Result = "Create topic failed (3)";
                return(result);
            }
            description = participant.LookupTopicDescription("MyDCPSTopic");
            if (topic != description)
            {
                result.Result = "Lookup topic failed (4)";
                return(result);
            }
            topic2 = participant.FindTopic("MyDCPSTopic", new DDS.Duration());
            if (topic2 == null)
            {
                result.Result = "Find topic failed (5)";
                return(result);
            }
            topic2.GetQos(ref topQosHolder2);
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, topQosHolder2))
            {
                result.Result = "Find Topic did not find the correct Topic. (5)";
                return(result);
            }
            topic3 = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic3 != null)
            {
                result.Result = "Create Topic with BAD_PARAM succeeded (6).";
                return(result);
            }
            topic4 = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic4 != null)
            {
                result.Result = "Create Topic with BAD_PARAM succeeded (7).";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic3);
            if (returnCode != DDS.ReturnCode.BadParameter)
            {
                result.Result = "Expected RETCODE_BAD_PARAMETER but received " + returnCode + " after deleting a non exisiting topic (8).";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic4);
            if (returnCode != DDS.ReturnCode.BadParameter)
            {
                result.Result = "Expected RETCODE_BAD_PARAMETER but received " + returnCode + " after deleting a non exisiting topic (9).";
                return(result);
            }
            participant2 = factory.CreateParticipant(DDS.DomainId.Default, qos);//, null, 0);
            if (participant2 == null)
            {
                result.Result = "Create Participant failed (10).";
                return(result);
            }
            returnCode = participant2.DeleteTopic(topic);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic on wrong Participant succeeded (11).";
                return(result);
            }
            returnCode = factory.DeleteParticipant(participant2);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Participant failed (12).";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed (13).";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic2);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed (14).";
                return(result);
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete of already deleted Topic succeeded (15).";
                return(result);
            }
            returnCode = participant.DeleteTopic(null);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete null Topic succeeded (16).";
                return(result);
            }
            returnCode = participant.IgnoreParticipant(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid participant succeeded.";
                return(result);
            }
            returnCode = participant.IgnorePublication(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid publication succeeded.";
                return(result);
            }
            returnCode = participant.IgnoreSubscription(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid subscription succeeded.";
                return(result);
            }
            returnCode = participant.IgnoreTopic(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid topic succeeded.";
                return(result);
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result  = expResult;
            return(result);
        }
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantQos     pqos   = null;
            DDS.SubscriberQos            subQos = null;
            DDS.ISubscriber           subscriber;
            DDS.PublisherQos          pubQos = null;
            DDS.IPublisher            publisher;
            mod.tstTypeSupport        typeSupport;
            DDS.TopicQos              tQos = null;
            DDS.ITopic                topic;
            DDS.DataReaderQos         drQos = null;
            mod.tstDataReader         datareader;
            DDS.DataWriterQos         dwQos = null;
            mod.tstDataWriter         datawriter;
            Test.Framework.TestResult result;
            DDS.ReturnCode            rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqos);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }

            if (participant.GetDefaultSubscriberQos(ref subQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                return(result);
            }
            subscriber = participant.CreateSubscriber(subQos);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            rc          = typeSupport.RegisterType(participant, "tstType");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Typesupport could not be registered.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref tQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return(result);
            }

            topic = participant.CreateTopic("tst", "tstType", tQos);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return(result);
            }
            if (participant.GetDefaultPublisherQos(ref pubQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                return(result);
            }
            publisher = participant.CreatePublisher(pubQos);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                return(result);
            }

            if (subscriber.GetDefaultDataReaderQos(ref drQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                return(result);
            }
            datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos);//, null, 0);
            if (datareader == null)
            {
                result.Result = "DataReader could not be created.";
                return(result);
            }

            if (publisher.GetDefaultDataWriterQos(ref dwQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                return(result);
            }
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, dwQos);//, null, 0);

            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqos);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", tQos);
            testCase.RegisterObject("subscriber", subscriber);
            testCase.RegisterObject("subscriberQos", subQos);
            testCase.RegisterObject("datareader", datareader);
            testCase.RegisterObject("datareaderQos", drQos);
            testCase.RegisterObject("publisher", publisher);
            testCase.RegisterObject("publisherQos", pubQos);
            testCase.RegisterObject("datawriter", datawriter);
            testCase.RegisterObject("datawriterQos", dwQos);
            result.Result  = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #25
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            string expResult = "contains_entity returns the correct result";

            DDS.IDomainParticipant       participant;
            DDS.DomainParticipantFactory factory;
            DDS.TopicQos      tHolder = new DDS.TopicQos();
            DDS.PublisherQos  pHolder = new DDS.PublisherQos();
            DDS.SubscriberQos sHolder = new DDS.SubscriberQos();
            DDS.DataWriterQos wHolder = new DDS.DataWriterQos();
            DDS.DataReaderQos rHolder = new DDS.DataReaderQos();
            DDS.ITopic        topic;
            DDS.IPublisher    publisher;
            DDS.ISubscriber   subscriber;
            mod.tstDataWriter writer;
            mod.tstDataReader reader;
            long handle;

            DDS.ReturnCode rc;
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");
            factory     = (DDS.DomainParticipantFactory) this.ResolveObject("factory");
            result      = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                                                        Test.Framework.TestVerdict.Fail);
            if (participant.ContainsEntity(0))
            {
                result.Result = "contains_entity with nil handle incorrect";
                return(result);
            }
            if (participant.ContainsEntity(100))
            {
                result.Result = "contains_entity with incorrect handle incorrect";
                return(result);
            }

            handle = participant.InstanceHandle;
            if (handle == DDS.InstanceHandle.Nil)
            {
                result.Result = "get_instance_handle returned 0";
                return(result);
            }
            if (participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with own handle incorrect";
                return(result);
            }
            mod.tstTypeSupport typeSupport = new mod.tstTypeSupport();
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return(result);
            }
            participant.GetDefaultTopicQos(ref tHolder);
            topic = participant.CreateTopic("TestTopic", "type1", tHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Create Topic failed.";
                return(result);
            }
            participant.GetDefaultPublisherQos(ref pHolder);
            publisher = participant.CreatePublisher(pHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Create Publisher failed.";
                return(result);
            }
            participant.GetDefaultSubscriberQos(ref sHolder);
            subscriber = participant.CreateSubscriber(sHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Create Subscriber failed.";
                return(result);
            }
            publisher.GetDefaultDataWriterQos(ref wHolder);
            writer = publisher.CreateDataWriter(topic, wHolder) as mod.tstDataWriter;
            if (writer == null)
            {
                result.Result = "Create Writer failed.";
                return(result);
            }

            subscriber.GetDefaultDataReaderQos(ref rHolder);
            reader = subscriber.CreateDataReader(topic, rHolder) as mod.tstDataReader;
            if (reader == null)
            {
                result.Result = "Create Reader failed.";
                return(result);
            }
            handle = topic.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (topic) returned 0";
                return(result);
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with topic handle incorrect";
                return(result);
            }
            handle = publisher.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (publisher) returned != 0";
                return(result);
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with publisher handle incorrect";
                return(result);
            }
            handle = subscriber.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (subscriber) returned != 0";
                return(result);
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with subscriber handle incorrect";
                return(result);
            }
            handle = writer.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (writer) returned 0";
                return(result);
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with writer handle incorrect";
                return(result);
            }
            handle = reader.InstanceHandle;
            if (handle == 0)
            {
                result.Result = "get_instance_handle (reader) returned 0";
                return(result);
            }
            if (!participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity with reader handle incorrect";
                return(result);
            }
            rc = participant.DeleteContainedEntities();
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_contained_entities failed.";
                return(result);
            }
            if (participant.ContainsEntity(handle))
            {
                result.Result = "contains_entity of deleted reader incorrect";
                return(result);
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result  = expResult;
            return(result);
        }
Exemple #26
0
        public override Test.Framework.TestResult Run()
        {
            string expResult = "register_typesupport tests pass";
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos participantQosHolder = null;
            DDS.IDomainParticipant participant;
            mod.tstTypeSupport typeSupport;
            mod.otherTypeTypeSupport otherTypeTypeSupport;
            DDS.ReturnCode rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory.get_instance() did not return a factory (1)";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref participantQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "factory.get_default_participant_qos() did not return a qos (2)";
                return result;
            }
            participant = factory.CreateParticipant(string.Empty, participantQosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "factory.create_participant() did not return a participant (2)";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            otherTypeTypeSupport = new mod.otherTypeTypeSupport();

            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register a type (3)";
                return result;
            }
            rc = typeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not register the same type a second time (4)";
                return result;
            }
            rc = otherTypeTypeSupport.RegisterType(participant, "type2");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could register a different type (5)";
                return result;
            }
            rc = otherTypeTypeSupport.RegisterType(participant, "type1");
            if (rc != DDS.ReturnCode.PreconditionNotMet)
            {
                result.Result = "Expected RETCODE_PRECONDITION_NOT_MET but recieved " + rc + " after calling register_type using an already used name for a different type (6)";
                return result;
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "could not delete a participant (7)";
                return result;
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #27
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant       participant;
            mod.tstTypeSupport           typeSupport;
            DDS.TopicQos              topicQos = null;
            DDS.ITopic                topic;
            DDS.DomainParticipantQos  pqos = null;
            DDS.ReturnCode            rc;
            Test.Framework.TestResult result;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict.Pass,
                                                   Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return(result);
            }

            if (factory.GetDefaultParticipantQos(ref pqos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return(result);
            }
            participant = factory.CreateParticipant(string.Empty, pqos);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return(result);
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return(result);
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "register_type failed.";
                return(result);
            }

            if (participant.GetDefaultTopicQos(ref topicQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "participant.get_default_topic_qos failed.";
                return(result);
            }
            topic = participant.CreateTopic("my_topic", "my_type", topicQos);//, null, 0);
            if (topic == null)
            {
                result.Result = "participant.create_topic failed.";
                return(result);
            }
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqos);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            result.Result  = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Exemple #28
0
        public override Test.Framework.TestResult Run(Test.Framework.TestCase testCase)
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
			DDS.DomainParticipantQos pqosHolder = null;
			DDS.TopicQos topQosHolder = null;
            DDS.ITopic topic;
            mod.tstTypeSupport typeSupport = null;
            Test.Framework.TestResult result;
            string name;
            string typeName;
            DDS.ReturnCode rc;
            result = new Test.Framework.TestResult("Initialization success", string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                return result;
            }
            name = "my_topic";
            typeName = "my_type";
            rc = typeSupport.RegisterType(participant, typeName);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                return result;
            }
            topic = participant.CreateTopic(name, typeName, topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                return result;
            }
            testCase.RegisterObject("factory", factory);
            testCase.RegisterObject("participantQos", pqosHolder);
            testCase.RegisterObject("participant", participant);
            testCase.RegisterObject("topic", topic);
            testCase.RegisterObject("topicQos", topQosHolder);
            testCase.RegisterObject("typeSupport", typeSupport);
            testCase.RegisterObject("topicName", name);
            testCase.RegisterObject("topicTypeName", typeName);
            result.Result = "Initialization success.";
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Exemple #29
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            DDS.IDomainParticipant participant;
            DDS.IDomainParticipant participant2;
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos qos = null;
            string expResult = "Topic test succeeded.";
            DDS.TopicQos topQosHolder1 = null;
            DDS.TopicQos topQosHolder2 = null;
            mod.tstTypeSupport typeSupport;
            DDS.ITopic topic;
            DDS.ITopic topic2;
            DDS.ITopic topic3;
            DDS.ITopic topic4;
            DDS.ITopicDescription description;
            DDS.ReturnCode returnCode;
            factory = (DDS.DomainParticipantFactory)this.ResolveObject("factory");
            qos = (DDS.DomainParticipantQos)this.ResolveObject("participantQos");
            participant = (DDS.IDomainParticipant)this.ResolveObject("participant");
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            typeSupport = new mod.tstTypeSupport();
            typeSupport.RegisterType(participant, "My_Type");

            if (participant.GetDefaultTopicQos(ref topQosHolder1) != DDS.ReturnCode.Ok)
            {
                result.Result = "Get default TopicQos failed (1).";
                return result;
            }
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, test.sacs.QosComparer.defaultTopicQos))
            {
                result.Result = "Get default TopicQos did not return the default qos (1).";
                return result;
            }
            topQosHolder1.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topQosHolder1.Liveliness.Kind = DDS.LivelinessQosPolicyKind.AutomaticLivelinessQos;
            topQosHolder1.Reliability.Kind = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topQosHolder1.DestinationOrder.Kind = DDS.DestinationOrderQosPolicyKind.ByReceptionTimestampDestinationorderQos;
            topQosHolder1.History.Kind = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            topQosHolder1.Ownership.Kind = DDS.OwnershipQosPolicyKind.SharedOwnershipQos;
            typeSupport = new mod.tstTypeSupport();
            returnCode = typeSupport.RegisterType(participant, "myTopicType");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }
            topic = participant.CreateTopic("MyDCPSTopic", "myTopicType", topQosHolder1);//, null, 0);
            if (topic == null)
            {
                result.Result = "Create topic failed (3)";
                return result;
            }
            description = participant.LookupTopicDescription("MyDCPSTopic");
            if (topic != description)
            {
                result.Result = "Lookup topic failed (4)";
                return result;
            }
            topic2 = participant.FindTopic("MyDCPSTopic", new DDS.Duration());
            if (topic2 == null)
            {
                result.Result = "Find topic failed (5)";
                return result;
            }
            topic2.GetQos(ref topQosHolder2);
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, topQosHolder2))
            {
                result.Result = "Find Topic did not find the correct Topic. (5)";
                return result;
            }
            topic3 = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic3 != null)
            {
                result.Result = "Create Topic with BAD_PARAM succeeded (6).";
                return result;
            }
            topic4 = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic4 != null)
            {
                result.Result = "Create Topic with BAD_PARAM succeeded (7).";
                return result;
            }
            returnCode = participant.DeleteTopic(topic3);
            if (returnCode != DDS.ReturnCode.BadParameter)
            {
                result.Result = "Expected RETCODE_BAD_PARAMETER but received " + returnCode + " after deleting a non exisiting topic (8).";
                return result;
            }
            returnCode = participant.DeleteTopic(topic4);
            if (returnCode != DDS.ReturnCode.BadParameter)
            {
                result.Result = "Expected RETCODE_BAD_PARAMETER but received " + returnCode + " after deleting a non exisiting topic (9).";
                return result;
            }
            participant2 = factory.CreateParticipant(string.Empty, qos);//, null, 0);
            if (participant2 == null)
            {
                result.Result = "Create Participant failed (10).";
                return result;
            }
            returnCode = participant2.DeleteTopic(topic);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic on wrong Participant succeeded (11).";
                return result;
            }
            returnCode = factory.DeleteParticipant(participant2);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Participant failed (12).";
                return result;
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed (13).";
                return result;
            }
            returnCode = participant.DeleteTopic(topic2);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed (14).";
                return result;
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete of already deleted Topic succeeded (15).";
                return result;
            }
            returnCode = participant.DeleteTopic(null);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Delete null Topic succeeded (16).";
                return result;
            }
            returnCode = participant.IgnoreParticipant(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid participant succeeded.";
                return result;
            }
            returnCode = participant.IgnorePublication(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid publication succeeded.";
                return result;
            }
            returnCode = participant.IgnoreSubscription(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid subscription succeeded.";
                return result;
            }
            returnCode = participant.IgnoreTopic(-10);
            if (returnCode == DDS.ReturnCode.Ok)
            {
                result.Result = "Ignore invalid topic succeeded.";
                return result;
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result = expResult;
            return result;
        }
Exemple #30
0
        public override Test.Framework.TestResult Run()
        {
            DDS.DomainParticipantFactory factory;
            DDS.IDomainParticipant participant;
			DDS.DomainParticipantQos pqosHolder = null;
			DDS.TopicQos topQosHolder = null;
            DDS.ITopic topic;
            mod.tstTypeSupport typeSupport = null;
            mod.tstDataReader datareader;
            test.sacs.MyDataReaderListener listener;
            DDS.ISubscriber subscriber;
			DDS.SubscriberQos sqosHolder = null;
			DDS.DataReaderQos dqosHolder = null;
            DDS.IPublisher publisher;
			DDS.PublisherQos pubQosHolder = null;
            mod.tstDataWriter datawriter;
			DDS.DataWriterQos wqosHolder = null;
            Test.Framework.TestResult result;
            DDS.ReturnCode rc;
            string expResult = "DataReaderListener test succeeded.";
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                .Pass, Test.Framework.TestVerdict.Fail);
            factory = DDS.DomainParticipantFactory.Instance;
            if (factory == null)
            {
                result.Result = "DomainParticipantFactory could not be initialized.";
                return result;
            }

            if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DomainParticipantQos could not be resolved.";
                return result;
            }
            participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0);
            if (participant == null)
            {
                result.Result = "Creation of DomainParticipant failed.";
                return result;
            }
            typeSupport = new mod.tstTypeSupport();
            if (typeSupport == null)
            {
                result.Result = "Creation of tstTypeSupport failed.";
                this.Cleanup(factory, participant);
                return result;
            }
            rc = typeSupport.RegisterType(participant, "my_type");
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (participant.GetDefaultTopicQos(ref topQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default TopicQos could not be resolved.";
                this.Cleanup(factory, participant);
                return result;
            }
            topQosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topic = participant.CreateTopic("my_topic_t", "my_type", topQosHolder);//, null, 0);
            if (topic == null)
            {
                result.Result = "Topic could not be created.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default PublisherQos could not be resolved.";
                this.Cleanup(factory, participant);
                return result;
            }
            publisher = participant.CreatePublisher(pubQosHolder);//, null, 0);
            if (publisher == null)
            {
                result.Result = "Publisher could not be created.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (publisher.GetDefaultDataWriterQos(ref wqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataWriterQos could not be resolved.";
                this.Cleanup(factory, participant);
                return result;
            }
            wqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            datawriter = (mod.tstDataWriter)publisher.CreateDataWriter(topic, wqosHolder);//, null, 0);
            if (datawriter == null)
            {
                result.Result = "DataWriter could not be created.";
                this.Cleanup(factory, participant);
                return result;
            }
            mod.tst t = new mod.tst();
            t.long_1 = 1;
            t.long_2 = 2;
            t.long_3 = 3;

            rc = datawriter.Write(t, DDS.InstanceHandle.Nil);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Data could not be written.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (participant.GetDefaultSubscriberQos(ref sqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default SubscriberQos could not be resolved.";
                this.Cleanup(factory, participant);
                return result;
            }
            subscriber = participant.CreateSubscriber(sqosHolder);//, null, 0);
            if (subscriber == null)
            {
                result.Result = "Subscriber could not be created.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (subscriber.GetDefaultDataReaderQos(ref dqosHolder) != DDS.ReturnCode.Ok)
            {
                result.Result = "Default DataReaderQos could not be resolved.";
                this.Cleanup(factory, participant);
                return result;
            }
            dqosHolder.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            listener = new test.sacs.MyDataReaderListener();
            datareader = (mod.tstDataReader)subscriber.CreateDataReader(topic, dqosHolder, listener, DDS.StatusKind.Any);
            if (datareader == null)
            {
                result.Result = "DataReader could not be created.";
                this.Cleanup(factory, participant);
                return result;
            }
            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e);
            }
            if (!listener.onLivelinessChangedCalled)
            {
                result.Result = "on_liveliness_changed does not work properly.";
                this.Cleanup(factory, participant);
                return result;
            }

            if (!listener.onDataAvailableCalled)
            {
                result.Result = "on_data_available does not work properly.";
                this.Cleanup(factory, participant);
                return result;
            }
            rc = participant.DeleteContainedEntities();
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete contained entities failed.";
                this.Cleanup(factory, participant);
                return result;
            }
            rc = factory.DeleteParticipant(participant);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete DomainParticipant failed.";
                return result;
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            DDS.IDomainParticipant participant;
            DDS.DomainParticipantFactory factory;
            DDS.DomainParticipantQos qos;
            string expResult = "Default topicQos is used when TOPIC_QOS_DEFAULT is specified.";
            DDS.TopicQos topQosHolder1;
            DDS.TopicQos topQosHolder2;
            mod.tstTypeSupport typeSupport;
            DDS.ITopic topic;
            DDS.ReturnCode returnCode;
            factory = (DDS.DomainParticipantFactory)this.ResolveObject("factory");
            qos = (DDS.DomainParticipantQos)this.ResolveObject("participantQos");
            participant = (DDS.IDomainParticipant)this.ResolveObject("participant");
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            typeSupport = new mod.tstTypeSupport();
            topQosHolder1 = new DDS.TopicQos();
            topQosHolder2 = new DDS.TopicQos();
            typeSupport.RegisterType(participant, "My_Type");

            if (participant.GetDefaultTopicQos(ref topQosHolder1) != DDS.ReturnCode.Ok)
            {
                result.Result = "Get default TopicQos failed (1).";
                return result;
            }

            topQosHolder1.Durability.Kind = DDS.DurabilityQosPolicyKind.TransientDurabilityQos;
            topQosHolder1.Liveliness.Kind = DDS.LivelinessQosPolicyKind.AutomaticLivelinessQos;
            topQosHolder1.Reliability.Kind = DDS.ReliabilityQosPolicyKind.ReliableReliabilityQos;
            topQosHolder1.DestinationOrder.Kind = DDS.DestinationOrderQosPolicyKind.ByReceptionTimestampDestinationorderQos;
            topQosHolder1.History.Kind = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            topQosHolder1.Ownership.Kind = DDS.OwnershipQosPolicyKind.SharedOwnershipQos;
            participant.SetDefaultTopicQos(topQosHolder1);
            typeSupport = new mod.tstTypeSupport();
            returnCode = typeSupport.RegisterType(participant, "myTopicType");
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Register type failed.";
                return result;
            }
            topic = participant.CreateTopic("MyDCPSTopic", "myTopicType");
            if (topic == null)
            {
                result.Result = "Create topic failed.";
                return result;
            }
            topic.GetQos(ref topQosHolder2);
            if (!test.sacs.QosComparer.TopicQosEquals(topQosHolder1, topQosHolder2))
            {
                result.Result = "Default topicQos is not used when TOPIC_QOS_DEFAULT is specified.";
                return result;
            }
            returnCode = participant.DeleteTopic(topic);
            if (returnCode != DDS.ReturnCode.Ok)
            {
                result.Result = "Delete Topic failed.";
                return result;
            }
            result.Verdict = Test.Framework.TestVerdict.Pass;
            result.Result = expResult;
            return result;
        }