From 5c9f35be7e7895ebab79e805aabd60a29b42d476 Mon Sep 17 00:00:00 2001
From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
Date: Thu, 12 Oct 2017 11:58:13 +0200
Subject: [PATCH] Correction of TC_CSE_SUB_NTF_003 to use batchNotify/duration

Signed-off-by: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
---
 LibOneM2M/OneM2M_Templates.ttcn |  4 ++--
 OneM2M_Testcases.ttcn           | 19 +++++++++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn
index 05ba96a..cab7b81 100644
--- a/LibOneM2M/OneM2M_Templates.ttcn
+++ b/LibOneM2M/OneM2M_Templates.ttcn
@@ -1564,9 +1564,9 @@ module OneM2M_Templates {
 			notificationEventType_list := p_notificationEventType_list// TODO this list should be able to be omited see 9.6.8 (TS0001)
 		};
         
-		template (value) BatchNotify m_batchNotify (in XSD.NonNegativeInteger p_number) := {
+		template (value) BatchNotify m_batchNotify (in XSD.NonNegativeInteger p_number, in XSD.Duration p_duration := "PT20S") := {
 			number := p_number,
-			duration := "PT5S" //TODO duration has to be set to 1s and match to the Duration regex 
+			duration := p_duration //TODO duration has to be set to 1s and match to the Duration regex 
 		};
 		//normaly duration can be omited
 		
diff --git a/OneM2M_Testcases.ttcn b/OneM2M_Testcases.ttcn
index dc2becd..2a9cf10 100644
--- a/OneM2M_Testcases.ttcn
+++ b/OneM2M_Testcases.ttcn
@@ -18,6 +18,7 @@ module OneM2M_Testcases {
 	import from OneM2M_Types all;//{type XSD.ID};
 	import from OneM2M_TypesAndValues all;
 	import from OneM2M_Pixits all;
+	import from LibCommon_Time all;
 	import from OneM2M_Pics all;
 	import from OneM2M_Functions all;
 	import from XSD all;
@@ -18111,7 +18112,9 @@ module OneM2M_Testcases {
 				 */
 				testcase TC_CSE_SUB_NTF_003() runs on AeSimu system CseSystem {
 					// Local variables
-					const integer numberOfAggregatedNotification := 2;
+					timer t_batchNotificationTimer := PX_TAC * 2.0;
+					var float v_elapsedTime;
+					const integer c_numberOfAggregatedNotification := 2;
 					var Labels v_labels_1:= {"VALUE_1"};
 					var Labels v_labels_2:= {"VALUE_2"};
 					var integer v_aeIndex := -1;
@@ -18136,7 +18139,7 @@ module OneM2M_Testcases {
 					
 					f_cse_preamble_subscriptionVerification(v_ae2Index, v_createRequest, int23);
 					
-					v_createRequest := m_createSubscriptionAdvanced(f_getResourceAddress(v_aeIndex), -, {f_getResourceAddress(v_ae2Index)},omit,omit,m_batchNotify(numberOfAggregatedNotification), omit, omit, -, int2);
+					v_createRequest := m_createSubscriptionAdvanced(f_getResourceAddress(v_aeIndex), -, {f_getResourceAddress(v_ae2Index)},omit,omit,m_batchNotify(c_numberOfAggregatedNotification + 1, "PT10S" ), omit, omit, -, int2);//batchNotify/number greater than number of notifications to be sent so that batchNotify/duration expires before
 
 					v_resourceIndex := f_cse_createResource(int23, v_createRequest, v_aeIndex);//Subscription
 					
@@ -18145,18 +18148,26 @@ module OneM2M_Testcases {
 					};
 
 					// Test Body
-					vc_ae2.start(f_cse_notifyProcedure_aggregatedNoficationHandler(v_contentResponse, 2)); // check that no notification is received
+					vc_ae2.start(f_cse_notifyProcedure_aggregatedNoficationHandler(v_contentResponse, c_numberOfAggregatedNotification)); 
 
 					v_updateRequest.primitiveContent.aE.labels := v_labels_1;
 					v_request:= f_getUpdateRequestPrimitive(int2, v_aeIndex, v_updateRequest); // Update request 1
 					f_cse_updateResource(v_request);
+					t_batchNotificationTimer.start;					
 					
 					v_updateRequest := m_updateAeBase;
-					v_updateRequest.requestIdentifier := "m_updateAe" & f_rnd(1, 1000000);
 					v_updateRequest.primitiveContent.aE.appName := "MyAppName2"; 
 					v_request:= f_getUpdateRequestPrimitive(int2, v_aeIndex, v_updateRequest); // Update request 2
 					f_cse_updateResource(v_request);
 
+					vc_ae2.done;
+					v_elapsedTime := t_batchNotificationTimer.read;
+					t_batchNotificationTimer.stop;		
+					
+					if(v_elapsedTime < 10.0) {
+						setverdict(fail, __SCOPE__ & ": Notifications sent before bathNotify/duration expired");
+					}
+					
 					f_checkComponentDoneAndGetVerdict(vc_ae2);
 
 					//Postamble
-- 
GitLab