public override Test.Framework.TestResult Run() { DDS.IDomainParticipant participant; DDS.ITopic topic; DDS.IPublisher publisher; DDS.ISubscriber subscriber; mod.tstDataWriter writer; mod.tstDataReader reader; Test.Framework.TestResult result; test.sacs.Listener7.ListenerThread[] threads; string expResult = "Listener multithread test succeeded."; DDS.ReturnCode[] results; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass, Test.Framework.TestVerdict.Fail); participant = (DDS.IDomainParticipant) this.ResolveObject("participant"); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); topic = (DDS.ITopic) this.ResolveObject("topic"); publisher = (DDS.IPublisher) this.ResolveObject("publisher"); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); threads = new test.sacs.Listener7.ListenerThread[6]; int i = 0; threads[i] = new test.sacs.Listener7.ListenerThread(this, participant, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, writer, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, reader, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, topic, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, subscriber, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, publisher, i); for (int j = 0; j < threads.Length; j++) { threads[j].Start(); } results = new DDS.ReturnCode[threads.Length]; for (int j = 0; j < threads.Length; j++) { try { threads[j].Join(); results[j] = threads[j].GetResult(); } catch (System.Exception e) { result.Result = string.Format("Thread {0} could not be joined. Exception: {1}", j, e); return(result); } } for (int j = 0; j < results.Length; j++) { if (results[j] != DDS.ReturnCode.Ok) { result.Result = string.Format("Listener thread {0} failed.", j); return(result); } } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { DDS.IDomainParticipant participant; DDS.ITopic topic; DDS.IPublisher publisher; DDS.ISubscriber subscriber; mod.tstDataWriter writer; mod.tstDataReader reader; Test.Framework.TestResult result; test.sacs.Listener7.ListenerThread[] threads; string expResult = "Listener multithread test succeeded."; DDS.ReturnCode[] results; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass, Test.Framework.TestVerdict.Fail); participant = (DDS.IDomainParticipant)this.ResolveObject("participant"); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); topic = (DDS.ITopic)this.ResolveObject("topic"); publisher = (DDS.IPublisher)this.ResolveObject("publisher"); subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber"); threads = new test.sacs.Listener7.ListenerThread[6]; int i = 0; threads[i] = new test.sacs.Listener7.ListenerThread(this, participant, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, writer, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, reader, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, topic, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, subscriber, i); i++; threads[i] = new test.sacs.Listener7.ListenerThread(this, publisher, i); for (int j = 0; j < threads.Length; j++) { threads[j].Start(); } results = new DDS.ReturnCode[threads.Length]; for (int j = 0; j < threads.Length; j++) { try { threads[j].Join(); results[j] = threads[j].GetResult(); } catch (System.Exception e) { result.Result = string.Format("Thread {0} could not be joined. Exception: {1}", j, e); return result; } } for (int j = 0; j < results.Length; j++) { if (results[j] != DDS.ReturnCode.Ok) { result.Result = string.Format("Listener thread {0} failed.", j); return result; } } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }