ing
This commit is contained in:
parent
31fd84e984
commit
58bddae263
28
.vscode/launch.test.json
vendored
Normal file
28
.vscode/launch.test.json
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"run": {
|
||||
"default": "",
|
||||
"items": [
|
||||
{
|
||||
"name": "central",
|
||||
"projectName": "central",
|
||||
"workingDirectory": "/project/loafle/overflow/central",
|
||||
"args": [],
|
||||
"vmargs": [],
|
||||
"preLaunchTask": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"debug": {
|
||||
"default": "",
|
||||
"items": [
|
||||
{
|
||||
"name": "central",
|
||||
"projectName": "central",
|
||||
"workingDirectory": "/project/loafle/overflow/central",
|
||||
"args": [],
|
||||
"vmargs": [],
|
||||
"preLaunchTask": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -122,8 +122,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
|
|||
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 1));
|
||||
this.noAuthProbeDAO.save(noAuthProbe);
|
||||
|
||||
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Accept",
|
||||
probe.getProbeKey());
|
||||
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Accept", probe.getProbeKey());
|
||||
|
||||
return this.readAllByDomainID(noAuthProbe.getDomain().getId());
|
||||
}
|
||||
|
|
|
@ -1,164 +1,154 @@
|
|||
// package com.loafle.overflow.central.module.noauthprobe.service;
|
||||
package com.loafle.overflow.central.module.noauthprobe.service;
|
||||
|
||||
// import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||
// import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
// import com.loafle.overflow.core.exception.OverflowException;
|
||||
// import com.loafle.overflow.model.domain.Domain;
|
||||
// import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
|
||||
// import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||
// import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
|
||||
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.domain.Domain;
|
||||
import com.loafle.overflow.model.meta.MetaNoAuthProbeStatus;
|
||||
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
|
||||
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
|
||||
|
||||
// import org.junit.Assert;
|
||||
// import org.junit.Ignore;
|
||||
// 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;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
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;
|
||||
|
||||
// import java.io.IOException;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// /**
|
||||
// * Created by snoop on 17. 6. 28.
|
||||
// */
|
||||
// @RunWith(SpringJUnit4ClassRunner.class)
|
||||
// @ContextConfiguration(classes = {AppConfigTest.class})
|
||||
// public class NoAuthProbeServiceTest {
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class NoAuthProbeServiceTest {
|
||||
|
||||
// @Autowired
|
||||
// private NoAuthProbeService noAuthProbeService;
|
||||
@Autowired
|
||||
private CentralNoAuthProbeService noAuthProbeService;
|
||||
|
||||
// @Autowired
|
||||
// private MessagePublisher messagePublisher;
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void regist() throws Exception {
|
||||
@Ignore
|
||||
@Test
|
||||
public void regist() throws Exception {
|
||||
|
||||
// NoAuthProbe noAuthProbe = new NoAuthProbe();
|
||||
NoAuthProbe noAuthProbe = new NoAuthProbe();
|
||||
|
||||
// noAuthProbe.setHostName("snoop");
|
||||
// noAuthProbe.setIpAddress(3232235980L);
|
||||
// noAuthProbe.setMacAddress(8796753988883L);
|
||||
noAuthProbe.setDescription(
|
||||
"{\"host\":{\"name\":\"snoop-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"DE60E4C3-347A-4D38-AEAB-1760471665EA\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
||||
|
||||
// // noAuthProbe.setHostName("snoop");
|
||||
// // noAuthProbe.setIpAddress(3232235980L);
|
||||
// // noAuthProbe.setMacAddress(8796753988883L);
|
||||
// noAuthProbe.setDescription("{\"host\":{\"name\":\"snoop-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"DE60E4C3-347A-4D38-AEAB-1760471665EA\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
||||
noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13");
|
||||
|
||||
// noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13");
|
||||
MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
||||
metaNoAuthProbeStatus.setId((short) 3);
|
||||
|
||||
// MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
||||
// metaNoAuthProbeStatus.setId((short)3);
|
||||
noAuthProbe.setStatus(metaNoAuthProbeStatus);
|
||||
noAuthProbe.setTempProbeKey("ac7f252b5bc811e784ad080027658d13");
|
||||
|
||||
// noAuthProbe.setStatus(metaNoAuthProbeStatus);
|
||||
// noAuthProbe.setTempProbeKey("ac7f252b5bc811e784ad080027658d13");
|
||||
Domain d = new Domain();
|
||||
d.setId(Long.valueOf(1));
|
||||
noAuthProbe.setDomain(d);
|
||||
|
||||
// Domain d = new Domain();
|
||||
// d.setId(1);
|
||||
// noAuthProbe.setDomain(d);
|
||||
this.noAuthProbeService.regist(noAuthProbe);
|
||||
|
||||
// this.noAuthProbeService.regist(noAuthProbe);
|
||||
Assert.assertNotEquals(noAuthProbe.getId().longValue(), 0);
|
||||
|
||||
// Assert.assertNotEquals(noAuthProbe.getId(), 0);
|
||||
}
|
||||
|
||||
// }
|
||||
@Ignore
|
||||
@Test
|
||||
public void registForNoAuthProbes() throws Exception {
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void registForNoAuthProbes() throws Exception {
|
||||
NoAuthProbe noAuthProbe = new NoAuthProbe();
|
||||
|
||||
// NoAuthProbe noAuthProbe = new NoAuthProbe();
|
||||
// noAuthProbe.setHostName("geek");
|
||||
// noAuthProbe.setIpAddress(3232235980L);
|
||||
// noAuthProbe.setMacAddress(8796753988883L);
|
||||
noAuthProbe.setDescription(
|
||||
"{\"host\":{\"name\":\"geek-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"03000200-0400-0500-0006-000700080009\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.103/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
||||
noAuthProbe.setApiKey("521abd6fd57e511e7ac52080027658d13");
|
||||
|
||||
// // noAuthProbe.setHostName("geek");
|
||||
// // noAuthProbe.setIpAddress(3232235980L);
|
||||
// // noAuthProbe.setMacAddress(8796753988883L);
|
||||
// noAuthProbe.setDescription("{\"host\":{\"name\":\"geek-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"03000200-0400-0500-0006-000700080009\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.103/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}");
|
||||
// noAuthProbe.setApiKey("521abd6fd57e511e7ac52080027658d13");
|
||||
MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
||||
metaNoAuthProbeStatus.setId((short) 3);
|
||||
|
||||
// MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus();
|
||||
// metaNoAuthProbeStatus.setId((short)3);
|
||||
noAuthProbe.setStatus(metaNoAuthProbeStatus);
|
||||
noAuthProbe.setTempProbeKey("a1c7f252b5bc811e784ad080027658d13");
|
||||
|
||||
// noAuthProbe.setStatus(metaNoAuthProbeStatus);
|
||||
// noAuthProbe.setTempProbeKey("a1c7f252b5bc811e784ad080027658d13");
|
||||
Domain d = new Domain();
|
||||
d.setId(Long.valueOf(1));
|
||||
noAuthProbe.setDomain(d);
|
||||
|
||||
// Domain d = new Domain();
|
||||
// d.setId(1);
|
||||
// noAuthProbe.setDomain(d);
|
||||
List<NoAuthProbe> noAuthProbes = new ArrayList<NoAuthProbe>();
|
||||
|
||||
// List<NoAuthProbe> noAuthProbes = new ArrayList<NoAuthProbe>();
|
||||
noAuthProbes.add(noAuthProbe);
|
||||
// List<NoAuthProbe> dd =
|
||||
// this.noAuthProbeService.registForNoAuthProbes(noAuthProbes);
|
||||
|
||||
// noAuthProbes.add(noAuthProbe);
|
||||
// // List<NoAuthProbe> dd = this.noAuthProbeService.registForNoAuthProbes(noAuthProbes);
|
||||
// System.out.println(dd.get(0).getId());
|
||||
|
||||
// // System.out.println(dd.get(0).getId());
|
||||
Assert.assertNotEquals(noAuthProbes.size(), 2);
|
||||
|
||||
// Assert.assertNotEquals(noAuthProbes.size(), 2);
|
||||
}
|
||||
|
||||
// }
|
||||
@Ignore
|
||||
@Test
|
||||
public void readAllByDomainID() throws Exception {
|
||||
List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomainID(Long.valueOf(1));
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void readAllByDomain() throws Exception {
|
||||
Assert.assertNotEquals(probes.size(), 0);
|
||||
|
||||
// Domain domain = new Domain();
|
||||
// domain.setId(1);
|
||||
}
|
||||
|
||||
// List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomain(domain);
|
||||
@Ignore
|
||||
@Test
|
||||
public void read() throws Exception {
|
||||
NoAuthProbe noAuthProbe = this.noAuthProbeService.read(Long.valueOf(1));
|
||||
|
||||
// Assert.assertNotEquals(probes.size(), 0);
|
||||
Assert.assertNotEquals(noAuthProbe, null);
|
||||
}
|
||||
|
||||
// }
|
||||
@Ignore
|
||||
@Test
|
||||
public void acceptProbe() throws Exception {
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void read() throws Exception {
|
||||
this.noAuthProbeService.acceptNoAuthProbe(Long.valueOf(1));
|
||||
|
||||
// NoAuthProbe noAuthProbe = this.noAuthProbeService.read(1);
|
||||
}
|
||||
|
||||
// Assert.assertNotEquals(noAuthProbe, null);
|
||||
// }
|
||||
@Ignore
|
||||
@Test
|
||||
public void ssss() {
|
||||
String ss = "192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64";
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void acceptProbe() throws IOException {
|
||||
String[] sss = ss.split("\\|");
|
||||
|
||||
// NoAuthProbe noAuthProbe = this.noAuthProbeService.read(1);
|
||||
System.out.println(sss[0]);
|
||||
}
|
||||
|
||||
// this.noAuthProbeService.acceptNoAuthProbe(noAuthProbe);
|
||||
@Test
|
||||
public void readByTempKey() throws Exception {
|
||||
|
||||
// }
|
||||
NoAuthProbe noAuthProbe = this.noAuthProbeService.readByTempProbeKey("1cf2555c57d511e79714080027658d15");
|
||||
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void ssss() {
|
||||
// String ss = "192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64";
|
||||
Assert.assertNotEquals(noAuthProbe, null);
|
||||
|
||||
// String[] sss = ss.split("\\|");
|
||||
}
|
||||
|
||||
// System.out.println(sss[0]);
|
||||
// }
|
||||
@Test
|
||||
@Ignore
|
||||
public void sendWeb() throws OverflowException {
|
||||
List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomainID(Long.valueOf(1));
|
||||
|
||||
// @Test
|
||||
// public void readByTempKey() {
|
||||
messagePublisher.publishToDomainMembers(Long.valueOf(1), "NoAuthProbeService.regist", probes);
|
||||
|
||||
// NoAuthProbe noAuthProbe = this.noAuthProbeService.readByTempKey("1cf2555c57d511e79714080027658d15");
|
||||
}
|
||||
|
||||
// Assert.assertNotEquals(noAuthProbe, null);
|
||||
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// @Ignore
|
||||
// public void sendWeb() throws OverflowException {
|
||||
|
||||
// Domain domain = new Domain();
|
||||
// domain.setId(1);
|
||||
|
||||
// List<NoAuthProbe> probes = this.noAuthProbeService.readAllByDomain(domain);
|
||||
|
||||
// messagePublisher.publishToDomainMembers(domain.getId(), "NoAuthProbeService.regist", probes);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
}
|
|
@ -1,41 +1,40 @@
|
|||
package com.loafle.overflow.central.module.target.service;
|
||||
package com.loafle.overflow.central.module.target.service;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
|
||||
import com.loafle.overflow.model.discovery.Host;
|
||||
import com.loafle.overflow.model.probe.Probe;
|
||||
import com.loafle.overflow.service.central.target.TargetDiscoveryService;
|
||||
import org.codehaus.jackson.map.DeserializationConfig;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import com.loafle.overflow.model.discovery.Host;
|
||||
import com.loafle.overflow.model.probe.Probe;
|
||||
import com.loafle.overflow.service.central.target.TargetDiscoveryService;
|
||||
import org.codehaus.jackson.map.DeserializationConfig;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class TargetDiscoveryServiceTest {
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class TargetDiscoveryServiceTest {
|
||||
|
||||
@Autowired
|
||||
private ResourceLoader resourceLoader;
|
||||
|
@ -85,7 +84,7 @@
|
|||
public void testParam() throws NoSuchMethodException {
|
||||
|
||||
Method m = this.targetDiscoveryService.getClass().getMethod("saveAllTarget", List.class, Probe.class);
|
||||
// Method m = TargetDiscoveryService.class.getMethod("saveAllTarget", List.class, Probe.class);
|
||||
// Method m = TargetDiscoveryService.class.getMethod("saveAllTarget", List.class, Probe.class);
|
||||
|
||||
Class<?> clazz = AopUtils.getTargetClass(this.targetDiscoveryService);
|
||||
Method[] ms = clazz.getMethods();
|
||||
|
@ -143,4 +142,4 @@
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user