diff options
author | Gokul Singaraju <gs244f@att.com> | 2018-03-23 02:19:09 -0400 |
---|---|---|
committer | Gokul Singaraju <gs244f@att.com> | 2018-03-23 02:21:20 -0400 |
commit | 628dd1bb98a25508f6fae41fe4ab249338abf53b (patch) | |
tree | 8ef91e810bc73f13f9598f23f4b3e74251ca64aa /veslibrary/ves_javalibrary/evel_javalib2 | |
parent | bb386b16dac2b9843625f7d7ad3b7b9efac17156 (diff) |
Increase coverage fix sonar issues
Issue-ID: VNFSDK-217
Change-Id: I74556357e52b534564476adf343f53a3453a96e5
Signed-Off-by: Gokul Singaraju <gs244f@att.com>
Diffstat (limited to 'veslibrary/ves_javalibrary/evel_javalib2')
6 files changed, 77 insertions, 27 deletions
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java index 7380d90..23a1b4d 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java @@ -252,8 +252,10 @@ public enum EVEL_ERR_CODES { try { Thread.sleep(5); } catch (InterruptedException e) { - logger.trace("Interrupted on "+url); - e.printStackTrace(); + Thread.currentThread().interrupt(); + logger.trace("Interrupted on "+url); + System.out.println("Interrupted on "+url); + //e.printStackTrace(); } } }//end for diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java index 6db25b5..9cc3d2b 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java @@ -43,7 +43,7 @@ public class EvelBatch { public EvelBatch(){
batch_events = new ArrayList<EvelHeader>();
- if( batch_events == null ) LOGGER.error("Unable to allocate new batch");
+ LOGGER.trace("Allocated new batch");
}
public boolean addEvent(EvelHeader element){
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelMobileFlow.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelMobileFlow.java index 339cb90..7a01dae 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelMobileFlow.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelMobileFlow.java @@ -449,6 +449,10 @@ public class EvelMobileFlow extends EvelHeader { /*****************************************************************************/
+ public EvelMobileFlow(String evname, String evid)
+ {
+ super(evname,evid);
+ }
/**************************************************************************//**
* Create a new Mobile Flow event.
*
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java index 8645427..1312eed 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java @@ -643,7 +643,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( cpu_usage == null ){
cpu_usage = new ArrayList<MEASUREMENT_CPU_USE>();
- if( cpu_usage == null)LOGGER.error("Unable to allocate new cpu usage");
+ LOGGER.debug("Allocate new cpu usage");
}
cpu_usage.add(cpu_use);
@@ -854,7 +854,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( mem_usage == null ){
mem_usage = new ArrayList<MEASUREMENT_MEM_USE>();
- if( mem_usage == null )LOGGER.error("Unable to allocate new memory usage");
+ LOGGER.debug("Allocated new memory usage");
}
@@ -1047,7 +1047,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( disk_usage == null ){
disk_usage = new ArrayList<MEASUREMENT_DISK_USE>();
- if( disk_usage == null ) LOGGER.error("Unable to allocate new disk usage");
+ LOGGER.debug("Unable to allocate new disk usage");
}
@@ -1862,7 +1862,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( filesystem_usage == null ){
filesystem_usage = new ArrayList<MEASUREMENT_FSYS_USE>();
- if( filesystem_usage == null )LOGGER.error("Unable to allocate new file system usage");
+ LOGGER.debug("Allocated new file system usage");
}
filesystem_usage.add(fsys_use);
@@ -1907,7 +1907,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( feature_usage == null ){
feature_usage = new ArrayList<MEASUREMENT_FEATURE_USE>();
- if( feature_usage == null )LOGGER.error("Unable to allocate new feature usage");
+ LOGGER.debug("Allocate new feature usage");
}
feature_usage.add(feature_use);
@@ -1988,9 +1988,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( additional_measurements == null){
LOGGER.debug("Creating new Measurement Group list"+group);
additional_measurements = new ArrayList<MEASUREMENT_GROUP>();
- if( additional_measurements == null ){
- LOGGER.error("Unable to allocate additional measurements ");
- }
+ LOGGER.debug("Allocate additional measurements ");
}
additional_measurements.add(measurement_group);
}
@@ -2039,7 +2037,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( codec_usage == null ){
codec_usage = new ArrayList<MEASUREMENT_CODEC_USE>();
- if( codec_usage == null )LOGGER.error("Unable to allocate new codec usage");
+ LOGGER.debug("Allocated new codec usage");
}
codec_usage.add(codec_use);
@@ -2219,7 +2217,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( latency_distribution == null ){
latency_distribution = new ArrayList<MEASUREMENT_LATENCY_BUCKET>();
- if( latency_distribution == null )LOGGER.error("Unable to allocate new file system usage");
+ LOGGER.debug("Allocate new file system usage");
}
latency_distribution.add(bucket);
@@ -3146,7 +3144,7 @@ public class EvelScalingMeasurement extends EvelHeader { if( vnic_usage == null ){
vnic_usage = new ArrayList<MEASUREMENT_VNIC_PERFORMANCE>();
- if( vnic_usage == null )LOGGER.error("Unable to allocate new file system usage");
+ LOGGER.debug("Allocate new file system usage");
}
vnic_usage.add(vnic_performance);
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/RingBuffer.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/RingBuffer.java index 144fc24..460e84a 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/RingBuffer.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/RingBuffer.java @@ -73,8 +73,7 @@ public class RingBuffer { spacesem.acquire();
lock.acquire();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
@@ -107,8 +106,7 @@ public class RingBuffer { spacesem.acquire();
lock.acquire();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
int readPos = 0;
@@ -178,8 +176,7 @@ public class RingBuffer { countsem.acquire();
lock.acquire();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
if(available == 0){
@@ -201,7 +198,7 @@ public class RingBuffer { }
- public int take(EvelObject[] into){
+ public int take(EvelObject[] into) {
return take(into, into.length);
}
@@ -214,8 +211,7 @@ public class RingBuffer { countsem.acquire();
lock.acquire();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
}
if(available <= writePos){
diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java index 24ce074..283d261 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java @@ -111,6 +111,9 @@ public class TestJunit { EVEL_VF_STATUSES.EVEL_VF_STATUS_ACTIVE); flt.evel_fault_addl_info_add("nichw", "fail"); flt.evel_fault_addl_info_add("nicsw", "fail"); + flt.evel_fault_category_set("intftype"); + flt.evel_fault_interface_set("eth0"); + flt.evel_fault_type_set("vmintf"); when(mymainmock.evel_post_event(flt)).thenReturn(true); boolean ret = mymainmock.evel_post_event(flt); LOG.info("Returned "+ret); @@ -146,8 +149,8 @@ public class TestJunit { EvelStateChange stc = new EvelStateChange("StateChange_vVNF", "vmname_ip", - EvelStateChange.EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_IN_SERVICE, - EvelStateChange.EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_OUT_OF_SERVICE,"bgp"); + EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_IN_SERVICE, + EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_OUT_OF_SERVICE,"bgp"); stc.evel_statechange_addl_info_add("bgpa", "fail"); stc.evel_statechange_addl_info_add("bgpb", "fail"); //AgentMain.evel_post_event(stc); @@ -216,6 +219,11 @@ public class TestJunit { "Router failed","JUNIPER"); sysl.evel_syslog_proc_id_set(456); sysl.evel_syslog_proc_set("routed"); + sysl.evel_syslog_type_set("named"); + sysl.evel_syslog_addl_filter_set("syslfilter"); + sysl.evel_syslog_event_source_host_set("vm2474"); + sysl.evel_syslog_facility_set(EvelSyslog.EVEL_SYSLOG_FACILITIES.EVEL_SYSLOG_FACILITY_LOCAL7); + sysl.evel_syslog_severity_set("Warning"); when(mymainmock.evel_post_event(sysl)).thenReturn(true); boolean ret = mymainmock.evel_post_event(sysl); @@ -227,18 +235,51 @@ public class TestJunit { public void testHtbtField() { EvelHeartbeatField hfld = new EvelHeartbeatField(123,"HeartbeatField_vVNF", "vmname_ip"); hfld.evel_hrtbt_interval_set(23); + hfld.evel_hrtbt_field_addl_info_add("bgpb", "fail"); + hfld.evel_hrtbt_interval_set(100); when(mymainmock.evel_post_event(hfld)).thenReturn(true); boolean ret = mymainmock.evel_post_event(hfld); LOG.info("Returned "+ret); assertTrue( ret ); } - + + + @Test + public void testEvelMobileFlow() { + EvelMobileFlow mf1 = new EvelMobileFlow("hello","there"); + EvelMobileFlow.MOBILE_GTP_PER_FLOW_METRICS gtp = mf1.new MOBILE_GTP_PER_FLOW_METRICS(12.0, 13.0, 1,2,3,4,5,6,7,new Date(), "mflow", 8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26); + mf1.gtp_per_flow_metrics = gtp; + + EvelMobileFlow mf = new EvelMobileFlow("MobileFlow_12", "MF_12345", "flowdir", gtp, "iptyp", + "ipv4", "ipendp", 100, "endpou",1234); + mf.evel_mobile_flow_addl_field_add("bgpb", "fail"); + mf.evel_mobile_flow_type_set("named"); + mf.evel_mobile_flow_app_type_set("named"); + + when(mymainmock.evel_post_event(mf)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(mf); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test public void testSipSignaling() { EvelSipSignaling sip = new EvelSipSignaling("SipSignaling_vVNF", "vmname_ip","aricent","corlator","127.0.0.1","5647","10.1.1.124","5678"); - + sip.evel_signaling_type_set("BVOIP"); + sip.evel_signaling_local_ip_address_set("1.2.3.4"); + sip.evel_signaling_local_port_set("446"); + sip.evel_signaling_remote_ip_address_set("1.2.3.4"); + sip.evel_signaling_remote_port_set("1446"); + sip.evel_signaling_vnfmodule_name_set("sipmc"); + sip.evel_signaling_vnfname_set("SIPVM"); + sip.evel_signaling_compressed_sip_set("comprsip"); + sip.evel_signaling_summary_sip_set("summsip"); + sip.evel_signaling_correlator_set("corl"); + sip.evel_signaling_addl_info_add("bgpb", "fail"); + when(mymainmock.evel_post_event(sip)).thenReturn(true); boolean ret = mymainmock.evel_post_event(sip); LOG.info("Returned "+ret); @@ -252,6 +293,15 @@ public class TestJunit { "callerSideCodc", "corlator", "midCllRtcp", "juniper"); vq.evel_voice_quality_end_metrics_set("adjname", "Caller", 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 15.1, 160.12, 170, 180, 190); + vq.evel_voice_quality_addl_info_add("bgpb", "fail"); + vq.evel_voice_quality_callee_codec_set("codec1"); + vq.evel_voice_quality_caller_codec_set("codec1"); + vq.evel_voice_quality_correlator_set("codec1"); + vq.evel_voice_quality_rtcp_data_set("codec1"); + vq.evel_voice_quality_vnfmodule_name_set("mod1"); + vq.evel_voice_quality_vnfname_set("mod1"); + vq.evel_voice_quality_phone_number_set("1234-567-8910"); + vq.evel_voice_quality_end_metrics_set("name","descr", 1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12,13.,14.,15.,16.,17.,18.,19.); when(mymainmock.evel_post_event(vq)).thenReturn(true); boolean ret = mymainmock.evel_post_event(vq); |