test monitor

test monitor
This commit is contained in:
liuchongrui 2014-09-25 17:10:14 +08:00
parent 2117b42e2e
commit 401c3b16d6
3 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package org.bench4q.monitor;
import java.util.List;
import org.bench4q.monitor.model.LimitableFieldsModel;
import org.junit.Test;
public class Test_LimitableFieldsModel {
@Test
public void testLimitableFieldsModelGet(){
LimitableFieldsModel limitList = new LimitableFieldsModel();
List<String> result = limitList.getFields();
for (int i = 0; i < result.size(); i++){
System.out.println(result.get(i).toString());
}
}
}

View File

@ -0,0 +1,20 @@
package org.bench4q.monitor;
import static org.junit.Assert.*;
import org.bench4q.monitor.model.MonitorMain;
import org.hyperic.sigar.SigarException;
import org.junit.Test;
public class Test_MonitorMain {
@Test
public void testContructMonitorMainWithNull() {
MonitorMain result = null;
try {
result = new MonitorMain(null);
} catch (SigarException e) {
e.printStackTrace();
}
assertNotNull(result);
}
}

View File

@ -0,0 +1,42 @@
package org.bench4q.monitor.controler;
import java.util.ArrayList;
import java.util.List;
import org.bench4q.monitor.model.LimitModel;
import org.bench4q.monitor.model.MonitorMain;
import org.hyperic.sigar.SigarException;
import org.junit.Assert;
import org.junit.Test;
public class Test_MainControler {
@Test
public void testSubmitLimit() {
LimitModel.ParameterModel params1 = new LimitModel.ParameterModel();
LimitModel.ParameterModel params2 = new LimitModel.ParameterModel();
LimitModel.ParameterModel params3 = new LimitModel.ParameterModel();
LimitModel.ParameterModel params4 = new LimitModel.ParameterModel();
params1.setName("memoryUsedPercent");
params1.setLimit(100);
params2.setName("processorTimePercent");
params2.setLimit(10);
params3.setName("userTimePercent");
params3.setLimit(100);
params4.setName("privilegedTimePercent");
params4.setLimit(100);
List<LimitModel.ParameterModel> list = new ArrayList<LimitModel.ParameterModel>();
list.add(params1);
list.add(params2);
list.add(params3);
list.add(params4);
LimitModel limits = new LimitModel();
limits.setParams(list);
MonitorMain result = null;
try {
result = new MonitorMain(limits);
} catch (SigarException e) {
e.printStackTrace();
}
Assert.assertEquals(false,result.getIsReachLimit());
}
}