Ejemplo n.º 1
0
	    private void runTests() {
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_001","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when no samples available");
	        tfw.TestPurpose ("Check that the read returns NO_DATA");
	
	        if ( reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.NoData ) {
	                tfw.TestResult("result == NO_DATA",
	                                   "result == NO_DATA", TestVerdict.Pass,TestVerdict.Pass);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = writeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_002","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when one sample per instance is available");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        {
	            selectSamples(fieldValueGreaterOrEqual, 0);
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_003","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data second time when one sample per instance is available");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = writeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_004","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when two samples per instance are available");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int j = 0; proceed && (j < MAX_DEPTH); j++ ) {
	                for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                    result = writeSample(writer, testData[i]);
	                    if ( result == ReturnCode.Ok ) {
	                        testData[i].long_2++;
	                        testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                    } else {
	                        proceed = false;
	                    }
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_005","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when a number of samples per instance is available");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        {
	            selectSamples(fieldValueLessOrEqual, 5);
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_006","tc_sampleinfo","DataReader.read_w_condition");
	        tfw.TestTitle ("read a selection of the samples using a query condition");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            string[] prms = new string[0];
	            IQueryCondition query;
	
	            query = reader.CreateQueryCondition(SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any, "long_3 <= 5", prms);
	            if ( query != null) {
	                result = reader.ReadWithCondition(ref dataList, ref infoList, Length.Unlimited, query);
	                if ( result == ReturnCode.Ok ) {
	                    if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                        tfw.TestResult("received data and sampleinfo is correct",
	                                           "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                    } else {
	                        tfw.TestResult("received data and sampleinfo is correct",
	                                           "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                    }
	                    markRead(dataList, dataList.Length);
	                    reader.ReturnLoan(ref dataList, ref infoList);
	                } else {
	                    reportResultCode(result);
	                    tfw.TestResult("result == NO_DATA",
	                                       "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                reader.DeleteReadCondition(query);
	            } else {
	                tfw.TestResult("create query succeeded",
	                                   "create query failed", TestVerdict.Pass,TestVerdict.Fail);
	             }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = disposeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_007","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances are disposed");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        {
	            selectSamples(fieldValueLessOrEqual, 5);
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_008","tc_sampleinfo","DataReader.read_w_condition");
	        tfw.TestTitle ("read a selection of the samples using a query condition when the instances are not ALIVE");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            string[] prms = new string[0];
	            IQueryCondition query;
	
	            query = reader.CreateQueryCondition(SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any, "long_3 <= 5", prms);
	            if ( query != null) {
	                result = reader.ReadWithCondition(ref dataList, ref infoList, Length.Unlimited, query);
	                if ( result == ReturnCode.Ok ) {
	                    if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                        tfw.TestResult("received data and sampleinfo is correct",
	                                           "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                    } else {
	                        tfw.TestResult("received data and sampleinfo is correct",
	                                           "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                    }
	                    markRead(dataList, dataList.Length);
	                    reader.ReturnLoan(ref dataList, ref infoList);
	                } else {
	                    reportResultCode(result);
	                    tfw.TestResult("result == NO_DATA",
	                                       "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                reader.DeleteReadCondition(query);
	            } else {
	                tfw.TestResult("create query succeeded",
	                                   "create query failed", TestVerdict.Pass,TestVerdict.Fail);
	             }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = writeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_009","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances are alive again");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct",
	                                        TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct",
	                                        TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA",
	                                    TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",
	                                 TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        {
	            selectSamples(fieldValueLessOrEqual, 5);
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_010","tc_sampleinfo","DataReader.read_w_condition");
	        tfw.TestTitle ("read a selection of the samples using a query condition when the instances are alive");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            string[] prms = new string[0];
	            IQueryCondition query;
	
	            query = reader.CreateQueryCondition(SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any, "long_3 <= 5", prms);
	            if ( query != null) {
	                result = reader.ReadWithCondition(ref dataList, ref infoList, Length.Unlimited, query);
	                if ( result == ReturnCode.Ok ) {
	                    if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                        tfw.TestResult(
	                            "received data and sampleinfo is correct",
	                            "received data and sampleinfo is correct",
	                             TestVerdict.Pass,TestVerdict.Pass);
	                    } else {
	                        tfw.TestResult(
	                            "received data and sampleinfo is correct",
	                            "received data and sampleinfo is not correct",
	                             TestVerdict.Pass,TestVerdict.Fail);
	                    }
	                    markRead(dataList, dataList.Length);
	                    reader.ReturnLoan(ref dataList, ref infoList);
	                } else {
	                    reportResultCode(result);
	                    tfw.TestResult("result == NO_DATA",
	                                       "result != NO_DATA",
	                                        TestVerdict.Pass,TestVerdict.Fail);
	                }
	                reader.DeleteReadCondition(query);
	            } else {
	                tfw.TestResult("create query succeeded",
	                                   "create query failed",
	                                    TestVerdict.Pass,TestVerdict.Fail);
	             }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",
	                                 TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = disposeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_011","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances are alive again");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct",
	                                        TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct",
	                                        TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA",
	                                    TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",
	                                 TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = writeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_012","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances are alive again");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct",
	                                        TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct",
	                                        TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA",
	                                    TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",
	                                 TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( writer != null) {
	            result = publisher.DeleteDataWriter(writer);
	            writer = null;
	            if ( result == ReturnCode.Ok ) {
	                for ( int i = 0; i < MAX_INSTANCE; i++ ) {
	                    markNoWriter(i);
	                }
	            } else {
	                proceed = false;
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        } else {
	            proceed = false;
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_013","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances have become not_alive_no_writers again");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct",
	                                        TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct",
	                                        TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA",
	                                    TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",
	                                 TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	        /**************************************************************************/
	        if ( proceed ) {
	            writer = publisher.CreateDataWriter(topic, dwQos, null, 0) as tstDataWriter;
	            if ( writer == null) {
	                proceed = false;
	            }
	        }
	
	        if ( writer != null) {
	            for ( int i = 0; proceed && (i < MAX_INSTANCE); i++ ) {
	                result = writeSample(writer, testData[i]);
	                if ( result == ReturnCode.Ok ) {
	                    testData[i].long_2++;
	                    testData[i].long_3 = testData[i].long_2 % MAX_DEPTH;
	                } else {
	                    proceed = false;
	                }
	            }
	            if ( proceed ) {
	                selectSamples(fieldValueGreaterOrEqual, 0);
	            }
	        }
	
	        /**************************************************************************/
	        tfw.TestStart ("sacs_sampleinfo_014","tc_sampleinfo","DataReader.read");
	        tfw.TestTitle ("read data when the instances are alive again");
	        tfw.TestPurpose ("Check that the read returns the correct SampleInfo");
	
	        if ( proceed && reader != null) {
	            result = reader.Read(ref dataList, ref infoList, Length.Unlimited);
	            if ( result == ReturnCode.Ok ) {
	                if ( checkReceivedInstanceSample(dataList, infoList, dataList.Length) ) {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is correct", TestVerdict.Pass,TestVerdict.Pass);
	                } else {
	                    tfw.TestResult("received data and sampleinfo is correct",
	                                       "received data and sampleinfo is not correct", TestVerdict.Pass,TestVerdict.Fail);
	                }
	                markRead(dataList, dataList.Length);
	                reader.ReturnLoan(ref dataList, ref infoList);
	            } else {
	                reportResultCode(result);
	                tfw.TestResult("result == NO_DATA",
	                                   "result != NO_DATA", TestVerdict.Pass,TestVerdict.Fail);
	            }
	         } else {
	            tfw.TestResult ("precondition ok",
	                                "precondition failed",TestVerdict.Unresolved,TestVerdict.Unresolved);
	        }
	
	        tfw.TestFinish();
	
	    }
Ejemplo n.º 2
0
	    private ReturnCode disposeSample (ItstDataWriter writer, tst data)
	    {
	        ReturnCode result;
	
	        result = writer.Dispose(data, InstanceHandle.Nil);
	
	        if ( result == ReturnCode.Ok ) {
	            markDisposed(data.long_1);
	        }
	        return result;
	    }
Ejemplo n.º 3
0
	    private void init()
	    {
	        tstTypeSupport typeSupport;
	        string errMsg = "Unknown error";
	        
	        for ( int i = 0; i < MAX_INSTANCE; i++ ) {
	            testData[i] = new tst();
	            testData[i].long_1 = i;
	            testData[i].long_2 = 0;
	            testData[i].long_3 = 0;
	        }
	        initialiseInstanceData();
	
	        
	        /**
	         * @addtogroup group_dds1290
	         *
	         * \b Test \b ID: \b saj_invalid_data_000
	         *
	         * \b Test \b Objectives:
	         *
	         * Create and initialise all required DDS entities
	         *
	         * \b Test \b Procedure:
	         *
	         * \e Action
	         *
	         * The following entities are obtained/created
	         * \arg \c DomainParticipantFactory
	         * \arg \c DomainParticipant with default QoS settings
	         * \arg \c Publisher with default QoS settings
	         * \arg \c Subscriber with default QoS settings
	         * \arg \c The mod::tst type is registered
	         * \arg \c A topic T1 of type tstModule::tst is created with default QoS settings
	         * \arg \c A DataWriter W for T1 with default QoS settings, writer_data_lifecycle.autodispose_unregistered_instances = FALSE
	         * \arg \c A DataReader for T1 with default QoS settings
	         *
	         * \e Result
	         * It is expected that all entities are created/initialized correctly and without any failures. \n
	         * If a failure occurs at any of the above stages, the test fails, this is reported and no further testing is performed
	         */
	        /*- INITIALIZATION ---------------------------------------------------------*/
	        tfw.TestStart ("sacs_sampleInfo_000","SampleInfo","initialization");
	        tfw.TestTitle ("Test SampleInfo initialization.");
	        tfw.TestPurpose ("Test SampleInfo initialization.");
	
	        factory = DomainParticipantFactory.Instance;
	        
	        if(factory == null){
	            errMsg = "DomainParticipantFactory could NOT be resolved";
	            proceed = false;
	        } else {
	            participant = factory.CreateParticipant(domainId);
	
	            if(participant == null){
	                errMsg = "DomainParticipant could NOT be created";
	                proceed = false;
	            } else {
	                typeSupport = new tstTypeSupport();
	
	                result = typeSupport.RegisterType(participant, "tst");
	                if(result == ReturnCode.Ok){
	                    topic = participant.CreateTopic("my_topic", "tst");
	
	                    if(topic != null){
	                        subscriber = participant.CreateSubscriber();
	
	                        if(subscriber != null){
	                            subscriber.GetDefaultDataReaderQos(ref drQos);
	                            
	                            if(drQos != null){
	                                drQos.History.Kind  = HistoryQosPolicyKind.KeepLastHistoryQos;
	                                drQos.History.Depth = MAX_DEPTH;
	                                reader = subscriber.CreateDataReader(topic, drQos) as tstDataReader;
	    
	                                if(reader != null){
	                                    publisher = participant.CreatePublisher();
	    
	                                    if(publisher != null){
	                                        result = publisher.GetDefaultDataWriterQos(ref dwQos);
	                                        if(dwQos != null && result == ReturnCode.Ok){
	                                            dwQos.WriterDataLifecycle.AutodisposeUnregisteredInstances = false;
	                                            writer = publisher.CreateDataWriter(topic, dwQos) as tstDataWriter;
	                                            if(writer == null){
	                                                errMsg = "DataWriter could NOT be created";
	                                                proceed = false;
	                                            }
	                                        } else {
	                                            reportResultCode(result);
	                                            errMsg = "Default DataWriterQos could NOT be retrieved";
	                                            proceed = false;
	                                        }
	                                    } else {
	                                        errMsg = "Publisher could NOT be created";
	                                        proceed = false;
	                                    }
	    
	                                } else {
	                                    errMsg = "DataReader could NOT be created";
	                                    proceed = false;
	                                }
	                            } else {
	                                errMsg = "Default DataReaderQos could not be resolved.";
	                                proceed = false;
	                            }
	                        } else {
	                            errMsg = "Subscriber could NOT be created";
	                            proceed = false;
	                        }
	                    } else {
	                        errMsg = "Topic could NOT be created";
	                        proceed = false;
	                    }
	                } else {
	                    errMsg = "Typesupport NOT loaded into DomainParticipant";
	                    proceed = false;
	                }
	            }
	        }
	        
	        if(proceed == true){
	            tfw.TestResult("Initialization OK", "Initialization OK", TestVerdict.Pass, TestVerdict.Pass);
	            tfw.TestFinish();
	        } else {
	            tfw.TestResult("Initialization OK", errMsg, TestVerdict.Pass, TestVerdict.Fail);
	            tfw.TestFinish();
	        }
	        /*- END OF INITIALIZATION --------------------------------------------------*/
	    }
Ejemplo n.º 4
0
	    private ReturnCode writeSample (ItstDataWriter writer, tst data)
	    {
	        ReturnCode result;
	
	        result = writer.Write(data, InstanceHandle.Nil);
	
	        if ( result == ReturnCode.Ok ) {
	            addSample(data);
	        }
	        return result;
	    }