package org.bench4q.master.integrated;

import static org.junit.Assert.*;

import org.bench4q.master.infrastructure.communication.impl.MonitorMessengerImpl;
import org.bench4q.share.models.monitor.MemoryModel;
import org.bench4q.share.models.monitor.MonitorMain;
import org.bench4q.share.models.monitor.NetworkInterfaceModel;
import org.bench4q.share.models.monitor.PhysicalDiskModel;
import org.bench4q.share.models.monitor.ProcessModel;
import org.bench4q.share.models.monitor.ProcessorModel;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
public class Test_MonitorMessenger {
	private static final int PORT = 5556;
	private static final String SUT_HOST_NAME = "133.133.12.3";
	private MonitorMessengerImpl monitorService;

	private MonitorMessengerImpl getMonitorService() {
		return monitorService;
	}

	@Autowired
	private void setMonitorService(MonitorMessengerImpl monitorService) {
		this.monitorService = monitorService;
	}

	@Test
	public void test() {
		assertNotNull(this.getMonitorService());
	}

	@Test
	public void testphysicalDisk() {
		PhysicalDiskModel logicalDiskModel = this.getMonitorService()
				.physicalDisk(SUT_HOST_NAME, 5556);
		assertNotNull(logicalDiskModel);
		assertNotNull(logicalDiskModel.getSamplingTime());
	}

	@Test
	public void testMemory() {
		MemoryModel memoryModel = this.getMonitorService().memory(
				SUT_HOST_NAME, PORT);
		assertNotNull(memoryModel);
		assertNotNull(memoryModel.getSamplingTime());
	}

	@Test
	public void tesProcessor() {
		ProcessorModel processorModel = this.getMonitorService().processor(
				SUT_HOST_NAME, PORT);
		assertNotNull(processorModel);
		assertNotNull(processorModel.getSamplingTime());
	}

	@Test
	public void testNetworkInterface() {
		NetworkInterfaceModel networkInterfaceModel = this.getMonitorService()
				.networkInterface(SUT_HOST_NAME, PORT);
		assertNotNull(networkInterfaceModel);
		assertNotNull(networkInterfaceModel.getSamplingTime());
	}
	@Test
	public void testMonitorModel(){
		MonitorMain monitorMain=this.getMonitorService().monitorModel(SUT_HOST_NAME, PORT);
		assertNotNull(monitorMain);
	}
	@Test
	public void testProcess(){
		ProcessModel processModel=this.getMonitorService().process(SUT_HOST_NAME, PORT);
		assertNotNull(processModel);
	}

}
